예제 #1
0
__forceinline bool CDecDXVA2::CopyFrame(LAVFrame *pFrame)
{
  HRESULT hr;
  LPDIRECT3DSURFACE9 pSurface = (LPDIRECT3DSURFACE9)pFrame->data[3];
  pFrame->format = LAVPixFmt_NV12;

  D3DSURFACE_DESC surfaceDesc;
  pSurface->GetDesc(&surfaceDesc);

  D3DLOCKED_RECT LockedRect;
  hr = pSurface->LockRect(&LockedRect, NULL, D3DLOCK_READONLY);
  if (FAILED(hr)) {
    DbgLog((LOG_TRACE, 10, L"pSurface->LockRect failed (hr: %X)", hr));
    return false;
  }

  // Free AVFrame based buffers again
  FreeLAVFrameBuffers(pFrame);
  // Allocate memory buffers
  AllocLAVFrameBuffers(pFrame, LockedRect.Pitch);
  // Copy surface onto memory buffers
  CopyFrameNV12((BYTE *)LockedRect.pBits, pFrame->data[0], pFrame->data[1], surfaceDesc.Height, pFrame->height, LockedRect.Pitch);

  pSurface->UnlockRect();

  return true;
}
예제 #2
0
HRESULT CopyLAVFrameInPlace(LAVFrame *pFrame)
{
  LAVFrame *tmpFrame = nullptr;
  CopyLAVFrame(pFrame, &tmpFrame);
  FreeLAVFrameBuffers(pFrame);
  *pFrame = *tmpFrame;
  SAFE_CO_FREE(tmpFrame);
  return S_OK;
}
예제 #3
0
static void lav_free_lavframe(void *opaque, uint8_t *data)
{
  LAVFrame *frame = (LAVFrame *)opaque;
  FreeLAVFrameBuffers(frame);
  SAFE_CO_FREE(opaque);
}