Commit b0768339 authored by multrus's avatar multrus
Browse files

[cleanup] accept FIX_917_LCLD_WARNINGS

parent 0fd20a73
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -151,7 +151,6 @@
/*#define FIX_I4_OL_PITCH*/                             /* fix open-loop pitch used for EVS core switching */
/*#define SPLIT_REND_WITH_HEAD_ROT  */                  /* Dlb,FhG: Split Rendering contributions 21 and 35 */

#define FIX_917_LCLD_WARNINGS                           /* Dlb: issue 917 and 918: fix LCLD codec warnings*/
#define FIX_920_IGF_INIT_ERROR                          /* FhG: issue 920: fix bitrate mismatch in initial IGF config to avoid error message in same cases */
#define FIX_SPLITREND_WARNINGS                          /* FhG: fix warnings related to split rendering observed in build jobs */
#define FIX_923_EXTERNAL_REND_COMMAND_LINE              /* VA: issue 923: enable external renderer command-line options in UPPER case letters */
+0 −42
Original line number Diff line number Diff line
@@ -39,48 +39,6 @@
#include "ivas_prot_rend.h"
#include "wmc_auto.h"

#ifndef FIX_917_LCLD_WARNINGS
/*------------------------------------------------------------------------------------------*
 * Function CreateNoiseGen()
 *
 *
 *------------------------------------------------------------------------------------------*/
// todo: not used!!
NoiseGen *CreateNoiseGen( void )
{
    int32_t n;

    NoiseGen *psNoiseGen = NULL;

    psNoiseGen = (NoiseGen *) malloc( sizeof( NoiseGen ) );
    psNoiseGen->iNoiseBufferLength = 2048;
    psNoiseGen->iNoiseBufferMask = 2047;
    psNoiseGen->iNoiseBufferIndex = 0;

    psNoiseGen->pfNoiseBuffer = (float *) malloc( psNoiseGen->iNoiseBufferLength * sizeof( float ) );

    /* Generate Laplacian distributed noise */
    for ( n = 0; n < psNoiseGen->iNoiseBufferLength; n++ )
    {
        float fNoise = 0.0f;
        float fScale = 0.707f;
        fNoise = (float) ( ( rand() & ( RAND_MAX - 1 ) ) - ( RAND_MAX >> 1 ) ) / (float) RAND_MAX;

        if ( fNoise < 0.0 )
        {
            fNoise = fScale * (float) logf( 1.0f + 1.9999999f * fNoise );
        }
        else
        {
            fNoise = -fScale * (float) logf( 1.0f - 1.9999999f * fNoise );
        }

        psNoiseGen->pfNoiseBuffer[n] = fNoise;
    }

    return psNoiseGen;
}
#endif

/*------------------------------------------------------------------------------------------*
 * Function DeleteNoiseGen()
+0 −219
Original line number Diff line number Diff line
@@ -275,107 +275,6 @@ static void ComputeBandEnergy(
    return;
}

#ifndef FIX_917_LCLD_WARNINGS
/*-------------------------------------------------------------------*
 * 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()
@@ -588,122 +487,7 @@ static float TryMerge2(
    return fMergedCost;
}

#ifndef FIX_917_LCLD_WARNINGS
/*-------------------------------------------------------------------*
 * 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;
}
#endif

#ifndef FIX_917_LCLD_WARNINGS
/*-------------------------------------------------------------------*
 * 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()
@@ -918,9 +702,6 @@ void ComputeEnvelopeGrouping(
    }

    /* Perform grouping via Greedy Merge */
#ifndef FIX_917_LCLD_WARNINGS
    /* ComputeGreedyGroups2( psRMSEnvelopeGrouping, iChannels, iNumBands, piBandwidths );*/
#endif
    /* Allows control over max groups can call using 16 if want same as previous call */
    ComputeGreedyGroups3( psRMSEnvelopeGrouping, iChannels, iNumBands, piBandwidths, LCLD_BLOCKS_PER_FRAME );

+0 −137
Original line number Diff line number Diff line
@@ -1200,143 +1200,6 @@ static void QuantizeSpectrumDPCM_Opt(
    return;
}

