From b611af1b7c227f66b43a10b3185ac4c6930eccd3 Mon Sep 17 00:00:00 2001 From: Markus <59919483+mave2802@users.noreply.github.com> Date: Wed, 23 Oct 2024 11:37:42 +0200 Subject: [PATCH 1/5] fixed application of IGF in case of tonal MDCT concealment --- lib_com/prot_fx.h | 3 ++- lib_dec/dec_tcx_fx.c | 5 +++-- lib_dec/igf_dec_fx.c | 8 +++++--- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 3239613af..292546d98 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -8921,7 +8921,8 @@ void IGFDecApplyStereo( const Word16 *coreMsMask, const Word16 restrict_hopsize, const Word16 bfi, /* i : frame loss == 1, frame good == 0 */ - const Word16 bfi_apply_damping ); + const Word16 bfi_apply_damping, + const Word16 tonalMDCTConcealment_flag); void IGFDecSetMode( const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* o : instance handle of IGF Decoder */ diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index 35a417a6c..53d866a70 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -3643,6 +3643,7 @@ void decoder_tcx_IGF_stereo_fx( Word16 coreMsMask[N_MAX]; STEREO_MDCT_BAND_PARAMETERS *sfbConf; Word16 core, sfb, igfGridIdx, restrict_hopsize; + Word16 tonalMDCTConcealment_flag = (sts[0]->hTonalMDCTConc != NULL); core = sts[0]->core; move16(); @@ -3750,7 +3751,7 @@ void decoder_tcx_IGF_stereo_fx( move16(); } - IGFDecApplyStereo( sts[0]->hIGFDec, sts[1]->hIGFDec, x_fx[0][k], &x_e[0][k], x_fx[1][k], &x_e[1][k], igfGridIdx, coreMsMask, restrict_hopsize, bfi, MCT_flag ); + IGFDecApplyStereo(sts[0]->hIGFDec, sts[1]->hIGFDec, x_fx[0][k], &x_e[0][k], x_fx[1][k], &x_e[1][k], igfGridIdx, coreMsMask, restrict_hopsize, bfi, MCT_flag, tonalMDCTConcealment_flag); x_len[0][k] = sts[0]->hIGFDec->igfData.igfInfo.grid[igfGridIdx].stopLine; move16(); @@ -4846,7 +4847,7 @@ void decoder_tcx_noisefilling_fx( test(); IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && MCT_flag == 0 ) { - TonalMDCTConceal_InsertNoise_ivas_fx( st->hTonalMDCTConc, x, x_e, st->tonal_mdct_plc_active, &st->seed_tcx_plc, noiseTiltFactor, f, concealment_noise, concealment_noise_exp, CngLevelBackgroundTrace_bfi_fx, CngLevelBackgroundTrace_bfi_exp, infoIGFStartLine ); + TonalMDCTConceal_InsertNoise_ivas_fx( st->hTonalMDCTConc, x, x_e, st->tonal_mdct_plc_active, &st->seed_tcx_plc, noiseTiltFactor, f, concealment_noise, concealment_noise_exp, CngLevelBackgroundTrace_bfi_fx, CngLevelBackgroundTrace_bfi_exp, infoIGFStartLine ); } ELSE { diff --git a/lib_dec/igf_dec_fx.c b/lib_dec/igf_dec_fx.c index 463875a1c..8ed3f3520 100644 --- a/lib_dec/igf_dec_fx.c +++ b/lib_dec/igf_dec_fx.c @@ -3694,7 +3694,8 @@ void IGFDecApplyStereo( const Word16 *coreMsMask, const Word16 restrict_hopsize, const Word16 bfi, /* i : frame loss == 1, frame good == 0 */ - const Word16 bfi_apply_damping ) + const Word16 bfi_apply_damping, + const Word16 tonalMDCTConcealment_flag) { IGF_DEC_PRIVATE_DATA_HANDLE hPrivateDataL, hPrivateDataR; H_IGF_GRID hGrid; @@ -3793,9 +3794,10 @@ void IGFDecApplyStereo( move16(); } - /* skip IGF processing if all IGF levels are zero */ + /* skip IGF processing if all IGF levels are zero or tonal MDCT concealment is active*/ test(); - IF( !hIGFDecL->infoIGFAllZero || !hIGFDecR->infoIGFAllZero ) + + IF(!(tonalMDCTConcealment_flag & bfi) && (!hIGFDecL->infoIGFAllZero || !hIGFDecR->infoIGFAllZero)) { FOR( i = 0; i < hGrid->nTiles; i++ ) { -- GitLab From bceb0b769e8ff33aa524774dcd74f0bd8eacdc9f Mon Sep 17 00:00:00 2001 From: Markus <59919483+mave2802@users.noreply.github.com> Date: Wed, 30 Oct 2024 10:55:45 +0100 Subject: [PATCH 2/5] As in fade out, set spectrum from last block to zero above the crossover frequency in first concealed frame --- lib_com/prot_fx.h | 4 ++-- lib_dec/dec_tcx_fx.c | 3 +-- lib_dec/igf_dec_fx.c | 7 +++---- lib_dec/tonalMDCTconcealment_fx.c | 2 +- 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 292546d98..9fa7ff0ed 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -8921,8 +8921,8 @@ void IGFDecApplyStereo( const Word16 *coreMsMask, const Word16 restrict_hopsize, const Word16 bfi, /* i : frame loss == 1, frame good == 0 */ - const Word16 bfi_apply_damping, - const Word16 tonalMDCTConcealment_flag); + const Word16 bfi_apply_damping); + void IGFDecSetMode( const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* o : instance handle of IGF Decoder */ diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index 53d866a70..a4656e639 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -3643,7 +3643,6 @@ void decoder_tcx_IGF_stereo_fx( Word16 coreMsMask[N_MAX]; STEREO_MDCT_BAND_PARAMETERS *sfbConf; Word16 core, sfb, igfGridIdx, restrict_hopsize; - Word16 tonalMDCTConcealment_flag = (sts[0]->hTonalMDCTConc != NULL); core = sts[0]->core; move16(); @@ -3751,7 +3750,7 @@ void decoder_tcx_IGF_stereo_fx( move16(); } - IGFDecApplyStereo(sts[0]->hIGFDec, sts[1]->hIGFDec, x_fx[0][k], &x_e[0][k], x_fx[1][k], &x_e[1][k], igfGridIdx, coreMsMask, restrict_hopsize, bfi, MCT_flag, tonalMDCTConcealment_flag); + IGFDecApplyStereo(sts[0]->hIGFDec, sts[1]->hIGFDec, x_fx[0][k], &x_e[0][k], x_fx[1][k], &x_e[1][k], igfGridIdx, coreMsMask, restrict_hopsize, bfi, MCT_flag); x_len[0][k] = sts[0]->hIGFDec->igfData.igfInfo.grid[igfGridIdx].stopLine; move16(); diff --git a/lib_dec/igf_dec_fx.c b/lib_dec/igf_dec_fx.c index 8ed3f3520..e417edf44 100644 --- a/lib_dec/igf_dec_fx.c +++ b/lib_dec/igf_dec_fx.c @@ -3694,8 +3694,7 @@ void IGFDecApplyStereo( const Word16 *coreMsMask, const Word16 restrict_hopsize, const Word16 bfi, /* i : frame loss == 1, frame good == 0 */ - const Word16 bfi_apply_damping, - const Word16 tonalMDCTConcealment_flag) + const Word16 bfi_apply_damping) { IGF_DEC_PRIVATE_DATA_HANDLE hPrivateDataL, hPrivateDataR; H_IGF_GRID hGrid; @@ -3794,10 +3793,10 @@ void IGFDecApplyStereo( move16(); } - /* skip IGF processing if all IGF levels are zero or tonal MDCT concealment is active*/ + /* skip IGF processing if all IGF levels are zero */ test(); - IF(!(tonalMDCTConcealment_flag & bfi) && (!hIGFDecL->infoIGFAllZero || !hIGFDecR->infoIGFAllZero)) + IF(!hIGFDecL->infoIGFAllZero || !hIGFDecR->infoIGFAllZero) { FOR( i = 0; i < hGrid->nTiles; i++ ) { diff --git a/lib_dec/tonalMDCTconcealment_fx.c b/lib_dec/tonalMDCTconcealment_fx.c index adb73de03..babc04ac6 100644 --- a/lib_dec/tonalMDCTconcealment_fx.c +++ b/lib_dec/tonalMDCTconcealment_fx.c @@ -1486,7 +1486,7 @@ void TonalMDCTConceal_InsertNoise_ivas_fx( FOR( l = crossOverFreq; l < hTonalMDCTConc->lastBlockData.nSamples; l++ ) { - mdctSpectrum[l] = L_shl( L_deposit_l( hTonalMDCTConc->lastBlockData.spectralData[l] ), 16 ); // Q31-spectralData_exp + mdctSpectrum[i] = 0; move32(); } -- GitLab From e00a8c5898b203d0fff5d7ac00a4e55c9294c44f Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 31 Oct 2024 14:56:24 +0100 Subject: [PATCH 3/5] fix formatting --- lib_com/prot_fx.h | 2 +- lib_dec/dec_tcx_fx.c | 4 ++-- lib_dec/igf_dec_fx.c | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 9fa7ff0ed..b80334f21 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -8921,7 +8921,7 @@ void IGFDecApplyStereo( const Word16 *coreMsMask, const Word16 restrict_hopsize, const Word16 bfi, /* i : frame loss == 1, frame good == 0 */ - const Word16 bfi_apply_damping); + const Word16 bfi_apply_damping ); void IGFDecSetMode( diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index a4656e639..35a417a6c 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -3750,7 +3750,7 @@ void decoder_tcx_IGF_stereo_fx( move16(); } - IGFDecApplyStereo(sts[0]->hIGFDec, sts[1]->hIGFDec, x_fx[0][k], &x_e[0][k], x_fx[1][k], &x_e[1][k], igfGridIdx, coreMsMask, restrict_hopsize, bfi, MCT_flag); + IGFDecApplyStereo( sts[0]->hIGFDec, sts[1]->hIGFDec, x_fx[0][k], &x_e[0][k], x_fx[1][k], &x_e[1][k], igfGridIdx, coreMsMask, restrict_hopsize, bfi, MCT_flag ); x_len[0][k] = sts[0]->hIGFDec->igfData.igfInfo.grid[igfGridIdx].stopLine; move16(); @@ -4846,7 +4846,7 @@ void decoder_tcx_noisefilling_fx( test(); IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && MCT_flag == 0 ) { - TonalMDCTConceal_InsertNoise_ivas_fx( st->hTonalMDCTConc, x, x_e, st->tonal_mdct_plc_active, &st->seed_tcx_plc, noiseTiltFactor, f, concealment_noise, concealment_noise_exp, CngLevelBackgroundTrace_bfi_fx, CngLevelBackgroundTrace_bfi_exp, infoIGFStartLine ); + TonalMDCTConceal_InsertNoise_ivas_fx( st->hTonalMDCTConc, x, x_e, st->tonal_mdct_plc_active, &st->seed_tcx_plc, noiseTiltFactor, f, concealment_noise, concealment_noise_exp, CngLevelBackgroundTrace_bfi_fx, CngLevelBackgroundTrace_bfi_exp, infoIGFStartLine ); } ELSE { diff --git a/lib_dec/igf_dec_fx.c b/lib_dec/igf_dec_fx.c index e417edf44..c5ee99d17 100644 --- a/lib_dec/igf_dec_fx.c +++ b/lib_dec/igf_dec_fx.c @@ -3694,7 +3694,7 @@ void IGFDecApplyStereo( const Word16 *coreMsMask, const Word16 restrict_hopsize, const Word16 bfi, /* i : frame loss == 1, frame good == 0 */ - const Word16 bfi_apply_damping) + const Word16 bfi_apply_damping ) { IGF_DEC_PRIVATE_DATA_HANDLE hPrivateDataL, hPrivateDataR; H_IGF_GRID hGrid; @@ -3796,7 +3796,7 @@ void IGFDecApplyStereo( /* skip IGF processing if all IGF levels are zero */ test(); - IF(!hIGFDecL->infoIGFAllZero || !hIGFDecR->infoIGFAllZero) + IF( !hIGFDecL->infoIGFAllZero || !hIGFDecR->infoIGFAllZero ) { FOR( i = 0; i < hGrid->nTiles; i++ ) { -- GitLab From 2fe0a149864f28e3ac122da5cdb7f6474b8c8fb4 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 31 Oct 2024 15:07:49 +0100 Subject: [PATCH 4/5] undo whitespace changes --- lib_com/prot_fx.h | 1 - lib_dec/igf_dec_fx.c | 1 - 2 files changed, 2 deletions(-) diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index b80334f21..3239613af 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -8923,7 +8923,6 @@ void IGFDecApplyStereo( const Word16 bfi, /* i : frame loss == 1, frame good == 0 */ const Word16 bfi_apply_damping ); - void IGFDecSetMode( const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* o : instance handle of IGF Decoder */ const Word32 total_brate, /* i : bitrate */ diff --git a/lib_dec/igf_dec_fx.c b/lib_dec/igf_dec_fx.c index c5ee99d17..463875a1c 100644 --- a/lib_dec/igf_dec_fx.c +++ b/lib_dec/igf_dec_fx.c @@ -3795,7 +3795,6 @@ void IGFDecApplyStereo( /* skip IGF processing if all IGF levels are zero */ test(); - IF( !hIGFDecL->infoIGFAllZero || !hIGFDecR->infoIGFAllZero ) { FOR( i = 0; i < hGrid->nTiles; i++ ) -- GitLab From 094c1d0d168df328ae0ab8b2367a3a9dcee37bf9 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 31 Oct 2024 15:15:09 +0100 Subject: [PATCH 5/5] fix index --- lib_dec/tonalMDCTconcealment_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/tonalMDCTconcealment_fx.c b/lib_dec/tonalMDCTconcealment_fx.c index babc04ac6..0a079d45d 100644 --- a/lib_dec/tonalMDCTconcealment_fx.c +++ b/lib_dec/tonalMDCTconcealment_fx.c @@ -1486,7 +1486,7 @@ void TonalMDCTConceal_InsertNoise_ivas_fx( FOR( l = crossOverFreq; l < hTonalMDCTConc->lastBlockData.nSamples; l++ ) { - mdctSpectrum[i] = 0; + mdctSpectrum[l] = 0; move32(); } -- GitLab