Commit 027ccdbc authored by TYAGIRIS's avatar TYAGIRIS
Browse files

remove unused functions

parent f00dd9a2
Loading
Loading
Loading
Loading
Loading
+0 −219
Original line number Diff line number Diff line
@@ -275,109 +275,6 @@ static void ComputeBandEnergy(
    return;
}


#ifdef SPLIT_REND_LCLD_5MS
/*-------------------------------------------------------------------*
 * Function TryMerge()
 *
 *
 *-------------------------------------------------------------------*/

/* THis is temporary cost function */
static float TryMerge(
    const int32_t iNumBands,
    const int32_t iStartBlock,
    const int32_t iGroupLength,
    const float fMaxAllowedDiffdB,
    float **ppfBandEnergy,
    float **ppfBandEnergydB,
#ifdef APPLY_WEIGHT
    float **ppfWeight,
#endif
    float *pfMegredEnergydB )
{
    int32_t b;
    int32_t n;
    float fMeanCost;
    float fMaxCost;
    float fMinDiffCost;
    float fMaxDiffCost;
    float fInvGroupSize = 1.0f / (float) iGroupLength;
    float fInvNumBands = 1.0f / (float) iNumBands;

    for ( b = 0; b < iNumBands; b++ )
    {
        float fGroupEnergy;


        fGroupEnergy = 0.0;
        for ( n = iStartBlock; n < ( iStartBlock + iGroupLength ); n++ )
        {
            fGroupEnergy += ppfBandEnergy[n][b];
        }
        fGroupEnergy *= fInvGroupSize;
        fGroupEnergy = 10.0f * log10f( fGroupEnergy ); // Note epsolon was added when computing BandEnergy;

        pfMegredEnergydB[b] = fGroupEnergy;
    }

    fMeanCost = 0.0;
    fMaxCost = 0.0;
    fMinDiffCost = 0.0;
    fMaxDiffCost = 0.0;
    for ( n = iStartBlock; n < ( iStartBlock + iGroupLength ); n++ )
    {
        float fMeanAbsDiff;
        float fMaxAbsDiff;
        float fMaxDiff;
        float fMinDiff;

        fMeanAbsDiff = 0.0;
        fMaxAbsDiff = 0.0;
        fMaxDiff = 0.0;
        fMinDiff = 0.0;
        for ( b = 0; b < iNumBands; b++ )
        {
            float fDiff;
            float fAbsDiff;

            fDiff = pfMegredEnergydB[b] - ppfBandEnergydB[n][b]; // Changed the order of this
            fAbsDiff = fabsf( fDiff );
#ifdef APPLY_WEIGHT
            fAbsDiff *= ppfWeight[n][b];
#endif

            fMeanAbsDiff += fAbsDiff;
            fMaxAbsDiff = ( fMaxAbsDiff > fAbsDiff ) ? fMaxAbsDiff : fAbsDiff;


            fMaxDiff = ( fMaxDiff > fDiff ) ? fMaxDiff : fDiff;
            fMinDiff = ( fMinDiff < fDiff ) ? fMinDiff : fDiff;
        }
        fMeanAbsDiff *= fInvNumBands;

        fMeanCost = ( fMeanCost > fMeanAbsDiff ) ? fMeanCost : fMeanAbsDiff;
        fMaxCost = ( fMaxCost > fMaxAbsDiff ) ? fMaxCost : fMaxAbsDiff;

        fMaxDiffCost = ( fMaxDiffCost > fMaxDiff ) ? fMaxDiffCost : fMaxDiff;
        fMinDiffCost = ( fMinDiffCost < fMinDiff ) ? fMinDiffCost : fMinDiff;
    }

    // printf("%f\t%f\t%f\t%f\n",fMeanCost,fMaxCost,fMaxDiffCost,fMinDiffCost);

    /*if(fMinDiffCost < -9.0){ // This prevents cliping
        fMeanCost = 1e12; //Some large value
    }*/

    if ( fMaxCost > fMaxAllowedDiffdB )
    {
        fMeanCost = 1e12f; // Some large value
    }

    return fMeanCost;
}
#endif

