Commit 6a0b7021 authored by Sandesh Venkatesh's avatar Sandesh Venkatesh
Browse files

Merge branch 'scaling_bug_fixes' into 'main'

Added missing scaling, removed unnecessary scaling and minor bug fix

See merge request !1065
parents b7b42e14 847d77fa
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -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
+1 −1
Original line number Diff line number Diff line
@@ -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
+1 −1
Original line number Diff line number Diff line
@@ -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();
        }
+4 −3
Original line number Diff line number Diff line
@@ -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*/
                            }
                        }

+8 −4
Original line number Diff line number Diff line
@@ -1628,11 +1628,15 @@ 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

                        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 );
                    mdst_spectrum_e[1][n] = sub( Q31, q_com );