From 46fc3b2bae56c76e5359c9fdd6f111e290e5d6ee Mon Sep 17 00:00:00 2001 From: kiene Date: Thu, 20 Oct 2022 15:29:44 +0200 Subject: [PATCH 1/2] accept MDCT_STEREO_PLC_FADE_2_BG_NOISE --- lib_com/ivas_cnst.h | 2 - lib_com/ivas_prot.h | 14 --- lib_com/ivas_sns_com.c | 4 - lib_com/ivas_stereo_psychlpc_com.c | 3 - lib_com/options.h | 1 - lib_com/prot.h | 24 ---- lib_dec/acelp_core_dec.c | 16 --- lib_dec/amr_wb_dec.c | 4 - lib_dec/core_dec_init.c | 12 -- lib_dec/core_dec_switch.c | 6 - lib_dec/dec_LPD.c | 8 -- lib_dec/dec_acelp_tcx_main.c | 4 - lib_dec/dec_prm.c | 10 -- lib_dec/dec_tcx.c | 58 ---------- lib_dec/er_dec_tcx.c | 8 -- lib_dec/evs_dec.c | 4 - lib_dec/fd_cng_dec.c | 79 ------------- lib_dec/igf_dec.c | 23 ---- lib_dec/init_dec.c | 10 -- lib_dec/ivas_core_dec.c | 22 ---- lib_dec/ivas_cpe_dec.c | 4 - lib_dec/ivas_mct_dec_mct.c | 4 - lib_dec/ivas_mdct_core_dec.c | 44 -------- lib_dec/ivas_sce_dec.c | 4 - lib_dec/ivas_stat_dec.h | 2 - lib_dec/ivas_stereo_mdct_core_dec.c | 18 --- lib_dec/ivas_stereo_switching_dec.c | 12 -- lib_dec/ivas_tcx_core_dec.c | 24 ---- lib_dec/stat_dec.h | 2 - lib_dec/tonalMDCTconcealment.c | 28 ----- lib_enc/enc_prm.c | 8 -- lib_enc/ivas_mdct_core_enc.c | 10 -- lib_enc/ivas_sns_enc.c | 169 ---------------------------- lib_enc/ivas_tcx_core_enc.c | 4 - 34 files changed, 645 deletions(-) diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index fe9cb54a69..5884d084b6 100644 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -793,7 +793,6 @@ enum fea_names #define MAX_MDCT_ITD_BRATE IVAS_64k #define SNS_LOW_BR_MODE -1 -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE #define SNS_NPTS 16 /* Number of downsampled SNS parameters */ #define MDCT_ST_PLC_FADEOUT_MIN_NOISE_NRG 0.001f @@ -812,7 +811,6 @@ typedef enum { ON_FIRST_LOST_FRAME, ON_FIRST_GOOD_FRAME, } TONALMDCTCONC_NOISE_SHAPE_WHITENING_MODE; -#endif /*----------------------------------------------------------------------------------* diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 84450e89a0..8e3558bbad 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -1985,9 +1985,7 @@ void decoder_tcx_invQ( void decoder_tcx_noisefilling( Decoder_State *st, /* i/o: coder memory state */ -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE float concealment_noise[L_FRAME48k], -#endif const float A[], /* i : coefficients NxAz[M+1] */ const int16_t L_frameTCX_glob, const int16_t L_spec, @@ -2000,9 +1998,7 @@ void decoder_tcx_noisefilling( const int16_t *prm_sqQ, int16_t nf_seed, const int16_t bfi, /* i : Bad frame indicator */ -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE const int16_t isMCT, -#endif const int16_t frame_cnt /* i : frame counter in the super frame */ ); @@ -2085,12 +2081,8 @@ void decoder_tcx_IGF_stereo( const int16_t L_frame, /* i : frame length */ const int16_t left_rect, /* i : left part is rectangular */ const int16_t k, /* i : Subframe index */ -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE const int16_t bfi, /* i : bad frame indicator */ const int16_t is_mct /* i : flag to signal MCT or SMDCT */ -#else - const int16_t bfi /* i : bad frame indicator */ -#endif ); void ms_processing( @@ -2123,12 +2115,8 @@ void IGFDecApplyStereo( const int16_t igfGridIdx, /* i : in case of CELP->TCX switching, use 1.25 framelength */ const int16_t *coreMsMask, const int16_t restrict_hopsize, -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE const int16_t bfi, /* i : frame loss == 1, frame good == 0 */ const int16_t bfi_apply_damping /* i : decoder element mode */ -#else - const int16_t bfi /* i : frame loss == 1, frame good == 0 */ -#endif ); void IGFEncStereoEncoder( @@ -5490,7 +5478,6 @@ ivas_error ivas_orient_trk_GetTrackedOrientation( float *roll ); -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE void TonalMdctConceal_create_concealment_noise( float concealment_noise[L_FRAME48k], CPE_DEC_HANDLE hCPE, @@ -5514,7 +5501,6 @@ int16_t get_igf_startline( int16_t L_frame, int16_t L_frameTCX ); -#endif float rand_triangular_signed( int16_t *seed ); diff --git a/lib_com/ivas_sns_com.c b/lib_com/ivas_sns_com.c index d975435994..cc0f07ffe0 100644 --- a/lib_com/ivas_sns_com.c +++ b/lib_com/ivas_sns_com.c @@ -37,15 +37,12 @@ #include "ivas_prot.h" #include "rom_com.h" #include -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE #include -#endif #ifdef DEBUGGING #include "debug.h" #endif #include "wmops.h" -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE /*------------------------------------------------------------------- * sns_compute_scf() @@ -212,7 +209,6 @@ void sns_compute_scf( return; } -#endif /*------------------------------------------------------------------- * sns_interpolate_scalefactors() diff --git a/lib_com/ivas_stereo_psychlpc_com.c b/lib_com/ivas_stereo_psychlpc_com.c index cdc48f5f98..3cbca73cc0 100644 --- a/lib_com/ivas_stereo_psychlpc_com.c +++ b/lib_com/ivas_stereo_psychlpc_com.c @@ -68,9 +68,6 @@ static void SpectrumWeighting_Init( * initialize a PsychoacousticParameters structure *-------------------------------------------------------------------*/ -#ifndef MDCT_STEREO_PLC_FADE_2_BG_NOISE -static -#endif ivas_error PsychoacousticParameters_Init( const int32_t sr_core, /* i : sampling rate of core-coder */ diff --git a/lib_com/options.h b/lib_com/options.h index b78976fe89..150ecc0dc1 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -142,7 +142,6 @@ #define DISABLE_ADAP_RES_COD_TMP /* temporary fix for IVAS-403, disables adaptive residual coding */ /*#define ITD_WINNER_GAIN_MODIFY */ /* ITD optimization - WORK IN PROGRESS */ /*#define FIX_I4_OL_PITCH*/ /* fix open-loop pitch used for EVS core switching */ -#define MDCT_STEREO_PLC_FADE_2_BG_NOISE /* IVAS-185 fix bug in TCX-PLC fadeout for MDCT-Stereo and improve fadeout by fading to background noise instead of white noise */ #define FADE_TO_ZERO_FOR_TOO_LONG_FRAMELOSS /*#define FIX_I1_113*/ /* under review : MCT bit distribution optimization for SBA high bitrates*/ diff --git a/lib_com/prot.h b/lib_com/prot.h index cffd699e46..5bc1e39753 100755 --- a/lib_com/prot.h +++ b/lib_com/prot.h @@ -5145,10 +5145,8 @@ void decod_amr_wb( ivas_error init_decoder( Decoder_State *st, /* o : Decoder static variables structure */ const int16_t idchan /* i : channel ID */ -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE , const MC_MODE mc_mode /* i : MC mode */ -#endif ); void destroy_decoder( @@ -6776,10 +6774,8 @@ void enc_acelp_tcx_main( void getTCXMode( Decoder_State *st, /* i/o: decoder memory state */ Decoder_State *st0 /* i : bitstream */ -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE , const int16_t MCT_flag -#endif ); void getTCXWindowing( @@ -7893,10 +7889,8 @@ void decoder_tcx_post( float *synthFB, float *A, const int16_t bfi -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE , const int16_t isMCT -#endif ); void coder_acelp( @@ -7949,9 +7943,7 @@ void decoder_acelp( void writeTCXMode( Encoder_State *st, /* i/o: encoder state structure */ BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE const int16_t is_mct, -#endif int16_t *nbits_start /* o : nbits start */ ); @@ -8140,10 +8132,8 @@ void con_tcx( const float coh, /* i : coherence of stereo signal */ int16_t *noise_seed, /* i/o: noise seed for stereo */ const int16_t only_left /* i : TD-PLC only in left channel */ -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE , const float *A_cng -#endif ); /*! r: codebook index */ @@ -8689,9 +8679,7 @@ void configureFdCngDec( void ApplyFdCng( float *timeDomainInput, -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE float *powerSpectrum, -#endif float **realBuffer, /* i/o: Real part of the buffer */ float **imagBuffer, /* i/o: Imaginary part of the buffer */ Decoder_State *st, @@ -8700,9 +8688,7 @@ void ApplyFdCng( void perform_noise_estimation_dec( const float *timeDomainInput, -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE float *power_spectrum, -#endif HANDLE_FD_CNG_DEC hFdCngDec, /* i/o: FD_CNG structure */ const int16_t element_mode, /* i : element mode type */ const int16_t bwidth, /* i : audio bandwidth */ @@ -9202,9 +9188,7 @@ void open_decoder_LPD( const int32_t last_total_brate, /* i : last total bitrate */ const int16_t bwidth, /* i : audio bandwidth */ const int16_t is_mct, /* i : MCT mode flag */ -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE const int16_t last_element_mode, -#endif const int16_t is_init /* i : indicate call during initialization */ ); @@ -9245,10 +9229,8 @@ void mode_switch_decoder_LPD( const int32_t last_total_brate, /* i : last frame total bitrate */ const int16_t frame_size_index, /* i : index determining the frame size*/ const int16_t is_mct /* i : MCT mode flag */ -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE , const int16_t last_element_mode /* i : last element mode */ -#endif ); void dec_acelp_tcx_frame( @@ -9529,10 +9511,8 @@ void TonalMDCTConceal_SaveFreqSignal( const uint16_t numSamples, const uint16_t nNewSamplesCore, const float *scaleFactors -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE , const int16_t infoIGFStartLine -#endif ); void TonalMDCTConceal_UpdateState( @@ -9567,10 +9547,8 @@ void TonalMDCTConceal_InsertNoise( int16_t *pSeed, /*IN/OUT*/ const float tiltCompFactor, const float crossfadeGain, -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE const float concealment_noise[L_FRAME48k], const float cngLevelBackgroundTrace_bfi, -#endif const int16_t crossOverFreq ); void DetectTonalComponents( @@ -9605,7 +9583,6 @@ void RefineTonalComponents( float floorPowerSpectrum, const PsychoacousticParameters *psychParamsCurrent ); -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE ivas_error PsychoacousticParameters_Init( const int32_t sr_core, /* i : sampling rate of core-coder */ const int16_t nBins, /* i : Number of bins (spectral lines) */ @@ -9613,7 +9590,6 @@ ivas_error PsychoacousticParameters_Init( const int16_t isTCX20, /* i : Flag indicating if the subband division is for TCX20 or TCX10 */ const int16_t isWarped, /* i : Flag indicating if the scale is linear or warped */ PsychoacousticParameters *pPsychParams ); -#endif void concealment_init( const int16_t L_frameTCX, diff --git a/lib_dec/acelp_core_dec.c b/lib_dec/acelp_core_dec.c index c108c80998..4c52cdb811 100644 --- a/lib_dec/acelp_core_dec.c +++ b/lib_dec/acelp_core_dec.c @@ -156,11 +156,7 @@ ivas_error acelp_core_dec( st->hFdCngDec->hFdCngCom->sidNoiseEstLp[i] = STEREO_DFT_FD_FILT * st->hFdCngDec->hFdCngCom->sidNoiseEstLp[i] + ( 1 - STEREO_DFT_FD_FILT ) * st->hFdCngDec->hFdCngCom->sidNoiseEst[i]; } -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE ApplyFdCng( NULL, NULL, NULL, NULL, st, 0, 0 ); -#else - ApplyFdCng( NULL, NULL, NULL, st, 0, 0 ); -#endif } else { @@ -530,11 +526,7 @@ ivas_error acelp_core_dec( { st->hFdCngDec->hFdCngCom->sidNoiseEstLp[i] = STEREO_DFT_FD_FILT * st->hFdCngDec->hFdCngCom->sidNoiseEstLp[i] + ( 1 - STEREO_DFT_FD_FILT ) * st->hFdCngDec->hFdCngCom->sidNoiseEst[i]; } -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE ApplyFdCng( syn, NULL, realBuffer, imagBuffer, st, 0, ( st->coder_type == AUDIO && !st->GSC_noisy_speech ) ); -#else - ApplyFdCng( syn, realBuffer, imagBuffer, st, 0, ( st->coder_type == AUDIO && !st->GSC_noisy_speech ) ); -#endif } generate_comfort_noise_dec( NULL, NULL, st, nchan_out ); @@ -1125,11 +1117,7 @@ ivas_error acelp_core_dec( if ( st->element_mode != IVAS_CPE_TD ) { /*Noise estimate*/ -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE ApplyFdCng( syn, NULL, realBuffer, imagBuffer, st, 0, ( st->coder_type == AUDIO && !st->GSC_noisy_speech ) ); -#else - ApplyFdCng( syn, realBuffer, imagBuffer, st, 0, ( st->coder_type == AUDIO && !st->GSC_noisy_speech ) ); -#endif } if ( !st->cna_dirac_flag ) @@ -1194,11 +1182,7 @@ ivas_error acelp_core_dec( /*Noise estimate*/ if ( st->idchan == 0 && ( nchan_out == 2 || ( st->core_brate != FRAME_NO_DATA && st->core_brate != SID_2k40 ) ) ) { -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE ApplyFdCng( syn, NULL, realBuffer, imagBuffer, st, 0, ( st->coder_type == AUDIO && !st->GSC_noisy_speech ) ); -#else - ApplyFdCng( syn, realBuffer, imagBuffer, st, 0, ( st->coder_type == AUDIO && !st->GSC_noisy_speech ) ); -#endif } } } diff --git a/lib_dec/amr_wb_dec.c b/lib_dec/amr_wb_dec.c index 907d90e9ab..29c4f939ed 100644 --- a/lib_dec/amr_wb_dec.c +++ b/lib_dec/amr_wb_dec.c @@ -621,11 +621,7 @@ ivas_error amr_wb_dec( /*VAD only for non inactive frame*/ st->VAD = ( st->VAD && ( st->coder_type != INACTIVE ) ); -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE ApplyFdCng( syn, NULL, NULL, NULL, st, 0, 0 ); -#else - ApplyFdCng( syn, NULL, NULL, st, 0, 0 ); -#endif st->hFdCngDec->hFdCngCom->frame_type_previous = st->m_frame_type; diff --git a/lib_dec/core_dec_init.c b/lib_dec/core_dec_init.c index bc8d95e24f..906d24adab 100644 --- a/lib_dec/core_dec_init.c +++ b/lib_dec/core_dec_init.c @@ -57,9 +57,7 @@ void open_decoder_LPD( const int32_t last_total_brate, const int16_t bwidth, const int16_t is_mct, /* i : MCT mode flag */ -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE const int16_t last_element_mode, -#endif const int16_t is_init /* i : indicate call from init_decoder() to avoid double TC initialization */ ) { @@ -552,7 +550,6 @@ void open_decoder_LPD( { st->hTcxDec->prev_widow_left_rect = 0; -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE if ( is_init || is_mct || !( st->element_mode == IVAS_CPE_MDCT && st->element_mode == last_element_mode ) ) { st->hTcxDec->CngLevelBackgroundTrace_bfi = PLC_MIN_CNG_LEV; @@ -563,15 +560,6 @@ void open_decoder_LPD( st->hTcxDec->cummulative_damping_tcx = 1.0f; } -#else - st->hTcxDec->CngLevelBackgroundTrace_bfi = PLC_MIN_CNG_LEV; - st->hTcxDec->NoiseLevelIndex_bfi = PLC_MIN_STAT_BUFF_SIZE - 1; - st->hTcxDec->CurrLevelIndex_bfi = 0; - st->hTcxDec->LastFrameLevel_bfi = PLC_MIN_CNG_LEV; - set_f( st->hTcxDec->NoiseLevelMemory_bfi, PLC_MIN_CNG_LEV, PLC_MIN_STAT_BUFF_SIZE ); - - st->hTcxDec->cummulative_damping_tcx = 1.0f; -#endif } st->cummulative_damping = 1.0f; diff --git a/lib_dec/core_dec_switch.c b/lib_dec/core_dec_switch.c index c2084f3f12..cc1619cba0 100644 --- a/lib_dec/core_dec_switch.c +++ b/lib_dec/core_dec_switch.c @@ -57,10 +57,8 @@ void mode_switch_decoder_LPD( const int32_t last_total_brate, /* i : last frame total bitrate */ const int16_t frame_size_index, /* i : index determining the frame size*/ const int16_t is_mct /* i : MCT mode flag */ -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE , const int16_t last_element_mode /* i : last element mode */ -#endif ) { int16_t fscale, switchWB; @@ -109,11 +107,7 @@ void mode_switch_decoder_LPD( if ( fscale != st->fscale || switchWB || bSwitchFromAmrwbIO || st->last_codec_mode == MODE1 || st->force_lpd_reset ) { -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE open_decoder_LPD( st, total_brate, last_total_brate, bwidth, is_mct, last_element_mode, 0 ); -#else - open_decoder_LPD( st, total_brate, last_total_brate, bwidth, is_mct, 0 ); -#endif } else { diff --git a/lib_dec/dec_LPD.c b/lib_dec/dec_LPD.c index a28630886e..c06bee28f9 100644 --- a/lib_dec/dec_LPD.c +++ b/lib_dec/dec_LPD.c @@ -478,11 +478,7 @@ void decoder_LPD( if ( bfi && st->last_core != ACELP_CORE ) { /* PLC: [TCX: TD PLC] */ -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE con_tcx( st, &synthFB[0], -1.f, NULL, 0, NULL ); -#else - con_tcx( st, &synthFB[0], -1.f, NULL, 0 ); -#endif lerp( synthFB, synth, st->L_frame, st->hTcxDec->L_frameTCX ); st->con_tcx = 1; set_f( &st->mem_pitch_gain[2], st->lp_gainp, st->nb_subfr ); @@ -650,11 +646,7 @@ void decoder_LPD( TonalMDCTConceal_SaveTimeSignal( st->hTonalMDCTConc, synthFB, L_frameTCX ); } -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE decoder_tcx_post( st, synth, synthFB, Aq, bfi, 0 ); -#else - decoder_tcx_post( st, synth, synthFB, Aq, bfi ); -#endif if ( st->core == TCX_20_CORE ) { diff --git a/lib_dec/dec_acelp_tcx_main.c b/lib_dec/dec_acelp_tcx_main.c index 1ca75fff20..b9d3481579 100644 --- a/lib_dec/dec_acelp_tcx_main.c +++ b/lib_dec/dec_acelp_tcx_main.c @@ -198,11 +198,7 @@ static void decode_frame_type( st->rate_switching_init = 1; /* Reconf Core */ -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE mode_switch_decoder_LPD( st, st->bwidth, st->total_brate, st->last_total_brate, frame_size_index, 0, st->element_mode ); -#else - mode_switch_decoder_LPD( st, st->bwidth, st->total_brate, st->last_total_brate, frame_size_index, 0 ); -#endif /* Reconf. CLDFB: check if the CLDFB works on the right sample rate */ if ( ( st->cldfbAna->no_channels * st->cldfbAna->no_col ) != st->L_frame ) diff --git a/lib_dec/dec_prm.c b/lib_dec/dec_prm.c index 925b561fd6..d458d62aa4 100644 --- a/lib_dec/dec_prm.c +++ b/lib_dec/dec_prm.c @@ -55,10 +55,8 @@ void getTCXMode( Decoder_State *st, /* i/o: decoder memory state */ Decoder_State *st0 /* i : bitstream */ -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE , const int16_t MCT_flag -#endif ) { uint16_t ind; @@ -94,7 +92,6 @@ void getTCXMode( } st->coder_type = INACTIVE; -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE if ( st->element_mode == IVAS_CPE_MDCT && !MCT_flag ) { st->VAD = get_next_indice( st0, 1 ); @@ -103,9 +100,6 @@ void getTCXMode( { st->VAD = 0; } -#else - st->VAD = 0; -#endif } else { @@ -793,11 +787,7 @@ void dec_prm( *--------------------------------------------------------------------------------*/ /* Modes (ACE_GC, ACE_UC, TCX20, TCX10...) */ -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE getTCXMode( st, st, 0 /* <- MCT_flag */ ); -#else - getTCXMode( st, st ); -#endif core = st->core; /* Decode last_core for error concealment */ diff --git a/lib_dec/dec_tcx.c b/lib_dec/dec_tcx.c index 8f6ee52fed..b5f78ab052 100644 --- a/lib_dec/dec_tcx.c +++ b/lib_dec/dec_tcx.c @@ -100,11 +100,7 @@ void decoder_tcx( decoder_tcx_invQ( st, prm, A, Aind, L_spec, L_frame, L_frameTCX, &x[0], &gainlpc2[0], &xn_buf[0], &fUseTns, &tnsData, &gain_tcx, &prm_sqQ, &nf_seed, bfi, frame_cnt ); -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE decoder_tcx_noisefilling( st, NULL, A, L_frameTCX_glob, L_spec, L_frame, L_frameTCX, &x[0], &gainlpc2[0], &tmp_concealment_method, gain_tcx, prm_sqQ, nf_seed, bfi, 0, frame_cnt ); -#else - decoder_tcx_noisefilling( st, A, L_frameTCX_glob, L_spec, L_frame, L_frameTCX, &x[0], &gainlpc2[0], &tmp_concealment_method, gain_tcx, prm_sqQ, nf_seed, bfi, frame_cnt ); -#endif decoder_tcx_noiseshaping_igf( st, L_spec, L_frame, L_frameTCX, left_rect, &x[0], &gainlpc2[0], &tmp_concealment_method, bfi ); @@ -129,10 +125,8 @@ void decoder_tcx_post( float *synthFB, float *A, const int16_t bfi -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE , const int16_t isMCT -#endif ) { int16_t i; @@ -184,11 +178,7 @@ void decoder_tcx_post( /* PLC: [TCX: Fade-out] * PLC: update or retrieve the background level */ -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE if ( bfi == 0 && st->tcxonly && ( st->element_mode != IVAS_CPE_MDCT || isMCT ) && st->clas_dec == UNVOICED_CLAS ) -#else - if ( bfi == 0 && st->tcxonly && st->clas_dec == UNVOICED_CLAS ) -#endif { minimumStatistics( hTcxDec->NoiseLevelMemory_bfi, &hTcxDec->NoiseLevelIndex_bfi, &hTcxDec->CurrLevelIndex_bfi, &hTcxDec->CngLevelBackgroundTrace_bfi, &hTcxDec->LastFrameLevel_bfi, level_syn, PLC_MIN_CNG_LEV, PLC_MIN_STAT_BUFF_SIZE ); } @@ -1077,9 +1067,7 @@ void decoder_tcx_invQ( void decoder_tcx_noisefilling( Decoder_State *st, /* i/o: coder memory state */ -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE float concealment_noise[L_FRAME48k], -#endif const float A[], /* i : coefficients NxAz[M+1] */ const int16_t L_frameTCX_glob, const int16_t L_spec, @@ -1092,9 +1080,7 @@ void decoder_tcx_noisefilling( const int16_t *prm_sqQ, int16_t nf_seed, const int16_t bfi, /* i : Bad frame indicator */ -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE const int16_t isMCT, -#endif const int16_t frame_cnt /* i : frame counter in the super frame*/ ) { @@ -1118,27 +1104,7 @@ void decoder_tcx_noisefilling( *-----------------------------------------------------------------*/ /* Init lengths */ -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE infoIGFStartLine = get_igf_startline( st, L_frame, L_frameTCX ); -#else - if ( st->igf == 0 ) - { - if ( st->narrowBand == 0 ) - { - /* minimum needed for output with sampling rates lower then the - nominal sampling rate */ - infoIGFStartLine = min( L_frameTCX, L_frame ); - } - else - { - infoIGFStartLine = L_frameTCX; - } - } - else - { - infoIGFStartLine = min( st->hIGFDec->infoIGFStartLine, L_frameTCX ); - } -#endif noiseFillingSize = L_spec; if ( st->igf ) @@ -1250,11 +1216,7 @@ void decoder_tcx_noisefilling( if ( !bfi && st->element_mode != IVAS_CPE_MDCT ) { -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE TonalMDCTConceal_SaveFreqSignal( st->hTonalMDCTConc, x, L_frameTCX, L_frame, gainlpc2, infoIGFStartLine ); -#else - TonalMDCTConceal_SaveFreqSignal( st->hTonalMDCTConc, x, L_frameTCX, L_frame, gainlpc2 ); -#endif } else if ( bfi ) { @@ -1263,11 +1225,7 @@ void decoder_tcx_noisefilling( { /* set f to 1 to not fade out */ /* set f to 0 to immediately switch to white noise */ -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE if ( st->tcxonly && ( st->element_mode != IVAS_CPE_MDCT || isMCT ) ) -#else - if ( st->tcxonly ) -#endif { f = 1.0f; } @@ -1306,7 +1264,6 @@ void decoder_tcx_noisefilling( noiseTiltFactor = 1.0f; tcxGetNoiseFillingTilt( A, L_frame, ( total_brate >= ACELP_13k20 && !st->rf_flag ), &noiseTiltFactor ); -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE if ( st->element_mode == IVAS_CPE_MDCT && !isMCT ) { TonalMDCTConceal_InsertNoise( st->hTonalMDCTConc, x, st->tonal_mdct_plc_active, &st->seed_tcx_plc, noiseTiltFactor, f, concealment_noise, hTcxDec->CngLevelBackgroundTrace_bfi, infoIGFStartLine ); @@ -1315,9 +1272,6 @@ void decoder_tcx_noisefilling( { TonalMDCTConceal_InsertNoise( st->hTonalMDCTConc, x, st->tonal_mdct_plc_active, &st->seed_tcx_plc, noiseTiltFactor, f, NULL, hTcxDec->CngLevelBackgroundTrace_bfi, infoIGFStartLine ); } -#else - TonalMDCTConceal_InsertNoise( st->hTonalMDCTConc, x, st->tonal_mdct_plc_active, &st->seed_tcx_plc, noiseTiltFactor, f, infoIGFStartLine ); -#endif } } } @@ -1395,11 +1349,7 @@ void decoder_tcx_noiseshaping_igf( * Noise shaping in frequency domain (1/Wz) * *-----------------------------------------------------------*/ -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE if ( st->igf && ( !bfi || ( st->element_mode == IVAS_CPE_MDCT && st->prev_bfi ) ) ) -#else - if ( st->igf && !bfi ) -#endif { if ( ( L_frame == st->L_frame >> 1 ) && ( st->tcxonly ) ) { @@ -1964,12 +1914,8 @@ void decoder_tcx_IGF_stereo( const int16_t L_frame, /* i : frame length */ const int16_t left_rect, /* i : left part is rectangular */ const int16_t k, /* i : Subframe index */ -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE const int16_t bfi, /* i : bad frame indicator */ const int16_t is_mct /* i : flag to signal MCT or SMDCT */ -#else - const int16_t bfi /* i : bad frame indicator */ -#endif ) { int16_t coreMsMask[N_MAX]; @@ -2022,11 +1968,7 @@ void decoder_tcx_IGF_stereo( igfGridIdx = ( sts[0]->last_core == ACELP_CORE || ( left_rect && bfi ) ) ? IGF_GRID_LB_TRAN : IGF_GRID_LB_NORM; } -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE IGFDecApplyStereo( sts[0]->hIGFDec, sts[1]->hIGFDec, x[0][k], x[1][k], igfGridIdx, coreMsMask, hStereoMdct->IGFStereoMode[k] == SMDCT_BW_MS, bfi, is_mct ); -#else - IGFDecApplyStereo( sts[0]->hIGFDec, sts[1]->hIGFDec, x[0][k], x[1][k], igfGridIdx, coreMsMask, hStereoMdct->IGFStereoMode[k] == SMDCT_BW_MS, bfi ); -#endif } return; diff --git a/lib_dec/er_dec_tcx.c b/lib_dec/er_dec_tcx.c index d72e88da5f..5a1cb5f881 100644 --- a/lib_dec/er_dec_tcx.c +++ b/lib_dec/er_dec_tcx.c @@ -59,10 +59,8 @@ void con_tcx( const float coh, /* i : coherence of stereo signal */ int16_t *noise_seed, /* i/o: noise seed for stereo */ const int16_t only_left /* i : TD-PLC only in left channel */ -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE , const float *A_cng -#endif ) { int16_t i, n, L_frame, L_subfr, fLowPassFilter, T0; @@ -437,7 +435,6 @@ void con_tcx( /* PLC: [TCX: Fade-out] retrieve background level */ tmp = 1.0f; -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE if ( A_cng != NULL ) { gainSynthDeemph = getLevelSynDeemph( &( tmp ), A_cng, L_frame / 4, st->preemph_fac, 1 ) / 4.f; @@ -446,9 +443,6 @@ void con_tcx( { gainSynthDeemph = getLevelSynDeemph( &( tmp ), A_local, L_frame / 4, st->preemph_fac, 1 ); } -#else - gainSynthDeemph = getLevelSynDeemph( &( tmp ), A_local, L_frame / 4, st->preemph_fac, 1 ); -#endif if ( st->tcxonly ) { gainCNG = hTcxDec->CngLevelBackgroundTrace_bfi / gainSynthDeemph; @@ -561,7 +555,6 @@ void con_tcx( mvr2r( buf, mem_syn, M ); -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE if ( A_cng != NULL ) { if ( st->plcBackgroundNoiseUpdated && alpha != 1.0f ) @@ -580,7 +573,6 @@ void con_tcx( lsp2a_stab( lsp_fade, A_local, M ); } } -#endif syn_filt( A_local, M, &exc[0], &syn[0], L_frame + ( L_frame / 2 ), mem_syn, 1 ); diff --git a/lib_dec/evs_dec.c b/lib_dec/evs_dec.c index e03b2ff2bc..299e6a31ce 100644 --- a/lib_dec/evs_dec.c +++ b/lib_dec/evs_dec.c @@ -676,11 +676,7 @@ ivas_error evs_dec( st->lp_noise = st->hFdCngDec->lp_noise; -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE ApplyFdCng( output, NULL, realBuffer, imagBuffer, st, concealWholeFrame, 0 ); -#else - ApplyFdCng( output, realBuffer, imagBuffer, st, concealWholeFrame, 0 ); -#endif /* Generate additional comfort noise to mask potential coding artefacts */ if ( st->m_frame_type == ACTIVE_FRAME && st->flag_cna ) diff --git a/lib_dec/fd_cng_dec.c b/lib_dec/fd_cng_dec.c index faaa37b52c..c1ddeeb79f 100644 --- a/lib_dec/fd_cng_dec.c +++ b/lib_dec/fd_cng_dec.c @@ -368,9 +368,7 @@ void deleteFdCngDec( void ApplyFdCng( float *timeDomainInput, -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE float *powerSpectrum, -#endif float **realBuffer, /* i/o: Real part of the buffer */ float **imagBuffer, /* i/o: Imaginary part of the buffer */ Decoder_State *st, @@ -384,7 +382,6 @@ void ApplyFdCng( int16_t j, k; float factor; float lsp_cng[M]; -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE int16_t L_frame, last_L_frame; int32_t sr_core; @@ -394,7 +391,6 @@ void ApplyFdCng( L_frame = min( st->L_frame, L_FRAME16k ); last_L_frame = min( st->last_L_frame, L_FRAME16k ); sr_core = min( st->sr_core, INT_FS_16k ); -#endif if ( hFdCngCom->frame_type_previous == ACTIVE_FRAME ) { @@ -419,27 +415,17 @@ void ApplyFdCng( /* set noise estimation inactive during concealment, as no update with noise generated by concealment should be performed. */ /* set noise estimation inactive when we have bit errors, as no update with noise generated by corrupt frame (biterror) should be performed. */ if ( concealWholeFrame == 0 && -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE ( timeDomainInput == NULL || ( *timeDomainInput( -FLT_MAX ) && *( timeDomainInput + hFdCngCom->frameSize - 1 ) < FLT_MAX && *( timeDomainInput + hFdCngCom->frameSize - 1 ) > ( -FLT_MAX ) ) ) && -#else - *timeDomainInput( -FLT_MAX ) && - *( timeDomainInput + hFdCngCom->frameSize - 1 ) < FLT_MAX && - *( timeDomainInput + hFdCngCom->frameSize - 1 ) > ( -FLT_MAX ) && -#endif ( ( ( ( st->element_mode != IVAS_CPE_TD && st->element_mode != IVAS_CPE_DFT && hFdCngDec->flag_dtx_mode ) || !st->VAD ) && !( st->cng_type == LP_CNG && hFdCngDec->flag_dtx_mode ) && ( is_music == 0 ) ) || ( st->element_mode == IVAS_CPE_TD ) ) && ( !st->BER_detect ) ) { /* Perform noise estimation at the decoder */ -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE perform_noise_estimation_dec( timeDomainInput, powerSpectrum, hFdCngDec, st->element_mode, st->bwidth, L_frame, last_L_frame, st->last_core_brate, st->VAD ); -#else - perform_noise_estimation_dec( timeDomainInput, hFdCngDec, st->element_mode, st->bwidth, st->L_frame, st->last_L_frame, st->last_core_brate, st->VAD ); -#endif if ( st->element_mode != IVAS_CPE_TD && st->element_mode != IVAS_CPE_DFT ) { @@ -471,7 +457,6 @@ void ApplyFdCng( } } -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE if ( st->element_mode == IVAS_CPE_MDCT && timeDomainInput == NULL ) { st->hTcxDec->CngLevelBackgroundTrace_bfi = sqrtf( sum_f( cngNoiseLevel, hFdCngCom->stopFFTbin - hFdCngCom->startBand ) / NORM_MDCT_FACTOR ); @@ -480,7 +465,6 @@ void ApplyFdCng( { st->hTcxDec->CngLevelBackgroundTrace_bfi = (float) sqrt( ( sum_f( cngNoiseLevel, hFdCngCom->stopFFTbin - hFdCngCom->startBand ) / 2 * hFdCngCom->fftlen ) / L_frame ); } -#endif st->cngTDLevel = (float) sqrt( ( sum_f( cngNoiseLevel, hFdCngCom->stopFFTbin - hFdCngCom->startBand ) / 2 * hFdCngCom->fftlen ) / st->L_frame ); } else if ( st->element_mode == IVAS_CPE_TD || st->element_mode == IVAS_CPE_DFT ) @@ -488,20 +472,10 @@ void ApplyFdCng( if ( hFdCngCom->active_frame_counter > 0 ) { /* Perform noise estimation in active frames in the decoder for downward updates */ -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE perform_noise_estimation_dec( timeDomainInput, powerSpectrum, hFdCngDec, st->element_mode, st->bwidth, L_frame, last_L_frame, st->last_core_brate, st->VAD ); -#else - perform_noise_estimation_dec( timeDomainInput, hFdCngDec, st->element_mode, st->bwidth, st->L_frame, st->last_L_frame, st->last_core_brate, st->VAD ); -#endif } } -#ifndef MDCT_STEREO_PLC_FADE_2_BG_NOISE - if ( ( concealWholeFrame == 1 ) && ( st->nbLostCmpt == 1 ) && sum_f( cngNoiseLevel + hFdCngCom->startBand, hFdCngCom->stopFFTbin - hFdCngCom->startBand ) > 0.01f ) - { - /* update lsf cng estimate for concealment. Do that during concealment, in order to avoid addition clean channel complexity*/ - lpc_from_spectrum( hFdCngCom, hFdCngCom->startBand, hFdCngCom->stopFFTbin, 0 ); -#else if ( ( concealWholeFrame == 1 ) && ( st->nbLostCmpt == 1 ) ) { /* update lsf cng estimate for concealment. Do that during concealment, in order to avoid addition clean channel complexity*/ @@ -528,15 +502,6 @@ void ApplyFdCng( } st->plcBackgroundNoiseUpdated = 1; } -#endif -#ifndef MDCT_STEREO_PLC_FADE_2_BG_NOISE - - a2lsp_stab( hFdCngCom->A_cng, lsp_cng, st->lspold_cng ); - mvr2r( lsp_cng, st->lspold_cng, M ); - - lsp2lsf( lsp_cng, st->lsf_cng, M, st->sr_core ); - st->plcBackgroundNoiseUpdated = 1; -#endif } break; @@ -549,11 +514,7 @@ void ApplyFdCng( if ( st != NULL && st->cng_type == LP_CNG ) { /* Perform noise estimation on inactive phase at the decoder */ -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE perform_noise_estimation_dec( timeDomainInput, powerSpectrum, hFdCngDec, st->element_mode, st->bwidth, L_frame, last_L_frame, st->last_core_brate, st->VAD ); -#else - perform_noise_estimation_dec( timeDomainInput, hFdCngDec, st->element_mode, st->bwidth, st->L_frame, st->last_L_frame, st->last_core_brate, st->VAD ); -#endif if ( st->element_mode != IVAS_CPE_TD && st->element_mode != IVAS_CPE_DFT ) { @@ -564,11 +525,7 @@ void ApplyFdCng( /* This sets the new CNG levels until a SID update overwrites it */ mvr2r( hFdCngDec->bandNoiseShape, cngNoiseLevel, hFdCngCom->stopFFTbin - hFdCngCom->startBand ); /* This sets the new CNG levels until a SID update overwrites it */ -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE st->cngTDLevel = (float) sqrt( ( sum_f( cngNoiseLevel, hFdCngCom->stopFFTbin - hFdCngCom->startBand ) / 2 * hFdCngCom->fftlen ) / L_frame ); -#else - st->cngTDLevel = (float) sqrt( ( sum_f( cngNoiseLevel, hFdCngCom->stopFFTbin - hFdCngCom->startBand ) / 2 * hFdCngCom->fftlen ) / st->L_frame ); -#endif break; } @@ -650,10 +607,8 @@ void ApplyFdCng( default: break; } -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE wmops_sub_end(); -#endif return; } @@ -667,9 +622,7 @@ void ApplyFdCng( void perform_noise_estimation_dec( const float *timeDomainInput, -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE float *power_spectrum, -#endif HANDLE_FD_CNG_DEC hFdCngDec, /* i/o: FD_CNG structure containing all buffers and variables */ const int16_t element_mode, /* i : element mode */ const int16_t bwidth, /* i : audio bandwidth */ @@ -702,16 +655,11 @@ void perform_noise_estimation_dec( float temp, ftemp, delta; float wght; -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE if ( !( element_mode == IVAS_CPE_MDCT && power_spectrum != NULL ) ) { /* Perform STFT analysis */ AnalysisSTFT( timeDomainInput, fftBuffer, hFdCngDec->hFdCngCom ); } -#else - /* Perform STFT analysis */ - AnalysisSTFT( timeDomainInput, fftBuffer, hFdCngDec->hFdCngCom ); -#endif if ( element_mode == IVAS_CPE_TD || element_mode == IVAS_CPE_DFT ) { @@ -944,7 +892,6 @@ void perform_noise_estimation_dec( } else { -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE if ( element_mode == IVAS_CPE_MDCT && power_spectrum != NULL ) { /* use power spectrum calculated in the MDCT-domain instead of calculating new power spectrum */ @@ -977,32 +924,6 @@ void perform_noise_estimation_dec( /* Rescale to get energy/sample: it should be 2*(1/N)*(2/N), parseval relation with 1/N,*2 for nrg computed till Nyquist only, 2/N as windowed samples correspond to half a frame*/ v_multc( periodog, 4.f / (float) ( hFdCngDec->hFdCngCom->fftlen * hFdCngDec->hFdCngCom->fftlen ), periodog, stopFFTbin - startBand ); } -#else - /* Compute the squared magnitude in each FFT bin */ - if ( startBand == 0 ) - { - ( *ptr_per ) = fftBuffer[0] * fftBuffer[0]; /* DC component */ - ptr_per++; - ptr_r = fftBuffer + 2; - } - else - { - ptr_r = fftBuffer + 2 * startBand; - } - - ptr_i = ptr_r + 1; - - for ( ; ptr_per < periodog + stopFFTbin - startBand; ptr_per++ ) - { - ( *ptr_per ) = ( *ptr_r ) * ( *ptr_r ) + ( *ptr_i ) * ( *ptr_i ); - ptr_r += 2; - ptr_i += 2; - } - /* Nyquist frequency is discarded */ - - /* Rescale to get energy/sample: it should be 2*(1/N)*(2/N), parseval relation with 1/N,*2 for nrg computed till Nyquist only, 2/N as windowed samples correspond to half a frame*/ - v_multc( periodog, 4.f / (float) ( hFdCngDec->hFdCngCom->fftlen * hFdCngDec->hFdCngCom->fftlen ), periodog, stopFFTbin - startBand ); -#endif /* Adjust to the desired frequency resolution by averaging over spectral partitions for SID transmission */ bandcombinepow( periodog, stopFFTbin - startBand, part, npart, psize_inv, msPeriodog ); diff --git a/lib_dec/igf_dec.c b/lib_dec/igf_dec.c index d3638ea44a..f876391b2d 100644 --- a/lib_dec/igf_dec.c +++ b/lib_dec/igf_dec.c @@ -679,12 +679,8 @@ static void IGF_appl( float *pSpectralData, /* i/o: Q31 | MDCT spectrum */ const float *igf_spec, /* i : Q31 | prepared IGF spectrum */ float *virtualSpec, /* o : Q31 | virtual IGF spectrum, used for temp flattening */ -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE int16_t *flag_sparse, /* o : Q0 | temp flattening indicator */ const int16_t bfi_apply_damping /* i : flag to indicate if damping for lost frames should be applied */ -#else - int16_t *flag_sparse /* o : Q0 | temp flattening indicator */ -#endif ) { H_IGF_GRID hGrid; @@ -860,11 +856,7 @@ static void IGF_appl( for ( sfb = start_sfb; sfb < stop_sfb; sfb++ ) { -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE if ( bfi_apply_damping && hPrivateData->frameLossCounter > 0 ) -#else - if ( hPrivateData->frameLossCounter > 0 ) -#endif { gain[sfb] = min( gain[sfb], 12.f ); @@ -1221,11 +1213,7 @@ void IGFDecApplyMono( /* apply IGF in three steps: */ IGF_prep( hPrivateData, igfGridIdx, hIGFDec->infoTCXNoise, igf_spec, hPrivateData->pSpecFlat, element_mode ); IGF_calc( hPrivateData, igfGridIdx, spectrum, igf_spec ); -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE IGF_appl( hPrivateData, igfGridIdx, spectrum, igf_spec, hIGFDec->virtualSpec, hIGFDec->flag_sparse, 1 ); -#else - IGF_appl( hPrivateData, igfGridIdx, spectrum, igf_spec, hIGFDec->virtualSpec, hIGFDec->flag_sparse ); -#endif } /* reset TCX noise indicator vector */ @@ -1251,12 +1239,8 @@ void IGFDecApplyStereo( const int16_t igfGridIdx, /* i : in case of CELP->TCX switching, use 1.25 framelength */ const int16_t *coreMsMask, const int16_t restrict_hopsize, -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE const int16_t bfi, /* i : frame loss == 1, frame good == 0 */ const int16_t bfi_apply_damping -#else - const int16_t bfi /* i : frame loss == 1, frame good == 0 */ -#endif ) { IGF_DEC_PRIVATE_DATA_HANDLE hPrivateDataL, hPrivateDataR; @@ -1353,13 +1337,8 @@ void IGFDecApplyStereo( IGF_calc( hPrivateDataL, igfGridIdx, spectrumL, igf_specL ); IGF_calc( hPrivateDataR, igfGridIdx, spectrumR, igf_specR ); -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE IGF_appl( hPrivateDataL, igfGridIdx, spectrumL, igf_specL, hIGFDecL->virtualSpec, hIGFDecL->flag_sparse, bfi_apply_damping ); IGF_appl( hPrivateDataR, igfGridIdx, spectrumR, igf_specR, hIGFDecR->virtualSpec, hIGFDecR->flag_sparse, bfi_apply_damping ); -#else - IGF_appl( hPrivateDataL, igfGridIdx, spectrumL, igf_specL, hIGFDecL->virtualSpec, hIGFDecL->flag_sparse ); - IGF_appl( hPrivateDataR, igfGridIdx, spectrumR, igf_specR, hIGFDecR->virtualSpec, hIGFDecR->flag_sparse ); -#endif } /* reset TCX noise indicator vector */ @@ -1612,7 +1591,6 @@ void init_igf_dec( return; } -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE int16_t get_igf_startline( Decoder_State *st, int16_t L_frame, @@ -1640,4 +1618,3 @@ int16_t get_igf_startline( return igf_startline; } -#endif diff --git a/lib_dec/init_dec.c b/lib_dec/init_dec.c index 2e31017eaa..2598cf29b6 100644 --- a/lib_dec/init_dec.c +++ b/lib_dec/init_dec.c @@ -54,10 +54,8 @@ ivas_error init_decoder( Decoder_State *st, /* o : Decoder static variables structure */ const int16_t idchan /* i : channel ID */ -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE , const MC_MODE mc_mode /* i : MC mode */ -#endif ) { int16_t i; @@ -691,11 +689,7 @@ ivas_error init_decoder( st->enablePlcWaveadjust = 0; /* Init Core Decoder */ -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE open_decoder_LPD( st, st->total_brate, st->last_total_brate, st->bwidth, 0, st->element_mode, 1 ); -#else - open_decoder_LPD( st, st->total_brate, st->last_total_brate, st->bwidth, 0, 1 ); -#endif /* PLC mode initialization */ st->m_decodeMode = DEC_NO_FRAM_LOSS; @@ -714,11 +708,7 @@ ivas_error init_decoder( * FD-CNG decoder *-----------------------------------------------------------------*/ -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE if ( ( st->element_mode == IVAS_CPE_MDCT || idchan == 0 ) && mc_mode != MC_MODE_MCT ) -#else - if ( idchan == 0 && st->element_mode != IVAS_CPE_MDCT ) -#endif { /* Create FD_CNG instance */ if ( ( error = createFdCngDec( &st->hFdCngDec ) ) != IVAS_ERR_OK ) diff --git a/lib_dec/ivas_core_dec.c b/lib_dec/ivas_core_dec.c index b3d5b60eca..fd5d5b3c1e 100644 --- a/lib_dec/ivas_core_dec.c +++ b/lib_dec/ivas_core_dec.c @@ -35,9 +35,7 @@ #ifdef DEBUGGING #include "debug.h" #endif -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE #include -#endif #include #include "cnst.h" #include "rom_com.h" @@ -183,23 +181,6 @@ ivas_error ivas_core_dec( st->flagGuidedAcelp = 0; } -#ifndef MDCT_STEREO_PLC_FADE_2_BG_NOISE - /* PLC: [TCX: Fade-out-recovery] - overlapping part needs to be attenuated for first good frame */ - if ( !st->bfi && st->prev_bfi && ( st->last_core_bfi == TCX_20_CORE || st->last_core_bfi == TCX_10_CORE ) && st->element_mode != IVAS_CPE_MDCT ) - { - if ( st->hPlcInfo != NULL ) - { - v_multc( st->hHQ_core->old_out, st->hPlcInfo->recovery_gain, st->hHQ_core->old_out, st->hTcxDec->L_frameTCX ); - v_multc( st->hHQ_core->old_outLB, st->hPlcInfo->recovery_gain, st->hHQ_core->old_outLB, st->L_frame ); - - if ( !st->hTcxCfg->last_aldo && st->hTcxDec != NULL ) - { - v_multc( st->hTcxDec->syn_OverlFB, st->hPlcInfo->recovery_gain, st->hTcxDec->syn_OverlFB, st->hTcxCfg->tcx_mdct_window_lengthFB ); - v_multc( st->hTcxDec->syn_Overl, st->hPlcInfo->recovery_gain, st->hTcxDec->syn_Overl, st->hTcxCfg->tcx_mdct_window_length ); - } - } - } -#else /* PLC: [TCX: Fade-out-recovery] - overlapping part needs to be attenuated for first good frame */ if ( !st->bfi && st->prev_bfi && ( st->last_core_bfi == TCX_20_CORE || st->last_core_bfi == TCX_10_CORE ) ) { @@ -220,7 +201,6 @@ ivas_error ivas_core_dec( } } } -#endif set_f( voice_factors[n], 0.f, NB_SUBFR16k ); set_f( hb_synth[n], 0.0f, L_FRAME48k ); @@ -422,7 +402,6 @@ ivas_error ivas_core_dec( updateBuffersForDmxMdctStereo( hCPE, output_frame, output, synth ); } -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE if ( sts[0]->bfi == 0 && sts[0]->prev_bfi == 1 ) { /* On first good frame after frameloss undo the whitening of the bg noise shape */ @@ -434,7 +413,6 @@ ivas_error ivas_core_dec( } } } -#endif } /*---------------------------------------------------------------------* diff --git a/lib_dec/ivas_cpe_dec.c b/lib_dec/ivas_cpe_dec.c index b008c68789..12b8fcb899 100644 --- a/lib_dec/ivas_cpe_dec.c +++ b/lib_dec/ivas_cpe_dec.c @@ -689,11 +689,7 @@ ivas_error create_cpe_dec( st->mct_chan_mode = MCT_CHAN_MODE_LFE; } -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE if ( ( error = init_decoder( st, n, st_ivas->mc_mode ) ) != IVAS_ERR_OK ) -#else - if ( ( error = init_decoder( st, n ) ) != IVAS_ERR_OK ) -#endif { return error; } diff --git a/lib_dec/ivas_mct_dec_mct.c b/lib_dec/ivas_mct_dec_mct.c index aaf27e6e1a..b46320cbcd 100644 --- a/lib_dec/ivas_mct_dec_mct.c +++ b/lib_dec/ivas_mct_dec_mct.c @@ -286,11 +286,7 @@ void mctStereoIGF_dec( /* stereo IGF decoding */ assert( ( sts[0]->core == sts[1]->core ) || ( hMCT->hBlockData[b]->hStereoMdct->mdct_stereo_mode[0] == SMDCT_DUAL_MONO ) ); -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE decoder_tcx_IGF_stereo( sts, hMCT->hBlockData[b]->hStereoMdct, hMCT->hBlockData[b]->mask, p_x, L_frame[0], left_rect[0], k, bfi, 1 /* <- is_mct */ ); -#else - decoder_tcx_IGF_stereo( sts, hMCT->hBlockData[b]->hStereoMdct, hMCT->hBlockData[b]->mask, p_x, L_frame[0], left_rect[0], k, bfi ); -#endif } else { diff --git a/lib_dec/ivas_mdct_core_dec.c b/lib_dec/ivas_mdct_core_dec.c index 24bd9e8396..14de87546d 100644 --- a/lib_dec/ivas_mdct_core_dec.c +++ b/lib_dec/ivas_mdct_core_dec.c @@ -102,9 +102,7 @@ static void dec_prm_tcx_sidebits( int16_t p_param[NB_DIV], /* o : pointer to parameters for next round of bs reading*/ int16_t nTnsBitsTCX10[NB_DIV], /* o : number of TNS bits per TCX10 subframe */ Decoder_State *st0, /* i/o: core decoder state handle - for bitstream */ -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE const int16_t MCT_flag, -#endif const int16_t ch /* i : channel */ ) { @@ -134,11 +132,7 @@ static void dec_prm_tcx_sidebits( *--------------------------------------------------------------------------------*/ /* Modes (ACE_GC, ACE_UC, TCX20, TCX10...) */ -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE getTCXMode( st, st0, MCT_flag ); -#else - getTCXMode( st, st0 ); -#endif st->flagGuidedAcelp = 0; @@ -381,11 +375,7 @@ void ivas_mdct_dec_side_bits_frame_channel( tmp = 3; } -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE dec_prm_tcx_sidebits( param[ch], st, ( ( st->element_mode == IVAS_CPE_MDCT && !MCT_flag ) ? sts[0]->hTcxDec->tnsActive : NULL ), p_param[ch], nTnsBitsTCX10[ch], st0, MCT_flag, tmp ); -#else - dec_prm_tcx_sidebits( param[ch], st, ( ( st->element_mode == IVAS_CPE_MDCT && !MCT_flag ) ? sts[0]->hTcxDec->tnsActive : NULL ), p_param[ch], nTnsBitsTCX10[ch], st0, tmp ); -#endif assert( st->BER_detect != 1 ); } @@ -481,18 +471,14 @@ void ivas_mdct_core_invQ( const int16_t *prm_sqQ; int16_t L_frameTCX_global[CPE_CHANNELS]; float tmp_ms_sig[CPE_CHANNELS][N_MAX]; -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE float concealment_noise[CPE_CHANNELS][L_FRAME48k]; TONALMDCTCONC_NOISE_GEN_MODE noise_gen_mode_bfi; -#endif wmops_sub_start( "mdct_core_invQ" ); sts = hCPE->hCoreCoder; bfi = sts[0]->bfi; -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE noise_gen_mode_bfi = -1; -#endif set_f( xn_buf, 0, L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX ); set_s( total_nbbits, 0, CPE_CHANNELS ); @@ -520,7 +506,6 @@ void ivas_mdct_core_invQ( #endif } -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE if ( bfi ) { if ( sts[0]->core == sts[1]->core ) @@ -536,7 +521,6 @@ void ivas_mdct_core_invQ( noise_gen_mode_bfi = TCX20_IN_0_TCX10_IN_1; } } -#endif /* parameter decoding */ for ( ch = 0; ch < CPE_CHANNELS; ch++ ) @@ -738,15 +722,11 @@ void ivas_mdct_core_invQ( mvr2r( x[ch][k], x_0[ch][k], L_frameTCX[ch] ); -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE if ( bfi && !isMCT ) { TonalMdctConceal_create_concealment_noise( concealment_noise[ch], hCPE, L_frameTCX[ch], L_frame[ch], ch, k, st->core, st->hTcxDec->cummulative_damping_tcx, noise_gen_mode_bfi ); } decoder_tcx_noisefilling( st, concealment_noise[ch], Aq[ch], L_frameTCX_global[ch], L_spec[ch], L_frame[ch], L_frameTCX[ch], x[ch][k], NULL, &tmp_concealment_method, gain_tcx, prm_sqQ, nf_seed, bfi, isMCT, k ); -#else - decoder_tcx_noisefilling( st, Aq[ch], L_frameTCX_global[ch], L_spec[ch], L_frame[ch], L_frameTCX[ch], x[ch][k], NULL, &tmp_concealment_method, gain_tcx, prm_sqQ, nf_seed, bfi, k ); -#endif decoder_tcx_noiseshaping_igf( st, L_spec[ch], L_frame[ch], L_frameTCX[ch], left_rect[ch], x[ch][k], NULL, &tmp_concealment_method, bfi ); @@ -863,11 +843,7 @@ void ivas_mdct_core_reconstruct( TonalMDCTConceal_SaveTimeSignal( st->hTonalMDCTConc, synthFB, L_frameTCX[ch] ); } -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE decoder_tcx_post( st, synth, synthFB, NULL, bfi, isMCT ); -#else - decoder_tcx_post( st, synth, synthFB, NULL, bfi ); -#endif } else /*ACELP core for ACELP-PLC */ { @@ -875,19 +851,11 @@ void ivas_mdct_core_reconstruct( /* PLC: [TCX: TD PLC] */ if ( isMCT ) { -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE con_tcx( st, &synthFB[0], -1.f, NULL, 0, NULL ); -#else - con_tcx( st, &synthFB[0], -1.f, NULL, 0 ); -#endif } else { -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE con_tcx( st, &synthFB[0], hCPE->hStereoMdct->lastCoh, &sts[0]->seed_acelp, ( sts[1]->core != ACELP_CORE ) ? 1 : 0, &st->hFdCngDec->hFdCngCom->A_cng[0] ); -#else - con_tcx( st, &synthFB[0], hCPE->hStereoMdct->lastCoh, &sts[0]->seed_acelp, ( sts[1]->core != ACELP_CORE ) ? 1 : 0 ); -#endif } lerp( synthFB, synth, st->L_frame, st->hTcxDec->L_frameTCX ); @@ -1066,24 +1034,15 @@ void ivas_mdct_core_tns_ns( { sns_interpolate_scalefactors( &sns_int_scf[0], &Aq[ch][k * M], DEC ); -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE if ( isMCT && st->hTonalMDCTConc != NULL && ( ( k + 1 ) == nSubframes[ch] ) ) -#else - if ( isMCT && st->hTonalMDCTConc != NULL ) -#endif { -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE TonalMDCTConceal_SaveFreqSignal( st->hTonalMDCTConc, x[ch][k], L_frameTCX[ch], L_frame[ch], &sns_int_scf[0], get_igf_startline( st, L_frame[ch], L_frameTCX[ch] ) ); -#else - TonalMDCTConceal_SaveFreqSignal( st->hTonalMDCTConc, x[ch][k], L_frameTCX[ch], L_frame[ch], &sns_int_scf[0] ); -#endif } } else { if ( st->hTonalMDCTConc != NULL ) { -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE if ( !isMCT && st->hTcxDec->cummulative_damping_tcx != 1.f ) { float *scf_last, *scf_bg; @@ -1107,9 +1066,6 @@ void ivas_mdct_core_tns_ns( st->hTonalMDCTConc->scf_fadeout = 1.0f; mvr2r( st->hTonalMDCTConc->lastBlockData.scaleFactors, &sns_int_scf[0], st->hTonalMDCTConc->nScaleFactors ); } -#else - mvr2r( st->hTonalMDCTConc->lastBlockData.scaleFactors, &sns_int_scf[0], st->hTonalMDCTConc->nScaleFactors ); -#endif } } diff --git a/lib_dec/ivas_sce_dec.c b/lib_dec/ivas_sce_dec.c index 1aa3e083f0..97ee2e8336 100644 --- a/lib_dec/ivas_sce_dec.c +++ b/lib_dec/ivas_sce_dec.c @@ -342,11 +342,7 @@ ivas_error create_sce_dec( st->total_brate = hSCE->element_brate; /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() */ st->mct_chan_mode = MCT_CHAN_MODE_REGULAR; -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE if ( ( error = init_decoder( st, 0, st_ivas->mc_mode ) ) != IVAS_ERR_OK ) -#else - if ( ( error = init_decoder( st, 0 ) ) != IVAS_ERR_OK ) -#endif { return error; } diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 9f36670a7d..8c0ea336c3 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -320,10 +320,8 @@ typedef struct stereo_mdct_dec_data_structure int16_t prev_ms_mask[NB_DIV][MAX_SFB]; float lastCoh; -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE int16_t noise_seeds_channels[CPE_CHANNELS]; int16_t noise_seed_common; -#endif int16_t isSBAStereoMode; } STEREO_MDCT_DEC_DATA, *STEREO_MDCT_DEC_DATA_HANDLE; diff --git a/lib_dec/ivas_stereo_mdct_core_dec.c b/lib_dec/ivas_stereo_mdct_core_dec.c index 1e923b5b7e..141858ccf8 100644 --- a/lib_dec/ivas_stereo_mdct_core_dec.c +++ b/lib_dec/ivas_stereo_mdct_core_dec.c @@ -50,9 +50,7 @@ *-------------------------------------------------------------------------*/ static void apply_dmx_weights( CPE_DEC_HANDLE hCPE, float *x[CPE_CHANNELS][NB_DIV], int16_t transform_type_left[NB_DIV], int16_t transform_type_right[NB_DIV] ); -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE static void run_min_stats( Decoder_State **sts, float *x[CPE_CHANNELS][NB_DIV] ); -#endif /*-------------------------------------------------------------------* * convert_coeffs_to_higher_res() @@ -294,11 +292,7 @@ void stereo_mdct_core_dec( assert( ( sts[0]->core == sts[1]->core ) || ( hCPE->hStereoMdct->mdct_stereo_mode[0] == SMDCT_DUAL_MONO ) ); /* stereo IGF decoding */ -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE decoder_tcx_IGF_stereo( sts, hCPE->hStereoMdct, ms_mask, x, L_frame[0], left_rect[0], k, bfi, 0 /* <- is_mct */ ); -#else - decoder_tcx_IGF_stereo( sts, hCPE->hStereoMdct, ms_mask, x, L_frame[0], left_rect[0], k, bfi ); -#endif } else { @@ -328,17 +322,9 @@ void stereo_mdct_core_dec( sns_interpolate_scalefactors( &sns_int_scf[0], &Aq[ch][k * M], DEC ); -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE if ( st->hTonalMDCTConc != NULL && ( ( k + 1 ) == nSubframes[ch] ) ) -#else - if ( st->hTonalMDCTConc != NULL ) -#endif { -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE TonalMDCTConceal_SaveFreqSignal( st->hTonalMDCTConc, x[ch][k], L_frameTCX[ch], L_frame[ch], &sns_int_scf[0], get_igf_startline( st, L_frame[ch], L_frameTCX[ch] ) ); -#else - TonalMDCTConceal_SaveFreqSignal( st->hTonalMDCTConc, x[ch][k], L_frameTCX[ch], L_frame[ch], &sns_int_scf[0] ); -#endif } } @@ -368,9 +354,7 @@ void stereo_mdct_core_dec( ivas_ls_setup_conversion_process_mdct_param_mc( st_ivas, x ); } -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE run_min_stats( sts, x ); -#endif if ( hCPE->nchan_out == 1 && ( !bfi || ( bfi && sts[0]->core != ACELP_CORE && sts[1]->core != ACELP_CORE ) ) ) { @@ -589,7 +573,6 @@ static void apply_dmx_weights( return; } -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE /*-------------------------------------------------------------------* * run_min_stats() * @@ -669,4 +652,3 @@ static void run_min_stats( st->VAD = save_VAD[ch]; } } -#endif diff --git a/lib_dec/ivas_stereo_switching_dec.c b/lib_dec/ivas_stereo_switching_dec.c index 9257f5cc3d..355eed3906 100644 --- a/lib_dec/ivas_stereo_switching_dec.c +++ b/lib_dec/ivas_stereo_switching_dec.c @@ -424,9 +424,7 @@ ivas_error stereo_memory_dec( if ( hCPE->last_element_mode == IVAS_CPE_MDCT ) { cpy_tcx_ltp_data( hCPE->hCoreCoder[1]->hTcxLtpDec, hCPE->hStereoDft->hTcxLtpDec, output_Fs ); -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE deleteFdCngDec( &hCPE->hCoreCoder[1]->hFdCngDec ); -#endif } /* memory update - needed in TD stereo, TCX/HQ frame -> DFT stereo, ACELP frame switching */ @@ -489,12 +487,10 @@ ivas_error stereo_memory_dec( /* deallocated TCX/IGF structures for second channel */ deallocate_CoreCoder_TCX( hCPE->hCoreCoder[1] ); -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE if ( hCPE->last_element_mode == IVAS_CPE_MDCT ) { deleteFdCngDec( &hCPE->hCoreCoder[1]->hFdCngDec ); } -#endif /* allocate TD stereo data structure */ if ( hCPE->hStereoTD != NULL ) @@ -675,10 +671,6 @@ ivas_error stereo_memory_dec( /* deallocate core-decoder substructures */ deallocate_CoreCoder( st ); -#ifndef MDCT_STEREO_PLC_FADE_2_BG_NOISE - /* deallocate FD_CNG substructure */ - deleteFdCngDec( &st->hFdCngDec ); -#endif st->first_CNG = 0; } @@ -702,7 +694,6 @@ ivas_error stereo_memory_dec( } } -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE /* allocate Fd-Cng structure for second channel */ if ( ( error = createFdCngDec( &st->hFdCngDec ) ) != IVAS_ERR_OK ) { @@ -711,7 +702,6 @@ ivas_error stereo_memory_dec( /* Init FD-CNG */ initFdCngDec( st ); -#endif if ( hCPE->last_element_mode == IVAS_CPE_DFT ) { @@ -1494,10 +1484,8 @@ void stereo_switching_dec( sts[1]->hTcxCfg->tcx_mdct_window_length = sts[0]->hTcxCfg->tcx_mdct_window_length; sts[1]->pit_res_max = sts[0]->pit_res_max; sts[1]->pit_res_max_past = sts[0]->pit_res_max_past; -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE sts[1]->hTcxDec->L_frameTCX = sts[0]->hTcxDec->L_frameTCX; sts[1]->hTcxDec->conceal_eof_gain = sts[0]->hTcxDec->conceal_eof_gain; -#endif } } else if ( hCPE->element_mode == IVAS_CPE_TD && hCPE->last_element_mode == IVAS_CPE_MDCT ) diff --git a/lib_dec/ivas_tcx_core_dec.c b/lib_dec/ivas_tcx_core_dec.c index e46c32ddbb..9420be9eb9 100644 --- a/lib_dec/ivas_tcx_core_dec.c +++ b/lib_dec/ivas_tcx_core_dec.c @@ -150,11 +150,7 @@ void stereo_tcx_init_dec( } /* Reconfigure Core */ -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE mode_switch_decoder_LPD( st, st->bwidth, st->bits_frame_nominal * FRAMES_PER_SEC, st->last_bits_frame_nominal * FRAMES_PER_SEC, frame_size_index, is_mct, last_element_mode ); -#else - mode_switch_decoder_LPD( st, st->bwidth, st->bits_frame_nominal * FRAMES_PER_SEC, st->last_bits_frame_nominal * FRAMES_PER_SEC, frame_size_index, is_mct ); -#endif } return; @@ -457,11 +453,7 @@ void stereo_tcx_core_dec( } /* PLC: [TCX: TD PLC] */ -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE con_tcx( st, &synthFB[0], -1.f, NULL, 0, NULL ); -#else - con_tcx( st, &synthFB[0], -1.f, NULL, 0 ); -#endif lerp( synthFB, synth, st->L_frame, hTcxDec->L_frameTCX ); st->con_tcx = 1; set_f( &st->mem_pitch_gain[2], st->lp_gainp, st->nb_subfr ); @@ -589,11 +581,7 @@ void stereo_tcx_core_dec( TonalMDCTConceal_SaveTimeSignal( st->hTonalMDCTConc, synthFB, hTcxDec->L_frameTCX ); } -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE decoder_tcx_post( st, synth, synthFB, Aq, bfi, 0 ); -#else - decoder_tcx_post( st, synth, synthFB, Aq, bfi ); -#endif if ( st->core == TCX_20_CORE ) { @@ -750,11 +738,7 @@ void stereo_tcx_core_dec( if ( st->element_mode != IVAS_CPE_TD ) { -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE ApplyFdCng( signal_out, NULL, NULL, NULL, st, st->bfi, 0 ); -#else - ApplyFdCng( signal_out, NULL, NULL, st, st->bfi, 0 ); -#endif } /* Generate additional comfort noise to mask potential coding artefacts */ @@ -779,11 +763,7 @@ void stereo_tcx_core_dec( if ( st->element_mode == IVAS_CPE_TD && st->idchan == 0 ) { -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE ApplyFdCng( signal_out, NULL, NULL, NULL, st, st->bfi, 0 ); -#else - ApplyFdCng( signal_out, NULL, NULL, st, st->bfi, 0 ); -#endif } } @@ -867,11 +847,7 @@ static void dec_prm_tcx( *--------------------------------------------------------------------------------*/ /* Modes (ACE_GC, ACE_UC, TCX20, TCX10...) */ -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE getTCXMode( st, st, 0 /* <- MCT_flag */ ); -#else - getTCXMode( st, st ); -#endif /* last_core for error concealment */ if ( !st->use_partial_copy && st->element_mode != IVAS_CPE_MDCT ) diff --git a/lib_dec/stat_dec.h b/lib_dec/stat_dec.h index 0c7a836cb4..d86cd42b72 100644 --- a/lib_dec/stat_dec.h +++ b/lib_dec/stat_dec.h @@ -204,7 +204,6 @@ typedef struct Float32 *secondLastPcmOut; float *secondLastPowerSpectrum; -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE float scaleFactorsBackground[FDNS_NPTS]; float scf_fadeout; PsychoacousticParameters *psychParams; @@ -214,7 +213,6 @@ typedef struct float last_block_nrg; float curr_noise_nrg; float faded_signal_nrg; -#endif float nFramesLost; diff --git a/lib_dec/tonalMDCTconcealment.c b/lib_dec/tonalMDCTconcealment.c index 6c0203ed42..0078ca8bb4 100644 --- a/lib_dec/tonalMDCTconcealment.c +++ b/lib_dec/tonalMDCTconcealment.c @@ -93,7 +93,6 @@ ivas_error TonalMDCTConceal_Init( hTonalMDCTConc->nSamplesCore = nSamplesCore; hTonalMDCTConc->nScaleFactors = nScaleFactors; -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE set_zero( hTonalMDCTConc->scaleFactorsBackground, FDNS_NPTS ); hTonalMDCTConc->scf_fadeout = 1.0f; PsychoacousticParameters_Init( INT_FS_16k, L_FRAME16k, 64, 1, 1, &hTonalMDCTConc->psychParamsTCX20 ); @@ -103,7 +102,6 @@ ivas_error TonalMDCTConceal_Init( hTonalMDCTConc->last_block_nrg = 0.0f; hTonalMDCTConc->curr_noise_nrg = 0.0f; hTonalMDCTConc->faded_signal_nrg = 0.0f; -#endif /* Offset the pointer to the end of buffer, so that pTCI is not destroyed when new time samples are stored in lastPcmOut */ @@ -125,10 +123,8 @@ void TonalMDCTConceal_SaveFreqSignal( const uint16_t nNewSamples, const uint16_t nNewSamplesCore, const float *scaleFactors -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE , const int16_t infoIGFStartLine -#endif ) { float *temp; @@ -170,7 +166,6 @@ void TonalMDCTConceal_SaveFreqSignal( if ( ( nNewSamples > 0 ) && ( nNewSamples <= 2 * L_FRAME_MAX ) ) { /* Store new data */ -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE int16_t i; hTonalMDCTConc->last_block_nrg = 0.0f; @@ -183,9 +178,6 @@ void TonalMDCTConceal_SaveFreqSignal( { hTonalMDCTConc->lastBlockData.spectralData[i] = mdctSpectrum[i]; } -#else - mvr2r( mdctSpectrum, hTonalMDCTConc->lastBlockData.spectralData, nNewSamples ); -#endif mvr2r( scaleFactors, hTonalMDCTConc->lastBlockData.scaleFactors, hTonalMDCTConc->nScaleFactors ); } @@ -502,28 +494,20 @@ void TonalMDCTConceal_InsertNoise( int16_t *pSeed, const float tiltCompFactor, const float crossfadeGain, -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE const float concealment_noise[L_FRAME48k], const float cngLevelBackgroundTrace_bfi, -#endif const int16_t crossOverFreq ) { int16_t i, l; float x, y; Word16 rnd; float g, nrgNoiseInLastFrame, nrgWhiteNoise, tiltFactor, tilt; -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE float last_block_nrg_correct; -#endif wmops_sub_start( "InsertNoise" ); g = 1.0f - crossfadeGain; -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE - if ( !hTonalMDCTConc->lastBlockData.blockIsConcealed ) -#else if ( !hTonalMDCTConc->lastBlockData.blockIsConcealed ) -#endif { rnd = 1977; } @@ -532,7 +516,6 @@ void TonalMDCTConceal_InsertNoise( rnd = *pSeed; } -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE /* based on what is done in tcx_noise_filling() */ /* always initialize these to avoid compiler warnings */ tiltFactor = (float) pow( max( 0.375f, tiltCompFactor ), 1.0f / hTonalMDCTConc->lastBlockData.nSamples ); @@ -541,14 +524,12 @@ void TonalMDCTConceal_InsertNoise( nrgWhiteNoise = 0.0f; hTonalMDCTConc->faded_signal_nrg = 0.0f; last_block_nrg_correct = 0.0f; -#endif if ( !hTonalMDCTConc->lastBlockData.blockIsValid ) { /* may just become active if the very first frame is lost */ set_f( mdctSpectrum, 0.0f, hTonalMDCTConc->nSamples ); } -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE else if ( concealment_noise != NULL ) { if ( !tonalConcealmentActive ) @@ -737,15 +718,8 @@ void TonalMDCTConceal_InsertNoise( v_multc( mdctSpectrum, nrg_corr_factor, mdctSpectrum, crossOverFreq ); } } -#endif else { -#ifndef MDCT_STEREO_PLC_FADE_2_BG_NOISE - /* based on what is done in tcx_noise_filling() */ - tiltFactor = (float) pow( max( 0.375f, tiltCompFactor ), 1.0f / hTonalMDCTConc->lastBlockData.nSamples ); - tilt = 1.0f; - nrgNoiseInLastFrame = nrgWhiteNoise = 0.0f; -#endif if ( !tonalConcealmentActive ) { for ( i = 0; i < crossOverFreq; i++ ) @@ -992,7 +966,6 @@ void TonalMDCTConceal_SaveTimeSignal( return; } -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE void TonalMdctConceal_create_concealment_noise( float concealment_noise[L_FRAME48k], CPE_DEC_HANDLE hCPE, @@ -1208,4 +1181,3 @@ void TonalMdctConceal_whiten_noise_shape( wmops_sub_end(); } -#endif diff --git a/lib_enc/enc_prm.c b/lib_enc/enc_prm.c index 33c9d6fc7b..a68f95aff6 100644 --- a/lib_enc/enc_prm.c +++ b/lib_enc/enc_prm.c @@ -55,9 +55,7 @@ void writeTCXMode( Encoder_State *st, /* i/o: encoder state structure */ BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE const int16_t is_mct, -#endif int16_t *nbits_start /* o : nbits start */ ) { @@ -88,12 +86,10 @@ void writeTCXMode( push_next_indice( hBstr, index, 2 ); -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE if ( st->element_mode == IVAS_CPE_MDCT && !is_mct ) { push_next_indice( hBstr, st->vad_flag, 1 ); } -#endif } else { @@ -792,11 +788,7 @@ void enc_prm( /* EVS header */ /* Modes (ACE_GC, ACE_UC, TCX20, TCX10...) */ -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE writeTCXMode( st, st->hBstr, 0, /* <- is_mct */ &nbits_start ); -#else - writeTCXMode( st, st->hBstr, &nbits_start ); -#endif /* write last_core for error concealment */ if ( !( core == ACELP_CORE && st->hTcxCfg->lfacNext <= 0 ) ) diff --git a/lib_enc/ivas_mdct_core_enc.c b/lib_enc/ivas_mdct_core_enc.c index 0d2f5817d6..5234ae5c60 100644 --- a/lib_enc/ivas_mdct_core_enc.c +++ b/lib_enc/ivas_mdct_core_enc.c @@ -63,9 +63,7 @@ static void enc_prm_pre_mdct( int16_t param[], /* i : parameters */ const int16_t *no_param_tns, /* i : number of TNS parameters per subframe */ int16_t p_param[2], /* o : pointer to parameters for next round of bs writing */ -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE const int16_t is_mct, -#endif BSTR_ENC_HANDLE hBstr /* i/o: encoder bitstream handle */ ) { @@ -80,11 +78,7 @@ static void enc_prm_pre_mdct( * Header *--------------------------------------------------------------------------------*/ -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE writeTCXMode( st, hBstr, is_mct, &nbits_start ); -#else - writeTCXMode( st, hBstr, &nbits_start ); -#endif /* write last_core for core switching and error concealment */ push_next_indice( hBstr, st->last_core != ACELP_CORE, 1 ); @@ -1065,11 +1059,7 @@ void ivas_mdct_core_whitening_enc( continue; } -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE enc_prm_pre_mdct( st, param_core[ch], ( ( ( ch > 0 ) && ( sts[0]->hTcxEnc->fUseTns[0] + sts[0]->hTcxEnc->fUseTns[1] > 0 ) && !mct_on ) ? tnsSize[ch] : NULL ), p_param[ch], mct_on, hBstr ); -#else - enc_prm_pre_mdct( st, param_core[ch], ( ( ( ch > 0 ) && ( sts[0]->hTcxEnc->fUseTns[0] + sts[0]->hTcxEnc->fUseTns[1] > 0 ) && !mct_on ) ? tnsSize[ch] : NULL ), p_param[ch], hBstr ); -#endif if ( ch > 0 && sts[0]->hTcxEnc->fUseTns[0] + sts[0]->hTcxEnc->fUseTns[1] > 0 && !mct_on ) { diff --git a/lib_enc/ivas_sns_enc.c b/lib_enc/ivas_sns_enc.c index 87019b8d91..6790f0cf6d 100644 --- a/lib_enc/ivas_sns_enc.c +++ b/lib_enc/ivas_sns_enc.c @@ -43,175 +43,6 @@ #endif #include "wmops.h" -#ifndef MDCT_STEREO_PLC_FADE_2_BG_NOISE -#define SNS_NPTS 16 /* Number of downsampled SNS parameters */ - -/*------------------------------------------------------------------- - * sns_compute_scf() - * - * - *-------------------------------------------------------------------*/ - -void sns_compute_scf( - float spectrum[], - const PsychoacousticParameters *pPsychParams, - const int16_t L_frame, - float *scf ) -{ - int16_t i, n, k; - float x[FDNS_NPTS], xs[FDNS_NPTS], sum, mean, xl4[SNS_NPTS], nf, xl[FDNS_NPTS]; - float tilt; - const uint8_t nBands = pPsychParams->nBands; - const uint8_t *bandLengths = pPsychParams->bandLengths; - int8_t bw = 0; - - - const float w_0 = 1.0f / 12.0f; - const float w_1 = 2.0f / 12.0f; - const float w_2 = 0.25f; /* 3.0f / 12.0f */ - const float w_3 = w_2; - const float w_4 = w_1; - const float w_5 = w_0; - - const float scale_log = INV_LOG_2 * 0.5f; - - assert( nBands == 64 ); - - set_f( x, 0.0f, FDNS_NPTS ); - - if ( bandLengths == NULL ) - { - bw = (int8_t) ( L_frame / nBands ); - /* Energy per band */ - k = 0; - for ( i = 0; i < nBands; ++i ) - { - x[i] = 0.0f; - for ( n = 0; n < bw; ++n, ++k ) - { - x[i] += spectrum[k]; - } - x[i] /= bw; - } - } - else - { - /* Energy per band */ - k = 0; - for ( i = 0; i < nBands; ++i ) - { - x[i] = 0.0f; - for ( n = 0; n < bandLengths[i]; ++n, ++k ) - { - x[i] += spectrum[k]; - } - x[i] /= bandLengths[i]; - } - } - - /* Smoothing */ - xs[0] = 0.75f * x[0] + 0.25f * x[1]; - - for ( i = 1; i < FDNS_NPTS - 1; i++ ) - { - xs[i] = 0.5f * x[i] + 0.25f * x[i - 1] + 0.25f * x[i + 1]; - } - - xs[FDNS_NPTS - 1] = 0.75f * x[FDNS_NPTS - 1] + 0.25f * x[FDNS_NPTS - 2]; - - /* Pre-emphasis */ - if ( L_frame == L_FRAME16k ) - { - tilt = 18.f; - } - else if ( L_frame == L_SPEC16k_EXT ) - { - tilt = 20.f; - } - else if ( L_frame == L_FRAME25_6k ) - { - tilt = 22.f; - } - else if ( L_frame == L_FRAME32k ) - { - tilt = 26.f; - } - else if ( L_frame == L_SPEC32k_EXT ) - { - tilt = 30.f; - } - else - { - tilt = 0.f; - assert( 0 && "illegal frame length in sns_compute_scf" ); - } - - for ( i = 0; i < FDNS_NPTS; i++ ) - { - xs[i] = xs[i] * powf( 10.0f, (float) i * (float) tilt / ( (float) FDNS_NPTS - 1.0f ) / 10.0f ); - } - - /* Noise floor at -40dB */ - sum = sum_f( xs, FDNS_NPTS ); - mean = sum / FDNS_NPTS; - - nf = mean * powf( 10.0f, -4.0f ); - nf = max( nf, powf( 2.0f, -32.0f ) ); - - - for ( i = 0; i < FDNS_NPTS; i++ ) - { - if ( xs[i] < nf ) - { - xs[i] = nf; - } - } - - /* Log-domain */ - for ( i = 0; i < FDNS_NPTS; i++ ) - { - xl[i] = logf( xs[i] ) * scale_log; - } - - /* Downsampling */ - xl4[0] = w_0 * xl[0] + - w_1 * xl[0] + - w_2 * xl[1] + - w_3 * xl[2] + - w_4 * xl[3] + - w_5 * xl[4]; - - - for ( n = 1; n < SNS_NPTS - 1; n++ ) - { - int16_t n4 = 4 * n; - xl4[n] = w_0 * xl[n4 - 1] + - w_1 * xl[n4] + - w_2 * xl[n4 + 1] + - w_3 * xl[n4 + 2] + - w_4 * xl[n4 + 3] + - w_5 * xl[n4 + 4]; - } - - xl4[SNS_NPTS - 1] = w_0 * xl[FDNS_NPTS - 5] + - w_1 * xl[FDNS_NPTS - 4] + - w_2 * xl[FDNS_NPTS - 3] + - w_3 * xl[FDNS_NPTS - 2] + - w_4 * xl[FDNS_NPTS - 1] + - w_5 * xl[FDNS_NPTS - 1]; - - /* Remove mean and scaling */ - sum = sum_f( xl4, SNS_NPTS ); - mean = sum / SNS_NPTS; - - for ( i = 0; i < SNS_NPTS; i++ ) - { - scf[i] = 0.85f * ( xl4[i] - mean ); - } - - return; -} -#endif /*------------------------------------------------------------------- diff --git a/lib_enc/ivas_tcx_core_enc.c b/lib_enc/ivas_tcx_core_enc.c index 4bd88cb00d..2c1e4a9051 100644 --- a/lib_enc/ivas_tcx_core_enc.c +++ b/lib_enc/ivas_tcx_core_enc.c @@ -268,11 +268,7 @@ void stereo_tcx_core_enc( *--------------------------------------------------------------------------------*/ /* TCX20/TCX10 and coder type */ -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE writeTCXMode( st, hBstr, 0, /* <- is_mct */ &nbits_start ); -#else - writeTCXMode( st, hBstr, &nbits_start ); -#endif /* write last_core for error concealment */ push_next_indice( hBstr, ( st->last_core != ACELP_CORE || st->core == TCX_10_CORE ), 1 ); -- GitLab From 37bf5da725492c9b3a1f4c390d51a01b2ecb34c4 Mon Sep 17 00:00:00 2001 From: kiene Date: Thu, 20 Oct 2022 15:30:44 +0200 Subject: [PATCH 2/2] acceptFADE_TO_ZERO_FOR_TOO_LONG_FRAMELOSS --- lib_com/ivas_cnst.h | 2 -- lib_com/options.h | 1 - lib_dec/dec_tcx.c | 2 -- lib_dec/er_dec_tcx.c | 2 -- 4 files changed, 7 deletions(-) diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index 5884d084b6..7d84adbb12 100644 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -796,10 +796,8 @@ enum fea_names #define SNS_NPTS 16 /* Number of downsampled SNS parameters */ #define MDCT_ST_PLC_FADEOUT_MIN_NOISE_NRG 0.001f -#ifdef FADE_TO_ZERO_FOR_TOO_LONG_FRAMELOSS #define MDCT_ST_PLC_FADEOUT_MAX_CONC_FRAME 2 * FRAMES_PER_SEC #define MDCT_ST_PLC_FADEOUT_TO_ZERO_LEN 20 -#endif typedef enum { EQUAL_CORES, diff --git a/lib_com/options.h b/lib_com/options.h index 150ecc0dc1..1c21e85d2d 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -142,7 +142,6 @@ #define DISABLE_ADAP_RES_COD_TMP /* temporary fix for IVAS-403, disables adaptive residual coding */ /*#define ITD_WINNER_GAIN_MODIFY */ /* ITD optimization - WORK IN PROGRESS */ /*#define FIX_I4_OL_PITCH*/ /* fix open-loop pitch used for EVS core switching */ -#define FADE_TO_ZERO_FOR_TOO_LONG_FRAMELOSS /*#define FIX_I1_113*/ /* under review : MCT bit distribution optimization for SBA high bitrates*/ #define FIX_I13_TCX_TNS_ISSUE /* Issue 13: Fix reported artifacts. Bug in TNS with TCX5 */ diff --git a/lib_dec/dec_tcx.c b/lib_dec/dec_tcx.c index b5f78ab052..d625139a47 100644 --- a/lib_dec/dec_tcx.c +++ b/lib_dec/dec_tcx.c @@ -192,7 +192,6 @@ void decoder_tcx_post( if ( st->tcxonly ) { gainCNG = hTcxDec->CngLevelBackgroundTrace_bfi / ( level_syn + 0.01f ); -#ifdef FADE_TO_ZERO_FOR_TOO_LONG_FRAMELOSS if ( st->element_mode == IVAS_CPE_MDCT && !isMCT ) { @@ -205,7 +204,6 @@ void decoder_tcx_post( gainCNG *= 1.f - (float) ( st->nbLostCmpt - MDCT_ST_PLC_FADEOUT_MAX_CONC_FRAME ) / MDCT_ST_PLC_FADEOUT_TO_ZERO_LEN; } } -#endif } else { diff --git a/lib_dec/er_dec_tcx.c b/lib_dec/er_dec_tcx.c index 5a1cb5f881..bf561c2abd 100644 --- a/lib_dec/er_dec_tcx.c +++ b/lib_dec/er_dec_tcx.c @@ -447,7 +447,6 @@ void con_tcx( { gainCNG = hTcxDec->CngLevelBackgroundTrace_bfi / gainSynthDeemph; -#ifdef FADE_TO_ZERO_FOR_TOO_LONG_FRAMELOSS if ( st->element_mode == IVAS_CPE_MDCT && A_cng != NULL ) { if ( st->nbLostCmpt > MDCT_ST_PLC_FADEOUT_MAX_CONC_FRAME + MDCT_ST_PLC_FADEOUT_TO_ZERO_LEN ) @@ -459,7 +458,6 @@ void con_tcx( gainCNG *= 1.f - (float) ( st->nbLostCmpt - MDCT_ST_PLC_FADEOUT_MAX_CONC_FRAME ) / MDCT_ST_PLC_FADEOUT_TO_ZERO_LEN; } } -#endif } else { -- GitLab