Commit 18600293 authored by Sandesh Venkatesh's avatar Sandesh Venkatesh
Browse files

Merge branch 'bug_fix_masa_ltv_crash_fixes' into 'main'

Bug fix in StableHighPitchDetect_ivas_fx, LTV crash fixes for MASA format

See merge request !938
parents 2f76d0ad 8369dfda
Loading
Loading
Loading
Loading
+43 −55
Original line number Diff line number Diff line
@@ -115,11 +115,12 @@ static Word16 ic_bwe_enc_specMapping_ivas_fx(
    Word16 Txx1_fx = 0, Txx2_fx = 0, Txx3_fx = 0, T_desired_fx = 0;
    Word16 Txx1_e = 0, Txx2_e = 0, Txx3_e = 0, T_desired_e = 0;
    Word16 T_nonref_target_fx, temp_fx;
    Word32 temp00_fx, temp11_fx;
    Word16 temp00_exp, temp11_exp;
    Word32 temp0_fx, temp1_fx, temp2_fx, temp3_fx;
    Word16 a_fx, b_fx, c_fx, a_e, b_e, c_e;
    Word16 u_fx, u1_fx, u2_fx, u_e = 0, u1_e, u2_e;
    Word16 temp0_exp, temp1_exp, temp2_exp, temp3_exp, exp, T_nonref_target_e;
    Word16 exp_buf[6];

    move16();
    move16();
@@ -133,35 +134,8 @@ static Word16 ic_bwe_enc_specMapping_ivas_fx(

    /* Calculate rxx(1)/rxx(0) of the non ref target */

    temp0_fx = dotp_fixed_ivas_fx( shb_frame_target_fx, shb_frame_target_e, shb_frame_target_fx, shb_frame_target_e, L_FRAME16k - 1, &temp0_exp );     /* Q31-temp0_exp */
    temp1_fx = dotp_fixed_ivas_fx( shb_frame_target_fx, shb_frame_target_e, shb_frame_target_fx + 1, shb_frame_target_e, L_FRAME16k - 1, &temp1_exp ); /* Q31-temp1_exp */

    /* Smoothing */
    temp0_fx = L_shr( temp0_fx, 1 );
    temp1_fx = L_shr( temp1_fx, 1 );


    memShbSpecXcorr_fx[0] = temp0_fx;                                 // tem0_exp
    memShbSpecXcorr_fx[1] = L_shr( temp1_fx, temp0_exp - temp1_exp ); // temp0_exp
    exp = sub( temp0_exp, temp1_exp );
    exp_buf[0] = exp;
    exp_buf[1] = exp;
    move32();
    move32();
    move16();
    move16();

    IF( temp0_fx != 0 )
    {
        T_nonref_target_fx = BASOP_Util_Divide3232_Scale( temp1_fx, temp0_fx, &T_nonref_target_e ); // exp
    }
    ELSE
    {
        T_nonref_target_fx = 0;
        T_nonref_target_e = 31;
        move32();
        move16();
    }
    temp00_fx = dotp_fixed_ivas_fx( shb_frame_target_fx, shb_frame_target_e, shb_frame_target_fx, shb_frame_target_e, L_FRAME16k - 1, &temp00_exp );     /* Q31-temp0_exp */
    temp11_fx = dotp_fixed_ivas_fx( shb_frame_target_fx, shb_frame_target_e, shb_frame_target_fx + 1, shb_frame_target_e, L_FRAME16k - 1, &temp11_exp ); /* Q31-temp1_exp */

    /* Calculate rxx(1)/rxx(0) of the non ref synth */
    temp0_fx = dotp_fixed_ivas_fx( shb_synth_nonref_fx, shb_synth_nonref_e, shb_synth_nonref_fx, shb_synth_nonref_e, L_FRAME16k - 3, &temp0_exp );     /* Q31-temp0_exp */
@@ -169,41 +143,55 @@ static Word16 ic_bwe_enc_specMapping_ivas_fx(
    temp2_fx = dotp_fixed_ivas_fx( shb_synth_nonref_fx, shb_synth_nonref_e, shb_synth_nonref_fx + 2, shb_synth_nonref_e, L_FRAME16k - 3, &temp2_exp ); /* Q31-temp2_exp */
    temp3_fx = dotp_fixed_ivas_fx( shb_synth_nonref_fx, shb_synth_nonref_e, shb_synth_nonref_fx + 3, shb_synth_nonref_e, L_FRAME16k - 3, &temp3_exp ); /* Q31-temp3_exp */

    exp = s_max( *memShbSpecXcorr_e, s_max( s_max( s_max( temp00_exp, temp11_exp ), s_max( temp0_exp, temp1_exp ) ), s_max( temp2_exp, temp3_exp ) ) );

    temp00_fx = L_shr( temp00_fx, sub( exp, temp00_exp ) );
    temp11_fx = L_shr( temp11_fx, sub( exp, temp11_exp ) );
    temp0_fx = L_shr( temp0_fx, sub( exp, temp0_exp ) );
    temp1_fx = L_shr( temp1_fx, sub( exp, temp1_exp ) );
    temp2_fx = L_shr( temp2_fx, sub( exp, temp2_exp ) );
    temp3_fx = L_shr( temp3_fx, sub( exp, temp3_exp ) );

    /* Smoothing */
    temp0_fx = L_shr( temp0_fx, 1 );
    temp1_fx = L_shr( temp1_fx, 1 );
    temp2_fx = L_shr( temp2_fx, 1 );
    temp3_fx = L_shr( temp3_fx, 1 );

    exp_buf[2] = temp0_exp;
    exp_buf[3] = temp1_exp;
    exp_buf[4] = temp2_exp;
    exp_buf[5] = temp3_exp;
    exp = exp_buf[0];
    move16();
    move16();
    move16();
    move16();
    move16();
    FOR( Word16 i = 0; i < 6; i++ )
    {
        IF( LT_16( exp, exp_buf[i] ) )
        {
            exp = exp_buf[i];
            move16();
        }
        memShbSpecXcorr_fx[i] = L_shl( memShbSpecXcorr_fx[i], sub( *memShbSpecXcorr_e, exp ) );
        move32();
    }
    memShbSpecXcorr_fx[2] = L_shr( temp0_fx, sub( exp, temp0_exp ) ); /* Q31-exp */
    memShbSpecXcorr_fx[3] = L_shr( temp1_fx, sub( exp, temp1_exp ) ); /* Q31-exp */
    memShbSpecXcorr_fx[4] = L_shr( temp2_fx, sub( exp, temp2_exp ) ); /* Q31-exp */
    memShbSpecXcorr_fx[5] = L_shr( temp3_fx, sub( exp, temp3_exp ) ); /* Q31-exp */
    *memShbSpecXcorr_e = exp;
    move16();

    temp00_fx = L_add( L_shr( temp00_fx, 1 ), L_shr( memShbSpecXcorr_fx[0], 1 ) );
    temp11_fx = L_add( L_shr( temp11_fx, 1 ), L_shr( memShbSpecXcorr_fx[1], 1 ) );
    temp0_fx = L_add( L_shr( temp0_fx, 1 ), L_shr( memShbSpecXcorr_fx[2], 1 ) );
    temp1_fx = L_add( L_shr( temp1_fx, 1 ), L_shr( memShbSpecXcorr_fx[3], 1 ) );
    temp2_fx = L_add( L_shr( temp2_fx, 1 ), L_shr( memShbSpecXcorr_fx[4], 1 ) );
    temp3_fx = L_add( L_shr( temp3_fx, 1 ), L_shr( memShbSpecXcorr_fx[5], 1 ) );

    T_nonref_target_fx = 0;
    move32();
    T_nonref_target_e = 31;
    move16();

    IF( temp00_fx != 0 )
    {
        T_nonref_target_fx = BASOP_Util_Divide3232_Scale( temp11_fx, temp00_fx, &T_nonref_target_e );
    }


    memShbSpecXcorr_fx[0] = temp00_fx;
    move32();
    memShbSpecXcorr_fx[1] = temp11_fx;
    move32();
    memShbSpecXcorr_fx[2] = temp0_fx; /* Q31-exp */
    move32();
    memShbSpecXcorr_fx[3] = temp1_fx; /* Q31-exp */
    move32();
    memShbSpecXcorr_fx[4] = temp2_fx; /* Q31-exp */
    move32();
    memShbSpecXcorr_fx[5] = temp3_fx; /* Q31-exp */
    move32();
    move16();


    IF( temp0_fx != 0 )
+1 −1
Original line number Diff line number Diff line
@@ -285,7 +285,7 @@ void StableHighPitchDetect_ivas_fx(
    *flag_spitch = 0;
    move16();
    IF( ( EQ_16( localVAD, 1 ) ) && ( EQ_16( *predecision_flag, 1 ) ) &&
        ( GT_16( *voicing0_sm, 16384 ) ) && ( GT_16( *voicing0_sm, mult_r( *voicing_sm, 21299 ) ) ) )
        ( GT_16( *voicing0_sm, 21299 ) ) && ( GT_16( *voicing0_sm, mult_r( *voicing_sm, 22938 ) ) ) )
    {
        *flag_spitch = 1;
        move16();