Commit 17dd0cfc authored by Sandesh Venkatesh's avatar Sandesh Venkatesh
Browse files

LTV crash fixes, crashes encountered with newly introduced changes

parent c2229c49
Loading
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -9462,6 +9462,12 @@ Word16 maximum_fx( /* o : index of the maximum value in t
                   Word16 *max_fx        /* o  : maximum value in the input vector              */
);

Word16 maximum_abs_16_fx(                    /* o  : index of the maximum abs value in the input vector */
                          const Word16 *vec, /* i  : input vector                                   */
                          const Word16 lvec, /* i  : length of input vector                         */
                          Word16 *max_val    /* o  : maximum value in the input vector              */
);

Word16 minimum_abs32_fx(                       /* o  : index of the minimum value in the input vector */
                         const Word32 *vec_fx, /* i  : input vector                                   */
                         const Word16 lvec_fx, /* i  : length of input vector                         */
+11 −0
Original line number Diff line number Diff line
@@ -2816,6 +2816,9 @@ void GenShapedSHBExcitation_ivas_fx(
    Word32 White_exc16k_32[L_FRAME16k];
    Word16 Q_temp;
    Word16 prev_Q_bwe_exc_fb;
    Word16 chk1, chk2;
    chk1 = 0;
    chk2 = 0;

#if 1 // def ADD_IVAS_TBE_CODE
    Word16 alpha, step, mem_csfilt_left, mem_csfilt_right, excNoisyEnvLeft[L_FRAME16k], excNoisyEnvRight[L_FRAME16k];
@@ -2898,6 +2901,7 @@ void GenShapedSHBExcitation_ivas_fx(
        /*excTmp2[k ] = (float)(fabs(exc16kWhtnd[k]));*/
        excTmp2[k] = abs_s( exc16kWhtnd[k] );
        move16();
        chk1 = s_or( chk1, exc16kWhtnd[k] );

        /* pow1 += exc16kWhtnd[k] * exc16kWhtnd[k]; */
#ifdef BASOP_NOGLOB
@@ -3149,6 +3153,7 @@ void GenShapedSHBExcitation_ivas_fx(
            /* White_exc16k[k] *= excNoisyEnv[k]; */
            White_exc16k[k] = mult_r( excNoisyEnv[k], shl( White_exc16k[k], tmp ) );
            move16();
            chk2 = s_or( chk2, White_exc16k[k] );
            /* i: excNoisyEnv in (Q_bwe_exc)     */
            /* i: White_exc16k  in Q6               */
            /* o: White_exc16k in (Q_bwe_exc-NOISE_QADJ)  */
@@ -3446,6 +3451,12 @@ void GenShapedSHBExcitation_ivas_fx(
#endif
        {
            L_tmp = root_a_over_b_fx( pow1, Q_pow1, pow22, Q_pow22, &exp );
            test();
            if ( chk1 == 0 && chk2 == 0 )
            {
                L_tmp = 0;
                move32();
            }
#ifdef BASOP_NOGLOB
            scale = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /*Q15 */
#else
+33 −0
Original line number Diff line number Diff line
@@ -1100,6 +1100,39 @@ Word16 maximum_fx( /* o : index of the maximum value in t
    return ind;
}

/*---------------------------------------------------------------------*
 * maximum_abs_16_fx()
 *
 * Find index and value of the absolute maximum in a vector
 *---------------------------------------------------------------------*/

Word16 maximum_abs_16_fx(                    /* o  : index of the maximum abs value in the input vector */
                          const Word16 *vec, /* i  : input vector                                   */
                          const Word16 lvec, /* i  : length of input vector                         */
                          Word16 *max_val    /* o  : maximum value in the input vector              */
)
{
    Word16 j, ind;
    Word16 tmp;
    ind = 0;
    move16();
    tmp = abs_s( vec[0] );

    FOR( j = 1; j < lvec; j++ )
    {
        if ( GT_16( abs_s( vec[j] ), tmp ) )
        {
            ind = j;
            move16();
        }
        tmp = s_max( tmp, abs_s( vec[j] ) );
    }
    *max_val = tmp;
    move16();

    return ind;
}

/*---------------------------------------------------------------------*
 * minimum_abs32_fx()
 *
+17 −3
Original line number Diff line number Diff line
@@ -1377,6 +1377,8 @@ void TonalMDCTConceal_InsertNoise_ivas_fx(
    Word16 inv_exp, inv_samples, exp;
    Word32 last_block_nrg_correct;
    Word16 last_block_nrg_correct_e;
    Word32 max_concealment_value;
    Word16 max_spectral_value;

    crossfadeGain = crossfadeGain_const;
    move16();
@@ -1463,7 +1465,6 @@ void TonalMDCTConceal_InsertNoise_ivas_fx(
            {
                Word32 num, den;
                Word16 exp_num, exp_den;
                Word32 max_concealment_value;

                exp_num = cngLevelBackgroundTrace_bfi_e;
                move16();
@@ -1519,6 +1520,13 @@ void TonalMDCTConceal_InsertNoise_ivas_fx(
                        move16();
                    }
                }
                ELSE
                {
                    (void) maximum_abs_16_fx( hTonalMDCTConc->lastBlockData.spectralData, crossOverFreq, &max_spectral_value );
                    exp = sub( norm_l( L_mult( max_spectral_value, crossfadeGain ) ), find_guarded_bits_fx( crossOverFreq ) );
                    *mdctSpectrum_exp = sub( hTonalMDCTConc->lastBlockData.spectralData_exp, exp );
                    move16();
                }

                FOR( i = 0; i < crossOverFreq; i++ )
                {
@@ -1646,7 +1654,6 @@ void TonalMDCTConceal_InsertNoise_ivas_fx(
            {
                Word32 num, den;
                Word16 exp_num, exp_den;
                Word32 max_concealment_value;

                exp_num = cngLevelBackgroundTrace_bfi_e;
                move16();
@@ -1674,7 +1681,7 @@ void TonalMDCTConceal_InsertNoise_ivas_fx(
                L_tmp = L_deposit_h( 0 );
                exp = sub( hTonalMDCTConc->lastBlockData.spectralData_exp, add( concealment_noise_e, exp ) );

                (void) maximum_abs_32_fx( concealment_noise, hTonalMDCTConc->pTCI->lowerIndex[0], &max_concealment_value );
                (void) maximum_abs_32_fx( concealment_noise, crossOverFreq, &max_concealment_value );
                IF( GT_32( max_concealment_value, 0 ) )
                {
                    IF( GT_16( exp, 0 ) )
@@ -1703,6 +1710,13 @@ void TonalMDCTConceal_InsertNoise_ivas_fx(
                        move16();
                    }
                }
                ELSE
                {
                    (void) maximum_abs_16_fx( hTonalMDCTConc->lastBlockData.spectralData, crossOverFreq, &max_spectral_value );
                    exp = sub( norm_l( L_mult( max_spectral_value, crossfadeGain ) ), find_guarded_bits_fx( crossOverFreq ) );
                    *mdctSpectrum_exp = sub( hTonalMDCTConc->lastBlockData.spectralData_exp, exp );
                    move16();
                }

                FOR( l = 0; l < hTonalMDCTConc->pTCI->lowerIndex[0]; l++ )
                {