From bcfd83cefcbf134bc7e6c1688913b8e5e3f6e6b5 Mon Sep 17 00:00:00 2001 From: Charles Kinuthia Date: Tue, 17 Jan 2023 15:10:19 +0100 Subject: [PATCH] Fix for critical item for contribution 20 under define LOW_RATE_TRANS_FIX --- lib_com/options.h | 1 + lib_enc/ivas_cpe_enc.c | 11 +++++++++++ lib_enc/ivas_ism_enc.c | 5 +++++ lib_enc/stat_enc.h | 6 ++++-- lib_enc/transient_detection.c | 8 +++++++- 5 files changed, 28 insertions(+), 3 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 54c20247d2..ad2f337748 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -154,6 +154,7 @@ #define FIX_292_VBAP_CALLOC_REMOVAL /* Nokia: Fixes issue 292 by removing the remnant callocs */ #define FIX_293_EXT_RENDERER_CLI /* FhG: Fix bugs in external renderer CLI */ #define FIX_268 /* Issue 268: Add low cost dry-run of memory analysis */ +#define LOW_RATE_TRANS_FIX /* Eri: Fix for critical item during transitions */ /* ################## End DEVELOPMENT switches ######################### */ /* clang-format on */ diff --git a/lib_enc/ivas_cpe_enc.c b/lib_enc/ivas_cpe_enc.c index 2440cc4fa6..598818f70c 100644 --- a/lib_enc/ivas_cpe_enc.c +++ b/lib_enc/ivas_cpe_enc.c @@ -656,6 +656,17 @@ ivas_error ivas_cpe_enc( hCPE->hFrontVad[0]->ini_frame = min( hCPE->hFrontVad[0]->ini_frame, MAX_FRAME_COUNTER ); } +#ifdef LOW_RATE_TRANS_FIX + /* Store previous attack detection flag */ + for ( n = 0; n < CPE_CHANNELS; n++ ) + { + if ( sts[n]->mct_chan_mode != MCT_CHAN_MODE_LFE ) + { + sts[n]->hTranDet->transientDetector.prev_bIsAttackPresent = sts[n]->hTranDet->transientDetector.bIsAttackPresent; + } + } +#endif + #ifdef DEBUG_MODE_INFO if ( hCPE->element_mode == IVAS_CPE_DFT ) { diff --git a/lib_enc/ivas_ism_enc.c b/lib_enc/ivas_ism_enc.c index 1849d2da03..58fa1330b9 100644 --- a/lib_enc/ivas_ism_enc.c +++ b/lib_enc/ivas_ism_enc.c @@ -273,6 +273,11 @@ ivas_error ivas_ism_enc( /* update input samples buffer */ mvr2r( st->input, st->old_input_signal, input_frame ); + +#ifdef LOW_RATE_TRANS_FIX + /* Store previous attack detection flag */ + st->hTranDet->transientDetector.prev_bIsAttackPresent = st->hTranDet->transientDetector.bIsAttackPresent; +#endif } pop_wmops(); diff --git a/lib_enc/stat_enc.h b/lib_enc/stat_enc.h index 48585881d0..a57c8f25b7 100644 --- a/lib_enc/stat_enc.h +++ b/lib_enc/stat_enc.h @@ -140,8 +140,10 @@ typedef struct TransientDetector TCheckSubblocksForAttack CheckSubblocksForAttack; /* Function for checking a presence of an attack. */ float attackRatioThreshold; /* Attack ratio threshold. */ int16_t bIsAttackPresent; /* True when an attack was detected. */ - int16_t attackIndex; /* The index of an attack. */ - +#ifdef LOW_RATE_TRANS_FIX + int16_t prev_bIsAttackPresent; /* True if an attack was detected in the previous frame. */ +#endif + int16_t attackIndex; /* The index of an attack. */ } TransientDetector; /* Transient detection: Holds all transient detectors and buffers used by them. */ diff --git a/lib_enc/transient_detection.c b/lib_enc/transient_detection.c index 4ba76500bf..16e981b375 100644 --- a/lib_enc/transient_detection.c +++ b/lib_enc/transient_detection.c @@ -577,6 +577,9 @@ static void InitTransientDetector( pTransientDetector->CheckSubblocksForAttack = pCheckSubblocksForAttack; pTransientDetector->attackRatioThreshold = attackRatioThreshold; pTransientDetector->bIsAttackPresent = FALSE; +#ifdef LOW_RATE_TRANS_FIX + pTransientDetector->prev_bIsAttackPresent = FALSE; +#endif pTransientDetector->attackIndex = -1; pTransientDetector->pSubblockEnergies->ramp_up_flag = 0x0; @@ -897,8 +900,11 @@ int16_t transient_analysis( prel_force_td |= 0x0001; } } - +#ifdef LOW_RATE_TRANS_FIX + if ( prel_force_td == 0 && hTranDet->transientDetector.prev_bIsAttackPresent == 1 ) +#else if ( prel_force_td == 0 ) +#endif { /* release analysis */ pSubblockNrg = hTranDet->transientDetector.pSubblockEnergies->subblockNrg; -- GitLab