/*-------------------------------------------------------------------*
 * Function ComputeMergeRMS()
 *
@@ -589,122 +486,6 @@ static float TryMerge2(
    return fMergedCost;
}

#ifndef SPLIT_REND_LCLD_5MS
/*-------------------------------------------------------------------*
 * Function ComputeGreedyGroups()
 *
 *
 *-------------------------------------------------------------------*/

static void ComputeGreedyGroups(
    RMSEnvelopeGrouping *psRMSEnvelopeGrouping,
    const int32_t iChannels,
    const int32_t iNumBands,
    const float fMeanAllowedDiffdB,
    const float fMaxAllowedDiffdB )
{
    float fBestMeanCost;

    fBestMeanCost = 0.0;
    while ( fBestMeanCost < fMeanAllowedDiffdB )
    {
        GMNode *psGMNode;
        GMNode *psBestGMNode;

        fBestMeanCost = fMeanAllowedDiffdB;
        psGMNode = &psRMSEnvelopeGrouping->psGMNodes[0];
        psBestGMNode = NULL;
        while ( psGMNode->psNext != NULL )
        {
            float fMeanCost;
            int32_t iGroupLength;

            iGroupLength = psGMNode->iGroupLength + psGMNode->psNext->iGroupLength;

            fMeanCost = TryMerge( iNumBands * iChannels,
                                  psGMNode->iGroupStart,
                                  iGroupLength, // psGMNode->iGroupLength, //Fix this bug
                                  fMaxAllowedDiffdB,
                                  psRMSEnvelopeGrouping->ppfBandEnergy,
                                  psRMSEnvelopeGrouping->ppfBandEnergydB,
#ifdef APPLY_WEIGHT
                                  psRMSEnvelopeGrouping->ppfWeight,
#endif
                                  psGMNode->pfMergedEnergydB );


            if ( fMeanCost < fBestMeanCost )
            {
                fBestMeanCost = fMeanCost;
                psBestGMNode = psGMNode;
            }

            psGMNode = psGMNode->psNext;
        }

        if ( fBestMeanCost < fMeanAllowedDiffdB && psBestGMNode != NULL && psBestGMNode->psNext != NULL )
        {
            psBestGMNode->iGroupLength += psBestGMNode->psNext->iGroupLength;
            psBestGMNode->psNext = psBestGMNode->psNext->psNext;
        }
    }

    return;
}


/*-------------------------------------------------------------------*
 * Function ComputeGreedyGroups2()
 *
 *
 *-------------------------------------------------------------------*/

static void ComputeGreedyGroups2(
    RMSEnvelopeGrouping *psRMSEnvelopeGrouping,
    const int32_t iChannels,
    const int32_t iNumBands,
    const int32_t *piBandwidths )
{
    float fBestMergeCost;
    // int32_t iDone = 0;
    fBestMergeCost = -1.0;

    while ( fBestMergeCost < 0.0 )
    {
        GMNode *psGMNode;
        GMNode *psBestGMNode;

        fBestMergeCost = 0.0;
        psGMNode = &psRMSEnvelopeGrouping->psGMNodes[0];
        psBestGMNode = NULL;
        while ( psGMNode->psNext != NULL )
        {
            float fMergeCost;

            fMergeCost = TryMerge2( iChannels, iNumBands, piBandwidths, psRMSEnvelopeGrouping->ppfBandEnergy, psRMSEnvelopeGrouping->ppfBandEnergydB, psGMNode, psGMNode->psNext );

            if ( fMergeCost < fBestMergeCost )
            {
                fBestMergeCost = fMergeCost;
                psBestGMNode = psGMNode;
            }

            psGMNode = psGMNode->psNext;
        }

        if ( fBestMergeCost < 0.0 && psBestGMNode != NULL && psBestGMNode->psNext != NULL )
        {
            psBestGMNode->iGroupLength += psBestGMNode->psNext->iGroupLength;
            psBestGMNode->iGroupRMSEnvelopeCost = -1;
            psBestGMNode->fGroupSNRPenalty = -1.0;
            psBestGMNode->psNext = psBestGMNode->psNext->psNext;
        }
    }

    return;
}
#endif

/*-------------------------------------------------------------------*
 * Function ComputeGreedyGroups3()
 *