#ifndef FIX_917_LCLD_WARNINGS
static void QuantizeSpectrumDPCM(
    const int32_t iNumGroups,
    const int32_t *piGroupLengths,
    const int32_t iNumBands,
    const int32_t *piBandwidths,
    int32_t **ppiAlloc,
    float **ppfReal,
    float **ppfImag,
    int32_t **ppiQReal,
    int32_t **ppiQImag,
    int32_t **ppiSignReal,
    int32_t **ppiSignImag,
    int32_t *piPredEnable,
    float *pfA1Real,
    float *pfA1Imag ) /* Pass in 2 previous value buffers NULLABLE */
{
    int32_t b, m, n, iBlockOffset;
    float fVal, fPrevReal, fPrevImag, fPredReal, fPredImag;
    int32_t iFBOffset;
    int32_t k, iAlloc, iQuantValue, iMaxQuantVal;
    float fSCFGain, fInvSCFGain;

    iFBOffset = 0;
    for ( b = 0; b < iNumBands; b++ )
    {
        for ( m = 0; m < piBandwidths[b]; m++ )
        {
            iBlockOffset = 0;
            fPrevReal = 0.0;
            fPrevImag = 0.0;
            for ( n = 0; n < iNumGroups; n++ )
            {

                iAlloc = ppiAlloc[n][b];
                iMaxQuantVal = c_aiQuantMaxValues[iAlloc];
                fSCFGain = c_afScaleFactor[iAlloc];
                fInvSCFGain = c_afInvScaleFactor[iAlloc];

                for ( k = 0; k < piGroupLengths[n]; k++ )
                {
                    fPredReal = 0.0;
                    fPredImag = 0.0;

                    if ( piPredEnable[iFBOffset] == 1 )
                    {
                        fPredReal = pfA1Real[iFBOffset] * fPrevReal - pfA1Imag[iFBOffset] * fPrevImag;
                        fPredImag = pfA1Real[iFBOffset] * fPrevImag + pfA1Imag[iFBOffset] * fPrevReal;
                    }
                    else
                    { // don't need
                        fPredReal = 0.0;
                        fPredImag = 0.0;
                    }

                    fVal = ppfReal[iBlockOffset][iFBOffset] + fPredReal;
                    if ( fVal > 0.0 )
                    {
                        iQuantValue = (int32_t) ( fSCFGain * fVal + 0.5 );
                        ppiSignReal[iBlockOffset][iFBOffset] = 0;
                    }
                    else
                    {
                        iQuantValue = (int32_t) ( -fSCFGain * fVal + 0.5 );
                        ppiSignReal[iBlockOffset][iFBOffset] = 1;
                    }
#ifdef _DEBUG_VERBOSE
                    if ( iQuantValue > iMaxQuantVal )
                    {
                        printf( "Value out of range %d\t%d\t%d\t%d\n", b, iAlloc, iQuantValue, iMaxQuantVal );
                        iQuantValue = iMaxQuantVal;
                    }
#else
                    iQuantValue = ( iQuantValue < iMaxQuantVal ) ? iQuantValue : iMaxQuantVal;
#endif

                    ppiQReal[iBlockOffset][iFBOffset] = iQuantValue;

                    fVal = ppfImag[iBlockOffset][iFBOffset] + fPredImag;
                    if ( fVal > 0.0 )
                    {
                        iQuantValue = (int32_t) ( fSCFGain * fVal + 0.5 );
                        ppiSignImag[iBlockOffset][iFBOffset] = 0;
                    }
                    else
                    {
                        iQuantValue = (int32_t) ( -fSCFGain * fVal + 0.5 );
                        ppiSignImag[iBlockOffset][iFBOffset] = 1;
                    }

#ifdef _DEBUG_VERBOSE
                    if ( iQuantValue > iMaxQuantVal )
                    {
                        printf( "Value out of range %d\t%d\t%d\t%d\n", b, iAlloc, iQuantValue, iMaxQuantVal );
                        iQuantValue = iMaxQuantVal;
                    }
#else
                    iQuantValue = ( iQuantValue < iMaxQuantVal ) ? iQuantValue : iMaxQuantVal;
#endif
                    ppiQImag[iBlockOffset][iFBOffset] = iQuantValue;

                    if ( piPredEnable[iFBOffset] == 1 )
                    {
                        if ( ppiSignReal[iBlockOffset][iFBOffset] == 0 )
                        {
                            fPrevReal = fInvSCFGain * (float) ppiQReal[iBlockOffset][iFBOffset] - fPredReal;
                        }
                        else
                        {
                            fPrevReal = -fInvSCFGain * (float) ppiQReal[iBlockOffset][iFBOffset] - fPredReal;
                        }
                        if ( ppiSignImag[iBlockOffset][iFBOffset] == 0 )
                        {
                            fPrevImag = fInvSCFGain * (float) ppiQImag[iBlockOffset][iFBOffset] - fPredImag;
                        }
                        else
                        {
                            fPrevImag = -fInvSCFGain * (float) ppiQImag[iBlockOffset][iFBOffset] - fPredImag;
                        }
                    }
                    else
                    {
                        fPrevReal = 0.0;
                        fPrevImag = 0.0;
                    }

                    iBlockOffset++;
                }
            }

            iFBOffset++;
        }
    }

    return;
}
#endif

static int32_t CountLCLDBits(
    const int32_t iNumGroups,
+0 −5
Original line number Diff line number Diff line
@@ -195,11 +195,6 @@ typedef struct NOISE_GEN
    float *pfNoiseBuffer;
} NoiseGen;

#ifndef FIX_917_LCLD_WARNINGS
NoiseGen *CreateNoiseGen( 
    void 
);
#endif

void DeleteNoiseGen( 
    NoiseGen *psNoiseGen 
Loading