//----------------------------------------------------------------------------- CPUTBuffer *CPUTAssetLibrary::GetBuffer(const cString &name, const CPUTModel *pModel, int meshIndex ) { // If we already have one by this name, then return it CPUTBuffer *pBuffer = FindBuffer(name, true, pModel, meshIndex); ASSERT( pBuffer, _L("Can't find buffer ") + name ); pBuffer->AddRef(); return pBuffer; }
//----------------------------------------------------------------------------- CPUTBuffer *CPUTAssetLibrary::GetBuffer(const std::string &name) { // If we already have one by this name, then return it CPUTBuffer *pBuffer = FindBuffer(name, true); LIBRARY_ASSERT(pBuffer, "Can't find buffer " + name); if (pBuffer != NULL) pBuffer->AddRef(); return pBuffer; }
void DXShader::UpdateBuffer(std::string name) { //Grab buffer object ConstantBuffer* cb = FindBuffer(name); if (!cb) return; //copy data into subresource m_context->UpdateSubresource(cb->Buffer, NULL, NULL, cb->LocalDataBuffer, NULL, NULL); }
void CDecMSDKMVC::ReleaseBuffer(mfxFrameSurface1 * pSurface) { if (!pSurface) return; CAutoLock lock(&m_BufferCritSec); MVCBuffer * pBuffer = FindBuffer(pSurface); if (pBuffer) { pBuffer->queued = 0; pBuffer->sync = nullptr; } }
void ESvnBase::AddLine (char *file,int line, const char* msg,int status) { SvnLine *l; l=(SvnLine *)malloc (sizeof (SvnLine)); if (l!=0) { l->File=file?strdup (file):0; l->Line=line; l->Msg=msg?strdup (msg):0; l->Buf=0; l->Status=status; LineCount++; Lines=(SvnLine **)realloc (Lines,sizeof (SvnLine *)*LineCount); Lines[LineCount-1]=l; FindBuffer (LineCount-1); UpdateList (); } }
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); if (sts == MFX_ERR_INCOMPATIBLE_VIDEO_PARAM) { DbgLog((LOG_TRACE, 10, L"CDevMSDKMVC::Decode(): Incompatible video parameters detected, flushing decoder")); bsBuffer.Clear(); bFlush = TRUE; m_bDecodeReady = FALSE; continue; } if (sync) { MVCBuffer * pOutputBuffer = FindBuffer(outsurf); pOutputBuffer->queued = 1; pOutputBuffer->sync = sync; HandleOutput(pOutputBuffer); continue; } if (sts != MFX_ERR_MORE_SURFACE && sts < 0) break; } if (!bs.DataOffset && !sync && !bFlush) { DbgLog((LOG_TRACE, 10, L"CDevMSDKMVC::Decode(): Decoder did not consume any data, discarding")); bs.DataOffset = mfxU32(bsBuffer.GetBufferSize()); } bsBuffer.Consume(bs.DataOffset); if (sts != MFX_ERR_MORE_DATA && sts < 0) { DbgLog((LOG_TRACE, 10, L"CDevMSDKMVC::Decode(): Error from Decode call (%d)", sts)); return S_FALSE; } return S_OK; }