STDMETHODIMP CDecDXVA2::PostConnect(IPin *pPin) { HRESULT hr = S_OK; if (!m_bNative && m_pD3DDevMngr) return S_OK; DbgLog((LOG_TRACE, 10, L"CDecDXVA2::PostConnect()")); IMFGetService *pGetService = nullptr; hr = pPin->QueryInterface(__uuidof(IMFGetService), (void**)&pGetService); if (FAILED(hr)) { DbgLog((LOG_ERROR, 10, L"-> IMFGetService not available")); goto done; } // Release old D3D resources, we're about to re-init m_pCallback->ReleaseAllDXVAResources(); FreeD3DResources(); // Get the Direct3D device manager. hr = pGetService->GetService(MR_VIDEO_ACCELERATION_SERVICE, __uuidof(IDirect3DDeviceManager9), (void**)&m_pD3DDevMngr); if (FAILED(hr)) { DbgLog((LOG_ERROR, 10, L"-> D3D Device Manager not available")); goto done; } hr = SetD3DDeviceManager(m_pD3DDevMngr); if (FAILED(hr)) { DbgLog((LOG_ERROR, 10, L"-> Setting D3D Device Manager faield")); goto done; } if (m_bNative) { if (!m_pDecoder) { // If this is the first call, re-align surfaces, as the requirements may only be known now m_dwSurfaceWidth = GetAlignedDimension(m_pAVCtx->coded_width); m_dwSurfaceHeight = GetAlignedDimension(m_pAVCtx->coded_height); } CMediaType mt = m_pCallback->GetOutputMediaType(); if (mt.subtype != MEDIASUBTYPE_NV12) { DbgLog((LOG_ERROR, 10, L"-> Connection is not NV12")); hr = E_FAIL; goto done; } hr = DXVA2NotifyEVR(); } done: SafeRelease(&pGetService); if (FAILED(hr)) { FreeD3DResources(); } return hr; }
STDMETHODIMP CDecDXVA2::PostConnect(IPin *pPin) { HRESULT hr = S_OK; if (!m_bNative && m_pD3DDevMngr) return S_OK; DbgLog((LOG_TRACE, 10, L"CDecDXVA2::PostConnect()")); IMFGetService *pGetService = NULL; hr = pPin->QueryInterface(__uuidof(IMFGetService), (void**)&pGetService); if (FAILED(hr)) { DbgLog((LOG_ERROR, 10, L"-> IMFGetService not available")); goto done; } // Release old D3D resources, we're about to re-init m_pCallback->ReleaseAllDXVAResources(); FreeD3DResources(); // Get the Direct3D device manager. hr = pGetService->GetService(MR_VIDEO_ACCELERATION_SERVICE, __uuidof(IDirect3DDeviceManager9), (void**)&m_pD3DDevMngr); if (FAILED(hr)) { DbgLog((LOG_ERROR, 10, L"-> D3D Device Manager not available")); goto done; } hr = SetD3DDeviceManager(m_pD3DDevMngr); if (FAILED(hr)) { DbgLog((LOG_ERROR, 10, L"-> Setting D3D Device Manager faield")); goto done; } if (m_bNative) { CMediaType mt = m_pCallback->GetOutputMediaType(); if (mt.subtype != MEDIASUBTYPE_NV12) { DbgLog((LOG_ERROR, 10, L"-> Connection is not NV12")); hr = E_FAIL; goto done; } hr = DXVA2NotifyEVR(); } done: SafeRelease(&pGetService); if (FAILED(hr)) { FreeD3DResources(); } return hr; }
STDMETHODIMP CDecDXVA2::DestroyDecoder(bool bFull, bool bNoAVCodec) { SafeRelease(&m_pDecoder); m_pCallback->ReleaseAllDXVAResources(); for (int i = 0; i < m_NumSurfaces; i++) { SafeRelease(&m_pSurfaces[i].d3d); } m_NumSurfaces = 0; for (int i = 0; i < DXVA2_QUEUE_SURFACES; i++) { SAFE_CO_FREE(m_FrameQueue[i]); } if (!bNoAVCodec) { if (m_pAVCtx) { av_freep(&m_pAVCtx->hwaccel_context); } CDecAvcodec::DestroyDecoder(); } if (bFull) { FreeD3DResources(); } return S_OK; }
STDMETHODIMP CDecDXVA2::DestroyDecoder(bool bFull, bool bNoAVCodec) { for (int i = 0; i < DXVA2_QUEUE_SURFACES; i++) { ReleaseFrame(&m_FrameQueue[i]); } m_pCallback->ReleaseAllDXVAResources(); for (int i = 0; i < m_NumSurfaces; i++) { SafeRelease(&m_pSurfaces[i].d3d); } m_NumSurfaces = 0; SafeRelease(&m_pDecoder); if (!bNoAVCodec) { CDecAvcodec::DestroyDecoder(); } if (bFull) { FreeD3DResources(); } return S_OK; }