From a8e2c96b93cb5e7da3959a8dd0e45b0abe564571 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Mon, 10 Feb 2025 15:15:52 +0530 Subject: [PATCH] TNS bug fixes, updates in swb_tbe_enc and lp_filt_exc_enc_ivas_fx --- lib_enc/cod_tcx.c | 4 ++-- lib_enc/lp_exc_e_fx.c | 2 +- lib_enc/swb_tbe_enc_fx.c | 6 +++--- lib_enc/tns_base_enc_fx.c | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib_enc/cod_tcx.c b/lib_enc/cod_tcx.c index aaa7e4e2e..8ddfb573b 100644 --- a/lib_enc/cod_tcx.c +++ b/lib_enc/cod_tcx.c @@ -290,7 +290,7 @@ void TNSAnalysisStereo_fx( Word16 maxEnergyChange_fx; maxEnergyChange_fx = mac_r( L_mult( GetTCXMaxenergyChange_ivas_fx( sts[0]->hTranDet, isTCX10, NSUBBLOCKS, 3 ), 16384 ), GetTCXMaxenergyChange_ivas_fx( sts[1]->hTranDet, isTCX10, NSUBBLOCKS, 3 ), 16384 ); - IF( GE_16( maxEnergyChange_fx, pTnsParameters[0]->minEnergyChange ) ) + IF( GE_16( maxEnergyChange_fx, L_shl( pTnsParameters[0]->minEnergyChange, Q3 - Q7 ) ) ) { sts[0]->hTcxEnc->tnsData[k].nFilters = add( sts[0]->hTcxEnc->tnsData[k].nFilters, 1 ); move16(); @@ -552,7 +552,7 @@ void TNSAnalysisStereo_fx( { Word16 maxEnergyChange_fx = GetTCXMaxenergyChange_ivas_fx( sts[ch]->hTranDet, isTCX10, NSUBBLOCKS, 3 ); - IF( GE_16( maxEnergyChange_fx, pTnsParameters->minEnergyChange ) ) + IF( GE_16( maxEnergyChange_fx, L_shl( pTnsParameters->minEnergyChange, Q3 - Q7 ) ) ) { sts[ch]->hTcxEnc->tnsData[k].nFilters = add( sts[ch]->hTcxEnc->tnsData[k].nFilters, 1 ); move16(); diff --git a/lib_enc/lp_exc_e_fx.c b/lib_enc/lp_exc_e_fx.c index 5afca5136..0887698f7 100644 --- a/lib_enc/lp_exc_e_fx.c +++ b/lib_enc/lp_exc_e_fx.c @@ -260,7 +260,7 @@ Word16 lp_filt_exc_enc_ivas_fx( } IF( use_prev_sf_pit_gain == 1 ) { - wtmp1 = adpt_enr_fx( codec_mode, exc_tmp, h1, y1_tmp, L_subfr, &gain2, gain_pit, clip_gain, xn, xn2_tmp, &exp_ener1, use_prev_sf_pit_gain ); + wtmp1 = adpt_enr_fx( codec_mode, exc_tmp, h1, y1_tmp, L_subfr, gain_pit, g_corr2, clip_gain, xn, xn2_tmp, &exp_ener1, use_prev_sf_pit_gain ); } ELSE { diff --git a/lib_enc/swb_tbe_enc_fx.c b/lib_enc/swb_tbe_enc_fx.c index 23bd387d4..f67d81c71 100644 --- a/lib_enc/swb_tbe_enc_fx.c +++ b/lib_enc/swb_tbe_enc_fx.c @@ -4049,7 +4049,9 @@ void swb_tbe_enc_ivas_fx( { /* Re-normalize gain shape before quantization */ // sum_gain = sum2_f(GainShape, NUM_SHB_SUBGAINS); - sum_gain_fx = sum16_32_fx( GainShape_fx, NUM_SHB_SUBGAINS ); + tmp = 0; + move16(); + sum_gain_fx = sum2_16_exp_fx( GainShape_fx, NUM_SHB_SUBGAINS, &tmp, 2 ); IF( sum_gain_fx == 0 ) { normFact_fx = 0; @@ -4058,8 +4060,6 @@ void swb_tbe_enc_ivas_fx( ELSE { // normFact = (float) sqrt( 1.0f / sum_gain ); - tmp = Q16; - move16(); normFact_fx = ISqrt32( sum_gain_fx, &tmp ); } diff --git a/lib_enc/tns_base_enc_fx.c b/lib_enc/tns_base_enc_fx.c index 79bb7b914..90028b732 100644 --- a/lib_enc/tns_base_enc_fx.c +++ b/lib_enc/tns_base_enc_fx.c @@ -675,7 +675,7 @@ Word16 DetectTnsFilt_ivas_fx( STnsConfig const *pTnsConfig, /* i : TNS Configur ELSE { maxEnergyChange = GetTCXMaxenergyChange_ivas_fx( hTranDet, isTCX10, NSUBBLOCKS, 3 ); - IF( sub( maxEnergyChange, pTnsParameters->minEnergyChange ) >= 0 ) + IF( sub( maxEnergyChange, L_shl( pTnsParameters->minEnergyChange, Q3 - Q7 ) ) >= 0 ) { pTnsData->nFilters = add( pTnsData->nFilters, 1 ); -- GitLab