From 9d1d7ebc8d9fa470716a9f0877dfe32a0089ccb9 Mon Sep 17 00:00:00 2001 From: knj Date: Wed, 13 Jul 2022 09:00:13 +0200 Subject: [PATCH 01/26] Modifications for MDCT-Stereo PLC fadeout --- lib_com/ivas_cnst.h | 2 +- lib_com/ivas_prot.h | 8 +++--- lib_com/ivas_sns_com.c | 4 +-- lib_com/ivas_stereo_psychlpc_com.c | 2 +- lib_com/options.h | 2 +- lib_com/prot.h | 24 ++++++++-------- lib_dec/acelp_core_dec.c | 8 +++--- lib_dec/amr_wb_dec.c | 2 +- lib_dec/core_dec_init.c | 6 ++-- lib_dec/core_dec_switch.c | 4 +-- lib_dec/dec_LPD.c | 4 +-- lib_dec/dec_acelp_tcx_main.c | 2 +- lib_dec/dec_prm.c | 6 ++-- lib_dec/dec_tcx.c | 43 +++++++++++++++++------------ lib_dec/er_dec_tcx.c | 18 ++++++------ lib_dec/evs_dec.c | 2 +- lib_dec/fd_cng_dec.c | 28 +++++++++---------- lib_dec/init_dec.c | 6 ++-- lib_dec/ivas_core_dec.c | 6 ++-- lib_dec/ivas_cpe_dec.c | 2 +- lib_dec/ivas_mdct_core_dec.c | 30 ++++++++++---------- lib_dec/ivas_sce_dec.c | 2 +- lib_dec/ivas_stat_dec.h | 2 +- lib_dec/ivas_stereo_mdct_core_dec.c | 10 +++---- lib_dec/ivas_stereo_switching_dec.c | 8 +++--- lib_dec/ivas_tcx_core_dec.c | 12 ++++---- lib_dec/stat_dec.h | 2 +- lib_dec/tonalMDCTconcealment.c | 16 +++++------ lib_enc/enc_prm.c | 6 ++-- lib_enc/ivas_mdct_core_enc.c | 6 ++-- lib_enc/ivas_sns_enc.c | 2 +- lib_enc/ivas_tcx_core_enc.c | 2 +- 32 files changed, 143 insertions(+), 134 deletions(-) diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index cc600418c6..e3a7b0485c 100644 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -797,7 +797,7 @@ enum fea_names #define MAX_MDCT_ITD_BRATE IVAS_64k #define SNS_LOW_BR_MODE -1 -#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE #define SNS_NPTS 16 /* Number of downsampled SNS parameters */ #define MDCT_ST_PLC_FADEOUT_START_FRAME 3 diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 0b5fb14d51..753976cb88 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -1945,7 +1945,7 @@ void decoder_tcx_invQ( const int16_t **prm_sqQ, int16_t *nf_seed, const int16_t bfi, /* i : Bad frame indicator */ -#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#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 */ @@ -1953,7 +1953,7 @@ void decoder_tcx_invQ( void decoder_tcx_noisefilling( Decoder_State *st, /* i/o: coder memory state */ -#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE float concealment_noise[L_FRAME48k], #endif const float A[], /* i : coefficients NxAz[M+1] */ @@ -1968,7 +1968,7 @@ void decoder_tcx_noisefilling( const int16_t *prm_sqQ, int16_t nf_seed, const int16_t bfi, /* i : Bad frame indicator */ -#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#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 */ @@ -5617,7 +5617,7 @@ ivas_error ivas_orient_trk_GetTrackedOrientation( float *roll ); -#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE void TonalMdctConceal_create_concealment_noise( float concealment_noise[L_FRAME48k], CPE_DEC_HANDLE hCPE, diff --git a/lib_com/ivas_sns_com.c b/lib_com/ivas_sns_com.c index 51f5fcee64..b1555a038b 100644 --- a/lib_com/ivas_sns_com.c +++ b/lib_com/ivas_sns_com.c @@ -37,7 +37,7 @@ #include "ivas_prot.h" #include "rom_com.h" #include -#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE #include #endif #ifdef DEBUGGING @@ -45,7 +45,7 @@ #endif #include "wmops.h" -#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE /*------------------------------------------------------------------- * sns_compute_scf() diff --git a/lib_com/ivas_stereo_psychlpc_com.c b/lib_com/ivas_stereo_psychlpc_com.c index 7093a91093..cdc48f5f98 100644 --- a/lib_com/ivas_stereo_psychlpc_com.c +++ b/lib_com/ivas_stereo_psychlpc_com.c @@ -68,7 +68,7 @@ static void SpectrumWeighting_Init( * initialize a PsychoacousticParameters structure *-------------------------------------------------------------------*/ -#ifndef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#ifndef MDCT_STEREO_PLC_FADE_2_BG_NOISE static #endif ivas_error diff --git a/lib_com/options.h b/lib_com/options.h index ce0e122c42..078d3435fb 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -143,7 +143,7 @@ /*#define FIX_I4_OL_PITCH*/ /* fix open-loop pitch used for EVS core switching */ -/*#define FIX_IVAS_185_MDCT_ST_PLC_FADEOUT*/ /* IVAS-185 fix bug in TCX-PLC fadeout for MDCT-Stereo and improve fadeout by fading to background noise instead of white noise */ +/*#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 FIX_IVAS_180_PLC_SIGNAL_LAST_OVLP_IN_TCX10 /* IVAS-180 write last overlap mode in TCX10 frames to allow for correct TCX10/TCX5 subframe decomposition in TCX10 frames after a lost frame */ /*#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 4357e98284..8a0523dfe8 100644 --- a/lib_com/prot.h +++ b/lib_com/prot.h @@ -5144,7 +5144,7 @@ void decod_amr_wb( ivas_error init_decoder( Decoder_State *st, /* o : Decoder static variables structure */ const int16_t idchan /* i : channel ID */ -#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE , const MC_MODE mc_mode /* i : MC mode */ #endif @@ -6775,7 +6775,7 @@ void enc_acelp_tcx_main( void getTCXMode( Decoder_State *st, /* i/o: decoder memory state */ Decoder_State *st0 /* i : bitstream */ -#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE , const int16_t MCT_flag #endif @@ -7894,7 +7894,7 @@ void decoder_tcx_post( float *synthFB, float *A, const int16_t bfi -#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE , const int16_t isMCT #endif @@ -7950,7 +7950,7 @@ void decoder_acelp( void writeTCXMode( Encoder_State *st, /* i/o: encoder state structure */ BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ -#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE const int16_t is_mct, #endif int16_t *nbits_start /* o : nbits start */ @@ -8141,7 +8141,7 @@ 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 FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE , const float *A_cng #endif @@ -8690,7 +8690,7 @@ void configureFdCngDec( void ApplyFdCng( float *timeDomainInput, -#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE float *powerSpectrum, #endif float **realBuffer, /* i/o: Real part of the buffer */ @@ -8701,7 +8701,7 @@ void ApplyFdCng( void perform_noise_estimation_dec( const float *timeDomainInput, -#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE float *power_spectrum, #endif HANDLE_FD_CNG_DEC hFdCngDec, /* i/o: FD_CNG structure */ @@ -9203,7 +9203,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 FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#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 */ @@ -9246,7 +9246,7 @@ 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 FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE , const int16_t last_element_mode #endif @@ -9530,7 +9530,7 @@ void TonalMDCTConceal_SaveFreqSignal( const uint16_t numSamples, const uint16_t nNewSamplesCore, const float *scaleFactors -#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE , const int16_t infoIGFStartLine #endif @@ -9568,7 +9568,7 @@ void TonalMDCTConceal_InsertNoise( int16_t *pSeed, /*IN/OUT*/ const float tiltCompFactor, const float crossfadeGain, -#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE const float concealment_noise[L_FRAME48k], #endif const int16_t crossOverFreq ); @@ -9605,7 +9605,7 @@ void RefineTonalComponents( float floorPowerSpectrum, const PsychoacousticParameters *psychParamsCurrent ); -#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#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) */ diff --git a/lib_dec/acelp_core_dec.c b/lib_dec/acelp_core_dec.c index 3b9efaa316..f133379396 100644 --- a/lib_dec/acelp_core_dec.c +++ b/lib_dec/acelp_core_dec.c @@ -156,7 +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 FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE ApplyFdCng( NULL, NULL, NULL, NULL, st, 0, 0 ); #else ApplyFdCng( NULL, NULL, NULL, st, 0, 0 ); @@ -530,7 +530,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 FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#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 ) ); @@ -1120,7 +1120,7 @@ ivas_error acelp_core_dec( if ( st->element_mode != IVAS_CPE_TD ) { /*Noise estimate*/ -#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#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 ) ); @@ -1189,7 +1189,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 FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#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 ) ); diff --git a/lib_dec/amr_wb_dec.c b/lib_dec/amr_wb_dec.c index c220c8201e..907d90e9ab 100644 --- a/lib_dec/amr_wb_dec.c +++ b/lib_dec/amr_wb_dec.c @@ -621,7 +621,7 @@ ivas_error amr_wb_dec( /*VAD only for non inactive frame*/ st->VAD = ( st->VAD && ( st->coder_type != INACTIVE ) ); -#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE ApplyFdCng( syn, NULL, NULL, NULL, st, 0, 0 ); #else ApplyFdCng( syn, NULL, NULL, st, 0, 0 ); diff --git a/lib_dec/core_dec_init.c b/lib_dec/core_dec_init.c index d2d94799ef..53e0939477 100644 --- a/lib_dec/core_dec_init.c +++ b/lib_dec/core_dec_init.c @@ -57,7 +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 FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#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,9 +552,9 @@ void open_decoder_LPD( { st->hTcxDec->prev_widow_left_rect = 0; -#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE /* Todo: should be considered for other stereo modes as well */ - if ( is_init || !( st->element_mode == IVAS_CPE_MDCT && st->element_mode == last_element_mode ) ) + 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; st->hTcxDec->NoiseLevelIndex_bfi = PLC_MIN_STAT_BUFF_SIZE - 1; diff --git a/lib_dec/core_dec_switch.c b/lib_dec/core_dec_switch.c index 637c185f32..e62cad57c4 100644 --- a/lib_dec/core_dec_switch.c +++ b/lib_dec/core_dec_switch.c @@ -57,7 +57,7 @@ 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 FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE , const int16_t last_element_mode #endif @@ -109,7 +109,7 @@ void mode_switch_decoder_LPD( if ( fscale != st->fscale || switchWB || bSwitchFromAmrwbIO || st->last_codec_mode == MODE1 || st->force_lpd_reset ) { -#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#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 ); diff --git a/lib_dec/dec_LPD.c b/lib_dec/dec_LPD.c index 422104ac43..a28630886e 100644 --- a/lib_dec/dec_LPD.c +++ b/lib_dec/dec_LPD.c @@ -478,7 +478,7 @@ void decoder_LPD( if ( bfi && st->last_core != ACELP_CORE ) { /* PLC: [TCX: TD PLC] */ -#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#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 ); @@ -650,7 +650,7 @@ void decoder_LPD( TonalMDCTConceal_SaveTimeSignal( st->hTonalMDCTConc, synthFB, L_frameTCX ); } -#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#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 ); diff --git a/lib_dec/dec_acelp_tcx_main.c b/lib_dec/dec_acelp_tcx_main.c index b1bfd3e225..1ca75fff20 100644 --- a/lib_dec/dec_acelp_tcx_main.c +++ b/lib_dec/dec_acelp_tcx_main.c @@ -198,7 +198,7 @@ static void decode_frame_type( st->rate_switching_init = 1; /* Reconf Core */ -#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#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 ); diff --git a/lib_dec/dec_prm.c b/lib_dec/dec_prm.c index c6d2b1a439..43dd70ffeb 100644 --- a/lib_dec/dec_prm.c +++ b/lib_dec/dec_prm.c @@ -55,7 +55,7 @@ void getTCXMode( Decoder_State *st, /* i/o: decoder memory state */ Decoder_State *st0 /* i : bitstream */ -#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE , const int16_t MCT_flag #endif @@ -94,7 +94,7 @@ void getTCXMode( } st->coder_type = INACTIVE; -#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE if ( st->element_mode == IVAS_CPE_MDCT && !MCT_flag ) { st->VAD = get_next_indice( st0, 1 ); @@ -797,7 +797,7 @@ void dec_prm( *--------------------------------------------------------------------------------*/ /* Modes (ACE_GC, ACE_UC, TCX20, TCX10...) */ -#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE getTCXMode( st, st, 0 /* <- MCT_flag */ ); #else getTCXMode( st, st ); diff --git a/lib_dec/dec_tcx.c b/lib_dec/dec_tcx.c index ae5faa4d73..ddd35a0274 100644 --- a/lib_dec/dec_tcx.c +++ b/lib_dec/dec_tcx.c @@ -98,13 +98,13 @@ void decoder_tcx( init_tcx_info( st, L_frame_glob, L_frameTCX_glob, frame_cnt, bfi, &tcx_offset, &tcx_offsetFB, &L_frame, &L_frameTCX, &left_rect, &L_spec ); -#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE 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, 0, /* <- isMCT */ frame_cnt ); #else 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 ); #endif -#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#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 ); @@ -133,7 +133,7 @@ void decoder_tcx_post( float *synthFB, float *A, const int16_t bfi -#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE , const int16_t isMCT #endif @@ -188,7 +188,7 @@ void decoder_tcx_post( /* PLC: [TCX: Fade-out] * PLC: update or retrieve the background level */ -#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#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 ) @@ -696,7 +696,7 @@ void decoder_tcx_invQ( const int16_t **prm_sqQ1, int16_t *nf_seed, const int16_t bfi, /* i : Bad frame indicator */ -#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#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 */ @@ -913,13 +913,22 @@ void decoder_tcx_invQ( hTcxDec->damping = 1; } -#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT - else if ( st->element_mode == IVAS_CPE_MDCT && st->nbLostCmpt >= MDCT_ST_PLC_FADEOUT_START_FRAME ) +#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE + else if ( st->element_mode == IVAS_CPE_MDCT && !isMCT ) { - *gain_tcx = hTcxDec->old_gaintcx_bfi; - hTcxDec->damping = Damping_fact( st->coder_type, st->nbLostCmpt - MDCT_ST_PLC_FADEOUT_START_FRAME, st->last_good, st->stab_fac, &( st->lp_gainp ), st->last_core ); + if ( st->nbLostCmpt >= MDCT_ST_PLC_FADEOUT_START_FRAME ) + { + *gain_tcx = hTcxDec->old_gaintcx_bfi; + hTcxDec->damping = Damping_fact( st->coder_type, st->nbLostCmpt - MDCT_ST_PLC_FADEOUT_START_FRAME, st->last_good, st->stab_fac, &( st->lp_gainp ), st->last_core ); + } + else + { + + *gain_tcx = hTcxDec->old_gaintcx_bfi; + hTcxDec->damping = 1.0f; + } } - else if ( st->element_mode != IVAS_CPE_MDCT || !isMCT ) + else if ( st->element_mode != IVAS_CPE_MDCT || isMCT ) #else else #endif @@ -1079,7 +1088,7 @@ void decoder_tcx_invQ( void decoder_tcx_noisefilling( Decoder_State *st, /* i/o: coder memory state */ -#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE float concealment_noise[L_FRAME48k], #endif const float A[], /* i : coefficients NxAz[M+1] */ @@ -1094,7 +1103,7 @@ void decoder_tcx_noisefilling( const int16_t *prm_sqQ, int16_t nf_seed, const int16_t bfi, /* i : Bad frame indicator */ -#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#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*/ @@ -1248,7 +1257,7 @@ void decoder_tcx_noisefilling( if ( !bfi && st->element_mode != IVAS_CPE_MDCT ) { -#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#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 ); @@ -1261,8 +1270,8 @@ void decoder_tcx_noisefilling( { /* set f to 1 to not fade out */ /* set f to 0 to immediately switch to white noise */ -#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT - if ( st->tcxonly && st->element_mode != IVAS_CPE_MDCT ) +#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE + if ( st->tcxonly && ( st->element_mode != IVAS_CPE_MDCT || isMCT ) ) #else if ( st->tcxonly ) #endif @@ -1304,7 +1313,7 @@ void decoder_tcx_noisefilling( noiseTiltFactor = 1.0f; tcxGetNoiseFillingTilt( A, L_frame, ( total_brate >= ACELP_13k20 && !st->rf_flag ), &noiseTiltFactor ); -#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#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, infoIGFStartLine ); @@ -1393,7 +1402,7 @@ void decoder_tcx_noiseshaping_igf( * Noise shaping in frequency domain (1/Wz) * *-----------------------------------------------------------*/ -#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#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 ) diff --git a/lib_dec/er_dec_tcx.c b/lib_dec/er_dec_tcx.c index 2fb4a8979a..13e3a45461 100644 --- a/lib_dec/er_dec_tcx.c +++ b/lib_dec/er_dec_tcx.c @@ -58,7 +58,7 @@ 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 FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE , const float *A_cng #endif @@ -280,13 +280,13 @@ void con_tcx( st->bpf_gain_param = 0; /* PLC: calculate damping factor */ -#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE alpha = 1.0f; - if ( st->element_mode == IVAS_CPE_MDCT && st->nbLostCmpt >= MDCT_ST_PLC_FADEOUT_START_FRAME ) + if ( st->element_mode == IVAS_CPE_MDCT && st->nbLostCmpt >= MDCT_ST_PLC_FADEOUT_START_FRAME && A_cng != NULL ) { alpha = Damping_fact( st->core_ext_mode, st->nbLostCmpt - MDCT_ST_PLC_FADEOUT_START_FRAME, st->last_good, st->stab_fac, &( st->lp_gainp ), 0 ); } - else if ( st->element_mode != IVAS_CPE_MDCT ) + else if ( A_cng == NULL ) { alpha = Damping_fact( st->core_ext_mode, st->nbLostCmpt, st->last_good, st->stab_fac, &( st->lp_gainp ), 0 ); } @@ -351,13 +351,13 @@ void con_tcx( set_f( pitch_buf, (float) L_SUBFR, st->nb_subfr ); /* PLC: calculate damping factor */ -#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE alpha = 1.0f; - if ( st->element_mode == IVAS_CPE_MDCT && st->nbLostCmpt >= MDCT_ST_PLC_FADEOUT_START_FRAME ) + if ( st->element_mode == IVAS_CPE_MDCT && st->nbLostCmpt >= MDCT_ST_PLC_FADEOUT_START_FRAME && A_cng != NULL ) { alpha = Damping_fact( st->core_ext_mode, st->nbLostCmpt - MDCT_ST_PLC_FADEOUT_START_FRAME, st->last_good, st->stab_fac, &( st->lp_gainp ), 0 ); } - else if ( st->element_mode != IVAS_CPE_MDCT ) + else if ( A_cng == NULL ) { alpha = Damping_fact( st->core_ext_mode, st->nbLostCmpt, st->last_good, st->stab_fac, &( st->lp_gainp ), 0 ); } @@ -460,7 +460,7 @@ void con_tcx( /* PLC: [TCX: Fade-out] retrieve background level */ tmp = 1.0f; -#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#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; @@ -570,7 +570,7 @@ void con_tcx( mvr2r( buf, mem_syn, M ); -#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE if ( A_cng != NULL ) { if ( ( st->nbLostCmpt == 1 && st->idchan == 0 ) || ( st->nbLostCmpt == 2 && st->idchan == 1 ) ) diff --git a/lib_dec/evs_dec.c b/lib_dec/evs_dec.c index 9943ca9b98..89369b21b7 100644 --- a/lib_dec/evs_dec.c +++ b/lib_dec/evs_dec.c @@ -676,7 +676,7 @@ ivas_error evs_dec( st->lp_noise = st->hFdCngDec->lp_noise; -#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE ApplyFdCng( output, NULL, realBuffer, imagBuffer, st, concealWholeFrame, 0 ); #else ApplyFdCng( output, realBuffer, imagBuffer, st, concealWholeFrame, 0 ); diff --git a/lib_dec/fd_cng_dec.c b/lib_dec/fd_cng_dec.c index 39fbf2a66c..3d66ff60c0 100644 --- a/lib_dec/fd_cng_dec.c +++ b/lib_dec/fd_cng_dec.c @@ -368,7 +368,7 @@ void deleteFdCngDec( void ApplyFdCng( float *timeDomainInput, -#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE float *powerSpectrum, #endif float **realBuffer, /* i/o: Real part of the buffer */ @@ -384,7 +384,7 @@ void ApplyFdCng( int16_t j, k; float factor; float lsp_cng[M]; -#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE int16_t L_frame, last_L_frame; int32_t sr_core; @@ -419,7 +419,7 @@ 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 FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE ( timeDomainInput == NULL || ( *timeDomainInput( -FLT_MAX ) && *( timeDomainInput + hFdCngCom->frameSize - 1 ) < FLT_MAX && @@ -435,7 +435,7 @@ void ApplyFdCng( ( !st->BER_detect ) ) { /* Perform noise estimation at the decoder */ -#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#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 ); @@ -471,7 +471,7 @@ void ApplyFdCng( } } -#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#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 ); @@ -488,7 +488,7 @@ void ApplyFdCng( if ( hFdCngCom->active_frame_counter > 0 ) { /* Perform noise estimation in active frames in the decoder for downward updates */ -#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#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 ); @@ -498,7 +498,7 @@ void ApplyFdCng( if ( ( concealWholeFrame == 1 ) && ( st->nbLostCmpt == 1 ) && sum_f( cngNoiseLevel + hFdCngCom->startBand, hFdCngCom->stopFFTbin - hFdCngCom->startBand ) > 0.01f ) { -#ifndef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#ifndef MDCT_STEREO_PLC_FADE_2_BG_NOISE /* 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 @@ -548,7 +548,7 @@ void ApplyFdCng( } #endif -#ifndef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#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 ); @@ -567,7 +567,7 @@ void ApplyFdCng( if ( st != NULL && st->cng_type == LP_CNG ) { /* Perform noise estimation on inactive phase at the decoder */ -#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#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 ); @@ -582,7 +582,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 FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#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 ); @@ -668,7 +668,7 @@ void ApplyFdCng( default: break; } -#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE wmops_sub_end(); #endif @@ -685,7 +685,7 @@ void ApplyFdCng( void perform_noise_estimation_dec( const float *timeDomainInput, -#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#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 */ @@ -720,7 +720,7 @@ void perform_noise_estimation_dec( float temp, ftemp, delta; float wght; -#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE if ( !( element_mode == IVAS_CPE_MDCT && power_spectrum != NULL ) ) { /* Perform STFT analysis */ @@ -962,7 +962,7 @@ void perform_noise_estimation_dec( } else { -#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#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 */ diff --git a/lib_dec/init_dec.c b/lib_dec/init_dec.c index 40c65d9503..2e31017eaa 100644 --- a/lib_dec/init_dec.c +++ b/lib_dec/init_dec.c @@ -54,7 +54,7 @@ ivas_error init_decoder( Decoder_State *st, /* o : Decoder static variables structure */ const int16_t idchan /* i : channel ID */ -#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE , const MC_MODE mc_mode /* i : MC mode */ #endif @@ -691,7 +691,7 @@ ivas_error init_decoder( st->enablePlcWaveadjust = 0; /* Init Core Decoder */ -#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#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 ); @@ -714,7 +714,7 @@ ivas_error init_decoder( * FD-CNG decoder *-----------------------------------------------------------------*/ -#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#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 ) diff --git a/lib_dec/ivas_core_dec.c b/lib_dec/ivas_core_dec.c index 6a3f588f9b..299c6ff620 100644 --- a/lib_dec/ivas_core_dec.c +++ b/lib_dec/ivas_core_dec.c @@ -35,7 +35,7 @@ #ifdef DEBUGGING #include "debug.h" #endif -#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE #include #endif #include @@ -183,7 +183,7 @@ ivas_error ivas_core_dec( st->flagGuidedAcelp = 0; } -#ifndef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#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 ) { @@ -201,7 +201,7 @@ ivas_error ivas_core_dec( } #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 ) ) + if ( !st->bfi && st->prev_bfi && ( st->last_core_bfi == TCX_20_CORE || st->last_core_bfi == TCX_10_CORE ) && hMCT == NULL ) { float gain; if ( st->hPlcInfo != NULL ) diff --git a/lib_dec/ivas_cpe_dec.c b/lib_dec/ivas_cpe_dec.c index 19c1ad43fb..ef61bbe23b 100644 --- a/lib_dec/ivas_cpe_dec.c +++ b/lib_dec/ivas_cpe_dec.c @@ -713,7 +713,7 @@ ivas_error create_cpe_dec( st->mct_chan_mode = MCT_CHAN_MODE_LFE; } -#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#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 ) diff --git a/lib_dec/ivas_mdct_core_dec.c b/lib_dec/ivas_mdct_core_dec.c index 0d340ca9f6..e9a86304bb 100644 --- a/lib_dec/ivas_mdct_core_dec.c +++ b/lib_dec/ivas_mdct_core_dec.c @@ -102,7 +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 FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE const int16_t MCT_flag, #endif const int16_t ch /* i : channel */ @@ -134,7 +134,7 @@ static void dec_prm_tcx_sidebits( *--------------------------------------------------------------------------------*/ /* Modes (ACE_GC, ACE_UC, TCX20, TCX10...) */ -#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE getTCXMode( st, st0, MCT_flag ); #else getTCXMode( st, st0 ); @@ -389,7 +389,7 @@ void ivas_mdct_dec_side_bits_frame_channel( tmp = 3; } -#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#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 ); @@ -489,7 +489,7 @@ 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 FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE float concealment_noise[CPE_CHANNELS][L_FRAME48k]; TONALMDCTCONC_NOISE_GEN_MODE noise_gen_mode_bfi; #endif @@ -498,7 +498,7 @@ void ivas_mdct_core_invQ( sts = hCPE->hCoreCoder; bfi = sts[0]->bfi; -#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE noise_gen_mode_bfi = -1; #endif @@ -522,7 +522,7 @@ void ivas_mdct_core_invQ( sts[0]->core, sts[1]->core, sts[0]->igf, L_frameTCX[0], 0, sts[0]->last_core, sts[1]->last_core, 1 ); } -#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE if ( bfi ) { if ( sts[0]->core == sts[1]->core ) @@ -736,7 +736,7 @@ void ivas_mdct_core_invQ( } nf_seed = 0; -#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE decoder_tcx_invQ( st, prm[ch], Aq[ch], Aind[ch], L_spec[ch], L_frame[ch], L_frameTCX[ch], x[ch][k], NULL, xn_buf, &fUseTns[ch][k], &tnsData[ch][k], &gain_tcx, &prm_sqQ, &nf_seed, bfi, isMCT, k ); #else decoder_tcx_invQ( st, prm[ch], Aq[ch], Aind[ch], L_spec[ch], L_frame[ch], L_frameTCX[ch], x[ch][k], NULL, xn_buf, &fUseTns[ch][k], &tnsData[ch][k], &gain_tcx, &prm_sqQ, &nf_seed, bfi, k ); @@ -744,7 +744,7 @@ void ivas_mdct_core_invQ( mvr2r( x[ch][k], x_0[ch][k], L_frameTCX[ch] ); -#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#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 ); @@ -873,7 +873,7 @@ void ivas_mdct_core_reconstruct( TonalMDCTConceal_SaveTimeSignal( st->hTonalMDCTConc, synthFB, L_frameTCX[ch] ); } -#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#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 ); @@ -885,7 +885,7 @@ void ivas_mdct_core_reconstruct( /* PLC: [TCX: TD PLC] */ if ( isMCT ) { -#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#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 ); @@ -893,7 +893,7 @@ void ivas_mdct_core_reconstruct( } else { -#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#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 ); @@ -1076,13 +1076,13 @@ void ivas_mdct_core_tns_ns( { sns_interpolate_scalefactors( &sns_int_scf[0], &Aq[ch][k * M], DEC ); -#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#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 FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE int16_t infoIGFStartLine; if ( st->igf == 0 ) @@ -1113,8 +1113,8 @@ void ivas_mdct_core_tns_ns( { if ( st->hTonalMDCTConc != NULL ) { -#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT - if ( st->hTcxDec->cummulative_damping_tcx != 1.f ) +#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE + if ( !isMCT && st->hTcxDec->cummulative_damping_tcx != 1.f ) { float *scf_last; float *scf_bg; diff --git a/lib_dec/ivas_sce_dec.c b/lib_dec/ivas_sce_dec.c index fbcf859c30..879ebd4233 100644 --- a/lib_dec/ivas_sce_dec.c +++ b/lib_dec/ivas_sce_dec.c @@ -342,7 +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 FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#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 ) diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index e7bb2e1267..aa25bfd3b1 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -320,7 +320,7 @@ typedef struct stereo_mdct_dec_data_structure int16_t prev_ms_mask[NB_DIV][MAX_SFB]; float lastCoh; -#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE int16_t noise_seeds_channels[CPE_CHANNELS]; int16_t noise_seed_common; #endif diff --git a/lib_dec/ivas_stereo_mdct_core_dec.c b/lib_dec/ivas_stereo_mdct_core_dec.c index d87be7f23a..991062a977 100644 --- a/lib_dec/ivas_stereo_mdct_core_dec.c +++ b/lib_dec/ivas_stereo_mdct_core_dec.c @@ -50,7 +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 FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE static void run_min_stats( Decoder_State **sts, float *x[CPE_CHANNELS][NB_DIV] ); #endif @@ -322,13 +322,13 @@ void stereo_mdct_core_dec( sns_interpolate_scalefactors( &sns_int_scf[0], &Aq[ch][k * M], DEC ); -#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE if ( st->hTonalMDCTConc != NULL && ( ( k + 1 ) == nSubframes[ch] ) ) #else if ( st->hTonalMDCTConc != NULL ) #endif { -#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE int16_t infoIGFStartLine; if ( st->igf == 0 ) @@ -379,7 +379,7 @@ void stereo_mdct_core_dec( ivas_ls_setup_conversion_process_mdct_param_mc( st_ivas, x ); } -#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE run_min_stats( sts, x ); #endif @@ -600,7 +600,7 @@ static void apply_dmx_weights( return; } -#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE /*-------------------------------------------------------------------* * run_min_stats() * diff --git a/lib_dec/ivas_stereo_switching_dec.c b/lib_dec/ivas_stereo_switching_dec.c index e4c5021dbc..d32423d830 100644 --- a/lib_dec/ivas_stereo_switching_dec.c +++ b/lib_dec/ivas_stereo_switching_dec.c @@ -424,7 +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 FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE deleteFdCngDec( &hCPE->hCoreCoder[1]->hFdCngDec ); #endif } @@ -489,7 +489,7 @@ ivas_error stereo_memory_dec( /* deallocated TCX/IGF structures for second channel */ deallocate_CoreCoder_TCX( hCPE->hCoreCoder[1] ); -#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE if ( hCPE->last_element_mode == IVAS_CPE_MDCT ) { deleteFdCngDec( &hCPE->hCoreCoder[1]->hFdCngDec ); @@ -675,7 +675,7 @@ ivas_error stereo_memory_dec( /* deallocate core-decoder substructures */ deallocate_CoreCoder( st ); -#ifndef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#ifndef MDCT_STEREO_PLC_FADE_2_BG_NOISE /* deallocate FD_CNG substructure */ deleteFdCngDec( &st->hFdCngDec ); #endif @@ -702,7 +702,7 @@ ivas_error stereo_memory_dec( } } -#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE /* allocate Fd-Cng structure for second channel */ if ( ( error = createFdCngDec( &st->hFdCngDec ) ) != IVAS_ERR_OK ) { diff --git a/lib_dec/ivas_tcx_core_dec.c b/lib_dec/ivas_tcx_core_dec.c index 1fc0de4a88..4577e566e3 100644 --- a/lib_dec/ivas_tcx_core_dec.c +++ b/lib_dec/ivas_tcx_core_dec.c @@ -150,7 +150,7 @@ void stereo_tcx_init_dec( } /* Reconfigure Core */ -#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#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 ); @@ -457,7 +457,7 @@ void stereo_tcx_core_dec( } /* PLC: [TCX: TD PLC] */ -#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#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 ); @@ -589,7 +589,7 @@ void stereo_tcx_core_dec( TonalMDCTConceal_SaveTimeSignal( st->hTonalMDCTConc, synthFB, hTcxDec->L_frameTCX ); } -#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#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 ); @@ -750,7 +750,7 @@ void stereo_tcx_core_dec( if ( st->element_mode != IVAS_CPE_TD ) { -#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#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 ); @@ -779,7 +779,7 @@ void stereo_tcx_core_dec( if ( st->element_mode == IVAS_CPE_TD && st->idchan == 0 ) { -#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#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 ); @@ -867,7 +867,7 @@ static void dec_prm_tcx( *--------------------------------------------------------------------------------*/ /* Modes (ACE_GC, ACE_UC, TCX20, TCX10...) */ -#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE getTCXMode( st, st, 0 /* <- MCT_flag */ ); #else getTCXMode( st, st ); diff --git a/lib_dec/stat_dec.h b/lib_dec/stat_dec.h index 8fc8ec5282..4762b1b166 100644 --- a/lib_dec/stat_dec.h +++ b/lib_dec/stat_dec.h @@ -204,7 +204,7 @@ typedef struct Float32 *secondLastPcmOut; float *secondLastPowerSpectrum; -#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE float scaleFactorsBackground[FDNS_NPTS]; PsychoacousticParameters *psychParams; /* could be stored only once, since the same for all channels (always at 16Khz fs) */ diff --git a/lib_dec/tonalMDCTconcealment.c b/lib_dec/tonalMDCTconcealment.c index b43f85b8f9..ac666c9ff9 100644 --- a/lib_dec/tonalMDCTconcealment.c +++ b/lib_dec/tonalMDCTconcealment.c @@ -93,7 +93,7 @@ ivas_error TonalMDCTConceal_Init( hTonalMDCTConc->nSamplesCore = nSamplesCore; hTonalMDCTConc->nScaleFactors = nScaleFactors; -#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE set_zero( hTonalMDCTConc->scaleFactorsBackground, FDNS_NPTS ); PsychoacousticParameters_Init( INT_FS_16k, L_FRAME16k, 64, 1, 1, &hTonalMDCTConc->psychParamsTCX20 ); PsychoacousticParameters_Init( INT_FS_16k, L_FRAME16k / 2, 64, 0, 1, &hTonalMDCTConc->psychParamsTCX10 ); @@ -123,7 +123,7 @@ void TonalMDCTConceal_SaveFreqSignal( const uint16_t nNewSamples, const uint16_t nNewSamplesCore, const float *scaleFactors -#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE , const int16_t infoIGFStartLine #endif @@ -168,7 +168,7 @@ void TonalMDCTConceal_SaveFreqSignal( if ( ( nNewSamples > 0 ) && ( nNewSamples <= 2 * L_FRAME_MAX ) ) { /* Store new data */ -#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE int16_t i; hTonalMDCTConc->last_block_nrg = 0.0f; @@ -500,7 +500,7 @@ void TonalMDCTConceal_InsertNoise( int16_t *pSeed, const float tiltCompFactor, const float crossfadeGain, -#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE const float concealment_noise[L_FRAME48k], #endif const int16_t crossOverFreq ) @@ -522,7 +522,7 @@ void TonalMDCTConceal_InsertNoise( rnd = *pSeed; } -#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#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 ); @@ -536,7 +536,7 @@ void TonalMDCTConceal_InsertNoise( /* may just become active if the very first frame is lost */ set_f( mdctSpectrum, 0.0f, hTonalMDCTConc->nSamples ); } -#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE else if ( concealment_noise != NULL ) { if ( !tonalConcealmentActive ) @@ -710,7 +710,7 @@ void TonalMDCTConceal_InsertNoise( #endif else { -#ifndef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#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; @@ -962,7 +962,7 @@ void TonalMDCTConceal_SaveTimeSignal( return; } -#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE void TonalMdctConceal_create_concealment_noise( float concealment_noise[L_FRAME48k], CPE_DEC_HANDLE hCPE, diff --git a/lib_enc/enc_prm.c b/lib_enc/enc_prm.c index c48e171517..d9767207d2 100644 --- a/lib_enc/enc_prm.c +++ b/lib_enc/enc_prm.c @@ -55,7 +55,7 @@ void writeTCXMode( Encoder_State *st, /* i/o: encoder state structure */ BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ -#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE const int16_t is_mct, #endif int16_t *nbits_start /* o : nbits start */ @@ -88,7 +88,7 @@ void writeTCXMode( push_next_indice( hBstr, index, 2 ); -#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#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 ); @@ -792,7 +792,7 @@ void enc_prm( /* EVS header */ /* Modes (ACE_GC, ACE_UC, TCX20, TCX10...) */ -#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE writeTCXMode( st, st->hBstr, 0, /* <- is_mct */ &nbits_start ); #else writeTCXMode( st, st->hBstr, &nbits_start ); diff --git a/lib_enc/ivas_mdct_core_enc.c b/lib_enc/ivas_mdct_core_enc.c index 98b3a354c5..f1c7541210 100644 --- a/lib_enc/ivas_mdct_core_enc.c +++ b/lib_enc/ivas_mdct_core_enc.c @@ -63,7 +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 FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE const int16_t is_mct, #endif BSTR_ENC_HANDLE hBstr /* i/o: encoder bitstream handle */ @@ -80,7 +80,7 @@ static void enc_prm_pre_mdct( * Header *--------------------------------------------------------------------------------*/ -#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE writeTCXMode( st, hBstr, is_mct, &nbits_start ); #else writeTCXMode( st, hBstr, &nbits_start ); @@ -1069,7 +1069,7 @@ void ivas_mdct_core_whitening_enc( continue; } -#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#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 ); diff --git a/lib_enc/ivas_sns_enc.c b/lib_enc/ivas_sns_enc.c index 1aeac19c57..87019b8d91 100644 --- a/lib_enc/ivas_sns_enc.c +++ b/lib_enc/ivas_sns_enc.c @@ -43,7 +43,7 @@ #endif #include "wmops.h" -#ifndef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#ifndef MDCT_STEREO_PLC_FADE_2_BG_NOISE #define SNS_NPTS 16 /* Number of downsampled SNS parameters */ /*------------------------------------------------------------------- diff --git a/lib_enc/ivas_tcx_core_enc.c b/lib_enc/ivas_tcx_core_enc.c index fa0851a52a..f481160707 100644 --- a/lib_enc/ivas_tcx_core_enc.c +++ b/lib_enc/ivas_tcx_core_enc.c @@ -270,7 +270,7 @@ void stereo_tcx_core_enc( *--------------------------------------------------------------------------------*/ /* TCX20/TCX10 and coder type */ -#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT +#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE writeTCXMode( st, hBstr, 0, /* <- is_mct */ &nbits_start ); #else writeTCXMode( st, hBstr, &nbits_start ); -- GitLab From cfd5b3e545e2275a5c2c43402868e5dfed71bc68 Mon Sep 17 00:00:00 2001 From: knj Date: Wed, 24 Aug 2022 13:56:24 +0200 Subject: [PATCH 02/26] update igf noise seed correctly in MDCT-St PLC --- lib_dec/tonalMDCTconcealment.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib_dec/tonalMDCTconcealment.c b/lib_dec/tonalMDCTconcealment.c index ac666c9ff9..77ab9c6336 100644 --- a/lib_dec/tonalMDCTconcealment.c +++ b/lib_dec/tonalMDCTconcealment.c @@ -513,7 +513,11 @@ void TonalMDCTConceal_InsertNoise( wmops_sub_start( "InsertNoise" ); g = 1.0f - crossfadeGain; +#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE + if ( !hTonalMDCTConc->lastBlockData.blockIsConcealed && concealment_noise != NULL ) +#else if ( !hTonalMDCTConc->lastBlockData.blockIsConcealed ) +#endif { rnd = 1977; } @@ -1108,6 +1112,8 @@ void TonalMdctConceal_create_concealment_noise( *rnd_c = save_rnd_c; } + st->seed_tcx_plc = *rnd; + wmops_sub_end(); return; -- GitLab From 2a3945985e35bd6381ac21ed1b86b99b646ad4d0 Mon Sep 17 00:00:00 2001 From: knj Date: Wed, 24 Aug 2022 14:24:12 +0200 Subject: [PATCH 03/26] do not apply igf gain damping for bfi frames --- lib_com/ivas_prot.h | 5 +++++ lib_dec/dec_tcx.c | 4 ++++ lib_dec/igf_dec.c | 23 +++++++++++++++++++++++ 3 files changed, 32 insertions(+) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 753976cb88..395af77dac 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -2086,7 +2086,12 @@ 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 element_mode /* i : decoder element mode */ +#else const int16_t bfi /* i : frame loss == 1, frame good == 0 */ +#endif ); void IGFEncStereoEncoder( diff --git a/lib_dec/dec_tcx.c b/lib_dec/dec_tcx.c index ddd35a0274..c29638cbe7 100644 --- a/lib_dec/dec_tcx.c +++ b/lib_dec/dec_tcx.c @@ -2005,7 +2005,11 @@ 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, sts[0]->element_mode ); +#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/igf_dec.c b/lib_dec/igf_dec.c index 55e526d665..9344bfd9e4 100644 --- a/lib_dec/igf_dec.c +++ b/lib_dec/igf_dec.c @@ -679,7 +679,12 @@ 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; @@ -855,7 +860,11 @@ 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 ); @@ -1212,7 +1221,11 @@ 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, element_mode != IVAS_CPE_MDCT ); +#else IGF_appl( hPrivateData, igfGridIdx, spectrum, igf_spec, hIGFDec->virtualSpec, hIGFDec->flag_sparse ); +#endif } /* reset TCX noise indicator vector */ @@ -1238,7 +1251,12 @@ 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 element_mode +#else const int16_t bfi /* i : frame loss == 1, frame good == 0 */ +#endif ) { IGF_DEC_PRIVATE_DATA_HANDLE hPrivateDataL, hPrivateDataR; @@ -1335,8 +1353,13 @@ 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, element_mode != IVAS_CPE_MDCT ); + IGF_appl( hPrivateDataR, igfGridIdx, spectrumR, igf_specR, hIGFDecR->virtualSpec, hIGFDecR->flag_sparse, element_mode != IVAS_CPE_MDCT ); +#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 */ -- GitLab From e22382ca104a64a6e5721c43f1e7d062b8d84157 Mon Sep 17 00:00:00 2001 From: knj Date: Thu, 25 Aug 2022 09:13:46 +0200 Subject: [PATCH 04/26] remove cng gain scaling which did not make sense --- lib_dec/er_dec_tcx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/er_dec_tcx.c b/lib_dec/er_dec_tcx.c index 13e3a45461..5907326997 100644 --- a/lib_dec/er_dec_tcx.c +++ b/lib_dec/er_dec_tcx.c @@ -463,7 +463,7 @@ void con_tcx( #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; + gainSynthDeemph = getLevelSynDeemph( &( tmp ), A_cng, L_frame / 4, st->preemph_fac, 1 ); } else { -- GitLab From b5eed8b0f52b7b86f31e7233e0096153567fe23b Mon Sep 17 00:00:00 2001 From: knj Date: Thu, 25 Aug 2022 14:44:19 +0200 Subject: [PATCH 05/26] use slower fade for scalefactors --- lib_dec/ivas_mdct_core_dec.c | 12 +++++++----- lib_dec/stat_dec.h | 1 + lib_dec/tonalMDCTconcealment.c | 1 + 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/lib_dec/ivas_mdct_core_dec.c b/lib_dec/ivas_mdct_core_dec.c index e9a86304bb..96548bb02c 100644 --- a/lib_dec/ivas_mdct_core_dec.c +++ b/lib_dec/ivas_mdct_core_dec.c @@ -1116,14 +1116,15 @@ void ivas_mdct_core_tns_ns( #ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE if ( !isMCT && st->hTcxDec->cummulative_damping_tcx != 1.f ) { - float *scf_last; - float *scf_bg; - float fade_in; - float fade_out; + float *scf_last, *scf_bg; + float fade_in, fade_out; scf_last = &st->hTonalMDCTConc->lastBlockData.scaleFactors[0]; scf_bg = &st->hTonalMDCTConc->scaleFactorsBackground[0]; - fade_out = st->hTcxDec->cummulative_damping_tcx; + + st->hTonalMDCTConc->scf_fadeout *= 0.95f; + + fade_out = st->hTonalMDCTConc->scf_fadeout; fade_in = 1 - fade_out; for ( int16_t i = 0; i < st->hTonalMDCTConc->nScaleFactors; i++ ) @@ -1133,6 +1134,7 @@ void ivas_mdct_core_tns_ns( } else { + st->hTonalMDCTConc->scf_fadeout = 1.0f; mvr2r( st->hTonalMDCTConc->lastBlockData.scaleFactors, &sns_int_scf[0], st->hTonalMDCTConc->nScaleFactors ); } #else diff --git a/lib_dec/stat_dec.h b/lib_dec/stat_dec.h index 4762b1b166..0afc05562b 100644 --- a/lib_dec/stat_dec.h +++ b/lib_dec/stat_dec.h @@ -206,6 +206,7 @@ typedef struct #ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE float scaleFactorsBackground[FDNS_NPTS]; + float scf_fadeout; PsychoacousticParameters *psychParams; /* could be stored only once, since the same for all channels (always at 16Khz fs) */ PsychoacousticParameters psychParamsTCX20; diff --git a/lib_dec/tonalMDCTconcealment.c b/lib_dec/tonalMDCTconcealment.c index 77ab9c6336..58ae215506 100644 --- a/lib_dec/tonalMDCTconcealment.c +++ b/lib_dec/tonalMDCTconcealment.c @@ -95,6 +95,7 @@ ivas_error TonalMDCTConceal_Init( #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 ); PsychoacousticParameters_Init( INT_FS_16k, L_FRAME16k / 2, 64, 0, 1, &hTonalMDCTConc->psychParamsTCX10 ); hTonalMDCTConc->psychParams = NULL; -- GitLab From d5ac7778a13ed8978f3c871affd77f6a81817fb3 Mon Sep 17 00:00:00 2001 From: knj Date: Fri, 26 Aug 2022 17:01:22 +0200 Subject: [PATCH 06/26] fix wrong noise shapes by avoiding double whitening --- lib_com/ivas_cnst.h | 5 +++ lib_com/ivas_prot.h | 6 ++++ lib_dec/fd_cng_dec.c | 57 ++++++++++++---------------------- lib_dec/ivas_core_dec.c | 15 +++++++++ lib_dec/tonalMDCTconcealment.c | 50 +++++++++++++++++++++++++++++ 5 files changed, 95 insertions(+), 38 deletions(-) diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index 054ed5e01e..408984f319 100644 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -807,6 +807,11 @@ typedef enum { TCX10_IN_0_TCX20_IN_1, TCX20_IN_0_TCX10_IN_1, } TONALMDCTCONC_NOISE_GEN_MODE; + +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 6e83860082..3ae4b1d07b 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -5454,6 +5454,12 @@ void TonalMdctConceal_create_concealment_noise( const int16_t crossfade_gain, const TONALMDCTCONC_NOISE_GEN_MODE noise_gen_mode ); + +void TonalMdctConceal_whiten_noise_shape( + Decoder_State *st, + const int16_t L_frame, + const TONALMDCTCONC_NOISE_SHAPE_WHITENING_MODE +); #endif float rand_triangular_signed( diff --git a/lib_dec/fd_cng_dec.c b/lib_dec/fd_cng_dec.c index 1fa2c0b740..6f27464c66 100644 --- a/lib_dec/fd_cng_dec.c +++ b/lib_dec/fd_cng_dec.c @@ -496,55 +496,36 @@ void ApplyFdCng( } } +#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 ) { -#ifndef MDCT_STEREO_PLC_FADE_2_BG_NOISE /* 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 ( st->element_mode == IVAS_CPE_MDCT && st->core != ACELP_CORE ) - { - float scf[SNS_NPTS]; - float scf_int[FDNS_NPTS]; - float whitenend_noise_shape[L_FRAME16k]; - int16_t inc, start_idx, stop_idx; - float *noiseLevelPtr; - - wmops_sub_start( "get scfs for bg" ); + if ( ( concealWholeFrame == 1 ) && ( st->nbLostCmpt == 1 ) ) + { + /* update lsf cng estimate for concealment. Do that during concealment, in order to avoid addition clean channel complexity*/ - inc = ( st->core > TCX_20 ) ? 2 : 1; - start_idx = hFdCngCom->startBand / inc; - stop_idx = L_frame / inc; - noiseLevelPtr = cngNoiseLevel; + /* always set psychParameters ... */ + if ( st->hTonalMDCTConc != NULL ) + { + st->hTonalMDCTConc->psychParams = ( st->core == TCX_20_CORE ) ? &st->hTonalMDCTConc->psychParamsTCX20 : &st->hTonalMDCTConc->psychParamsTCX10; + } - set_zero( whitenend_noise_shape, start_idx ); - for ( j = start_idx; j < stop_idx; j++, noiseLevelPtr += inc ) - { - whitenend_noise_shape[j] = *noiseLevelPtr; - } - if ( st->core == TCX_20_CORE ) + /* ... but do actual computations only if sufficient energy in noise shape */ + if ( sum_f( cngNoiseLevel + hFdCngCom->startBand, hFdCngCom->stopFFTbin - hFdCngCom->startBand ) > 0.01f ) + { + if ( st->element_mode == IVAS_CPE_MDCT && st->core != ACELP_CORE ) { - st->hTonalMDCTConc->psychParams = &st->hTonalMDCTConc->psychParamsTCX20; + TonalMdctConceal_whiten_noise_shape( st, L_frame, ON_FIRST_LOST_FRAME ); } - else + else if ( st->element_mode != IVAS_CPE_MDCT ) { - st->hTonalMDCTConc->psychParams = &st->hTonalMDCTConc->psychParamsTCX10; + lpc_from_spectrum( hFdCngCom, hFdCngCom->startBand, hFdCngCom->stopFFTbin, 0.f ); + a2lsp_stab( hFdCngCom->A_cng, lsp_cng, st->lspold_cng ); + mvr2r( lsp_cng, st->lspold_cng, M ); + lsp2lsf( lsp_cng, st->lsf_cng, M, sr_core ); } - - sns_compute_scf( whitenend_noise_shape, st->hTonalMDCTConc->psychParams, L_frame, scf ); - sns_interpolate_scalefactors( scf_int, scf, ENC ); - sns_interpolate_scalefactors( st->hTonalMDCTConc->scaleFactorsBackground, scf, DEC ); - sns_shape_spectrum( whitenend_noise_shape, st->hTonalMDCTConc->psychParams, scf_int, L_frame ); - - mvr2r( whitenend_noise_shape + start_idx, cngNoiseLevel, stop_idx - start_idx ); - wmops_sub_end(); - } - else if ( st->element_mode != IVAS_CPE_MDCT ) - { - lpc_from_spectrum( hFdCngCom, hFdCngCom->startBand, hFdCngCom->stopFFTbin, 0.f ); - a2lsp_stab( hFdCngCom->A_cng, lsp_cng, st->lspold_cng ); - mvr2r( lsp_cng, st->lspold_cng, M ); - lsp2lsf( lsp_cng, st->lsf_cng, M, sr_core ); } #endif diff --git a/lib_dec/ivas_core_dec.c b/lib_dec/ivas_core_dec.c index a1674e46e9..917d64bf20 100755 --- a/lib_dec/ivas_core_dec.c +++ b/lib_dec/ivas_core_dec.c @@ -428,6 +428,21 @@ 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 */ + for ( n = 0; n < n_channels; ++n ) + { + if ( sts[n]->last_core != ACELP_CORE ) + { + TonalMdctConceal_whiten_noise_shape( sts[n], L_FRAME16k, ON_FIRST_GOOD_FRAME ); + } + } + } +#endif + } /*---------------------------------------------------------------------* diff --git a/lib_dec/tonalMDCTconcealment.c b/lib_dec/tonalMDCTconcealment.c index 58ae215506..b5e14f58ab 100644 --- a/lib_dec/tonalMDCTconcealment.c +++ b/lib_dec/tonalMDCTconcealment.c @@ -1119,4 +1119,54 @@ void TonalMdctConceal_create_concealment_noise( return; } + +void TonalMdctConceal_whiten_noise_shape( + Decoder_State *st, + const int16_t L_frame, + const TONALMDCTCONC_NOISE_SHAPE_WHITENING_MODE whitening_mode +) +{ + float scf[SNS_NPTS]; + float scfs_int[FDNS_NPTS]; + float whitenend_noise_shape[L_FRAME16k]; + int16_t inc, start_idx, stop_idx; + float *noiseLevelPtr, *scfs_bg, *scfs_for_shaping; + PsychoacousticParameters **psychParams; + HANDLE_FD_CNG_COM hFdCngCom; + + wmops_sub_start( "apply_sns_on_noise_shape" ); + + scfs_bg = &st->hTonalMDCTConc->scaleFactorsBackground[0]; + psychParams = &st->hTonalMDCTConc->psychParams; + hFdCngCom = st->hFdCngDec->hFdCngCom; + + inc = ( ( whitening_mode == ON_FIRST_LOST_FRAME ? st->core : st->last_core ) > TCX_20_CORE ) ? 2 : 1; + start_idx = hFdCngCom->startBand / inc; + stop_idx = L_frame / inc; + noiseLevelPtr = hFdCngCom->cngNoiseLevel; + + set_zero( whitenend_noise_shape, start_idx ); + for ( int16_t j = start_idx; j < stop_idx; j++, noiseLevelPtr += inc ) + { + whitenend_noise_shape[j] = *noiseLevelPtr; + } + + if ( whitening_mode == ON_FIRST_LOST_FRAME ) + { + sns_compute_scf( whitenend_noise_shape, *psychParams, L_frame, scf ); + sns_interpolate_scalefactors( scfs_int, scf, ENC ); + sns_interpolate_scalefactors( scfs_bg, scf, DEC ); + scfs_for_shaping = &scfs_int[0]; + } + else if ( whitening_mode == ON_FIRST_GOOD_FRAME ) + { + scfs_for_shaping = &scfs_bg[0]; + } + + sns_shape_spectrum( whitenend_noise_shape, *psychParams, scfs_for_shaping, L_frame ); + + mvr2r( whitenend_noise_shape + start_idx, hFdCngCom->cngNoiseLevel, stop_idx - start_idx ); + wmops_sub_end(); +} + #endif -- GitLab From 25a154f2172239d6c24a949bd1158af233092949 Mon Sep 17 00:00:00 2001 From: knj Date: Fri, 26 Aug 2022 17:57:26 +0200 Subject: [PATCH 07/26] small cleanup and optimization --- lib_dec/tonalMDCTconcealment.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/lib_dec/tonalMDCTconcealment.c b/lib_dec/tonalMDCTconcealment.c index b5e14f58ab..63b2849d6e 100644 --- a/lib_dec/tonalMDCTconcealment.c +++ b/lib_dec/tonalMDCTconcealment.c @@ -1054,7 +1054,6 @@ void TonalMdctConceal_create_concealment_noise( c_inv = sqrtf( 1 - hStereoMdct->lastCoh ); /* pre-compute the noise shape for later weighting of the noise spectra */ - /* TODO: optimize by intertwining with later loop */ cngNoiseLevelPtr = &hFdCngCom->cngNoiseLevel[0]; inc = ( st->core > TCX_20_CORE ) ? 2 : 1; start_idx = hFdCngCom->startBand / inc; @@ -1126,8 +1125,6 @@ void TonalMdctConceal_whiten_noise_shape( const TONALMDCTCONC_NOISE_SHAPE_WHITENING_MODE whitening_mode ) { - float scf[SNS_NPTS]; - float scfs_int[FDNS_NPTS]; float whitenend_noise_shape[L_FRAME16k]; int16_t inc, start_idx, stop_idx; float *noiseLevelPtr, *scfs_bg, *scfs_for_shaping; @@ -1153,6 +1150,9 @@ void TonalMdctConceal_whiten_noise_shape( if ( whitening_mode == ON_FIRST_LOST_FRAME ) { + float scf[SNS_NPTS]; + float scfs_int[FDNS_NPTS]; + sns_compute_scf( whitenend_noise_shape, *psychParams, L_frame, scf ); sns_interpolate_scalefactors( scfs_int, scf, ENC ); sns_interpolate_scalefactors( scfs_bg, scf, DEC ); @@ -1163,9 +1163,16 @@ void TonalMdctConceal_whiten_noise_shape( scfs_for_shaping = &scfs_bg[0]; } - sns_shape_spectrum( whitenend_noise_shape, *psychParams, scfs_for_shaping, L_frame ); + if ( sum_f( scfs_for_shaping, FDNS_NPTS ) > 0.0f ) + { + sns_shape_spectrum( whitenend_noise_shape, *psychParams, scfs_for_shaping, L_frame ); + mvr2r( whitenend_noise_shape + start_idx, hFdCngCom->cngNoiseLevel, stop_idx - start_idx ); + } + else + { + set_zero( hFdCngCom->cngNoiseLevel, stop_idx - start_idx ); + } - mvr2r( whitenend_noise_shape + start_idx, hFdCngCom->cngNoiseLevel, stop_idx - start_idx ); wmops_sub_end(); } -- GitLab From 4ac16bb1b5a3353a928ae5dd87334386a4effb2c Mon Sep 17 00:00:00 2001 From: knj Date: Wed, 31 Aug 2022 14:43:50 +0200 Subject: [PATCH 08/26] do correct scalign also for tonal PLC --- lib_com/prot.h | 1 + lib_dec/dec_tcx.c | 4 ++-- lib_dec/stat_dec.h | 2 +- lib_dec/tonalMDCTconcealment.c | 26 ++++++++++++++++++++++++-- 4 files changed, 28 insertions(+), 5 deletions(-) diff --git a/lib_com/prot.h b/lib_com/prot.h index 0b16926f32..f5d7eb5ef3 100644 --- a/lib_com/prot.h +++ b/lib_com/prot.h @@ -9571,6 +9571,7 @@ void TonalMDCTConceal_InsertNoise( 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 ); diff --git a/lib_dec/dec_tcx.c b/lib_dec/dec_tcx.c index c29638cbe7..ae647f21d0 100644 --- a/lib_dec/dec_tcx.c +++ b/lib_dec/dec_tcx.c @@ -1316,11 +1316,11 @@ void decoder_tcx_noisefilling( #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, infoIGFStartLine ); + TonalMDCTConceal_InsertNoise( st->hTonalMDCTConc, x, st->tonal_mdct_plc_active, &st->seed_tcx_plc, noiseTiltFactor, f, concealment_noise, st->hTcxDec->CngLevelBackgroundTrace_bfi, infoIGFStartLine ); } else { - TonalMDCTConceal_InsertNoise( st->hTonalMDCTConc, x, st->tonal_mdct_plc_active, &st->seed_tcx_plc, noiseTiltFactor, f, NULL, infoIGFStartLine ); + 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 ); diff --git a/lib_dec/stat_dec.h b/lib_dec/stat_dec.h index 0afc05562b..0c7a836cb4 100644 --- a/lib_dec/stat_dec.h +++ b/lib_dec/stat_dec.h @@ -208,12 +208,12 @@ typedef struct float scaleFactorsBackground[FDNS_NPTS]; float scf_fadeout; PsychoacousticParameters *psychParams; - /* could be stored only once, since the same for all channels (always at 16Khz fs) */ PsychoacousticParameters psychParamsTCX20; PsychoacousticParameters psychParamsTCX10; 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 63b2849d6e..8bb2c118c1 100644 --- a/lib_dec/tonalMDCTconcealment.c +++ b/lib_dec/tonalMDCTconcealment.c @@ -102,6 +102,7 @@ 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 @@ -503,6 +504,7 @@ void TonalMDCTConceal_InsertNoise( 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 ) { @@ -510,6 +512,9 @@ void TonalMDCTConceal_InsertNoise( 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" ); @@ -534,6 +539,8 @@ void TonalMDCTConceal_InsertNoise( tilt = 1.0f; nrgNoiseInLastFrame = 0.0f; nrgWhiteNoise = 0.0f; + hTonalMDCTConc->faded_signal_nrg = 0.0f; + last_block_nrg_correct = 0.0f; #endif if ( !hTonalMDCTConc->lastBlockData.blockIsValid ) @@ -569,7 +576,7 @@ void TonalMDCTConceal_InsertNoise( /* actual fadeout is done in this case */ else { - g *= (float) sqrt( hTonalMDCTConc->last_block_nrg / hTonalMDCTConc->curr_noise_nrg ); + g *= (float) sqrt( cngLevelBackgroundTrace_bfi / hTonalMDCTConc->curr_noise_nrg ); for ( i = 0; i < crossOverFreq; i++ ) { @@ -584,6 +591,8 @@ void TonalMDCTConceal_InsertNoise( { mdctSpectrum[i] = g * y - crossfadeGain * x; } + + hTonalMDCTConc->faded_signal_nrg += mdctSpectrum[i] * mdctSpectrum[i]; } for ( l = crossOverFreq; l < hTonalMDCTConc->lastBlockData.nSamples; l++ ) { @@ -603,7 +612,9 @@ void TonalMDCTConceal_InsertNoise( { for ( l = hTonalMDCTConc->pTCI->lowerIndex[i]; l <= hTonalMDCTConc->pTCI->upperIndex[i]; l++ ) { + last_block_nrg_correct += hTonalMDCTConc->lastBlockData.spectralData[l] * hTonalMDCTConc->lastBlockData.spectralData[l]; mdctSpectrum[l] = 0; + hTonalMDCTConc->curr_noise_nrg -= concealment_noise[l] * concealment_noise[l]; } } @@ -656,7 +667,7 @@ void TonalMDCTConceal_InsertNoise( /* actual fadeout is done in this case */ else { - g *= (float) sqrt( hTonalMDCTConc->last_block_nrg / hTonalMDCTConc->curr_noise_nrg ); + g *= (float) sqrt( cngLevelBackgroundTrace_bfi / hTonalMDCTConc->curr_noise_nrg ); for ( l = 0; l < hTonalMDCTConc->pTCI->lowerIndex[0]; l++ ) { @@ -671,6 +682,7 @@ void TonalMDCTConceal_InsertNoise( { mdctSpectrum[l] = g * y - crossfadeGain * x; } + hTonalMDCTConc->faded_signal_nrg += mdctSpectrum[i] * mdctSpectrum[i]; } for ( i = 1; i < hTonalMDCTConc->pTCI->numIndexes; i++ ) { @@ -687,6 +699,7 @@ void TonalMDCTConceal_InsertNoise( { mdctSpectrum[l] = g * y - crossfadeGain * x; } + hTonalMDCTConc->faded_signal_nrg += mdctSpectrum[i] * mdctSpectrum[i]; } } @@ -703,6 +716,7 @@ void TonalMDCTConceal_InsertNoise( { mdctSpectrum[l] = g * y - crossfadeGain * x; } + hTonalMDCTConc->faded_signal_nrg += mdctSpectrum[i] * mdctSpectrum[i]; } for ( l = crossOverFreq; l < hTonalMDCTConc->lastBlockData.nSamples; l++ ) @@ -711,6 +725,14 @@ void TonalMDCTConceal_InsertNoise( } } } + + if ( hTonalMDCTConc->faded_signal_nrg > 0.0f ) + { + float nrg_corr_factor; + + nrg_corr_factor = sqrtf( ( hTonalMDCTConc->last_block_nrg - last_block_nrg_correct ) / hTonalMDCTConc->faded_signal_nrg ); + v_multc( mdctSpectrum, nrg_corr_factor, mdctSpectrum, crossOverFreq ); + } } #endif else -- GitLab From 0d2980c4704e22002f19dc5d1127512fe506ef1e Mon Sep 17 00:00:00 2001 From: knj Date: Wed, 31 Aug 2022 15:07:18 +0200 Subject: [PATCH 09/26] no nrg correction when noise level is at min --- lib_com/ivas_cnst.h | 1 + lib_dec/tonalMDCTconcealment.c | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index 408984f319..84f6b11316 100644 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -801,6 +801,7 @@ enum fea_names #define SNS_NPTS 16 /* Number of downsampled SNS parameters */ #define MDCT_ST_PLC_FADEOUT_START_FRAME 3 +#define MDCT_ST_PLC_FADEOUT_MIN_NOISE_NRG 0.001f typedef enum { EQUAL_CORES, diff --git a/lib_dec/tonalMDCTconcealment.c b/lib_dec/tonalMDCTconcealment.c index 8bb2c118c1..f10c7985a4 100644 --- a/lib_dec/tonalMDCTconcealment.c +++ b/lib_dec/tonalMDCTconcealment.c @@ -726,7 +726,7 @@ void TonalMDCTConceal_InsertNoise( } } - if ( hTonalMDCTConc->faded_signal_nrg > 0.0f ) + if ( hTonalMDCTConc->faded_signal_nrg > 0.0f && hTonalMDCTConc->curr_noise_nrg > MDCT_ST_PLC_FADEOUT_MIN_NOISE_NRG ) { float nrg_corr_factor; @@ -1098,7 +1098,7 @@ void TonalMdctConceal_create_concealment_noise( } /* fill the noise vector */ - hTonalMDCTConc->curr_noise_nrg = 0.001f; + hTonalMDCTConc->curr_noise_nrg = MDCT_ST_PLC_FADEOUT_MIN_NOISE_NRG; if ( noise_gen_mode == EQUAL_CORES || ( ( noise_gen_mode == TCX20_IN_0_TCX10_IN_1 && idchan == 0 ) || ( noise_gen_mode == TCX10_IN_0_TCX20_IN_1 && idchan == 1 ) ) ) { /* current channel is TCX20 -> generate noise for "full-length" spectrum */ -- GitLab From bf1bf0477064aac37ce267baa54fe5131e50b0df Mon Sep 17 00:00:00 2001 From: knj Date: Thu, 1 Sep 2022 10:34:35 +0200 Subject: [PATCH 10/26] only calculate energy correction on lines below IGF starting freq --- lib_dec/tonalMDCTconcealment.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib_dec/tonalMDCTconcealment.c b/lib_dec/tonalMDCTconcealment.c index f10c7985a4..2c29e955c4 100644 --- a/lib_dec/tonalMDCTconcealment.c +++ b/lib_dec/tonalMDCTconcealment.c @@ -612,9 +612,12 @@ void TonalMDCTConceal_InsertNoise( { for ( l = hTonalMDCTConc->pTCI->lowerIndex[i]; l <= hTonalMDCTConc->pTCI->upperIndex[i]; l++ ) { - last_block_nrg_correct += hTonalMDCTConc->lastBlockData.spectralData[l] * hTonalMDCTConc->lastBlockData.spectralData[l]; mdctSpectrum[l] = 0; - hTonalMDCTConc->curr_noise_nrg -= concealment_noise[l] * concealment_noise[l]; + if ( l < crossOverFreq ) + { + last_block_nrg_correct += hTonalMDCTConc->lastBlockData.spectralData[l] * hTonalMDCTConc->lastBlockData.spectralData[l]; + hTonalMDCTConc->curr_noise_nrg -= concealment_noise[l] * concealment_noise[l]; + } } } -- GitLab From ff7a8064923d9c8218092df671c5ff3d5fa48e6c Mon Sep 17 00:00:00 2001 From: knj Date: Thu, 1 Sep 2022 11:21:49 +0200 Subject: [PATCH 11/26] fix asan error --- lib_dec/tonalMDCTconcealment.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/tonalMDCTconcealment.c b/lib_dec/tonalMDCTconcealment.c index 2c29e955c4..20f80e2826 100644 --- a/lib_dec/tonalMDCTconcealment.c +++ b/lib_dec/tonalMDCTconcealment.c @@ -1155,6 +1155,7 @@ void TonalMdctConceal_whiten_noise_shape( float *noiseLevelPtr, *scfs_bg, *scfs_for_shaping; PsychoacousticParameters **psychParams; HANDLE_FD_CNG_COM hFdCngCom; + float scfs_int[FDNS_NPTS]; wmops_sub_start( "apply_sns_on_noise_shape" ); @@ -1176,7 +1177,6 @@ void TonalMdctConceal_whiten_noise_shape( if ( whitening_mode == ON_FIRST_LOST_FRAME ) { float scf[SNS_NPTS]; - float scfs_int[FDNS_NPTS]; sns_compute_scf( whitenend_noise_shape, *psychParams, L_frame, scf ); sns_interpolate_scalefactors( scfs_int, scf, ENC ); -- GitLab From 1fa6ffe1e64e2e6d15e27eae488a0e570e7b1814 Mon Sep 17 00:00:00 2001 From: knj Date: Thu, 1 Sep 2022 14:46:26 +0200 Subject: [PATCH 12/26] fix bug in nrg correction for tonal concealment also zero-out noise above IGF starting freq when generating concealment noise -> could lead to wrong energy if tonal components are detected in the IGF region --- lib_dec/tonalMDCTconcealment.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lib_dec/tonalMDCTconcealment.c b/lib_dec/tonalMDCTconcealment.c index 20f80e2826..31cad74a15 100644 --- a/lib_dec/tonalMDCTconcealment.c +++ b/lib_dec/tonalMDCTconcealment.c @@ -685,7 +685,7 @@ void TonalMDCTConceal_InsertNoise( { mdctSpectrum[l] = g * y - crossfadeGain * x; } - hTonalMDCTConc->faded_signal_nrg += mdctSpectrum[i] * mdctSpectrum[i]; + hTonalMDCTConc->faded_signal_nrg += mdctSpectrum[l] * mdctSpectrum[l]; } for ( i = 1; i < hTonalMDCTConc->pTCI->numIndexes; i++ ) { @@ -702,7 +702,7 @@ void TonalMDCTConceal_InsertNoise( { mdctSpectrum[l] = g * y - crossfadeGain * x; } - hTonalMDCTConc->faded_signal_nrg += mdctSpectrum[i] * mdctSpectrum[i]; + hTonalMDCTConc->faded_signal_nrg += mdctSpectrum[l] * mdctSpectrum[l]; } } @@ -719,7 +719,7 @@ void TonalMDCTConceal_InsertNoise( { mdctSpectrum[l] = g * y - crossfadeGain * x; } - hTonalMDCTConc->faded_signal_nrg += mdctSpectrum[i] * mdctSpectrum[i]; + hTonalMDCTConc->faded_signal_nrg += mdctSpectrum[l] * mdctSpectrum[l]; } for ( l = crossOverFreq; l < hTonalMDCTConc->lastBlockData.nSamples; l++ ) @@ -1129,6 +1129,14 @@ void TonalMdctConceal_create_concealment_noise( } } + if ( st->tonal_mdct_plc_active ) + { + for ( i = crossOverFreq; i < max( crossOverFreq, hTonalMDCTConc->pTCI->lowerIndex[hTonalMDCTConc->pTCI->numIndexes - 1] ); ++i ) + { + concealment_noise[i] *= 0.0f; + } + } + /* restore common seed - after finishing the first channel - after a first subframe if the current channel is TCX10 */ -- GitLab From 0f38b815d0697e4ba829dc2723898fb2c37358da Mon Sep 17 00:00:00 2001 From: knj Date: Thu, 1 Sep 2022 15:29:37 +0200 Subject: [PATCH 13/26] Revert "remove cng gain scaling which did not make sense" This reverts commit e22382ca104a64a6e5721c43f1e7d062b8d84157. --- lib_dec/er_dec_tcx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/er_dec_tcx.c b/lib_dec/er_dec_tcx.c index 5907326997..13e3a45461 100644 --- a/lib_dec/er_dec_tcx.c +++ b/lib_dec/er_dec_tcx.c @@ -463,7 +463,7 @@ void con_tcx( #ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE if ( A_cng != NULL ) { - gainSynthDeemph = getLevelSynDeemph( &( tmp ), A_cng, L_frame / 4, st->preemph_fac, 1 ); + gainSynthDeemph = getLevelSynDeemph( &( tmp ), A_cng, L_frame / 4, st->preemph_fac, 1 ) / 4.f; } else { -- GitLab From a4058bdf3436bcdcd9556c07a269ccfeadb6c752 Mon Sep 17 00:00:00 2001 From: knj Date: Thu, 1 Sep 2022 16:06:18 +0200 Subject: [PATCH 14/26] remove fadeout delay --- lib_com/ivas_cnst.h | 1 - lib_com/ivas_prot.h | 3 --- lib_dec/dec_tcx.c | 25 ------------------------- lib_dec/er_dec_tcx.c | 24 ------------------------ lib_dec/ivas_mdct_core_dec.c | 4 ---- 5 files changed, 57 deletions(-) diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index 84f6b11316..bc4b0f0ae6 100644 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -800,7 +800,6 @@ enum fea_names #ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE #define SNS_NPTS 16 /* Number of downsampled SNS parameters */ -#define MDCT_ST_PLC_FADEOUT_START_FRAME 3 #define MDCT_ST_PLC_FADEOUT_MIN_NOISE_NRG 0.001f typedef enum { diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 3ae4b1d07b..08c25258e4 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -1946,9 +1946,6 @@ void decoder_tcx_invQ( 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 */ ); diff --git a/lib_dec/dec_tcx.c b/lib_dec/dec_tcx.c index ae647f21d0..41f3570662 100644 --- a/lib_dec/dec_tcx.c +++ b/lib_dec/dec_tcx.c @@ -98,11 +98,7 @@ void decoder_tcx( init_tcx_info( st, L_frame_glob, L_frameTCX_glob, frame_cnt, bfi, &tcx_offset, &tcx_offsetFB, &L_frame, &L_frameTCX, &left_rect, &L_spec ); -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE - 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, 0, /* <- isMCT */ frame_cnt ); -#else 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 ); -#endif #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 ); @@ -696,9 +692,6 @@ void decoder_tcx_invQ( const int16_t **prm_sqQ1, 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 */ ) { @@ -913,25 +906,7 @@ void decoder_tcx_invQ( hTcxDec->damping = 1; } -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE - else if ( st->element_mode == IVAS_CPE_MDCT && !isMCT ) - { - if ( st->nbLostCmpt >= MDCT_ST_PLC_FADEOUT_START_FRAME ) - { - *gain_tcx = hTcxDec->old_gaintcx_bfi; - hTcxDec->damping = Damping_fact( st->coder_type, st->nbLostCmpt - MDCT_ST_PLC_FADEOUT_START_FRAME, st->last_good, st->stab_fac, &( st->lp_gainp ), st->last_core ); - } - else - { - - *gain_tcx = hTcxDec->old_gaintcx_bfi; - hTcxDec->damping = 1.0f; - } - } - else if ( st->element_mode != IVAS_CPE_MDCT || isMCT ) -#else else -#endif { *gain_tcx = hTcxDec->old_gaintcx_bfi; hTcxDec->damping = Damping_fact( st->coder_type, st->nbLostCmpt, st->last_good, st->stab_fac, &( st->lp_gainp ), st->last_core ); diff --git a/lib_dec/er_dec_tcx.c b/lib_dec/er_dec_tcx.c index 13e3a45461..436189f3a9 100644 --- a/lib_dec/er_dec_tcx.c +++ b/lib_dec/er_dec_tcx.c @@ -280,19 +280,7 @@ void con_tcx( st->bpf_gain_param = 0; /* PLC: calculate damping factor */ -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE - alpha = 1.0f; - if ( st->element_mode == IVAS_CPE_MDCT && st->nbLostCmpt >= MDCT_ST_PLC_FADEOUT_START_FRAME && A_cng != NULL ) - { - alpha = Damping_fact( st->core_ext_mode, st->nbLostCmpt - MDCT_ST_PLC_FADEOUT_START_FRAME, st->last_good, st->stab_fac, &( st->lp_gainp ), 0 ); - } - else if ( A_cng == NULL ) - { - alpha = Damping_fact( st->core_ext_mode, st->nbLostCmpt, st->last_good, st->stab_fac, &( st->lp_gainp ), 0 ); - } -#else alpha = Damping_fact( st->core_ext_mode, st->nbLostCmpt, st->last_good, st->stab_fac, &( st->lp_gainp ), 0 ); -#endif if ( st->nbLostCmpt == 1 ) { @@ -351,19 +339,7 @@ void con_tcx( set_f( pitch_buf, (float) L_SUBFR, st->nb_subfr ); /* PLC: calculate damping factor */ -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE - alpha = 1.0f; - if ( st->element_mode == IVAS_CPE_MDCT && st->nbLostCmpt >= MDCT_ST_PLC_FADEOUT_START_FRAME && A_cng != NULL ) - { - alpha = Damping_fact( st->core_ext_mode, st->nbLostCmpt - MDCT_ST_PLC_FADEOUT_START_FRAME, st->last_good, st->stab_fac, &( st->lp_gainp ), 0 ); - } - else if ( A_cng == NULL ) - { - alpha = Damping_fact( st->core_ext_mode, st->nbLostCmpt, st->last_good, st->stab_fac, &( st->lp_gainp ), 0 ); - } -#else alpha = Damping_fact( st->core_ext_mode, st->nbLostCmpt, st->last_good, st->stab_fac, &( st->lp_gainp ), 0 ); -#endif } /*-----------------------------------------------------------------* diff --git a/lib_dec/ivas_mdct_core_dec.c b/lib_dec/ivas_mdct_core_dec.c index 76a3d0844c..0c77176766 100644 --- a/lib_dec/ivas_mdct_core_dec.c +++ b/lib_dec/ivas_mdct_core_dec.c @@ -728,11 +728,7 @@ void ivas_mdct_core_invQ( } nf_seed = 0; -#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE - decoder_tcx_invQ( st, prm[ch], Aq[ch], Aind[ch], L_spec[ch], L_frame[ch], L_frameTCX[ch], x[ch][k], NULL, xn_buf, &fUseTns[ch][k], &tnsData[ch][k], &gain_tcx, &prm_sqQ, &nf_seed, bfi, isMCT, k ); -#else decoder_tcx_invQ( st, prm[ch], Aq[ch], Aind[ch], L_spec[ch], L_frame[ch], L_frameTCX[ch], x[ch][k], NULL, xn_buf, &fUseTns[ch][k], &tnsData[ch][k], &gain_tcx, &prm_sqQ, &nf_seed, bfi, k ); -#endif mvr2r( x[ch][k], x_0[ch][k], L_frameTCX[ch] ); -- GitLab From f562a8b1f6439263de06c49958bec3d11f27ee1f Mon Sep 17 00:00:00 2001 From: knj Date: Fri, 2 Sep 2022 12:44:49 +0200 Subject: [PATCH 15/26] still apply IGF gain fading for MCT modes --- lib_com/ivas_prot.h | 7 ++++++- lib_dec/dec_tcx.c | 9 +++++++-- lib_dec/igf_dec.c | 6 +++--- lib_dec/ivas_mct_dec_mct.c | 4 ++++ lib_dec/ivas_stereo_mdct_core_dec.c | 4 ++++ 5 files changed, 24 insertions(+), 6 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 3602d6ae58..b96f45c905 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -2051,7 +2051,12 @@ 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( @@ -2086,7 +2091,7 @@ void IGFDecApplyStereo( 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 element_mode /* i : decoder element mode */ + const int16_t apply_damping_bfi /* i : decoder element mode */ #else const int16_t bfi /* i : frame loss == 1, frame good == 0 */ #endif diff --git a/lib_dec/dec_tcx.c b/lib_dec/dec_tcx.c index 41f3570662..b9c098b952 100644 --- a/lib_dec/dec_tcx.c +++ b/lib_dec/dec_tcx.c @@ -1927,7 +1927,12 @@ 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 */ - const int16_t bfi /* i : bad frame indicator */ +#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]; @@ -1981,7 +1986,7 @@ void decoder_tcx_IGF_stereo( } #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, sts[0]->element_mode ); + 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 diff --git a/lib_dec/igf_dec.c b/lib_dec/igf_dec.c index 9344bfd9e4..ede8975992 100644 --- a/lib_dec/igf_dec.c +++ b/lib_dec/igf_dec.c @@ -1253,7 +1253,7 @@ void IGFDecApplyStereo( 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 element_mode + const int16_t apply_damping_bfi #else const int16_t bfi /* i : frame loss == 1, frame good == 0 */ #endif @@ -1354,8 +1354,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, element_mode != IVAS_CPE_MDCT ); - IGF_appl( hPrivateDataR, igfGridIdx, spectrumR, igf_specR, hIGFDecR->virtualSpec, hIGFDecR->flag_sparse, element_mode != IVAS_CPE_MDCT ); + IGF_appl( hPrivateDataL, igfGridIdx, spectrumL, igf_specL, hIGFDecL->virtualSpec, hIGFDecL->flag_sparse, apply_damping_bfi ); + IGF_appl( hPrivateDataR, igfGridIdx, spectrumR, igf_specR, hIGFDecR->virtualSpec, hIGFDecR->flag_sparse, apply_damping_bfi ); #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 ); diff --git a/lib_dec/ivas_mct_dec_mct.c b/lib_dec/ivas_mct_dec_mct.c index 00eff03dac..ec19acb602 100644 --- a/lib_dec/ivas_mct_dec_mct.c +++ b/lib_dec/ivas_mct_dec_mct.c @@ -283,7 +283,11 @@ 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_stereo_mdct_core_dec.c b/lib_dec/ivas_stereo_mdct_core_dec.c index ff94a59589..dc0bc915c9 100644 --- a/lib_dec/ivas_stereo_mdct_core_dec.c +++ b/lib_dec/ivas_stereo_mdct_core_dec.c @@ -299,7 +299,11 @@ 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 { -- GitLab From 54ce653ff14896af6cb451791b1c6a960e68103d Mon Sep 17 00:00:00 2001 From: knj Date: Fri, 2 Sep 2022 14:35:22 +0200 Subject: [PATCH 16/26] fix compilation error --- lib_dec/dec_tcx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/dec_tcx.c b/lib_dec/dec_tcx.c index b9c098b952..7c948506c6 100644 --- a/lib_dec/dec_tcx.c +++ b/lib_dec/dec_tcx.c @@ -1931,7 +1931,7 @@ void decoder_tcx_IGF_stereo( 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 */ + const int16_t bfi /* i : bad frame indicator */ #endif ) { -- GitLab From 6fd5cf2eb55087a08ed71f5c484ccd139f661609 Mon Sep 17 00:00:00 2001 From: knj Date: Fri, 2 Sep 2022 15:28:31 +0200 Subject: [PATCH 17/26] tiny cleanup --- lib_dec/dec_tcx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/dec_tcx.c b/lib_dec/dec_tcx.c index 7c948506c6..65effab983 100644 --- a/lib_dec/dec_tcx.c +++ b/lib_dec/dec_tcx.c @@ -1291,7 +1291,7 @@ void decoder_tcx_noisefilling( #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, st->hTcxDec->CngLevelBackgroundTrace_bfi, infoIGFStartLine ); + TonalMDCTConceal_InsertNoise( st->hTonalMDCTConc, x, st->tonal_mdct_plc_active, &st->seed_tcx_plc, noiseTiltFactor, f, concealment_noise, hTcxDec->CngLevelBackgroundTrace_bfi, infoIGFStartLine ); } else { -- GitLab From 0a070491f1f793fec637402bb272febde65bd2e5 Mon Sep 17 00:00:00 2001 From: knj Date: Fri, 2 Sep 2022 15:29:56 +0200 Subject: [PATCH 18/26] fix non-BE in non-MDCT Stereo TCX modes --- lib_dec/fd_cng_dec.c | 7 ++++--- lib_dec/igf_dec.c | 4 ++-- lib_dec/tonalMDCTconcealment.c | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/lib_dec/fd_cng_dec.c b/lib_dec/fd_cng_dec.c index 6f27464c66..06ebedcd27 100644 --- a/lib_dec/fd_cng_dec.c +++ b/lib_dec/fd_cng_dec.c @@ -506,8 +506,8 @@ void ApplyFdCng( { /* update lsf cng estimate for concealment. Do that during concealment, in order to avoid addition clean channel complexity*/ - /* always set psychParameters ... */ - if ( st->hTonalMDCTConc != NULL ) + /* always set psychParameters for MDCT-Stereo ... */ + if ( st->element_mode == IVAS_CPE_MDCT && st->hTonalMDCTConc != NULL ) { st->hTonalMDCTConc->psychParams = ( st->core == TCX_20_CORE ) ? &st->hTonalMDCTConc->psychParamsTCX20 : &st->hTonalMDCTConc->psychParamsTCX10; } @@ -526,6 +526,7 @@ void ApplyFdCng( mvr2r( lsp_cng, st->lspold_cng, M ); lsp2lsf( lsp_cng, st->lsf_cng, M, sr_core ); } + st->plcBackgroundNoiseUpdated = 1; } #endif @@ -534,8 +535,8 @@ void ApplyFdCng( mvr2r( lsp_cng, st->lspold_cng, M ); lsp2lsf( lsp_cng, st->lsf_cng, M, st->sr_core ); -#endif st->plcBackgroundNoiseUpdated = 1; +#endif } break; diff --git a/lib_dec/igf_dec.c b/lib_dec/igf_dec.c index ede8975992..063463093b 100644 --- a/lib_dec/igf_dec.c +++ b/lib_dec/igf_dec.c @@ -681,7 +681,7 @@ static void IGF_appl( 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 */ + 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 @@ -1222,7 +1222,7 @@ void IGFDecApplyMono( 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, element_mode != IVAS_CPE_MDCT ); + 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 diff --git a/lib_dec/tonalMDCTconcealment.c b/lib_dec/tonalMDCTconcealment.c index 31cad74a15..4a63761d16 100644 --- a/lib_dec/tonalMDCTconcealment.c +++ b/lib_dec/tonalMDCTconcealment.c @@ -520,7 +520,7 @@ void TonalMDCTConceal_InsertNoise( g = 1.0f - crossfadeGain; #ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE - if ( !hTonalMDCTConc->lastBlockData.blockIsConcealed && concealment_noise != NULL ) + if ( !hTonalMDCTConc->lastBlockData.blockIsConcealed ) #else if ( !hTonalMDCTConc->lastBlockData.blockIsConcealed ) #endif -- GitLab From 6fb9241da0dfc9758b631f6bc6f3f9163dc721fd Mon Sep 17 00:00:00 2001 From: knj Date: Fri, 2 Sep 2022 16:03:34 +0200 Subject: [PATCH 19/26] cleanup and refactoring --- lib_com/ivas_prot.h | 8 ++++++- lib_com/ivas_stereo_psychlpc_com.c | 3 +-- lib_com/options.h | 2 +- lib_dec/core_dec_init.c | 1 - lib_dec/dec_tcx.c | 18 +------------- lib_dec/er_dec_tcx.c | 6 +---- lib_dec/fd_cng_dec.c | 2 +- lib_dec/igf_dec.c | 37 ++++++++++++++++++++++++++--- lib_dec/ivas_mdct_core_dec.c | 22 +---------------- lib_dec/ivas_stereo_mdct_core_dec.c | 22 +---------------- 10 files changed, 48 insertions(+), 73 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index b96f45c905..29f833c093 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -2091,7 +2091,7 @@ void IGFDecApplyStereo( 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 apply_damping_bfi /* i : decoder element mode */ + const int16_t bfi_apply_damping /* i : decoder element mode */ #else const int16_t bfi /* i : frame loss == 1, frame good == 0 */ #endif @@ -5448,6 +5448,12 @@ void TonalMdctConceal_whiten_noise_shape( const int16_t L_frame, const TONALMDCTCONC_NOISE_SHAPE_WHITENING_MODE ); + +int16_t get_igf_startline( + Decoder_State *st, + int16_t L_frame, + int16_t L_frameTCX +); #endif float rand_triangular_signed( diff --git a/lib_com/ivas_stereo_psychlpc_com.c b/lib_com/ivas_stereo_psychlpc_com.c index cdc48f5f98..4ca10255a7 100644 --- a/lib_com/ivas_stereo_psychlpc_com.c +++ b/lib_com/ivas_stereo_psychlpc_com.c @@ -71,8 +71,7 @@ static void SpectrumWeighting_Init( #ifndef MDCT_STEREO_PLC_FADE_2_BG_NOISE static #endif - ivas_error - PsychoacousticParameters_Init( +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) */ const int8_t nBands, /* i : Number of spectrum subbands */ diff --git a/lib_com/options.h b/lib_com/options.h index 16e8370398..78f5eee7ad 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -143,7 +143,7 @@ /*#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 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 FIX_I1_113*/ /* under review : MCT bit distribution optimization for SBA high bitrates*/ #define FIX_ADAP_STEFI_SHIFT /* Issue 89: fix bug in parameter shift of adaptive stereo filling */ diff --git a/lib_dec/core_dec_init.c b/lib_dec/core_dec_init.c index 53e0939477..bc8d95e24f 100644 --- a/lib_dec/core_dec_init.c +++ b/lib_dec/core_dec_init.c @@ -553,7 +553,6 @@ void open_decoder_LPD( st->hTcxDec->prev_widow_left_rect = 0; #ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE - /* Todo: should be considered for other stereo modes as well */ 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; diff --git a/lib_dec/dec_tcx.c b/lib_dec/dec_tcx.c index 65effab983..4aea664192 100644 --- a/lib_dec/dec_tcx.c +++ b/lib_dec/dec_tcx.c @@ -1104,23 +1104,7 @@ void decoder_tcx_noisefilling( *-----------------------------------------------------------------*/ /* Init lengths */ - 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 ); - } + infoIGFStartLine = get_igf_startline( st, L_frame, L_frameTCX ); noiseFillingSize = L_spec; if ( st->igf ) diff --git a/lib_dec/er_dec_tcx.c b/lib_dec/er_dec_tcx.c index 5ba52bbff7..4d2a030492 100644 --- a/lib_dec/er_dec_tcx.c +++ b/lib_dec/er_dec_tcx.c @@ -560,11 +560,8 @@ void con_tcx( if ( alpha != 1.0f ) { - float lsp_local[M]; - float lsp_fade[M]; - float alpha_inv; + float lsp_local[M], lsp_fade[M], alpha_inv; - wmops_sub_start( "Fade LSPs" ); alpha_inv = 1.0f - alpha; a2lsp_stab( A_local, lsp_local, lsp_local ); @@ -575,7 +572,6 @@ void con_tcx( } lsp2a_stab( lsp_fade, A_local, M ); - wmops_sub_end(); } } #endif diff --git a/lib_dec/fd_cng_dec.c b/lib_dec/fd_cng_dec.c index 06ebedcd27..ffbb785351 100644 --- a/lib_dec/fd_cng_dec.c +++ b/lib_dec/fd_cng_dec.c @@ -529,8 +529,8 @@ 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 ); diff --git a/lib_dec/igf_dec.c b/lib_dec/igf_dec.c index 063463093b..4e1e7ebd0a 100644 --- a/lib_dec/igf_dec.c +++ b/lib_dec/igf_dec.c @@ -1253,7 +1253,7 @@ void IGFDecApplyStereo( 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 apply_damping_bfi + const int16_t bfi_apply_damping #else const int16_t bfi /* i : frame loss == 1, frame good == 0 */ #endif @@ -1354,8 +1354,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, apply_damping_bfi ); - IGF_appl( hPrivateDataR, igfGridIdx, spectrumR, igf_specR, hIGFDecR->virtualSpec, hIGFDecR->flag_sparse, apply_damping_bfi ); + 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 ); @@ -1611,3 +1611,34 @@ 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, + int16_t L_frameTCX +) +{ + int16_t igf_startline; + + if ( st->igf == 0 ) + { + if ( st->narrowBand == 0 ) + { + /* minimum needed for output with sampling rates lower then the + nominal sampling rate */ + igf_startline = min( L_frameTCX, L_frame ); + } + else + { + igf_startline = L_frameTCX; + } + } + else + { + igf_startline = min( st->hIGFDec->infoIGFStartLine, L_frameTCX ); + } + + return igf_startline; +} +#endif \ No newline at end of file diff --git a/lib_dec/ivas_mdct_core_dec.c b/lib_dec/ivas_mdct_core_dec.c index 0c77176766..d05024c565 100644 --- a/lib_dec/ivas_mdct_core_dec.c +++ b/lib_dec/ivas_mdct_core_dec.c @@ -1067,27 +1067,7 @@ void ivas_mdct_core_tns_ns( #endif { #ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE - int16_t infoIGFStartLine; - - 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[ch], L_frame[ch] ); - } - else - { - infoIGFStartLine = L_frameTCX[ch]; - } - } - else - { - infoIGFStartLine = min( st->hIGFDec->infoIGFStartLine, L_frameTCX[ch] ); - } - - TonalMDCTConceal_SaveFreqSignal( st->hTonalMDCTConc, x[ch][k], L_frameTCX[ch], L_frame[ch], &sns_int_scf[0], infoIGFStartLine ); + 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 diff --git a/lib_dec/ivas_stereo_mdct_core_dec.c b/lib_dec/ivas_stereo_mdct_core_dec.c index dc0bc915c9..9bbb343c21 100644 --- a/lib_dec/ivas_stereo_mdct_core_dec.c +++ b/lib_dec/ivas_stereo_mdct_core_dec.c @@ -340,27 +340,7 @@ void stereo_mdct_core_dec( #endif { #ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE - int16_t infoIGFStartLine; - - 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[ch], L_frame[ch] ); - } - else - { - infoIGFStartLine = L_frameTCX[ch]; - } - } - else - { - infoIGFStartLine = min( st->hIGFDec->infoIGFStartLine, L_frameTCX[ch] ); - } - - TonalMDCTConceal_SaveFreqSignal( st->hTonalMDCTConc, x[ch][k], L_frameTCX[ch], L_frame[ch], &sns_int_scf[0], infoIGFStartLine ); + 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 -- GitLab From d6917ed6fe2344231a24f7b5b9f91c06978a2238 Mon Sep 17 00:00:00 2001 From: knj Date: Fri, 2 Sep 2022 16:18:39 +0200 Subject: [PATCH 20/26] fix compilation error and warning --- lib_dec/dec_tcx.c | 20 ++++++++++++++++++++ lib_dec/igf_dec.c | 2 +- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/lib_dec/dec_tcx.c b/lib_dec/dec_tcx.c index 4aea664192..0614c5e0db 100644 --- a/lib_dec/dec_tcx.c +++ b/lib_dec/dec_tcx.c @@ -1104,7 +1104,27 @@ 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 ) diff --git a/lib_dec/igf_dec.c b/lib_dec/igf_dec.c index 4e1e7ebd0a..fecc8e96df 100644 --- a/lib_dec/igf_dec.c +++ b/lib_dec/igf_dec.c @@ -1641,4 +1641,4 @@ int16_t get_igf_startline( return igf_startline; } -#endif \ No newline at end of file +#endif -- GitLab From f033b2175bf4e6da1116a29768f5d1fc10929264 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Tue, 6 Sep 2022 09:11:38 +0200 Subject: [PATCH 21/26] remove unnecessary double pointer which also fixes instrumented build --- lib_dec/tonalMDCTconcealment.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib_dec/tonalMDCTconcealment.c b/lib_dec/tonalMDCTconcealment.c index 4a63761d16..872cf1efa9 100644 --- a/lib_dec/tonalMDCTconcealment.c +++ b/lib_dec/tonalMDCTconcealment.c @@ -1158,17 +1158,17 @@ void TonalMdctConceal_whiten_noise_shape( const TONALMDCTCONC_NOISE_SHAPE_WHITENING_MODE whitening_mode ) { - float whitenend_noise_shape[L_FRAME16k]; int16_t inc, start_idx, stop_idx; float *noiseLevelPtr, *scfs_bg, *scfs_for_shaping; - PsychoacousticParameters **psychParams; HANDLE_FD_CNG_COM hFdCngCom; + float whitenend_noise_shape[L_FRAME16k]; float scfs_int[FDNS_NPTS]; + const PsychoacousticParameters *psychParams; wmops_sub_start( "apply_sns_on_noise_shape" ); scfs_bg = &st->hTonalMDCTConc->scaleFactorsBackground[0]; - psychParams = &st->hTonalMDCTConc->psychParams; + psychParams = st->hTonalMDCTConc->psychParams; hFdCngCom = st->hFdCngDec->hFdCngCom; inc = ( ( whitening_mode == ON_FIRST_LOST_FRAME ? st->core : st->last_core ) > TCX_20_CORE ) ? 2 : 1; @@ -1186,7 +1186,7 @@ void TonalMdctConceal_whiten_noise_shape( { float scf[SNS_NPTS]; - sns_compute_scf( whitenend_noise_shape, *psychParams, L_frame, scf ); + sns_compute_scf( whitenend_noise_shape, psychParams, L_frame, scf ); sns_interpolate_scalefactors( scfs_int, scf, ENC ); sns_interpolate_scalefactors( scfs_bg, scf, DEC ); scfs_for_shaping = &scfs_int[0]; @@ -1198,7 +1198,7 @@ void TonalMdctConceal_whiten_noise_shape( if ( sum_f( scfs_for_shaping, FDNS_NPTS ) > 0.0f ) { - sns_shape_spectrum( whitenend_noise_shape, *psychParams, scfs_for_shaping, L_frame ); + sns_shape_spectrum( whitenend_noise_shape, psychParams, scfs_for_shaping, L_frame ); mvr2r( whitenend_noise_shape + start_idx, hFdCngCom->cngNoiseLevel, stop_idx - start_idx ); } else -- GitLab From 4e43ae51db9262eb156a77ac951290e3bf82030a Mon Sep 17 00:00:00 2001 From: knj Date: Thu, 22 Sep 2022 10:04:45 +0200 Subject: [PATCH 22/26] fix bugs in TD-PLC and whitening of noise shape --- lib_dec/er_dec_tcx.c | 18 +++++------------- lib_dec/fd_cng_dec.c | 2 +- lib_dec/ivas_core_dec.c | 2 +- 3 files changed, 7 insertions(+), 15 deletions(-) diff --git a/lib_dec/er_dec_tcx.c b/lib_dec/er_dec_tcx.c index 4d2a030492..7ff9190f4c 100644 --- a/lib_dec/er_dec_tcx.c +++ b/lib_dec/er_dec_tcx.c @@ -34,6 +34,8 @@ EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 ====================================================================================*/ +#include "cnst.h" +#include "ivas_cnst.h" #include #include #include "options.h" @@ -279,7 +281,7 @@ void con_tcx( st->bpf_gain_param = 0; /* PLC: calculate damping factor */ - alpha = Damping_fact( st->core_ext_mode, st->nbLostCmpt, st->last_good, st->stab_fac, &( st->lp_gainp ), 0 ); + alpha = Damping_fact( st->core_ext_mode, st->nbLostCmpt, st->last_good, st->stab_fac, &( st->lp_gainp ), ACELP_CORE ); if ( st->nbLostCmpt == 1 ) { @@ -338,7 +340,7 @@ void con_tcx( set_f( pitch_buf, (float) L_SUBFR, st->nb_subfr ); /* PLC: calculate damping factor */ - alpha = Damping_fact( st->core_ext_mode, st->nbLostCmpt, st->last_good, st->stab_fac, &( st->lp_gainp ), 0 ); + alpha = Damping_fact( st->core_ext_mode, st->nbLostCmpt, st->last_good, st->stab_fac, &( st->lp_gainp ), ACELP_CORE ); } /*-----------------------------------------------------------------* @@ -548,17 +550,7 @@ void con_tcx( #ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE if ( A_cng != NULL ) { - if ( ( st->nbLostCmpt == 1 && st->idchan == 0 ) || ( st->nbLostCmpt == 2 && st->idchan == 1 ) ) - { - float lsp_cng[M]; - - lpc_from_spectrum( st->hFdCngDec->hFdCngCom, st->hFdCngDec->hFdCngCom->startBand, st->hFdCngDec->hFdCngCom->stopFFTbin, 0.f ); - - a2lsp_stab( st->hFdCngDec->hFdCngCom->A_cng, lsp_cng, st->lspold_cng ); - mvr2r( lsp_cng, st->lspold_cng, M ); - } - - if ( alpha != 1.0f ) + if ( st->plcBackgroundNoiseUpdated && alpha != 1.0f ) { float lsp_local[M], lsp_fade[M], alpha_inv; diff --git a/lib_dec/fd_cng_dec.c b/lib_dec/fd_cng_dec.c index ffbb785351..56bd2ff99e 100644 --- a/lib_dec/fd_cng_dec.c +++ b/lib_dec/fd_cng_dec.c @@ -519,7 +519,7 @@ void ApplyFdCng( { TonalMdctConceal_whiten_noise_shape( st, L_frame, ON_FIRST_LOST_FRAME ); } - else if ( st->element_mode != IVAS_CPE_MDCT ) + else if ( st->element_mode != IVAS_CPE_MDCT || st->core == ACELP_CORE ) { lpc_from_spectrum( hFdCngCom, hFdCngCom->startBand, hFdCngCom->stopFFTbin, 0.f ); a2lsp_stab( hFdCngCom->A_cng, lsp_cng, st->lspold_cng ); diff --git a/lib_dec/ivas_core_dec.c b/lib_dec/ivas_core_dec.c index 917d64bf20..ad350f4e30 100644 --- a/lib_dec/ivas_core_dec.c +++ b/lib_dec/ivas_core_dec.c @@ -435,7 +435,7 @@ ivas_error ivas_core_dec( /* On first good frame after frameloss undo the whitening of the bg noise shape */ for ( n = 0; n < n_channels; ++n ) { - if ( sts[n]->last_core != ACELP_CORE ) + if ( sts[n]->last_core_bfi != ACELP_CORE ) { TonalMdctConceal_whiten_noise_shape( sts[n], L_FRAME16k, ON_FIRST_GOOD_FRAME ); } -- GitLab From 8bdcaf00291019d3fffe6fb2f0bf4816de2c016b Mon Sep 17 00:00:00 2001 From: knj Date: Fri, 16 Sep 2022 16:15:17 +0200 Subject: [PATCH 23/26] fade to complete zero after 2 seconds --- lib_com/ivas_cnst.h | 4 ++++ lib_com/options.h | 1 + lib_dec/dec_tcx.c | 14 ++++++++++++++ lib_dec/er_dec_tcx.c | 14 ++++++++++++++ 4 files changed, 33 insertions(+) diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index 6cddb98120..d7702ca3b6 100644 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -801,6 +801,10 @@ 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 1 * 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 abaf5a49d3..9b6e33bb7b 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -144,6 +144,7 @@ /*#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*/ #define SPAR_SCALING_HARMONIZATION /* Issue 80: Changes to harmonize scaling in spar */ diff --git a/lib_dec/dec_tcx.c b/lib_dec/dec_tcx.c index 0614c5e0db..502433517e 100644 --- a/lib_dec/dec_tcx.c +++ b/lib_dec/dec_tcx.c @@ -202,6 +202,20 @@ 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 ) + { + if ( st->nbLostCmpt > MDCT_ST_PLC_FADEOUT_MAX_CONC_FRAME + MDCT_ST_PLC_FADEOUT_TO_ZERO_LEN ) + { + gainCNG = 0.f; + } + else if ( st->nbLostCmpt > MDCT_ST_PLC_FADEOUT_MAX_CONC_FRAME ) + { + 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 7ff9190f4c..d72e88da5f 100644 --- a/lib_dec/er_dec_tcx.c +++ b/lib_dec/er_dec_tcx.c @@ -452,6 +452,20 @@ void con_tcx( if ( st->tcxonly ) { 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 ) + { + gainCNG = 0.f; + } + else if ( st->nbLostCmpt > MDCT_ST_PLC_FADEOUT_MAX_CONC_FRAME ) + { + gainCNG *= 1.f - (float) ( st->nbLostCmpt - MDCT_ST_PLC_FADEOUT_MAX_CONC_FRAME ) / MDCT_ST_PLC_FADEOUT_TO_ZERO_LEN; + } + } +#endif } else { -- GitLab From d3f28017277a44bc26fbab15ad2b2d715ead7558 Mon Sep 17 00:00:00 2001 From: knj Date: Wed, 28 Sep 2022 14:07:21 +0200 Subject: [PATCH 24/26] Revert "fix for 24 bit wav files in pyaudio3dtools" This reverts commit 3f7bbf9a778480d657290db5a517bebc98f50297. --- scripts/pyaudio3dtools/audiofile.py | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/scripts/pyaudio3dtools/audiofile.py b/scripts/pyaudio3dtools/audiofile.py index b03b472ae9..46bb452082 100755 --- a/scripts/pyaudio3dtools/audiofile.py +++ b/scripts/pyaudio3dtools/audiofile.py @@ -35,7 +35,6 @@ import platform import shutil import struct import subprocess as sp -import warnings from importlib import import_module from tempfile import TemporaryDirectory from typing import Optional, Tuple @@ -74,18 +73,6 @@ def readfile( if file_extension == ".wav": fs, data = wav.read(filename) - if data.dtype == np.int32: - data = np.interp( - data, - (np.iinfo(np.int32).min, np.iinfo(np.int32).max), - (np.iinfo(np.int16).min, np.iinfo(np.int16).max), - ) - elif data.dtype == np.float32: - data = np.interp( - data, - (-1, 1), - (np.iinfo(np.int16).min, np.iinfo(np.int16).max), - ) x = np.array(data, dtype=outdtype) file_len = x.shape[0] if x.ndim == 1: @@ -120,11 +107,9 @@ def writefile(filename: str, x: np.ndarray, fs: int = 48000) -> None: """ _, file_extension = os.path.splitext(os.path.basename(filename)) - clipped_samples = np.sum( - np.logical_or(x < np.iinfo(np.int16).min, x > np.iinfo(np.int16).max) - ) + clipped_samples = np.sum(np.logical_or(x < np.iinfo(np.int16).min, x > np.iinfo(np.int16).max)) if clipped_samples > 0: - warnings.warn(f" Warning: {clipped_samples} samples clipped") + print(" Warning: %i samples clipped"%clipped_samples) x = np.clip(x, np.iinfo(np.int16).min, np.iinfo(np.int16).max) if file_extension == ".wav": @@ -504,6 +489,7 @@ def loudnessinfo( in_sig: np.ndarray, in_fs: Optional[int] = 48000, in_format: Optional[str] = "MONO", + in_ls_layout_file: Optional[str] = None, output_loudness: Optional[int] = -26, loudness_tool: Optional[str] = "bs1770demo", use_rms: Optional[bool] = False, @@ -538,10 +524,13 @@ def loudnessinfo( else: null_file = "/dev/null" + # check for binary if shutil.which(loudness_tool) is None: raise FileNotFoundError(f"The binary {loudness_tool} was not found in path!") - in_spfmt = spatialaudioformat.Format(in_format=in_format) + in_spfmt = spatialaudioformat.Format( + in_format=in_format, ls_layout_file=in_ls_layout_file + ) if not (in_spfmt.isheadphones or in_spfmt.isloudspeaker or in_spfmt.ambi_order > 1): raise NotImplementedError( @@ -554,7 +543,7 @@ def loudnessinfo( ) with TemporaryDirectory() as tmp_dir: - tmp_file = os.path.join(tmp_dir, "tmp_loudness.pcm") + tmp_file = os.path.join(tmp_dir, "tmp.pcm") if "bs1770demo" in loudness_tool: """ -- GitLab From b2ca4103c85832476f66ecaf32fc4e14f9b13fad Mon Sep 17 00:00:00 2001 From: knj Date: Fri, 30 Sep 2022 10:52:22 +0200 Subject: [PATCH 25/26] correct start of fade to zero --- lib_com/ivas_cnst.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index a70e69b32a..020d1bdc1d 100644 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -810,7 +810,7 @@ enum fea_names #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 1 * FRAMES_PER_SEC +#define MDCT_ST_PLC_FADEOUT_MAX_CONC_FRAME 2 * FRAMES_PER_SEC #define MDCT_ST_PLC_FADEOUT_TO_ZERO_LEN 20 #endif -- GitLab From b63baaeffd9fce0718286f6be9c34d0faca600c2 Mon Sep 17 00:00:00 2001 From: knj Date: Fri, 30 Sep 2022 10:54:25 +0200 Subject: [PATCH 26/26] activate MDCT-ST fadeout contribution switches --- lib_com/options.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 7a6569aa31..3c30e33d86 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -142,8 +142,8 @@ #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 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*/ #define FIX_I106_TDREND_5MS /* Issue 106: 5 ms update rate in TD object renderer */ -- GitLab