Commit 0cc38a34 authored by Sandesh Venkatesh's avatar Sandesh Venkatesh
Browse files

LTV crash fixes and updates for addressing high MLD issue in ISM formats

[x] crash fix for ltv case +10dB : [ltv-stereo bitrate switching from 13.2 kbps to 128 kbps, 32kHz in, 32kHz out]
[x] Fix for High MLD issue in ISM Stream: stv-3 ISM with metadata at 128 kbps, 48 kHz in, 32 kHz out, HOA3 out, random FER at 5%
[x] Resolved LTV crash: +10dB [ltv-stereo at 32 kbps, 32kHz in, 32kHz out, DTX on, MONO out, random FER at 5%]
parent a3b5cfa8
Loading
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -776,9 +776,6 @@ enum

#define L_FILT_2OVER3                       12
#define L_FILT_2OVER3_LP                    3
#ifdef NONE_BE_FIX_816_LFE_PLC_FLOAT
#define MAX_LP_FILTER_ORDER                 20                                              /* Max order of an LP filter */
#endif

typedef enum
{
+1 −1
Original line number Diff line number Diff line
@@ -3467,7 +3467,7 @@ void GenShapedSHBExcitation_ivas_fx(
                /* White_exc16k: (Q_bwe_exc-NOISE_QADJ), scale: Q15 */
                L_tmp = L_mult( White_exc16k[k], scale );
                /* L_tmp: (Q_bwe_exc-NOISE_QADJ) + 15 + 1 */
                exc16kWhtnd[k] = round_fx( L_shl( L_tmp, NOISE_QADJ ) );
                exc16kWhtnd[k] = round_fx_sat( L_shl_sat( L_tmp, NOISE_QADJ ) );
                move16();
                /* exc16kWhtnd:  Q_bwe_exc */
            }
+1 −2
Original line number Diff line number Diff line
@@ -1332,8 +1332,7 @@ static void shb_CNG_decod_ivas_fx(
        move32();
    }
    fra = L_Extract_lc( L_tmp, &exp );
    L_tmp = L_shl( Pow2( exp, fra ), 5 ); /*Q5 */
    L_tmp = L_shr( L_tmp, 10 );
    L_tmp = L_shr( Pow2( exp, fra ), 5 ); /*Q5 */
    if ( !L_tmp )
    {
        L_tmp = 1;
+2 −2
Original line number Diff line number Diff line
@@ -2047,7 +2047,7 @@ void generate_masking_noise_ivas_fx(
        {
            rand_gauss_fx( &fftBuffer_fx[0], seed, *exp_out ); // Q15
            ptr_r_fx = fftBuffer_fx + 2;
            Word16 exp1 = sub( 32, hFdCngCom->cngNoiseLevelExp );
            Word16 exp1 = add( hFdCngCom->cngNoiseLevelExp, 1 );
            Word32 mpy1 = Sqrt32( Mpy_32_32( scale_fx, *ptr_level_fx ), &exp1 );            // Q = noise_exp-1
            mpy1 = L_shl( mpy1, exp1 );                                                     // Q31
            fftBuffer_fx[0] = Mpy_32_32( fftBuffer_fx[0], mpy1 ); /* DC component in FFT */ // Q = Q15
@@ -2065,7 +2065,7 @@ void generate_masking_noise_ivas_fx(
        {
            /* Real part in FFT bins */
            rand_gauss_fx( ptr_r_fx, seed, *exp_out ); // Q15
            Word16 exp2 = sub( 32, hFdCngCom->cngNoiseLevelExp );
            Word16 exp2 = add( hFdCngCom->cngNoiseLevelExp, 1 );
            Word32 mpy2 = Sqrt32( L_shr( Mpy_32_32( scale_fx, *ptr_level_fx ), 1 ), &exp2 ); // Q = noise_exp-1
            ( *ptr_r_fx ) = L_shl( Mpy_32_32( *ptr_r_fx, mpy2 ), exp2 );                     // Q = Q15
            ptr_r_fx += 2;
+14 −8
Original line number Diff line number Diff line
@@ -760,7 +760,7 @@ static void ivas_CalcPowerSpecAndDetectTonalComponents_fx(
    move32();
#endif

    // Word16 nBands;
    Word16 nBands;
    Word32 invScaleFactors_fx[FDNS_NPTS];
    Word16 old_power_spectrum_q, power_spectrum_q;

@@ -826,16 +826,17 @@ static void ivas_CalcPowerSpecAndDetectTonalComponents_fx(
            tmp_exp = old_exp;
            move16();
            powerSpectrum[i] = Sqrt32( powerSpectrum[i], &tmp_exp );
            move32();
            powerSpectrum[i] = L_shr( powerSpectrum[i], sub( powerSpectrum_exp, tmp_exp ) );
            move32();
        }

        FOR( i = 0; i < hTonalMDCTConc->nScaleFactors; i++ )
        {
            move16();
            move16();
            invScaleFactors_exp[i] = hTonalMDCTConc->secondLastBlockData.scaleFactors_exp[i];
            move16();
            invScaleFactors[i] = Inv16( hTonalMDCTConc->secondLastBlockData.scaleFactors[i], &invScaleFactors_exp[i] );
            move16();
        }

        power_spectrum_q = sub( 31, powerSpectrum_exp );
@@ -846,6 +847,8 @@ static void ivas_CalcPowerSpecAndDetectTonalComponents_fx(
        /* here mdct_shaping() is intentionally used rather then mdct_shaping_16() */
        IF( psychParamsCurrent == NULL )
        {
            nBands = FDNS_NPTS;
            move16();
            mdct_shaping( powerSpectrum, hTonalMDCTConc->nSamplesCore, invScaleFactors, invScaleFactors_exp );
        }
        ELSE
@@ -857,8 +860,8 @@ static void ivas_CalcPowerSpecAndDetectTonalComponents_fx(
            }
            sns_shape_spectrum_fx( powerSpectrum, &power_spectrum_q, psychParamsCurrent, invScaleFactors_fx, 16, hTonalMDCTConc->nSamplesCore, &length );
            power_spectrum_q = add( power_spectrum_q, 1 );
            // sns_shape_spectrum(powerSpectrum, psychParamsCurrent, invScaleFactors, hTonalMDCTConc->nSamplesCore);
            // nBands = psychParamsCurrent->nBands;
            nBands = psychParamsCurrent->nBands;
            move16();
        }
        IF( LT_16( old_power_spectrum_q, power_spectrum_q ) )
        {
@@ -874,13 +877,17 @@ static void ivas_CalcPowerSpecAndDetectTonalComponents_fx(
        FOR( i = hTonalMDCTConc->nSamplesCore; i < nSamples; i++ )
        {
#ifdef BASOP_NOGLOB
            powerSpectrum[i] = L_shl_sat( Mpy_32_16_1( powerSpectrum[i], invScaleFactors[FDNS_NPTS - 1] ), invScaleFactors_exp[FDNS_NPTS - 1] );
            powerSpectrum[i] = L_shl_sat( Mpy_32_16_1( powerSpectrum[i], invScaleFactors[nBands - 1] ), invScaleFactors_exp[nBands - 1] );
#else
            powerSpectrum[i] = L_shl( Mpy_32_16_1( powerSpectrum[i], invScaleFactors[FDNS_NPTS - 1] ), invScaleFactors_exp[FDNS_NPTS - 1] );
            powerSpectrum[i] = L_shl( Mpy_32_16_1( powerSpectrum[i], invScaleFactors[nBands - 1] ), invScaleFactors_exp[nBands - 1] );
#endif
            move32();
        }

        Word16 shift = Find_Max_Norm32( powerSpectrum, nSamples );
        scale_sig32( powerSpectrum, nSamples, shift );
        powerSpectrum_exp = sub( powerSpectrum_exp, shift );

        /* 16 bits are now enough for storing the power spectrum */
        FOR( i = 0; i < nSamples; i++ )
        {
@@ -892,7 +899,6 @@ static void ivas_CalcPowerSpecAndDetectTonalComponents_fx(
            move32();
        }

        powerSpectrum_exp = sub( powerSpectrum_exp, hTonalMDCTConc->secondLastBlockData.gain_tcx_exp );
        hTonalMDCTConc->secondLastPowerSpectrum_exp = powerSpectrum_exp;
        move16();
    }