📄 vidrendf.cpp
字号:
#ifdef ENABLE_FRAME_TRACE
if (pPacket && (ulFrameTraceIdx < MAX_FRAME_TRACE_ENTRIES))
{
frameTraceArray[ulFrameTraceIdx][2] = pPacket->m_ulTime;
frameTraceArray[ulFrameTraceIdx][0] =
(LONG32) pPacket->m_pData;
frameTraceArray[ulFrameTraceIdx++][1] = 'G';
}
#endif // ENABLE_FRAME_TRACE
return pPacket;
}
/****************************************************************************
* Method:
* CVideoFormat::Reset
*
*/
void CVideoFormat::Reset(void)
{
_Reset();
}
void CVideoFormat::_Reset()
{
m_pMutex->Lock();
CMediaPacket* pFrame;
while (!m_InputQueue.IsEmpty())
{
pFrame = (CMediaPacket*) m_InputQueue.RemoveHead();
pFrame->Clear();
delete pFrame;
}
FlushOutputQueue();
m_pMutex->Unlock();
}
/****************************************************************************
* Method:
* CVideoFormat::DecodeFrame
*
*/
void CVideoFormat::FlushOutputQueue(void)
{
CMediaPacket* pFrame;
if (m_pOutputQueue)
{
while ((pFrame = (CMediaPacket*) m_pOutputQueue->Get()) != NULL)
{
#ifdef ENABLE_FRAME_TRACE
if (ulFrameTraceIdx < MAX_FRAME_TRACE_ENTRIES)
{
frameTraceArray[ulFrameTraceIdx][2] = pFrame->m_ulTime;
frameTraceArray[ulFrameTraceIdx][0] =
(LONG32) pFrame->m_pData;
frameTraceArray[ulFrameTraceIdx++][1] = 'F';
}
#endif // ENABLE_FRAME_TRACE
pFrame->Clear();
delete pFrame;
}
}
}
/****************************************************************************
* Method:
* CVideoFormat::DecodeFrame
*
*/
BOOL CVideoFormat::DecodeFrame(void)
{
CMediaPacket* pEncodedPacket;
CMediaPacket* pDecodedPacket = NULL;
ULONG32 ulLoopCounter = 0;
m_pVideoRenderer->BltIfNeeded();
m_pDecoderMutex->Lock();
m_pMutex->Lock();
if ((!m_InputQueue.IsEmpty()) &&
(!m_pOutputQueue->IsFull()) &&
(!m_bDecodeSuspended))
{
do
{
pEncodedPacket = (CMediaPacket*) m_InputQueue.RemoveHead();
m_pMutex->Unlock();
pDecodedPacket = CreateDecodedPacket(pEncodedPacket);
if (pDecodedPacket)
{
#ifdef ENABLE_FRAME_TRACE
if (ulFrameTraceIdx < MAX_FRAME_TRACE_ENTRIES)
{
frameTraceArray[ulFrameTraceIdx][2] = pDecodedPacket->m_ulTime;
frameTraceArray[ulFrameTraceIdx][0] =
(LONG32) pDecodedPacket->m_pData;
frameTraceArray[ulFrameTraceIdx++][1] = 'D';
}
#endif // ENABLE_FRAME_TRACE
m_pOutputQueue->Put(pDecodedPacket);
if (pDecodedPacket->m_pData)
{
m_pDecoderMutex->Unlock();
m_pVideoRenderer->BltIfNeeded();
return TRUE;
}
}
m_pDecoderMutex->Unlock();
if( m_LastError == HXR_OUTOFMEMORY )
{
m_bDecodeSuspended = TRUE;
}
else
{
m_pVideoRenderer->BltIfNeeded();
}
ulLoopCounter++;
m_pDecoderMutex->Lock();
m_pMutex->Lock();
} while ((!m_InputQueue.IsEmpty()) &&
(!m_pOutputQueue->IsFull()) &&
((ulLoopCounter++) < MAX_DECODE_SPIN) &&
(!m_bDecodeSuspended));
}
m_pMutex->Unlock();
m_pDecoderMutex->Unlock();
return pDecodedPacket ? TRUE : FALSE;
}
/****************************************************************************
* Method:
* CVideoFormat::ReturnDecodedPacket
*
*/
BOOL CVideoFormat::ReturnDecodedPacket(CMediaPacket* pDecodedPacket)
{
BOOL bPacketAccepted = FALSE;
if (pDecodedPacket)
{
#ifdef ENABLE_FRAME_TRACE
if (ulFrameTraceIdx < MAX_FRAME_TRACE_ENTRIES)
{
frameTraceArray[ulFrameTraceIdx][2] = pDecodedPacket->m_ulTime;
frameTraceArray[ulFrameTraceIdx][0] =
(LONG32) pDecodedPacket->m_pData;
frameTraceArray[ulFrameTraceIdx++][1] = 'D';
}
#endif // ENABLE_FRAME_TRACE
bPacketAccepted = m_pOutputQueue->Put(pDecodedPacket);
}
return bPacketAccepted;
}
/****************************************************************************
* Method:
* CVideoFormat::GetMaxDecodedFrames
*
*/
ULONG32 CVideoFormat::GetMaxDecodedFrames(void)
{
return MAX_BUFFERED_DECODED_FRAMES;
}
/****************************************************************************
* Method:
* CVideoFormat::CreateDecodedPacket
*
*/
CMediaPacket* CVideoFormat::CreateDecodedPacket(CMediaPacket* pCodedPacket)
{
CMediaPacket* pDecodedPacket = NULL;
if (pCodedPacket != NULL)
{
pCodedPacket->Clear();
delete pCodedPacket;
pCodedPacket = NULL;
}
return pDecodedPacket;
}
/****************************************************************************
* Method:
* CVideoFormat::OnDecodedPacketRelease
*
*/
void CVideoFormat::OnDecodedPacketRelease(CMediaPacket* &pPacket)
{
#ifdef ENABLE_FRAME_TRACE
if (ulFrameTraceIdx < MAX_FRAME_TRACE_ENTRIES)
{
frameTraceArray[ulFrameTraceIdx][2] = pPacket->m_ulTime;
frameTraceArray[ulFrameTraceIdx][0] =
(LONG32) pPacket->m_pData;
frameTraceArray[ulFrameTraceIdx++][1] = 'R';
}
#endif // ENABLE_FRAME_TRACE
;
}
/****************************************************************************
* Method:
* CVideoFormat::InitBitmapInfoHeader
*
*/
HX_RESULT CVideoFormat::InitBitmapInfoHeader(
HXBitmapInfoHeader &BitmapInfoHeader,
CMediaPacket* pVideoPacket)
{
HX_RESULT retVal = HXR_OK;
return retVal;
}
/****************************************************************************
* Method:
* CVideoFormat::GetDefaultPreroll
*
*/
ULONG32 CVideoFormat::GetDefaultPreroll(IHXValues* pValues)
{
return FORMAT_DEFAULT_PREROLL;
}
/****************************************************************************
* Method:
* CVideoFormat::GetMinimumPreroll
*
*/
ULONG32 CVideoFormat::GetMinimumPreroll(IHXValues* pValues)
{
return FORMAT_MINIMUM_PREROLL;
}
/****************************************************************************
* Method:
* CVideoFormat::GetMaximumPreroll
*
*/
ULONG32 CVideoFormat::GetMaximumPreroll(IHXValues* pValues)
{
return FORMAT_MAXIMUM_PREROLL;
}
/****************************************************************************
* Method:
* CVideoFormat::GetMimeTypes
*
*/
const char** CVideoFormat::GetMimeTypes(void)
{
return NULL;
}
// *** IUnknown methods ***
/****************************************************************************
* IUnknown::AddRef ref: hxcom.h
*
* This routine increases the object reference count in a thread safe
* manner. The reference count is used to manage the lifetime of an object.
* This method must be explicitly called by the user whenever a new
* reference to an object is used.
*/
STDMETHODIMP_(ULONG32) CVideoFormat::AddRef()
{
return InterlockedIncrement(&m_lRefCount);
}
/****************************************************************************
* IUnknown::Release ref: hxcom.h
*
* This routine decreases the object reference count in a thread safe
* manner, and deletes the object if no more references to it exist. It must
* be called explicitly by the user whenever an object is no longer needed.
*/
STDMETHODIMP_(ULONG32) CVideoFormat::Release()
{
if (InterlockedDecrement(&m_lRefCount) > 0)
{
return m_lRefCount;
}
delete this;
return 0;
}
/****************************************************************************
* IUnknown::QueryInterface ref: hxcom.h
*
* This routine indicates which interfaces this object supports. If a given
* interface is supported, the object's reference count is incremented, and
* a reference to that interface is returned. Otherwise a NULL object and
* error code are returned. This method is called by other objects to
* discover the functionality of this object.
*/
STDMETHODIMP CVideoFormat::QueryInterface(REFIID riid, void** ppvObj)
{
if (IsEqualIID(riid, IID_IUnknown))
{
AddRef();
*ppvObj = (IUnknown*)(IHXPlugin*) this;
return HXR_OK;
}
*ppvObj = NULL;
return HXR_NOINTERFACE;
}
HX_RESULT
CVideoFormat::GetLastError()
{
return m_LastError;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -