⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pxcpngrn.cpp

📁 linux下的一款播放器
💻 CPP
📖 第 1 页 / 共 2 页
字号:
                pDecode->SetLastSeqNum((UINT32) 0xFFFFFFFF);                // Initialize the valid flag                pDecode->SetValid(TRUE);                // Set image dimensions                rImageDim.cx = (INT32) pDecode->GetWidth();                rImageDim.cy = (INT32) pDecode->GetHeight();                // Add it to the map                retVal = m_pMapManager->AddEntry((void*) pDecode, rulSessionHandle);                if (SUCCEEDED(retVal))                {                    // AddRef it since it's in the map now                    pDecode->AddRef();                }            }        }        else        {            retVal = HXR_OUTOFMEMORY;        }        HX_RELEASE(pDecode);    }    else    {        retVal = HXR_FAIL;    }    return retVal;}STDMETHODIMP CRealPixPNGRendererCodec::GetFrameInfo(UINT32           ulSessionHandle,                                                    UINT32           ulFrameNum,                                                    REF(HXxRect)     rFrameDim,                                                    REF(IHXValues*) rpMoreInfo){    HX_RESULT retVal = HXR_FAIL;    if (ulSessionHandle && !ulFrameNum && m_pMapManager)    {        // Set defaults        rFrameDim.left   = 0;        rFrameDim.top    = 0;        rFrameDim.right  = 0;        rFrameDim.bottom = 0;        rpMoreInfo       = NULL;        // Get the PXPNGDecode object        PXPNGDecode* pDecode = NULL;        retVal               = m_pMapManager->GetEntry(ulSessionHandle, (void**) &pDecode);        if (SUCCEEDED(retVal))        {            // Create an IHXValues object            IHXValues* pInfo = NULL;            retVal            = m_pCommonClassFactory->CreateInstance(CLSID_IHXValues,                                                                      (void**) &pInfo);            if (SUCCEEDED(retVal))            {                // Set the "UsesAlphaChannel" property                pInfo->SetPropertyULONG32("UsesAlphaChannel", (pDecode->UsesAlphaChannel() ? 1 : 0));                // Set the out parameters                rFrameDim.right  = pDecode->GetWidth();                rFrameDim.bottom = pDecode->GetHeight();                rpMoreInfo       = pInfo;                rpMoreInfo->AddRef();            }            HX_RELEASE(pInfo);        }    }    return retVal;}STDMETHODIMP CRealPixPNGRendererCodec::SetDecompressParam(UINT32      ulSessionHandle,                                                          UINT32      ulFrameNum,                                                          IHXBuffer* pOutputBuffer,                                                          HXxSize     cFrameDim,                                                          UINT32      ulRowStride,                                                          UINT32      ulBitsPerPixel,                                                          UINT32      ulColorFormat,                                                          BOOL        bRowsInverted,                                                          IHXValues* pMoreParam){    HX_RESULT retVal = HXR_FAIL;    if (ulFrameNum     == 0  && pOutputBuffer &&        ulBitsPerPixel == 32 && ulColorFormat == HX_RGB &&        m_pMapManager)    {        PXPNGDecode* pDecode = NULL;        retVal               = m_pMapManager->GetEntry(ulSessionHandle, (void**) &pDecode);        if (SUCCEEDED(retVal))        {            BOOL bTransparentIsZero = FALSE;                        if( pMoreParam )            {            	ULONG32 valueProperty;            	if( SUCCEEDED( pMoreParam->GetPropertyULONG32( "TransparentIsZero", valueProperty ) ) )            	{            		bTransparentIsZero = ( valueProperty != 0 );            	}            }                        // Make sure that we are decoding to 1/1            if (cFrameDim.cx == (INT32) pDecode->GetWidth() &&                cFrameDim.cy == (INT32) pDecode->GetHeight())            {                retVal = pDecode->SetDecompressParam(pOutputBuffer,                                                     (UINT32) cFrameDim.cx,                                                     (UINT32) cFrameDim.cy,                                                     ulRowStride,                                                     ulBitsPerPixel,                                                     ulColorFormat,                                                     bRowsInverted,                                                     bTransparentIsZero);            }            else            {                retVal = HXR_INVALID_PARAMETER;            }        }    }    return retVal;}STDMETHODIMP CRealPixPNGRendererCodec::Decompress(UINT32      ulSessionHandle,                                                  IHXBuffer* pBuffer,                                                  IHXBuffer* pOpaquePacketData){    HX_RESULT retVal = HXR_OK;    if (ulSessionHandle && pBuffer && m_pMapManager)    {        PXPNGDecode* pDecode = NULL;        retVal               = m_pMapManager->GetEntry(ulSessionHandle, (void**) &pDecode);        if (SUCCEEDED(retVal))        {            // If the object has been labelled invalid, that means that we lost the            // header packet - therefore we don't need to do any of this stuff.            if (pDecode->GetValid())            {                if (pOpaquePacketData)                {                    BYTE* pBuf = pOpaquePacketData->GetBuffer();                    if (pBuf)                    {                        // Unpack the sequence number from the opaque data                        UINT32 ulSeqNum = 0;                        UnPack32(pBuf, ulSeqNum);                        // Check seq num                        if (ulSeqNum != pDecode->GetLastSeqNum() + 1)                        {                            // All we can do is stop decoding                            pDecode->SetValid(FALSE);                        }                        else                        {                            pDecode->SetLastSeqNum(ulSeqNum);                        }                    }                }                if (pDecode->GetValid())                {                    // Now call decompress for the object                    retVal = pDecode->Decompress(pBuffer);                }            }        }    }    else    {        retVal = HXR_INVALID_PARAMETER;    }    return retVal;}STDMETHODIMP CRealPixPNGRendererCodec::GetDecompressStatus(UINT32     ulSessionHandle,                                                           REF(INT32) rlStatus){    HX_RESULT retVal = HXR_FAIL;    if (m_pMapManager)    {        PXPNGDecode* pDecode = NULL;        retVal               = m_pMapManager->GetEntry(ulSessionHandle, (void**) &pDecode);        if (SUCCEEDED(retVal))        {            if (!pDecode->GetValid())            {                rlStatus = DECOMPRESS_STATUS_ABORTED;            }            else if (pDecode->IsFinished())            {                rlStatus = DECOMPRESS_STATUS_FINISHED;            }            else            {                rlStatus = DECOMPRESS_STATUS_INPROGRESS;            }        }    }    return retVal;}STDMETHODIMP CRealPixPNGRendererCodec::FinishDecompress(UINT32 ulSessionHandle){    HX_RESULT retVal = HXR_FAIL;    if (m_pMapManager)    {        PXPNGDecode* pDecode = NULL;        retVal               = m_pMapManager->DeleteEntry(ulSessionHandle, (void**) &pDecode);        HX_RELEASE(pDecode);    }    return retVal;}HX_RESULT STDAPICALLTYPE CRealPixPNGRendererCodec::HXCreateInstance(IUnknown** ppIUnknown){    HX_RESULT retVal = HXR_OK;    if (ppIUnknown)    {        // Create renderer codec        CRealPixPNGRendererCodec* pCodec = new CRealPixPNGRendererCodec();        if (pCodec)        {            // QI for IUnknown            retVal = pCodec->QueryInterface(IID_IUnknown, (void**) ppIUnknown);        }        else        {            retVal = HXR_OUTOFMEMORY;        }        if (FAILED(retVal))        {            HX_DELETE(pCodec);        }    }    else    {        retVal = HXR_FAIL;    }    return retVal;}void CRealPixPNGRendererCodec::ReleaseAllDecodeObjects(){    if (m_pMapManager)    {        UINT32       ulHandle = 0;        PXPNGDecode* pDecode = NULL;        HX_RESULT    retVal   = m_pMapManager->GetFirstEntry(ulHandle, (void**) &pDecode);        while (SUCCEEDED(retVal))        {            HX_RELEASE(pDecode);            retVal = m_pMapManager->GetNextEntry(ulHandle, (void**) &pDecode);        }        m_pMapManager->DeleteAllEntries();    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -