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

Fix for 3GPP issue 1079: Encoder crashes in complexity pipeline: Stereo DMX EVS

link #1079
parent e1432023
Loading
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -1154,7 +1154,7 @@ void core_signal_analysis_high_bitrate_ivas_fx(
                    }

                    /* Compute noise-measure flags for spectrum filling and quantization */
                    AnalyzePowerSpectrum_ivas_fx( st, div_l( L_mult( L_subframe, st->L_frame ), hTcxEnc->L_frameTCX ),
                    AnalyzePowerSpectrum_fx( st, div_l( L_mult( L_subframe, st->L_frame ), hTcxEnc->L_frameTCX ),
                                             L_subframe, left_overlap, right_overlap, hTcxEnc->spectrum_fx[frameno], hTcxEnc->spectrum_e[frameno],
                                             pMdstWin, powerSpec, &powerSpec_e );
                }
+0 −11
Original line number Diff line number Diff line
@@ -1237,17 +1237,6 @@ void AnalyzePowerSpectrum_fx(
    Word32 powerSpec[],    /* o  : Power spectrum. Can point to signal          */
    Word16 *powerSpec_e );

void AnalyzePowerSpectrum_ivas_fx(
    Encoder_State *st,           /* i/o: encoder states                                  */
    Word16 L_frame,              /* i  : frame length                                  */
    Word16 L_frameTCX,           /* i  : full band frame length                        */
    Word16 left_overlap,         /* i  : left overlap length                           */
    Word16 right_overlap,        /* i  : right overlap length                          */
    Word32 const mdctSpectrum[], /* i  : MDCT spectrum                                 */
    Word16 mdctSpectrum_e,
    Word16 const signal[], /* i  : windowed signal corresponding to mdctSpectrum */
    Word32 powerSpec[],    /* o  : Power spectrum. Can point to signal          */
    Word16 *powerSpec_e );
void AdaptLowFreqEmph_fx( Word32 x[],
                          Word16 x_e,
                          Word16 xq[],
+0 −112
Original line number Diff line number Diff line
@@ -264,118 +264,6 @@ void AnalyzePowerSpectrum_fx(
    /* power spectrum: MDCT^2 + MDST^2 */
    FOR( i = iStart; i < iEnd; i++ )
    {
        tmp = round_fx( L_shl( mdctSpectrum[i], s1 ) );
        tmp32 = L_mult0( tmp, tmp );

#ifdef BASOP_NOGLOB
        tmp = round_fx_sat( L_shl_sat( powerSpec[i], s2 ) );
#else
        tmp = round_fx( L_shl( powerSpec[i], s2 ) );
#endif
        tmp32 = L_mac0( tmp32, tmp, tmp );

        powerSpec[i] = tmp32;
        move32();
    }

    *powerSpec_e = add( shl( sub( mdctSpectrum_e, s1 ), 1 ), 1 );
    move16();

    tmp8 = 0;
    move16();
    test();
    if ( L_msu0( L_mult0( st->L_frame, extract_l( st->last_sr_core ) ), st->L_frame_past, extract_l( st->sr_core ) ) != 0 || NE_16( st->last_core, TCX_20_CORE ) )
    {
        tmp8 = 1;
        move16();
    }

    ComputeSpectrumNoiseMeasure_fx( powerSpec,
                                    L_frameTCX,
                                    divide3216( L_mult( hTcxEnc->nmStartLine, L_frame ), st->L_frame ),
                                    tmp8,
                                    hTcxEnc->memQuantZeros,
                                    lowpassLine );

    IF( LE_32( st->total_brate, ACELP_24k40 ) )
    {
        lowpassLine = shl( mult( st->hTcxCfg->bandwidth, L_frame ), 1 );

        test();
        detectLowpassFac( powerSpec, *powerSpec_e,
                          L_frame,
                          sub( st->last_core, ACELP_CORE ) == 0,
                          &hTcxEnc->measuredBwRatio,
                          lowpassLine );
    }
    ELSE
    {
        hTcxEnc->measuredBwRatio = 0x4000;
        move16();
    }
}

void AnalyzePowerSpectrum_ivas_fx(
    Encoder_State *st,           /* i/o: encoder states                                  */
    Word16 L_frame,              /* input: frame length                                  */
    Word16 L_frameTCX,           /* input: full band frame length                        */
    Word16 left_overlap,         /* input: left overlap length                           */
    Word16 right_overlap,        /* input: right overlap length                          */
    Word32 const mdctSpectrum[], /* input: MDCT spectrum                                 */
    Word16 mdctSpectrum_e,
    Word16 const signal[], /* input: windowed signal corresponding to mdctSpectrum */
    Word32 powerSpec[],    /* output: Power spectrum. Can point to signal          */
    Word16 *powerSpec_e )
{
    Word16 i, iStart, iEnd, lowpassLine;
    Word16 tmp, s1, s2;
    Word32 tmp32;
    Word8 tmp8;
    TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc;

    lowpassLine = L_frameTCX;
    move16();

    *powerSpec_e = 16;
    move16();
    TCX_MDST( signal, powerSpec, powerSpec_e, left_overlap, sub( L_frameTCX, shr( add( left_overlap, right_overlap ), 1 ) ), right_overlap, st->element_mode );

    iStart = 0;
    move16();
    iEnd = L_frameTCX;
    move16();

    IF( st->narrowBand != 0 )
    {
        attenuateNbSpectrum_fx( L_frameTCX, powerSpec );
    }

    /* get shift to common exponent */
    s1 = 0;
    move16();
    s2 = 0;
    move16();
    tmp = sub( mdctSpectrum_e, *powerSpec_e );
    if ( tmp > 0 )
    {
        s2 = negate( tmp );
    }
    if ( tmp < 0 )
    {
        s1 = tmp;
        move16();
    }

    /* get headroom */
    tmp = sub( getScaleFactor32( mdctSpectrum, L_frameTCX ), s1 );
    tmp = s_min( tmp, sub( getScaleFactor32( powerSpec, L_frameTCX ), s2 ) );
    s1 = add( s1, tmp );
    s2 = add( s2, tmp );

    /* power spectrum: MDCT^2 + MDST^2 */
    FOR( i = iStart; i < iEnd; i++ )
    {
        // To be checked
#ifdef BASOP_NOGLOB
        tmp = round_fx_sat( L_shl_sat( mdctSpectrum[i], s1 ) );
#else