From 9b587180ecc269be049ac0e5cccdfda2b22b746a Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Mon, 3 Feb 2025 10:55:19 +0530 Subject: [PATCH 1/2] Added missing scaling, removed unnecessary scaling and minor bug fix --- lib_enc/cod4t64_fast.c | 2 +- lib_enc/igf_enc.c | 7 ++++--- lib_enc/ivas_mdct_core_enc.c | 12 ++++++++---- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/lib_enc/cod4t64_fast.c b/lib_enc/cod4t64_fast.c index 93bcc1ce3..e4c8124e6 100644 --- a/lib_enc/cod4t64_fast.c +++ b/lib_enc/cod4t64_fast.c @@ -901,7 +901,7 @@ void acelp_fast_fx( move16(); } - Copy( y_tmp, y, L_subfr ); // q_H + Copy_Scale_sig( y_tmp, y, L_subfr, sub( 9, q_H ) ); // y in Q9 skip_track_max = skip_track[q]; move16(); } diff --git a/lib_enc/igf_enc.c b/lib_enc/igf_enc.c index c15c68666..2d03fde78 100644 --- a/lib_enc/igf_enc.c +++ b/lib_enc/igf_enc.c @@ -1264,9 +1264,10 @@ static void IGF_CalculateStereoEnvelope_fx( move16(); move16(); - BASOP_Util_Add_MantExp( hPrivateData->SFM_sb_fx[sfb], tmp_sb_e, negate( hPrivateData->SFM_tb_fx[sfb] ), tmp_tb_e, &diffSFM_fx ); /*stores the resultant exponent for diffSFM_fx*/ + diffSFM_fx = sub( hPrivateData->SFM_sb_fx[sfb], hPrivateData->SFM_tb_fx[sfb] ); /*Q13*/ - IF( diffSFM_fx > 0 && LT_32( hPrivateData->SFM_tb_fx[sfb], L_shr( 3277 /*0.1 Q15*/, tmp_tb_e ) ) ) /* check whether target SFB is more tonal than source SFB */ + test(); + IF( diffSFM_fx > 0 && LT_16( hPrivateData->SFM_tb_fx[sfb], 819 /*0.1 Q13*/ ) ) /* check whether target SFB is more tonal than source SFB */ { Word16 currDampingFactor_fx, dampingFactor_fx, alpha_fx; Word16 threshold_e, threshold_fx, alpha_e, currDampingFactor_e, dampingFactor_e; @@ -1391,7 +1392,7 @@ static void IGF_CalculateStereoEnvelope_fx( { // currDampingFactor += 0.1f * ( ( 10 + adap ) - tonalToNoise ); Word32 temp2 = BASOP_Util_Add_Mant32Exp( L_add( L_shl( 10, sub( 15, adap_e ) ) /*exp:adap_e*/, adap ), add( adap_e, 16 ), L_negate( tonalToNoise ), tonalToNoise_e, &tmp_e ); /* resultant exp is tmp_e*/ - currDampingFactor_e = BASOP_Util_Add_MantExp( currDampingFactor_fx, currDampingFactor_e, extract_l( Mult_32_32( 3277 /*0.1f Q15*/, temp2 ) ), tmp_e, &currDampingFactor_fx ); /*stores resultant exp for currDampingFactor_fx*/ + currDampingFactor_e = BASOP_Util_Add_MantExp( currDampingFactor_fx, currDampingFactor_e, extract_l( Mult_32_16( temp2, 3277 /*0.1f Q15*/ ) ), tmp_e, &currDampingFactor_fx ); /*stores resultant exp for currDampingFactor_fx*/ } } diff --git a/lib_enc/ivas_mdct_core_enc.c b/lib_enc/ivas_mdct_core_enc.c index 734fbcf9d..710eb864f 100644 --- a/lib_enc/ivas_mdct_core_enc.c +++ b/lib_enc/ivas_mdct_core_enc.c @@ -1628,10 +1628,14 @@ void ivas_mdct_core_whitening_enc_fx( Scale_sig32( mdst_spectrum_fx[0][n], tcx5SizeFB, scale ); // q_com Scale_sig32( mdst_spectrum_fx[1][n], tcx5SizeFB, scale ); // q_com - Scale_sig32( hTcxEnc0->spectrum_fx[n] + offset1, offset2, scale ); // q_com - Scale_sig32( hTcxEnc1->spectrum_fx[n] + offset1, offset2, scale ); // q_com - Scale_sig32( mdst_spectrum_fx[0][n] + offset1, offset2, scale ); // q_com - Scale_sig32( mdst_spectrum_fx[1][n] + offset1, offset2, scale ); // q_com + offset2 = sub( idiv1616( hTcxEnc0->L_frameTCX, nSubframes ), offset1 ); + IF( offset2 > 0 ) + { + Scale_sig32( hTcxEnc0->spectrum_fx[n] + offset1, offset2, scale ); // q_com + Scale_sig32( hTcxEnc1->spectrum_fx[n] + offset1, offset2, scale ); // q_com + Scale_sig32( mdst_spectrum_fx[0][n] + offset1, offset2, scale ); // q_com + Scale_sig32( mdst_spectrum_fx[1][n] + offset1, offset2, scale ); // q_com + } } mdst_spectrum_e[0][n] = sub( Q31, q_com ); hTcxEnc0->spectrum_e[n] = sub( Q31, q_com ); -- GitLab From 847d77faac443812b040e07a2c4b6d7b9d939205 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Mon, 3 Feb 2025 12:27:00 +0530 Subject: [PATCH 2/2] Q-doc update and comment removal --- lib_dec/FEC_HQ_phase_ecu_fx.c | 8 ++++---- lib_dec/ivas_stereo_mdct_core_dec_fx.c | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib_dec/FEC_HQ_phase_ecu_fx.c b/lib_dec/FEC_HQ_phase_ecu_fx.c index 778cc9ec3..708fc39e6 100644 --- a/lib_dec/FEC_HQ_phase_ecu_fx.c +++ b/lib_dec/FEC_HQ_phase_ecu_fx.c @@ -1591,7 +1591,7 @@ static void ivas_spec_ana_fx( IF( n > 0 && *pPlocs == 0 ) /* Very 1st peak position possible to have a peak at 0/DC index position. */ { #ifdef FIX_ISSUE_1237 - Copy_Scale_sig_16_32_no_sat( &xfp[*pPlocs], xfp_32, 3, Q15 ); // Q + 16 + Copy_Scale_sig_16_32_no_sat( &xfp[*pPlocs], xfp_32, 3, Q15 ); // Q + 15 #else Copy_Scale_sig_16_32_DEPREC( &xfp[*pPlocs], xfp_32, 3, Q16 ); // Q + 16 #endif @@ -1606,7 +1606,7 @@ static void ivas_spec_ana_fx( IF( n > 0 && EQ_16( *pPlocs, 1 ) ) /* Also 2nd peak position uses DC which makes jacobsen unsuitable. */ { #ifdef FIX_ISSUE_1237 - Copy_Scale_sig_16_32_no_sat( &xfp[*pPlocs - 1], xfp_32, 3, Q15 ); // Q + 16 + Copy_Scale_sig_16_32_no_sat( &xfp[*pPlocs - 1], xfp_32, 3, Q15 ); // Q + 15 #else Copy_Scale_sig_16_32_DEPREC( &xfp[*pPlocs - 1], xfp_32, 3, Q16 ); // Q + 16 #endif @@ -1656,7 +1656,7 @@ static void ivas_spec_ana_fx( IF( EQ_16( currPlocs, ( sub( Lprot2_1, DELTA_CORR_F0_INT ) ) ) ) /* Also 2nd last peak position uses fs/2 which makes jacobsen less suitable. */ { #ifdef FIX_ISSUE_1237 - Copy_Scale_sig_16_32_no_sat( &xfp[currPlocs - 1], xfp_32, 3, Q15 ); // Q + 16 + Copy_Scale_sig_16_32_no_sat( &xfp[currPlocs - 1], xfp_32, 3, Q15 ); // Q + 15 #else Copy_Scale_sig_16_32_DEPREC( &xfp[currPlocs - 1], xfp_32, 3, Q16 ); // Q + 16 #endif @@ -1674,7 +1674,7 @@ static void ivas_spec_ana_fx( IF( n > 0 ) /* fs/2 which makes special case . */ { #ifdef FIX_ISSUE_1237 - Copy_Scale_sig_16_32_no_sat( &xfp[currPlocs - 2], xfp_32, 3, Q15 ); // Q + 16 + Copy_Scale_sig_16_32_no_sat( &xfp[currPlocs - 2], xfp_32, 3, Q15 ); // Q + 15 #else Copy_Scale_sig_16_32_DEPREC( &xfp[currPlocs - 2], xfp_32, 3, Q16 ); // Q + 16 #endif diff --git a/lib_dec/ivas_stereo_mdct_core_dec_fx.c b/lib_dec/ivas_stereo_mdct_core_dec_fx.c index bcebc8008..3014dba06 100644 --- a/lib_dec/ivas_stereo_mdct_core_dec_fx.c +++ b/lib_dec/ivas_stereo_mdct_core_dec_fx.c @@ -542,7 +542,7 @@ void stereo_mdct_core_dec_fx( move16(); } } -#ifdef FIX_ISSUE_1237 // VA2ITTIAM -> This ( 28 - norm_s( hCPE->hCoreCoder[0]->old_Aq_12_8_fx[0] - 1 ) ) is not working, leads to a left shit of 25 and old_Aq_12_8_fx[0] usually takes between 10 and 14 bits; should be something like (28 - (15 - norm_s(A[0]-1)) +#ifdef FIX_ISSUE_1237 Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->old_Aq_12_8_fx, hCPE->hCoreCoder[0]->old_Aq_12_8_fx_32, M + 1, sub( 28, sub( 15, norm_s( sub( hCPE->hCoreCoder[0]->old_Aq_12_8_fx[0], 1 ) ) ) ) ); /* Q28 */ Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[1]->old_Aq_12_8_fx, hCPE->hCoreCoder[1]->old_Aq_12_8_fx_32, M + 1, sub( 28, sub( 15, norm_s( sub( hCPE->hCoreCoder[1]->old_Aq_12_8_fx[0], 1 ) ) ) ) ); /* Q28 */ #else -- GitLab