STDMETHODIMP CVRPresenterStreamDXVA::Present(LPBYTE *ppbPlanes, DWORD *pdwStrides, DWORD dwFlags) { LPBYTE pBuf = NULL; DWORD stride = 0; HRESULT hr = S_OK; hr = LockSurface(&pBuf , &stride); if(FAILED(hr)) return hr; DWORD srcWidth[3]; DWORD srcHeight[3]; srcWidth[0] = m_open_param.dwWidth; srcWidth[1] = srcWidth[2] = m_open_param.dwWidth>>1; srcHeight[0] = m_open_param.dwHeight; srcHeight[1] = srcHeight[2] = m_open_param.dwHeight>>1; if(m_open_param.dwFourCC == MAKE_FOURCC('Y','V','1','2')) hr = m_PrepareData.PrepareBufferYV12(pBuf, stride, ppbPlanes, pdwStrides, srcWidth, srcHeight, dwFlags, 0,0,0,m_deinterlace); else if(m_open_param.dwFourCC == MAKE_FOURCC('R','5','6','5')) { } hr = UnlockSurface(); return hr; }
mfxStatus CQuickSyncDecoder::Decode(mfxBitstream* pBS, mfxFrameSurface1*& pOutSurface) { MSDK_CHECK_POINTER(m_pmfxDEC, MFX_ERR_NOT_INITIALIZED); mfxStatus sts = MFX_ERR_NONE; mfxSyncPoint syncp; mfxFrameSurface1* pWorkSurface = FindFreeSurface(); MSDK_CHECK_POINTER(pWorkSurface, MFX_ERR_NOT_ENOUGH_BUFFER); do { sts = m_pmfxDEC->DecodeFrameAsync(pBS, pWorkSurface, &pOutSurface, &syncp); // Need 1 more work surface if (MFX_ERR_MORE_SURFACE == sts) { pWorkSurface = FindFreeSurface(); MSDK_CHECK_POINTER(pWorkSurface, MFX_ERR_NOT_ENOUGH_BUFFER); } else if (MFX_WRN_DEVICE_BUSY == sts) { static int s_BusyCount = 0; MSDK_TRACE("QsDecoder: MFX_WRN_DEVICE_BUSY (%i)\n", ++s_BusyCount); Sleep(1); } } while (MFX_WRN_DEVICE_BUSY == sts || MFX_ERR_MORE_SURFACE == sts); // Output will be shortly available if (MSDK_SUCCEEDED(sts)) { // Wait for the asynch decoding to finish sts = m_mfxVideoSession->SyncOperation(syncp, 0xFFFF); if (MSDK_SUCCEEDED(sts)) { // The surface is locked from being reused in another Decode call LockSurface(pOutSurface); } } return sts; }
void CPainter::DrawPoint(const CPoint& Point, const CRGBColor& PointColor) { CPoint RealPoint = (m_pWindow != 0) ? Point + m_pWindow->GetClientRect().TopLeft() : Point; if (CRect(0, 0, m_pSurface->w, m_pSurface->h).HitTest(RealPoint) == CRect::RELPOS_INSIDE) { LockSurface(); Uint8* PixelOffset = static_cast<Uint8*>(m_pSurface->pixels) + m_pSurface->format->BytesPerPixel * RealPoint.XPos() + m_pSurface->pitch * RealPoint.YPos(); switch (m_pSurface->format->BytesPerPixel) { case 1: // 8 bpp *reinterpret_cast<Uint8*>(PixelOffset) = static_cast<Uint8>(MixColor(ReadPoint(Point), PointColor).SDLColor(m_pSurface->format)); break; case 2: // 16 bpp *reinterpret_cast<Uint16*>(PixelOffset) = static_cast<Uint16>(MixColor(ReadPoint(Point), PointColor).SDLColor(m_pSurface->format)); break; case 3: // 24 bpp { Uint32 PixelColor = MixColor(ReadPoint(Point), PointColor).SDLColor(m_pSurface->format); Uint8* pPixelSource = reinterpret_cast<Uint8*>(&PixelColor); Uint8* pPixelDest = reinterpret_cast<Uint8*>(PixelOffset); *pPixelDest = *pPixelSource; *(++pPixelDest) = *(++pPixelSource); *(++pPixelDest) = *(++pPixelSource); break; } case 4: // 32 bpp *reinterpret_cast<Uint32*>(PixelOffset) = static_cast<Uint32>(MixColor(ReadPoint(Point), PointColor).SDLColor(m_pSurface->format)); break; default: throw(Wg_Ex_SDL("CPainter::DrawPoint : Unrecognized BytesPerPixel.")); break; } UnlockSurface(); } }