本文整理汇总了C++中CH264Nalu::GetNALPos方法的典型用法代码示例。如果您正苦于以下问题:C++ CH264Nalu::GetNALPos方法的具体用法?C++ CH264Nalu::GetNALPos怎么用?C++ CH264Nalu::GetNALPos使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CH264Nalu
的用法示例。
在下文中一共展示了CH264Nalu::GetNALPos方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Decode
STDMETHODIMP CDecMSDKMVC::Decode(const BYTE *buffer, int buflen, REFERENCE_TIME rtStart, REFERENCE_TIME rtStop, BOOL bSyncPoint, BOOL bDiscontinuity)
{
if (!m_mfxSession)
return E_UNEXPECTED;
HRESULT hr = S_OK;
CBitstreamBuffer bsBuffer(&m_buff);
mfxStatus sts = MFX_ERR_NONE;
mfxBitstream bs = { 0 };
BOOL bFlush = (buffer == nullptr);
if (rtStart >= -TIMESTAMP_OFFSET && rtStart != AV_NOPTS_VALUE)
bs.TimeStamp = rtStart + TIMESTAMP_OFFSET;
else
bs.TimeStamp = MFX_TIMESTAMP_UNKNOWN;
bs.DecodeTimeStamp = MFX_TIMESTAMP_UNKNOWN;
if (!bFlush) {
if (m_pAnnexBConverter) {
BYTE *pOutBuffer = nullptr;
int pOutSize = 0;
hr = m_pAnnexBConverter->Convert(&pOutBuffer, &pOutSize, buffer, buflen);
if (FAILED(hr))
return hr;
bsBuffer.SetBuffer(pOutBuffer, pOutSize, true);
}
else {
bsBuffer.SetBuffer((BYTE *)buffer, buflen, false);
}
// Check the buffer for SEI NALU, and some unwanted NALUs that need filtering
// MSDK's SEI reading functionality is slightly buggy
CH264Nalu nalu;
nalu.SetBuffer(bsBuffer.GetBuffer(), bsBuffer.GetBufferSize(), 0);
BOOL bNeedFilter = FALSE;
while (nalu.ReadNext()) {
if (nalu.GetType() == NALU_TYPE_SEI) {
ParseSEI(nalu.GetDataBuffer() + 1, nalu.GetDataLength() - 1, bs.TimeStamp);
}
else if (nalu.GetType() == NALU_TYPE_EOSEQ) {
bsBuffer.EnsureWriteable();
// This is rather ugly, and relies on the bitstream being AnnexB, so simply overwriting the EOS NAL with zero works.
// In the future a more elaborate bitstream filter might be advised
memset(bsBuffer.GetBuffer() + nalu.GetNALPos(), 0, 4);
}
}
bs.Data = bsBuffer.GetBuffer();
bs.DataLength = mfxU32(bsBuffer.GetBufferSize());
bs.MaxLength = bs.DataLength;
AddFrameToGOP(bs.TimeStamp);
}
if (!m_bDecodeReady) {
sts = MFXVideoDECODE_DecodeHeader(m_mfxSession, &bs, &m_mfxVideoParams);
if (sts == MFX_ERR_NOT_ENOUGH_BUFFER) {
hr = AllocateMVCExtBuffers();
if (FAILED(hr))
return hr;
sts = MFXVideoDECODE_DecodeHeader(m_mfxSession, &bs, &m_mfxVideoParams);
}
if (sts == MFX_ERR_NONE) {
m_mfxVideoParams.IOPattern = MFX_IOPATTERN_OUT_SYSTEM_MEMORY;
m_mfxVideoParams.AsyncDepth = ASYNC_DEPTH;
sts = MFXVideoDECODE_Init(m_mfxSession, &m_mfxVideoParams);
if (sts != MFX_ERR_NONE) {
DbgLog((LOG_TRACE, 10, L"CDevMSDKMVC::Decode(): Error initializing the MSDK decoder (%d)", sts));
return E_FAIL;
}
if (m_mfxExtMVCSeq.NumView != 2) {
DbgLog((LOG_TRACE, 10, L"CDevMSDKMVC::Decode(): Only MVC with two views is supported"));
return E_FAIL;
}
DbgLog((LOG_TRACE, 10, L"CDevMSDKMVC::Decode(): Initialized MVC with View Ids %d, %d", m_mfxExtMVCSeq.View[0].ViewId, m_mfxExtMVCSeq.View[1].ViewId));
m_bDecodeReady = TRUE;
}
}
if (!m_bDecodeReady)
return S_FALSE;
mfxSyncPoint sync = nullptr;
// Loop over the decoder to ensure all data is being consumed
while (1) {
MVCBuffer *pInputBuffer = GetBuffer();
if (pInputBuffer == nullptr)
return E_OUTOFMEMORY;
mfxFrameSurface1 *outsurf = nullptr;
sts = MFXVideoDECODE_DecodeFrameAsync(m_mfxSession, bFlush ? nullptr : &bs, &pInputBuffer->surface, &outsurf, &sync);
//.........这里部分代码省略.........