Commit 4b96fe11 authored by Sandesh Venkatesh's avatar Sandesh Venkatesh
Browse files

LTV test with all bug fixes and MR changes

parent 863ee6ff
Loading
Loading
Loading
Loading
Loading
+176 −1
Original line number Diff line number Diff line
@@ -60,6 +60,19 @@ static void cldfb_init_proto_and_twiddles( HANDLE_CLDFB_FILTER_BANK hs );

static void cldfb_init_proto_and_twiddles_enc_fx( HANDLE_CLDFB_FILTER_BANK hs );

static void GetEnergyCldfb_ivas_fx( Word32 *energyLookahead,     /*!< o: Q(*sf_energyLookahead) |   pointer to the result in the core look-ahead slot */
                                    Word16 *sf_energyLookahead,  /*!< o:         pointer to the scalefactor of the result in the core look-ahead slot  */
                                    const Word16 numLookahead,   /*!< i: Q0      the number of look-ahead time-slots */
                                    Word16 **realValues,         /*!< i: Q(sf_Values) |   the real part of the CLDFB subsamples */
                                    Word16 **imagValues,         /*!< i: Q(sf_Values) |   the imaginary part of the CLDFB subsamples */
                                    Word16 sf_Values,            /*!< i:         scalefactor of the CLDFB subcamples - apply as a negated Exponent */
                                    Word16 numberBands,          /*!< i: Q0  |   number of CLDFB bands */
                                    Word16 numberCols,           /*!< i: Q0  |   number of CLDFB subsamples */
                                    Word32 *energyHF,            /*!< o: Q31 |   pointer to HF energy */
                                    Word16 *energyHF_Exp,        /*!< o:         pointer to exponent of HF energy */
                                    Word32 *energyValuesSum,     /*!< o: Q(2*sf_Values-4) |   pointer to sum array of energy values, not initialized*/
                                    Word16 *energyValuesSum_Exp, /*!< o:         pointer to exponents of energyValuesSum, not initialized */
                                    TEC_ENC_HANDLE hTecEnc );

