Commit 6b57bcb8 authored by vaclav's avatar vaclav
Browse files

add exits if malloc() fails - decoder side

parent 18fc7092
Loading
Loading
Loading
Loading
+132 −36
Original line number Diff line number Diff line
@@ -346,7 +346,8 @@ static void CreateDecodeTable( CQMFDecoder *psCQMFDecoder, int32_t num, const ui
 *
 *------------------------------------------------------------------------------------------*/

CQMFDecoder *CreateCQMFDecoder(
ivas_error CreateCQMFDecoder(
    CQMFDecoder **psCQMFDecoder_out,
    const int32_t iSampleRate,
    const int32_t iChannels )
{
@@ -354,11 +355,15 @@ CQMFDecoder *CreateCQMFDecoder(
#ifdef ROM_TO_RAM
    int32_t read_length;
#endif
    ivas_error error;
    CQMFDecoder *psCQMFDecoder = NULL;

    assert( iSampleRate == 48000 ); // Fix

    psCQMFDecoder = (CQMFDecoder *) malloc( sizeof( CQMFDecoder ) );
    if ( ( psCQMFDecoder = (CQMFDecoder *) malloc( sizeof( CQMFDecoder ) ) ) == NULL )
    {
        return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) );
    }
    psCQMFDecoder->iSampleRate = iSampleRate;
    psCQMFDecoder->iChannels = iChannels;
    psCQMFDecoder->iNumBlocks = CQMF_BLOCKS_PER_FRAME;
@@ -368,7 +373,10 @@ CQMFDecoder *CreateCQMFDecoder(
    psCQMFDecoder->piBandwidths = c_aiBandwidths48; // Fix

    psCQMFDecoder->iMSMode = 0;
    psCQMFDecoder->piMSFlags = (int32_t *) malloc( MAX_BANDS * sizeof( int32_t ) );
    if ( ( psCQMFDecoder->piMSFlags = (int32_t *) malloc( MAX_BANDS * sizeof( int32_t ) ) ) == NULL )
    {
        return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) );
    }
    for ( n = 0; n < MAX_BANDS; n++ )
    {
        psCQMFDecoder->piLRPhaseDiffs[n] = 0;
@@ -380,46 +388,129 @@ CQMFDecoder *CreateCQMFDecoder(
#endif

    psCQMFDecoder->iCommonGrouping = 1; /* Common grouping always on only impacts stereo */
    psCQMFDecoder->piNumGroups = (int32_t *) malloc( psCQMFDecoder->iChannels * sizeof( int32_t ) );
    psCQMFDecoder->ppiGroupLengths = (int32_t **) malloc( psCQMFDecoder->iChannels * sizeof( int32_t * ) );
    psCQMFDecoder->pppiRMSEnvelope = (int32_t ***) malloc( psCQMFDecoder->iChannels * sizeof( int32_t ** ) );
    psCQMFDecoder->pppiSMR = (int32_t ***) malloc( psCQMFDecoder->iChannels * sizeof( int32_t ** ) );
    psCQMFDecoder->pppiExcitation = (int32_t ***) malloc( psCQMFDecoder->iChannels * sizeof( int32_t ** ) );
    psCQMFDecoder->pppiAlloc = (int32_t ***) malloc( psCQMFDecoder->iChannels * sizeof( int32_t ** ) );

    psCQMFDecoder->pppiCQMFSignReal = (int32_t ***) malloc( psCQMFDecoder->iChannels * sizeof( int32_t ** ) );
    psCQMFDecoder->pppiCQMFSignImag = (int32_t ***) malloc( psCQMFDecoder->iChannels * sizeof( int32_t ** ) );
    psCQMFDecoder->pppiQCQMFReal = (int32_t ***) malloc( psCQMFDecoder->iChannels * sizeof( int32_t ** ) );
    psCQMFDecoder->pppiQCQMFImag = (int32_t ***) malloc( psCQMFDecoder->iChannels * sizeof( int32_t ** ) );
    if ( ( psCQMFDecoder->piNumGroups = (int32_t *) malloc( psCQMFDecoder->iChannels * sizeof( int32_t ) ) ) == NULL )
    {
        return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) );
    }
    if ( ( psCQMFDecoder->ppiGroupLengths = (int32_t **) malloc( psCQMFDecoder->iChannels * sizeof( int32_t * ) ) ) == NULL )
    {
        return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) );
    }
    if ( ( psCQMFDecoder->pppiRMSEnvelope = (int32_t ***) malloc( psCQMFDecoder->iChannels * sizeof( int32_t ** ) ) ) == NULL )
    {
        return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) );
    }
    if ( ( psCQMFDecoder->pppiSMR = (int32_t ***) malloc( psCQMFDecoder->iChannels * sizeof( int32_t ** ) ) ) == NULL )
    {
        return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) );
    }
    if ( ( psCQMFDecoder->pppiExcitation = (int32_t ***) malloc( psCQMFDecoder->iChannels * sizeof( int32_t ** ) ) ) == NULL )
    {
        return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) );
    }
    if ( ( psCQMFDecoder->pppiAlloc = (int32_t ***) malloc( psCQMFDecoder->iChannels * sizeof( int32_t ** ) ) ) == NULL )
    {
        return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) );
    }

    if ( ( psCQMFDecoder->pppiCQMFSignReal = (int32_t ***) malloc( psCQMFDecoder->iChannels * sizeof( int32_t ** ) ) ) == NULL )
    {
        return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) );
    }
    if ( ( psCQMFDecoder->pppiCQMFSignImag = (int32_t ***) malloc( psCQMFDecoder->iChannels * sizeof( int32_t ** ) ) ) == NULL )
    {
        return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) );
    }
    if ( ( psCQMFDecoder->pppiQCQMFReal = (int32_t ***) malloc( psCQMFDecoder->iChannels * sizeof( int32_t ** ) ) ) == NULL )
    {
        return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) );
    }
    if ( ( psCQMFDecoder->pppiQCQMFImag = (int32_t ***) malloc( psCQMFDecoder->iChannels * sizeof( int32_t ** ) ) ) == NULL )
    {
        return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) );
    }

    for ( n = 0; n < iChannels; n++ )
    {
        int32_t k;
        int16_t k;
#ifdef ENABLE_PMOD_ADJUST
        psCQMFDecoder->ppiHiSMRFlags[n] =
            (int32_t *) malloc( MAX_BANDS * sizeof( int32_t ) );
        ;
#endif
        psCQMFDecoder->ppiGroupLengths[n] = (int32_t *) malloc( CQMF_BLOCKS_PER_FRAME * sizeof( int32_t ) );
        psCQMFDecoder->pppiRMSEnvelope[n] = (int32_t **) malloc( CQMF_BLOCKS_PER_FRAME * sizeof( int32_t * ) );
        psCQMFDecoder->pppiSMR[n] = (int32_t **) malloc( CQMF_BLOCKS_PER_FRAME * sizeof( int32_t * ) );
        psCQMFDecoder->pppiExcitation[n] = (int32_t **) malloc( CQMF_BLOCKS_PER_FRAME * sizeof( int32_t * ) );
        psCQMFDecoder->pppiAlloc[n] = (int32_t **) malloc( CQMF_BLOCKS_PER_FRAME * sizeof( int32_t * ) );

        psCQMFDecoder->pppiCQMFSignReal[n] = (int32_t **) malloc( CQMF_BLOCKS_PER_FRAME * sizeof( int32_t * ) );
        psCQMFDecoder->pppiCQMFSignImag[n] = (int32_t **) malloc( CQMF_BLOCKS_PER_FRAME * sizeof( int32_t * ) );
        psCQMFDecoder->pppiQCQMFReal[n] = (int32_t **) malloc( CQMF_BLOCKS_PER_FRAME * sizeof( int32_t * ) );
        psCQMFDecoder->pppiQCQMFImag[n] = (int32_t **) malloc( CQMF_BLOCKS_PER_FRAME * sizeof( int32_t * ) );
        if ( ( psCQMFDecoder->ppiGroupLengths[n] = (int32_t *) malloc( CQMF_BLOCKS_PER_FRAME * sizeof( int32_t ) ) ) == NULL )
        {
            return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) );
        }
        if ( ( psCQMFDecoder->pppiRMSEnvelope[n] = (int32_t **) malloc( CQMF_BLOCKS_PER_FRAME * sizeof( int32_t * ) ) ) == NULL )
        {
            return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) );
        }
        if ( ( psCQMFDecoder->pppiSMR[n] = (int32_t **) malloc( CQMF_BLOCKS_PER_FRAME * sizeof( int32_t * ) ) ) == NULL )
        {
            return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) );
        }
        if ( ( psCQMFDecoder->pppiExcitation[n] = (int32_t **) malloc( CQMF_BLOCKS_PER_FRAME * sizeof( int32_t * ) ) ) == NULL )
        {
            return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) );
        }
        if ( ( psCQMFDecoder->pppiAlloc[n] = (int32_t **) malloc( CQMF_BLOCKS_PER_FRAME * sizeof( int32_t * ) ) ) == NULL )
        {
            return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) );
        }

        if ( ( psCQMFDecoder->pppiCQMFSignReal[n] = (int32_t **) malloc( CQMF_BLOCKS_PER_FRAME * sizeof( int32_t * ) ) ) == NULL )
        {
            return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) );
        }
        if ( ( psCQMFDecoder->pppiCQMFSignImag[n] = (int32_t **) malloc( CQMF_BLOCKS_PER_FRAME * sizeof( int32_t * ) ) ) == NULL )
        {
            return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) );
        }
        if ( ( psCQMFDecoder->pppiQCQMFReal[n] = (int32_t **) malloc( CQMF_BLOCKS_PER_FRAME * sizeof( int32_t * ) ) ) == NULL )
        {
            return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) );
        }
        if ( ( psCQMFDecoder->pppiQCQMFImag[n] = (int32_t **) malloc( CQMF_BLOCKS_PER_FRAME * sizeof( int32_t * ) ) ) == NULL )
        {
            return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) );
        }

        for ( k = 0; k < CQMF_BLOCKS_PER_FRAME; k++ )
        {
            psCQMFDecoder->pppiRMSEnvelope[n][k] = (int32_t *) malloc( MAX_BANDS * sizeof( int32_t ) );
            psCQMFDecoder->pppiSMR[n][k] = (int32_t *) malloc( MAX_BANDS * sizeof( int32_t ) );
            psCQMFDecoder->pppiExcitation[n][k] = (int32_t *) malloc( MAX_BANDS * sizeof( int32_t ) );
            psCQMFDecoder->pppiAlloc[n][k] = (int32_t *) malloc( MAX_BANDS * sizeof( int32_t ) );
            if ( ( psCQMFDecoder->pppiRMSEnvelope[n][k] = (int32_t *) malloc( MAX_BANDS * sizeof( int32_t ) ) ) == NULL )
            {
                return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) );
            }
            if ( ( psCQMFDecoder->pppiSMR[n][k] = (int32_t *) malloc( MAX_BANDS * sizeof( int32_t ) ) ) == NULL )
            {
                return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) );
            }
            if ( ( psCQMFDecoder->pppiExcitation[n][k] = (int32_t *) malloc( MAX_BANDS * sizeof( int32_t ) ) ) == NULL )
            {
                return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) );
            }
            if ( ( psCQMFDecoder->pppiAlloc[n][k] = (int32_t *) malloc( MAX_BANDS * sizeof( int32_t ) ) ) == NULL )
            {
                return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) );
            }

            psCQMFDecoder->pppiCQMFSignReal[n][k] = (int32_t *) malloc( CQMF_BANDS * sizeof( int32_t ) );
            psCQMFDecoder->pppiCQMFSignImag[n][k] = (int32_t *) malloc( CQMF_BANDS * sizeof( int32_t ) );
            psCQMFDecoder->pppiQCQMFReal[n][k] = (int32_t *) malloc( CQMF_BANDS * sizeof( int32_t ) );
            psCQMFDecoder->pppiQCQMFImag[n][k] = (int32_t *) malloc( CQMF_BANDS * sizeof( int32_t ) );
            if ( ( psCQMFDecoder->pppiCQMFSignReal[n][k] = (int32_t *) malloc( CQMF_BANDS * sizeof( int32_t ) ) ) == NULL )
            {
                return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) );
            }
            if ( ( psCQMFDecoder->pppiCQMFSignImag[n][k] = (int32_t *) malloc( CQMF_BANDS * sizeof( int32_t ) ) ) == NULL )
            {
                return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) );
            }
            if ( ( psCQMFDecoder->pppiQCQMFReal[n][k] = (int32_t *) malloc( CQMF_BANDS * sizeof( int32_t ) ) ) == NULL )
            {
                return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) );
            }
            if ( ( psCQMFDecoder->pppiQCQMFImag[n][k] = (int32_t *) malloc( CQMF_BANDS * sizeof( int32_t ) ) ) == NULL )
            {
                return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) );
            }
        }
    }

