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

📄 h263vidfmt.cpp

📁 linux下的一款播放器
💻 CPP
📖 第 1 页 / 共 2 页
字号:
		if (pNewBuffer)		{		    pFramePacket = new CMediaPacket(					    pNewBuffer,					    pData,					    ulNewBufferSize,					    ulDataSize,					    pPacket->GetTime(),					    ulFlags,					    pFrameDims);		}		if (pFramePacket)		{		    pFramePacket->SetSampleDescKiller(KillH263ampleDesc);		}		else		{                    m_LastError = HXR_OUTOFMEMORY;		}	    }	    pBuffer->Release();	}        if( m_LastError != HXR_OUTOFMEMORY )        {	    m_pH263VideoRenderer->BltIfNeeded();        }	pPacket->Release();    }    else    {	if (pCodecData->IsLost())	{#if defined(HELIX_FEATURE_STATS)	    m_pH263VideoRenderer->ReportLostFrame();#endif /* #if defined(HELIX_FEATURE_STATS) */	}    }    return pFramePacket;}/**************************************************************************** *  Method: *    CQTVideoFormat::Reset * */void CH263VideoFormat::Reset(){    _Reset();    CVideoFormat::Reset();}void CH263VideoFormat::_Reset(void){    HX_DELETE(m_pAssmDims);    if (m_pRssm)    {	m_pRssm->Reset();    }    m_DecoderDims.cx = 0;    m_DecoderDims.cy = 0;    m_ulDecoderBufSize = 0;}/**************************************************************************** *  Method: *    CQTVideoFormat::CreateDecodedPacket * */CMediaPacket* CH263VideoFormat::CreateDecodedPacket(CMediaPacket* pFrameToDecode){    HXxSize currentFrameDims;    CMediaPacket* pDecodedFrame = NULL;    UINT8* pData = NULL;    HX_ASSERT(pFrameToDecode);    // Compute Decode Buffer Storage if info. available    if (pFrameToDecode->m_pSampleDesc)    {	if (memcmp(pFrameToDecode->m_pSampleDesc,		   &m_DecoderDims,		   sizeof(HXxSize)) != 0)	{	    m_DecoderDims = *((HXxSize*) pFrameToDecode->m_pSampleDesc);	    m_ulDecoderBufSize = m_DecoderDims.cx *				 m_DecoderDims.cy *				 H263_PIXEL_SIZE /				 8;	    m_LastFrameDims = m_DecoderDims;	    if (m_pDecoder->InitDecoder(&m_DecoderDims) != HXR_OK)	    {		m_DecoderDims.cx = 0;		m_DecoderDims.cy = 0;		m_ulDecoderBufSize = 0;	    }	}    }    // Get the storage for the Decode Buffer    if (m_ulDecoderBufSize > 0)    {	CMediaPacket* pVideoPacket = NULL;	pVideoPacket = (CMediaPacket*) m_pFramePool->Get(m_ulDecoderBufSize);	if (pVideoPacket)	{	    pData = pVideoPacket->m_pData;	    HX_ASSERT(pData);	    pVideoPacket->Init(pData,			       m_ulDecoderBufSize,			       pFrameToDecode->m_ulTime,			       0,			       pFrameToDecode->m_pSampleDesc);	    pFrameToDecode->m_pSampleDesc = NULL;	    pDecodedFrame = pVideoPacket;	}	else	{	    pData = new UINT8 [m_ulDecoderBufSize];	}    }    if (pData && m_pH263VideoRenderer->IsActive())    {	LONG32 lTimeAhead;	lTimeAhead = m_pH263VideoRenderer->ComputeTimeAhead(				pFrameToDecode->m_ulTime,				0);	if (lTimeAhead < NON_KEYFRM_DCDE_FALLBEHIND_THRSHLD)	{	    // Throw away this frame	    if (pDecodedFrame)	    {		m_pFramePool->Put(pDecodedFrame);		pDecodedFrame = NULL;		pData = NULL;	    }	    else	    {		delete [] pData;		pData = NULL;	    }#if defined(HELIX_FEATURE_STATS)	    m_pH263VideoRenderer->ReportDroppedFrame();#endif /* #if defined(HELIX_FEATURE_STATS) */	}    }    // Decode    if (pData)    {	m_pH263VideoRenderer->BltIfNeeded();	if (m_pDecoder->DecodeFrame(pFrameToDecode,				    pData,				    &currentFrameDims) != HXR_OK)	{	    // Throw away this frame	    if (pDecodedFrame)	    {		m_pFramePool->Put(pDecodedFrame);		pDecodedFrame = NULL;		pData = NULL;	    }	    else	    {		delete [] pData;		pData = NULL;	    }#if defined(HELIX_FEATURE_STATS)	    m_pH263VideoRenderer->ReportDroppedFrame();#endif /* #if defined(HELIX_FEATURE_STATS) */	}    }    m_pH263VideoRenderer->BltIfNeeded();    // If the frame is not formed yet, form it    if (!pDecodedFrame)    {	if (pData)	{	    // Data exists to form the docoded packet with	    pFrameToDecode->SetBuffer(pData,				      pData,				      m_ulDecoderBufSize,				      m_ulDecoderBufSize);	    pDecodedFrame = pFrameToDecode;	    pFrameToDecode = NULL;	    // If there is a change in frame size, forward the change	    if (m_LastFrameDims != currentFrameDims)	    {		HXxSize* pNewFrameDims = new HXxSize;		HX_ASSERT(currentFrameDims.cx <= m_DecoderDims.cx);		HX_ASSERT(currentFrameDims.cy <= m_DecoderDims.cy);		if (pNewFrameDims)		{		    *pNewFrameDims = currentFrameDims;		    pDecodedFrame->SetSampleDesc(pNewFrameDims);		    m_LastFrameDims = currentFrameDims;		}	    }	}	else if (pFrameToDecode->m_pSampleDesc)	{	    // No data exists to form the frame with, but description	    // exists and must be passed down the pipe - form empty	    // frame packet	    pDecodedFrame = pFrameToDecode;	    pDecodedFrame->m_pData = NULL;	    pDecodedFrame->m_ulDataSize = 0;	    pFrameToDecode = NULL;	}    }    if (pFrameToDecode != NULL)    {	pFrameToDecode->Clear();	delete pFrameToDecode;    }    return pDecodedFrame;}/**************************************************************************** *  Method: *    CH263VideoFormat::CSecureH263VideoFormat * */CH263Decoder* CH263VideoFormat::CreateDecoder(){    return new CH263Decoder(m_pH263VideoRenderer->GetContext());}/**************************************************************************** *  Method: *    CH263VideoFormat::ConfigFrom3GPPHeader * */HX_RESULT CH263VideoFormat::ConfigFrom3GPPHeader(IHXBuffer* pConfigData){    UINT8* pData;    ULONG32 ulSize;    HX_RESULT retVal = HXR_FAIL;    HX_DELETE(m_pMaxDims);    if (pConfigData)    {	pData = pConfigData->GetBuffer();	ulSize = pConfigData->GetSize();	m_pMaxDims = new HXxSize;	retVal = HXR_OUTOFMEMORY;    }    if (m_pMaxDims)    {	retVal = HXR_OK;	// We'll assume unknown size	m_pMaxDims->cx = 0;	m_pMaxDims->cy = 0;	if (ulSize >= sizeof(DecoderSpecificInfoV20))	{	    // Try 3GPP-v2.0 DecoderSpecificInfo	    if (getlong(((DecoderSpecificInfoV20*) pData)->pType)		== CCCC_ENCODE('d', '2', '6', '3'))	    {		// Looks good as 3GPP-v2.0 DecoderSpecificInfo		;	    }	    else if ((ulSize >= sizeof(DecoderSpecificInfoV10))&&		     (((DecoderSpecificInfoV10*) pData)->pTag[0] == 0x05))	    {		// Looks good as 3GPP-v1.0 DecoderSpecificInfo		m_pMaxDims->cx = getshort(		    ((DecoderSpecificInfoV10*) pData)->pMaxWidth);		m_pMaxDims->cy = getshort(		    ((DecoderSpecificInfoV10*) pData)->pMaxHeight);	    }	}    }    return retVal;}/**************************************************************************** *  Method: *    CH263VideoFormat::IsBitmapFormatChanged * */BOOL CH263VideoFormat::IsBitmapFormatChanged(			    HXBitmapInfoHeader &BitmapInfoHeader,			    CMediaPacket* pVideoPacket){    if (pVideoPacket->m_pSampleDesc != NULL)    {	HXxSize* pDims = (HXxSize*) pVideoPacket->m_pSampleDesc;	if ((BitmapInfoHeader.biWidth != pDims->cx) ||	    (BitmapInfoHeader.biHeight != pDims->cy))	{	    return TRUE;	}    }    return FALSE;}/**************************************************************************** *  Method: *    CH263VideoFormat::InitBitmapInfoHeader * */HX_RESULT CH263VideoFormat::InitBitmapInfoHeader(    HXBitmapInfoHeader &bitmapInfoHeader,    CMediaPacket* pVideoPacket){    HXxSize* pDims = (HXxSize*) pVideoPacket->m_pSampleDesc;    if (pDims)    {	bitmapInfoHeader.biWidth = pDims->cx;	bitmapInfoHeader.biHeight = pDims->cy;	bitmapInfoHeader.biSizeImage = bitmapInfoHeader.biWidth *				       bitmapInfoHeader.biHeight *				       bitmapInfoHeader.biBitCount /				       8;    }    return HXR_OK;}/**************************************************************************** *  Method: *    CH263VideoFormat::KillH263ampleDesc * */void CH263VideoFormat::KillH263ampleDesc(void* pSampleDesc, void* pUserData){    if (pSampleDesc)    {	HXxSize* pFrameDims = (HXxSize*) pSampleDesc;	delete pFrameDims;    }}

⌨️ 快捷键说明

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