/*-------------------------------------------------------------------*
 * cplxMult()
@@ -1552,6 +1565,168 @@ void resampleCldfb_ivas_fx(
    return;
}

static void GetEnergyCldfb_ivas_fx( Word32 *energyLookahead,     /*!< o: Q(*sf_energyLookahead) |   pointer to the result in the core look-ahead slot */
                                    Word16 *sf_energyLookahead,  /*!< o:         pointer to the scalefactor of the result in the core look-ahead slot  */
                                    const Word16 numLookahead,   /*!< i: Q0      the number of look-ahead time-slots */
                                    Word16 **realValues,         /*!< i: Q(sf_Values) |   the real part of the CLDFB subsamples */
                                    Word16 **imagValues,         /*!< i: Q(sf_Values) |   the imaginary part of the CLDFB subsamples */
                                    Word16 sf_Values,            /*!< i:         scalefactor of the CLDFB subcamples - apply as a negated Exponent */
                                    Word16 numberBands,          /*!< i: Q0  |   number of CLDFB bands */
                                    Word16 numberCols,           /*!< i: Q0  |   number of CLDFB subsamples */
                                    Word32 *energyHF,            /*!< o: Q31 |   pointer to HF energy */
                                    Word16 *energyHF_Exp,        /*!< o:         pointer to exponent of HF energy */
                                    Word32 *energyValuesSum,     /*!< o: Q(2*sf_Values-4) |   pointer to sum array of energy values, not initialized*/
                                    Word16 *energyValuesSum_Exp, /*!< o:         pointer to exponents of energyValuesSum, not initialized */
                                    TEC_ENC_HANDLE hTecEnc )
{
    Word16 j;
    Word16 k;
    Word16 s;
    Word16 sm;
    Word32 nrg;
    Word16 numberColsL;
    Word16 numberBandsM;
    Word16 numberBandsM20;
    Word32 energyValues[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX];
    Word16 energyValuesSumE[CLDFB_NO_CHANNELS_MAX];
    // Word16 freqTable[2] = {20, 40};
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
    move32();
#endif

    FOR( k = 0; k < numberCols; k++ )
    {
        FOR( j = 0; j < numberBands; j++ )
        {
            nrg = L_mult0( realValues[k][j], realValues[k][j] );     // Q(2*sf_Values)
            nrg = L_mac0( nrg, imagValues[k][j], imagValues[k][j] ); // Q(2*sf_Values)

            energyValues[k][j] = nrg;
            move32();
        }
    }

    IF( GE_16( numberBands, freqTable[1] ) && hTecEnc != NULL )
    {
        Word32 *tempEnergyValuesArry[CLDFB_NO_COL_MAX];
        Word16 ScaleX2;
        assert( numberCols == CLDFB_NO_COL_MAX );
        FOR( j = 0; j < numberCols; j++ )
        {
            tempEnergyValuesArry[j] = &energyValues[j][0];
        }

        ScaleX2 = shl( sf_Values, 1 );
        calcHiEnvLoBuff_Fix(
            numberCols,
            freqTable,
            1,
            tempEnergyValuesArry,
            hTecEnc->loBuffer,
            hTecEnc->hiTempEnv,
            ScaleX2 );
    }

    FOR( j = 0; j < numberBands; j++ )
    {
        energyValuesSum[j] = 0;
        move32();
        energyValuesSumE[j] = 31;
        move16();
        FOR( k = 0; k < CLDFB_NO_COL_MAX; k++ )
        {
            nrg = L_shr_r( energyValues[k][j], sub( energyValuesSumE[j], 31 ) ); // Q(2*sf_Values - (energyValuesSumE[j]-31))
            IF( LT_32( L_sub( maxWord32, nrg ), energyValuesSum[j] ) )
            {
                energyValuesSumE[j] = add( energyValuesSumE[j], 1 );
                move16();
                energyValuesSum[j] = L_shr_r( energyValuesSum[j], 1 );
                move32();
                nrg = L_shr_r( nrg, 1 );
            }
            energyValuesSum[j] = L_add( energyValuesSum[j], nrg );
            move32();
        }
        test();
        if ( j == 0 || GT_16( energyValuesSumE[j], *energyValuesSum_Exp ) )
        {
            *energyValuesSum_Exp = energyValuesSumE[j];
            move16();
        }
    }
    FOR( j = 0; j < numberBands; j++ )
    {
        energyValuesSum[j] = L_shr_r( energyValuesSum[j], sub( *energyValuesSum_Exp, energyValuesSumE[j] ) ); // Q(energyValuesSum_Exp - (2*sf_Values))
        move32();
    }
    *energyValuesSum_Exp = sub( *energyValuesSum_Exp, shl( sf_Values, 1 ) );
    move16();

    IF( GT_16( numberBands, 20 ) )
    {
        numberBandsM = s_min( numberBands, 40 );
        numberBandsM20 = sub( numberBandsM, 20 );

        numberColsL = sub( numberCols, numLookahead );

        /* sum up CLDFB energy above 8 kHz */
        s = BASOP_util_norm_s_bands2shift( i_mult( numberColsL, numberBandsM20 ) );
        s = sub( s, 4 );
        nrg = 0;
        move32();
        FOR( k = 0; k < numberColsL; k++ )
        {
            FOR( j = 20; j < numberBandsM; j++ )
            {
                nrg = L_add_o( nrg, L_shr_o( energyValues[k][j], s, &Overflow ), &Overflow );
            }
        }

        s = sub( sub( shl( sf_Values, 1 ), 1 ), s );
        sm = sub( s_min( s, *sf_energyLookahead ), 1 );

        *energyHF = L_add( L_shr( nrg, limitScale32( sub( s, sm ) ) ),
                           L_shr( *energyLookahead, sub( *sf_energyLookahead, sm ) ) ); // Q(31-(-nm))
        move32();

        *energyHF_Exp = negate( sm );
        move16();

        /* process look-ahead region */
        s = BASOP_util_norm_s_bands2shift( i_mult( numLookahead, numberBandsM20 ) );
        s = sub( s, 2 );
        nrg = 0;
        move32();
        FOR( k = numberColsL; k < numberCols; k++ )
        {
            FOR( j = 20; j < numberBandsM; j++ )
            {
                nrg = L_add_o( nrg, L_shr_o( energyValues[k][j], s, &Overflow ), &Overflow );
            }
        }

        s = sub( shl( sf_Values, 1 ), s );
        sm = sub( s_min( s, 44 ), 1 );
        BASOP_SATURATE_WARNING_OFF_EVS
        /* nrg + 6.1e-5f => value 0x40000000, scale 44 */
        *energyLookahead = L_add_sat( L_shr_sat( nrg, sub( s, sm ) ),
                                      L_shr_sat( 0x40000000, s_max( -31, s_min( 31, sub( 44, sm ) ) ) ) );
        move32();
        BASOP_SATURATE_WARNING_ON_EVS
        *sf_energyLookahead = sm;
        move16();

        return;
    }


    *energyHF = 0x40000000;
    move32();
    *energyHF_Exp = 17;
    move16();
}


void analysisCldfbEncoder_ivas_fx(
    Encoder_State *st, /* i/o: encoder state structure   */
@@ -1613,7 +1788,7 @@ void analysisCldfbEncoder_ivas_fx(

    AnalysisPostSpectrumScaling_Fx( st->cldfbAnaEnc, ppBuf_Real, ppBuf_Imag, ppBuf_Real16, ppBuf_Imag16, &enerScale.lb_scale16 );

    GetEnergyCldfb( &st->energyCoreLookahead_Fx, &st->sf_energyCoreLookahead_Fx, 1, ppBuf_Real16, ppBuf_Imag16, enerScale.lb_scale16, st->cldfbAnaEnc->no_channels, st->cldfbAnaEnc->no_col, &st->currEnergyHF_fx, &st->currEnergyHF_e_fx, ppBuf_Ener, enerBuffSum_exp, st->hTECEnc );
    GetEnergyCldfb_ivas_fx( &st->energyCoreLookahead_Fx, &st->sf_energyCoreLookahead_Fx, 1, ppBuf_Real16, ppBuf_Imag16, enerScale.lb_scale16, st->cldfbAnaEnc->no_channels, st->cldfbAnaEnc->no_col, &st->currEnergyHF_fx, &st->currEnergyHF_e_fx, ppBuf_Ener, enerBuffSum_exp, st->hTECEnc );

    return;
}
+1 −1
Original line number Diff line number Diff line
@@ -3341,7 +3341,7 @@ void mctStereoIGF_enc_fx(
    Word32 powerSpec_fx[MCT_MAX_CHANNELS][L_FRAME48k],   /* i/o: MDCT^2 + MDST^2 spectrum,or estimate       */
    Word16 q_powerSpec[MCT_MAX_CHANNELS],                /* i  : Q for powSpec_fx                           */
    Word32 *powerSpecMsInv_fx[MCT_MAX_CHANNELS][NB_DIV], /* i  : same as powerSpec_fx but for inverse spect.*/
    Word16 q_powerSpecMsInv[MCT_MAX_CHANNELS],           /* i  : Q for powSpecMsInv_fx                      */
    Word16 *q_powerSpecMsInv[MCT_MAX_CHANNELS][NB_DIV],  /* i  : Q for powSpecMsInv_fx                      */
    Word32 *inv_spectrum_fx[MCT_MAX_CHANNELS][NB_DIV],   /* i  : inverse spectrum                           */
    const Word16 sp_aud_decision0[MCT_MAX_CHANNELS]      /* i  : speech audio decision                      */
);
+23 −23
Original line number Diff line number Diff line
@@ -10844,7 +10844,7 @@ void ProcessStereoIGF_fx(
    Word32 *pPowerSpectrum_fx[CPE_CHANNELS],                /* i/o: MDCT^2 + MDST^2 spectrum, or estimate   */
    Word16 exp_pPowerSpectrum_fx[CPE_CHANNELS],             /* i/o: exp of pPowerSpectrum_fx                */
    Word32 *pPowerSpectrumMsInv_fx[CPE_CHANNELS][NB_DIV],   /* i  : inverse power spectrum                  */
    Word16 exp_pPowerSpectrumMsInv_fx[CPE_CHANNELS],      /* i/o: exp of pPowerSpectrumMsInv_fx           */
    Word16 *q_pPowerSpectrumMsInv_fx[CPE_CHANNELS][NB_DIV], /* i/o: Q of pPowerSpectrumMsInv_fx           */
    Word32 *inv_spectrum_fx[CPE_CHANNELS][NB_DIV],          /* i  : inverse spectrum                        */
    Word16 exp_inv_spectrum_fx[CPE_CHANNELS],               /* i/o: exp of inv_spectrum_fx                  */
    const Word16 frameno,                                   /* i  : flag indicating index of current subfr. */
@@ -10861,7 +10861,7 @@ void IGFEncApplyStereo_fx(
    Word32 *pPowerSpectrum_fx[CPE_CHANNELS],                /* i/o: MDCT^2 + MDST^2 spectrum, or estimate   */
    Word16 exp_pPowerSpectrum_fx[CPE_CHANNELS],             /* i/o: exp of pPowerSpectrum_fx                */
    Word32 *pPowerSpectrumMsInv_fx[CPE_CHANNELS][NB_DIV],   /* i/o: inverse power spectrum                  */
    Word16 exp_pPowerSpectrumMsInv_fx[CPE_CHANNELS],      /* i/o: exp of pPowerSpectrumMsInv_fx           */
    Word16 *q_pPowerSpectrumMsInv_fx[CPE_CHANNELS][NB_DIV], /* i/o: Q of pPowerSpectrumMsInv_fx           */
    Word32 *inv_spectrum_fx[CPE_CHANNELS][NB_DIV],          /* i  : inverse spectrum                        */
    Word16 exp_inv_spectrum_fx[CPE_CHANNELS],               /* i  : exp of inverse spectrum                 */
    const Word16 frameno,                                   /* i  : flag indicating index of current subfr. */
+5 −5
Original line number Diff line number Diff line
@@ -219,13 +219,13 @@ void find_targets_ivas_fx(
        /* first half: xn[] --> cn[] */
        temp[0] = 0;
        move16();
        preemph_copy_fx( xn, cn, tilt_fac, L_SUBFR / 2, temp );
        syn_filt_s_lc_fx( 1, Ap, cn, temp, L_SUBFR / 2 );   /* Q-1 -> Q-2 */
        Residu3_lc_fx( p_Aq, M, temp, cn, L_SUBFR / 2, 1 ); /* Q-2 -> Q-1 */
        Scale_sig( cn, L_SUBFR / 2, 1 );
        preemph_copy_fx( xn, cn, tilt_fac, L_subfr / 2, temp );
        syn_filt_s_lc_fx( 1, Ap, cn, temp, L_subfr / 2 );   /* Q-1 -> Q-2 */
        Residu3_lc_fx( p_Aq, M, temp, cn, L_subfr / 2, 1 ); /* Q-2 -> Q-1 */
        Scale_sig( cn, L_subfr / 2, 1 );

        /* second half: res[] --> cn[] (approximated and faster) */
        Copy( &res[i_subfr + ( L_SUBFR / 2 )], cn + ( L_SUBFR / 2 ), L_SUBFR / 2 );
        Copy( &res[i_subfr + ( L_subfr / 2 )], cn + ( L_subfr / 2 ), L_subfr / 2 );
    }

    /*---------------------------------------------------------------*
+53 −22
Original line number Diff line number Diff line
@@ -1002,12 +1002,12 @@ static void IGF_CalculateStereoEnvelope_fx(
    const Word32 *pPowerSpectrum_fx,       /* i  : MDCT^2 + MDST^2 spectrum, or estimate       */
    Word16 pPowerSpectrum_e,               /* i  : exponent for pPowerSpectrum_fx              */
    const Word32 *pPowerSpectrumMsInv_fx,  /* i  : inverse power spectrum                      */
    Word16 pPowerSpectrumMsInv_e,          /* i  : exponent for pPowerSpectrumMsInv_fx         */
    Word16 *q_pPowerSpectrumMsInv,         /* i  : Q for pPowerSpectrumMsInv_fx         */
    const Word16 igfGridIdx,               /* i  : IGF grid index                                     */
    const Word16 coreMsMask[N_MAX],        /* i  : line wise ms Mask                                  */
    const Word16 isTransient,              /* i  : flag indicating if transient is detected           */
    const Word16 last_core_acelp           /* i  : indicator if last frame was ACELP core             */
)
    const Word16 last_core_acelp,          /* i  : indicator if last frame was ACELP core             */
    const Word16 mct_on )
{
    IGF_ENC_PRIVATE_DATA_HANDLE hPrivateData;
    H_IGF_GRID hGrid;
@@ -1047,6 +1047,32 @@ static void IGF_CalculateStereoEnvelope_fx(
    Word16 slope_e;              /*stores exponent for slope_fx*/
    Word16 sfbEnergyR_e;         /*stores exponent for sfbEnergyR*/
    Word16 tmp_e;
    Word32 temp_pPowerSpectrumMsInv[N_MAX], length;
    Word16 q_temp_pPowerSpectrumMsInv = Q31, i;
    move16();

    IF( pPowerSpectrumMsInv_fx != NULL )
    {
        length = N_MAX;
        move16();
        if ( mct_on )
        {
            length = L_FRAME48k;
            move16();
        }
        FOR( i = 0; i < length; i++ )
        {
            IF( pPowerSpectrumMsInv_fx[i] != 0 )
            {
                q_temp_pPowerSpectrumMsInv = s_min( q_temp_pPowerSpectrumMsInv, add( q_pPowerSpectrumMsInv[i], norm_l( pPowerSpectrumMsInv_fx[i] ) ) );
            }
        }
        FOR( i = 0; i < length; i++ )
        {
            temp_pPowerSpectrumMsInv[i] = L_shl( pPowerSpectrumMsInv_fx[i], sub( q_temp_pPowerSpectrumMsInv, q_pPowerSpectrumMsInv[i] ) );
            move32();
        }
    }

    hPrivateData = &hIGFEnc->igfData;
    hGrid = &hPrivateData->igfInfo.grid[(Word16) igfGridIdx];
@@ -1131,9 +1157,9 @@ static void IGF_CalculateStereoEnvelope_fx(
                        final_exp = sub( pMDCTSpectrumMsInv_e, norm_exp );
                        scaled_value = L_shl( pMDCTSpectrumMsInv_fx[strt_cpy], norm_exp );
                        sfbEnergyTileR_fx = BASOP_Util_Add_Mant32Exp( sfbEnergyTileR_fx, sfbEnergyTileR_e, Mult_32_32( scaled_value, scaled_value ), shl( final_exp, 1 ), &sfbEnergyTileR_e );                /*resultant exponent is stored in sfbEnergyTileR_e*/
                        sfbEnergyTileC_fx = BASOP_Util_Add_Mant32Exp( sfbEnergyTileC_fx, sfbEnergyTileC_e, pPowerSpectrumMsInv_fx[strt_cpy], pPowerSpectrumMsInv_e, &sfbEnergyTileC_e );       /*resultant exponent is stored in sfbEnergyTileC_e*/
                        tileSrcSpec_fx[sub( strt_cpy, tmp )] = pPowerSpectrumMsInv_fx[strt_cpy];                                                                                               /*resultant exponent is stored in tileSrcSpec_e*/
                        tileSrcSpec_e = pPowerSpectrumMsInv_e;
                        sfbEnergyTileC_fx = BASOP_Util_Add_Mant32Exp( sfbEnergyTileC_fx, sfbEnergyTileC_e, pPowerSpectrumMsInv_fx[strt_cpy], sub( 31, q_pPowerSpectrumMsInv[strt_cpy] ), &sfbEnergyTileC_e ); /*resultant exponent is stored in sfbEnergyTileC_e*/
                        tileSrcSpec_fx[sub( strt_cpy, tmp )] = temp_pPowerSpectrumMsInv[strt_cpy];                                                                                                            /*resultant exponent is stored in tileSrcSpec_e*/
                        tileSrcSpec_e = sub( 31, q_temp_pPowerSpectrumMsInv );
                    }
                    ELSE
                    {
@@ -2628,7 +2654,7 @@ void IGFEncApplyStereo_fx(
    Word32 *pPowerSpectrum_fx[CPE_CHANNELS],                /* i/o: MDCT^2 + MDST^2 spectrum, or estimate   */
    Word16 exp_pPowerSpectrum_fx[CPE_CHANNELS],             /* i/o: exp of pPowerSpectrum_fx                */
    Word32 *pPowerSpectrumMsInv_fx[CPE_CHANNELS][NB_DIV],   /* i/o: inverse power spectrum                  */
    Word16 exp_pPowerSpectrumMsInv_fx[CPE_CHANNELS],      /* i/o: exp of pPowerSpectrumMsInv_fx           */
    Word16 *q_pPowerSpectrumMsInv_fx[CPE_CHANNELS][NB_DIV], /* i/o: Q of pPowerSpectrumMsInv_fx           */
    Word32 *inv_spectrum_fx[CPE_CHANNELS][NB_DIV],          /* i  : inverse spectrum                        */
    Word16 exp_inv_spectrum_fx[CPE_CHANNELS],               /* i  : exp of inverse spectrum                 */
    const Word16 frameno,                                   /* i  : flag indicating index of current subfr. */
@@ -2638,6 +2664,7 @@ void IGFEncApplyStereo_fx(
{
    Word32 *pPowerSpectrumParameter_fx[NB_DIV]; /* If it is NULL it informs a function that specific handling is needed */
    Word32 *pPowerSpectrumParameterMsInv_fx[NB_DIV];
    Word16 *q_pPowerSpectrumParameterMsInv_fx[NB_DIV];
    Word16 coreMsMask[N_MAX];
    Word16 sfb, ch, last_core_acelp;
    STEREO_MDCT_BAND_PARAMETERS *sfbConf;
@@ -2681,6 +2708,8 @@ void IGFEncApplyStereo_fx(
        pPowerSpectrumParameter_fx[1] = &pPowerSpectrum_fx[1][0];
        pPowerSpectrumParameterMsInv_fx[0] = pPowerSpectrumMsInv_fx[0][0];
        pPowerSpectrumParameterMsInv_fx[1] = pPowerSpectrumMsInv_fx[1][0];
        q_pPowerSpectrumParameterMsInv_fx[0] = q_pPowerSpectrumMsInv_fx[0][0];
        q_pPowerSpectrumParameterMsInv_fx[1] = q_pPowerSpectrumMsInv_fx[1][0];
    }
    ELSE
    {
@@ -2688,6 +2717,8 @@ void IGFEncApplyStereo_fx(
        pPowerSpectrumParameter_fx[1] = NULL;
        pPowerSpectrumParameterMsInv_fx[0] = NULL;
        pPowerSpectrumParameterMsInv_fx[1] = NULL;
        q_pPowerSpectrumParameterMsInv_fx[0] = NULL;
        q_pPowerSpectrumParameterMsInv_fx[1] = NULL;
    }
    FOR( ch = 0; ch < CPE_CHANNELS; ch++ )
    {
@@ -2696,7 +2727,7 @@ void IGFEncApplyStereo_fx(
        IGF_UpdateInfo( hIGFEnc[ch], igfGridIdx );
        IGF_CalculateStereoEnvelope_fx( hIGFEnc[ch], sts[ch]->hTcxEnc->spectrum_fx[frameno], sts[ch]->hTcxEnc->spectrum_e[frameno], inv_spectrum_fx[ch][frameno],
                                        exp_inv_spectrum_fx[ch], pPowerSpectrumParameter_fx[ch], exp_pPowerSpectrum_fx[ch], pPowerSpectrumParameterMsInv_fx[ch],
                                        exp_pPowerSpectrumMsInv_fx[ch], igfGridIdx, coreMsMask, sts[ch]->hTranDet->transientDetector.bIsAttackPresent, last_core_acelp );
                                        q_pPowerSpectrumParameterMsInv_fx[ch], igfGridIdx, coreMsMask, sts[ch]->hTranDet->transientDetector.bIsAttackPresent, last_core_acelp, mct_on );

        IF( EQ_16( sts[ch]->core, TCX_20_CORE ) )
        {
Loading