OSCL_EXPORT_REF ColorConvertBase::~ColorConvertBase()
{
    if (_mRowPix)
    {
        OSCL_ARRAY_DELETE(_mRowPix);
    }
    if (_mColPix)
    {
        OSCL_ARRAY_DELETE(_mColPix);
    }
}
/*
-----------------------------------------------------------------------------

    CDecoder_AMR_NB

    TerminateDecoderL

    Stop decoder object. close decoder.

    Parameters:     none

    Return Values:  none

-----------------------------------------------------------------------------
*/
OSCL_EXPORT_REF void CDecoder_AMR_NB::TerminateDecoderL()
{
    GSMDecodeFrameExit(&iDecState);
    iDecState = NULL;

    if (iInputBuf)
    {
        OSCL_ARRAY_DELETE(iInputBuf);
        iInputBuf = NULL;
    }

    if (iOutputBuf)
    {
        OSCL_ARRAY_DELETE(iOutputBuf);
        iOutputBuf = NULL;
    }
}
/*
-----------------------------------------------------------------------------

    CDecoder_AMR_NB

    ~CDecoder_AMR_NB

    Empty decoder destructor.

    Parameters:     none

    Return Values:  none

-----------------------------------------------------------------------------
*/
OSCL_EXPORT_REF CDecoder_AMR_NB::~CDecoder_AMR_NB()
{
    if (iDecState)
        oscl_free(iDecState);
    iDecState = NULL;

    if (iInputBuf)
    {
        OSCL_ARRAY_DELETE(iInputBuf);
        iInputBuf = NULL;
    }

    if (iOutputBuf)
    {
        OSCL_ARRAY_DELETE(iOutputBuf);
        iOutputBuf = NULL;
    }
}
Example #4
0
/*
-----------------------------------------------------------------------------

    CDecoder_AAC

    ~CDecoder_AAC

    Empty decoder destructor.

    Parameters:     none

    Return Values:  none

-----------------------------------------------------------------------------
*/
OSCL_EXPORT_REF CDecoder_AAC::~CDecoder_AAC()
{
    if (pMem != NULL)
    {
        OSCL_ARRAY_DELETE(pMem);
        pMem = NULL;
    }

    if (iAllocateInputBuffer && iInputBuf)
    {
        OSCL_ARRAY_DELETE(iInputBuf);
        iInputBuf = NULL;
    }

    if (iAllocateOutputBuffer && iOutputBuf)
    {
        OSCL_ARRAY_DELETE(iOutputBuf);
        iOutputBuf = NULL;
    }
}
/**************************************************************
nRotation : Rotation direction is defined at run time
            0 -- No rotation
            1 -- 90 degree counter clockwise (default)
            2 -- 180 degree rotation (upside-down)
            3 -- 90 degree clockwise
            -1 -- flip left-right
            -2 -- flip and rotate 90 degree cnt clk
            -3 -- flip and rotate 180 degree
            -4 -- flip and rotate 270 degree
**************************************************************/
int32 ColorConvertBase::Init(int32 Src_width, int32 Src_height, int32 Src_pitch, int32 Dst_width, int32 Dst_height, int32 Dst_pitch, int32 nRotation)
{

    /* check the followings, must be multiple of 2 */
    if ((Src_pitch&1) || (Dst_pitch&1) || (Dst_height&1) || (Src_height&1) || (Src_width&1))
    {
        return 0;
    }

    _mInitialized = false;
    _mSrc_mheight = Src_height;
    _mRotation  =   nRotation;
    _mDisp.src_pitch = _mSrc_pitch  =   Src_pitch;
    _mDisp.dst_pitch = _mDst_pitch  =   Dst_pitch;
    _mDisp.src_width = _mSrc_width  =   Src_width;
    _mDisp.src_height = _mSrc_height =  Src_height;
    _mDisp.dst_width = _mDst_width  =   Dst_width;
    _mDisp.dst_height = _mDst_height =  Dst_height;

    /* Check support for rotation */
    if (_mRotation&0x1)
    {
        if (!(GetCapability()&CCSUPPORT_ROTATION))
        {
            return 0;
        }
    }

    _mIsFlip = false;
    if (_mRotation & 0x4)
    {
        _mIsFlip = true;
        _mRotation -= 4;
    }

    //For now, we only support the zoom ratio <=3
    if (_mRotation&0x1)
    {
        if (((Src_width*3) < Dst_height) || ((Src_height*3) < Dst_width))
        {
            return 0;
        }
    }
    else
    {
        if (((Src_width*3) < Dst_width) || ((Src_height*3) < Dst_height))
        {
            return 0;
        }
    }

    if (_mRowPix)
    {
        OSCL_ARRAY_DELETE(_mRowPix);
    }
    if (_mColPix)
    {
        OSCL_ARRAY_DELETE(_mColPix);
    }
    _mRowPix = NULL;
    _mColPix = NULL;

    if ((_mRotation&0x1) == 0)
    { /* no rotation */
        if ((_mDst_width != _mSrc_width) || (_mDst_height != _mSrc_height))
        { /* scaling */
            //calulate the Row
            int32 leavecode = 0;
            OSCL_TRY(leavecode,
                     _mRowPix = OSCL_ARRAY_NEW(uint8, _mSrc_width);
                     _mColPix = OSCL_ARRAY_NEW(uint8, _mSrc_height);
                    );
            OSCL_FIRST_CATCH_ANY(leavecode,
                                 if (_mRowPix)
        {
            OSCL_ARRAY_DELETE(_mRowPix);
            }
            if (_mColPix)
        {
            OSCL_ARRAY_DELETE(_mColPix);
            }
            _mRowPix = NULL;
            _mColPix = NULL;
            return 0;
                                );
OSCL_EXPORT_REF int32 GetActualAacConfig(uint8* aConfigHeader,
        uint8* aAudioObjectType,
        int32* aConfigHeaderSize,
        uint8* SamplingRateIndex,
        uint32* NumChannels)
{

    tPVMP4AudioDecoderExternal * iAACDecExt = NULL;
    UInt           initialUsedBits;  /* Unsigned for C55x */
    tDec_Int_File *pVars;            /* Helper pointer */
    MC_Info       *pMC_Info;         /* Helper pointer */


    Int            status = ERROR_BUFFER_OVERRUN;



    /*
     *  Allocate memory to decode one AAC frame
     */

    if (!iAACDecExt)
    {
        iAACDecExt = new tPVMP4AudioDecoderExternal;
        if (!iAACDecExt)
        {
            return 1;
        }
        iAACDecExt->inputBufferCurrentLength = 0;
    }

    iAACDecExt->pInputBuffer = aConfigHeader;
    iAACDecExt->inputBufferMaxLength = PVMP4AUDIODECODER_INBUFSIZE;


    iAACDecExt->inputBufferUsedLength    = 0;
    iAACDecExt->remainderBits            = 0;

    int32 memreq =  PVMP4AudioDecoderGetMemRequirements();

    uint8 *pMem = OSCL_ARRAY_NEW(uint8 , memreq);

    if (pMem == 0)
    {
        return KCODEC_INIT_FAILURE;
    }

    if (PVMP4AudioDecoderInitLibrary(iAACDecExt, pMem) != 0)
    {
        return KCODEC_INIT_FAILURE;
    }

    iAACDecExt->inputBufferCurrentLength =  *aConfigHeaderSize;


    /*
     * Initialize "helper" pointers to existing memory.
     */

    pVars = (tDec_Int_File *)pMem;


    pMC_Info = &pVars->mc_info;



    /*
     * Translate input buffer variables.
     */
    pVars->inputStream.pBuffer = iAACDecExt->pInputBuffer;

    pVars->inputStream.availableBits =
        (UInt)(iAACDecExt->inputBufferCurrentLength << INBUF_ARRAY_INDEX_SHIFT);

    initialUsedBits =
        (UInt)((iAACDecExt->inputBufferUsedLength << INBUF_ARRAY_INDEX_SHIFT) +
               iAACDecExt->remainderBits);

    pVars->inputStream.inputBufferCurrentLength =
        (UInt)iAACDecExt->inputBufferCurrentLength;

    pVars->inputStream.usedBits = initialUsedBits;

    pVars->aacPlusEnabled = true;   /* Always enable aacplus decoding */


    if (initialUsedBits <= pVars->inputStream.availableBits)
    {
        /*
         * Buffer is not overrun, then
         * decode the AudioSpecificConfig() structure
         */
        status = get_audio_specific_config(pVars);

    }


    byte_align(&pVars->inputStream);

    *aConfigHeaderSize = (Int32)((pVars->inputStream.usedBits) >> 3);


    *SamplingRateIndex = pVars->prog_config.sampling_rate_idx;

    *NumChannels = pVars->mc_info.nch;

    *aAudioObjectType = pVars->mc_info.audioObjectType;

    /*
     *  Set parameters  based on the explicit information from the
     *  audio specific config
     */

    if (pVars->mc_info.sbrPresentFlag)
    {
        if (pVars->mc_info.psPresentFlag)
        {
            *NumChannels += 1;
        }
    }


    pVars->status = status;

    /*
     *  Clear allocated memory
     */
    if (pMem != NULL)
    {
        OSCL_ARRAY_DELETE(pMem);
        pMem = NULL;
    }

    if (iAACDecExt)
    {
        OSCL_DELETE(iAACDecExt);
        iAACDecExt = NULL;
    }

    return status;
}