@@ -439,12 +530,17 @@ CQMFDecoder *CreateCQMFDecoder(
        }
    }
#endif
    psCQMFDecoder->psPredictionDecoder = CreatePredictionDecoder( iChannels, psCQMFDecoder->iNumBlocks );
    if ( ( error = CreatePredictionDecoder( &psCQMFDecoder->psPredictionDecoder, iChannels, psCQMFDecoder->iNumBlocks ) ) != IVAS_ERR_OK )
    {
        return error;
    }
    psCQMFDecoder->psNoiseGen = NULL; // CreateNoiseGen(); // No noise fill for now

    psCQMFDecoder->iLastError = DECODER_ERROR_NONE;

    return psCQMFDecoder;
    *psCQMFDecoder_out = psCQMFDecoder;

    return IVAS_ERR_OK;
}


+2 −1
Original line number Diff line number Diff line
@@ -41,7 +41,8 @@

typedef struct CQMF_DECODER CQMFDecoder;

CQMFDecoder *CreateCQMFDecoder(
ivas_error CreateCQMFDecoder(
    CQMFDecoder **psCQMFDecoder_out,
    const int32_t iSampleRate,
    const int32_t iChannels );

+68 −27
Original line number Diff line number Diff line
@@ -49,43 +49,86 @@
 *
 *-------------------------------------------------------------------*/

PredictionDecoder *CreatePredictionDecoder(
ivas_error CreatePredictionDecoder(
    PredictionDecoder **psPredictionDecoder_out,
    const int32_t iChannels,
    const int32_t iNumBlocks )
{
    int32_t n;
    int16_t n;

    PredictionDecoder *psPredictionDecoder = NULL;

    psPredictionDecoder = (PredictionDecoder *) malloc( sizeof( PredictionDecoder ) );
    if ( ( psPredictionDecoder = (PredictionDecoder *) malloc( sizeof( PredictionDecoder ) ) ) == NULL )
    {
        return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) );
    }

    psPredictionDecoder->iChannels = iChannels;
    psPredictionDecoder->iNumBlocks = iNumBlocks;

    psPredictionDecoder->piPredChanEnable = (int32_t *) malloc( sizeof( int32_t ) * iChannels );
    psPredictionDecoder->piNumPredBands = (int32_t *) malloc( sizeof( int32_t ) * iChannels );
    if ( ( psPredictionDecoder->piPredChanEnable = (int32_t *) malloc( sizeof( int32_t ) * iChannels ) ) == NULL )
    {
        return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) );
    }
    if ( ( psPredictionDecoder->piNumPredBands = (int32_t *) malloc( sizeof( int32_t ) * iChannels ) ) == NULL )
    {
        return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) );
    }

    if ( ( psPredictionDecoder->ppfEstPredGain = (float **) malloc( sizeof( float * ) * iChannels ) ) == NULL )
    {
        return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) );
    }
    if ( ( psPredictionDecoder->ppiPredBandEnable = (int32_t **) malloc( sizeof( int32_t * ) * iChannels ) ) == NULL )
    {
        return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) );
    }
    if ( ( psPredictionDecoder->ppfA1Real = (float **) malloc( sizeof( float * ) * iChannels ) ) == NULL )
    {
        return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) );
    }
    if ( ( psPredictionDecoder->ppfA1Imag = (float **) malloc( sizeof( float * ) * iChannels ) ) == NULL )
    {
        return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) );
    }
    if ( ( psPredictionDecoder->ppiA1Mag = (int32_t **) malloc( sizeof( int32_t * ) * iChannels ) ) == NULL )
    {
        return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) );
    }
    if ( ( psPredictionDecoder->ppiA1Phase = (int32_t **) malloc( sizeof( int32_t * ) * iChannels ) ) == NULL )
    {
        return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) );
    }

    psPredictionDecoder->ppfEstPredGain = (float **) malloc( sizeof( float * ) * iChannels );
    psPredictionDecoder->ppiPredBandEnable = (int32_t **) malloc( sizeof( int32_t * ) * iChannels );
    psPredictionDecoder->ppfA1Real = (float **) malloc( sizeof( float * ) * iChannels );
    psPredictionDecoder->ppfA1Imag = (float **) malloc( sizeof( float * ) * iChannels );
    psPredictionDecoder->ppiA1Mag = (int32_t **) malloc( sizeof( int32_t * ) * iChannels );
    psPredictionDecoder->ppiA1Phase = (int32_t **) malloc( sizeof( int32_t * ) * iChannels );
    for ( n = 0; n < psPredictionDecoder->iChannels; n++ )
    {
        psPredictionDecoder->ppfEstPredGain[n] = (float *) malloc( sizeof( float ) * CQMF_BANDS );
        psPredictionDecoder->ppiPredBandEnable[n] = (int32_t *) malloc( sizeof( int32_t ) * CQMF_BANDS );
        psPredictionDecoder->ppfA1Real[n] = (float *) malloc( sizeof( float ) * CQMF_BANDS );
        psPredictionDecoder->ppfA1Imag[n] = (float *) malloc( sizeof( float ) * CQMF_BANDS );
        psPredictionDecoder->ppiA1Mag[n] = (int32_t *) malloc( sizeof( int32_t ) * CQMF_BANDS );
        psPredictionDecoder->ppiA1Phase[n] = (int32_t *) malloc( sizeof( int32_t ) * CQMF_BANDS );
        if ( ( psPredictionDecoder->ppfEstPredGain[n] = (float *) malloc( sizeof( float ) * CQMF_BANDS ) ) == NULL )
        {
            return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) );
        }
        if ( ( psPredictionDecoder->ppiPredBandEnable[n] = (int32_t *) malloc( sizeof( int32_t ) * CQMF_BANDS ) ) == NULL )
        {
            return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) );
        }
        if ( ( psPredictionDecoder->ppfA1Real[n] = (float *) malloc( sizeof( float ) * CQMF_BANDS ) ) == NULL )
        {
            return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) );
        }
        if ( ( psPredictionDecoder->ppfA1Imag[n] = (float *) malloc( sizeof( float ) * CQMF_BANDS ) ) == NULL )
        {
            return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) );
        }
        if ( ( psPredictionDecoder->ppiA1Mag[n] = (int32_t *) malloc( sizeof( int32_t ) * CQMF_BANDS ) ) == NULL )
        {
            return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) );
        }
        if ( ( psPredictionDecoder->ppiA1Phase[n] = (int32_t *) malloc( sizeof( int32_t ) * CQMF_BANDS ) ) == NULL )
        {
            return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) );
        }
    }

    /* pre-define these tables? */
    psPredictionDecoder->pfMagLUT = (float *) malloc( sizeof( float ) * ( 1 << PRED_QUNAT_FILTER_MAG_BITS ) );
    psPredictionDecoder->pfP2RRealLUT = (float *) malloc( sizeof( float ) * ( 1 << PRED_QUANT_FILTER_PHASE_BITS ) );
    psPredictionDecoder->pfP2RImagLUT = (float *) malloc( sizeof( float ) * ( 1 << PRED_QUANT_FILTER_PHASE_BITS ) );

    for ( n = 0; n < ( 1 << PRED_QUNAT_FILTER_MAG_BITS ); n++ )
    {
        const float fInvMagScale = M_PI / ( 2.0f * (float) ( 1 << ( PRED_QUNAT_FILTER_MAG_BITS ) ) + 1.0f );
@@ -95,15 +138,16 @@ PredictionDecoder *CreatePredictionDecoder(
    for ( n = 0; n < ( 1 << PRED_QUANT_FILTER_PHASE_BITS ); n++ )
    {
        const float fInvPhaseScale = M_PI / (float) ( 1 << ( PRED_QUANT_FILTER_PHASE_BITS - 1 ) );
        int32_t iVal;
        int16_t iVal;

        iVal = n + PRED_QUANT_FILTER_PHASE_MIN;
        psPredictionDecoder->pfP2RRealLUT[n] = cosf( fInvPhaseScale * (float) iVal );
        psPredictionDecoder->pfP2RImagLUT[n] = sinf( fInvPhaseScale * (float) iVal );
    }

    *psPredictionDecoder_out = psPredictionDecoder;

    return psPredictionDecoder;
    return IVAS_ERR_OK;
}


@@ -136,11 +180,8 @@ void DeletePredictionDecoder(
    free( psPredictionDecoder->ppiA1Mag );
    free( psPredictionDecoder->ppiA1Phase );

    free( psPredictionDecoder->pfMagLUT );
    free( psPredictionDecoder->pfP2RRealLUT );
    free( psPredictionDecoder->pfP2RImagLUT );

    free( psPredictionDecoder );
    psPredictionDecoder = NULL;

    return;
}
+6 −4
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@
#include "options.h"
#ifdef SPLIT_REND_WITH_HEAD_ROT
#include "ivas_cldfb_codec_bitstream.h"
#include "ivas_PredTables.h"

typedef struct PREDICTION_DECODER
{
@@ -55,13 +56,14 @@ typedef struct PREDICTION_DECODER
    int32_t **ppiA1Mag;
    int32_t **ppiA1Phase;

    float *pfMagLUT;
    float *pfP2RRealLUT;
    float *pfP2RImagLUT;
    float pfMagLUT[1 << PRED_QUNAT_FILTER_MAG_BITS];
    float pfP2RRealLUT[1 << PRED_QUANT_FILTER_PHASE_BITS];
    float pfP2RImagLUT[1 << PRED_QUANT_FILTER_PHASE_BITS];

} PredictionDecoder;

PredictionDecoder *CreatePredictionDecoder(
ivas_error CreatePredictionDecoder(
    PredictionDecoder **psPredictionDecoder_out,
    const int32_t iChannels,
    const int32_t iNumBlocks );

+32 −33

File changed.

Preview size limit exceeded, changes collapsed.

Loading