mirror of
https://github.com/opencv/opencv.git
synced 2024-11-27 12:40:05 +08:00
videoio(MSMF): backport WITH_MSMF_DXVA flag
This commit is contained in:
parent
3903174f7c
commit
b7bb79c7c8
@ -357,9 +357,12 @@ OCV_OPTION(WITH_LIBV4L "Use libv4l for Video 4 Linux support" OFF
|
||||
OCV_OPTION(WITH_DSHOW "Build VideoIO with DirectShow support" ON
|
||||
VISIBLE_IF WIN32 AND NOT ARM AND NOT WINRT
|
||||
VERIFY HAVE_DSHOW)
|
||||
OCV_OPTION(WITH_MSMF "Build VideoIO with Media Foundation support" ON
|
||||
OCV_OPTION(WITH_MSMF "Build VideoIO with Media Foundation support" NOT MINGW
|
||||
VISIBLE_IF WIN32
|
||||
VERIFY HAVE_MSMF)
|
||||
OCV_OPTION(WITH_MSMF_DXVA "Enable hardware acceleration in Media Foundation backend" WITH_MSMF
|
||||
VISIBLE_IF WIN32
|
||||
VERIFY HAVE_MSMF_DXVA)
|
||||
OCV_OPTION(WITH_XIMEA "Include XIMEA cameras support" OFF
|
||||
VISIBLE_IF NOT ANDROID AND NOT WINRT
|
||||
VERIFY HAVE_XIMEA)
|
||||
@ -1478,6 +1481,7 @@ endif()
|
||||
|
||||
if(WITH_MSMF OR HAVE_MSMF)
|
||||
status(" Media Foundation:" HAVE_MSMF THEN YES ELSE NO)
|
||||
status(" DXVA:" HAVE_MSMF_DXVA THEN YES ELSE NO)
|
||||
endif()
|
||||
|
||||
if(WITH_XIMEA OR HAVE_XIMEA)
|
||||
|
@ -274,14 +274,15 @@ endif(WITH_DSHOW)
|
||||
ocv_clear_vars(HAVE_MSMF)
|
||||
if(WITH_MSMF)
|
||||
check_include_file(Mfapi.h HAVE_MSMF)
|
||||
check_include_file(D3D11.h D3D11_found)
|
||||
check_include_file(D3d11_4.h D3D11_4_found)
|
||||
if(D3D11_found AND D3D11_4_found)
|
||||
set(HAVE_DXVA YES)
|
||||
else()
|
||||
set(HAVE_DXVA NO)
|
||||
set(HAVE_MSMF_DXVA "")
|
||||
if(WITH_MSMF_DXVA)
|
||||
check_include_file(D3D11.h D3D11_found)
|
||||
check_include_file(D3d11_4.h D3D11_4_found)
|
||||
if(D3D11_found AND D3D11_4_found)
|
||||
set(HAVE_MSMF_DXVA YES)
|
||||
endif()
|
||||
endif()
|
||||
endif(WITH_MSMF)
|
||||
endif()
|
||||
|
||||
# --- Extra HighGUI and VideoIO libs on Windows ---
|
||||
if(WIN32)
|
||||
|
@ -85,11 +85,11 @@ if (WIN32 AND HAVE_DSHOW)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (WIN32 AND HAVE_MSMF)
|
||||
if(WIN32 AND HAVE_MSMF)
|
||||
list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_msmf.hpp)
|
||||
list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_msmf.cpp)
|
||||
if (HAVE_DXVA)
|
||||
add_definitions(-DHAVE_DXVA)
|
||||
if(HAVE_MSMF_DXVA)
|
||||
add_definitions(-DHAVE_MSMF_DXVA)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
@ -55,15 +55,15 @@
|
||||
#include <windows.h>
|
||||
#include <guiddef.h>
|
||||
#include <mfidl.h>
|
||||
#include <Mfapi.h>
|
||||
#include <mfapi.h>
|
||||
#include <mfplay.h>
|
||||
#include <mfobjects.h>
|
||||
#include <tchar.h>
|
||||
#include <strsafe.h>
|
||||
#include <Mfreadwrite.h>
|
||||
#ifdef HAVE_DXVA
|
||||
#include <D3D11.h>
|
||||
#include <D3d11_4.h>
|
||||
#ifdef HAVE_MSMF_DXVA
|
||||
#include <d3d11.h>
|
||||
#include <d3d11_4.h>
|
||||
#endif
|
||||
#include <new>
|
||||
#include <map>
|
||||
@ -81,7 +81,7 @@
|
||||
#pragma comment(lib, "mfuuid")
|
||||
#pragma comment(lib, "Strmiids")
|
||||
#pragma comment(lib, "Mfreadwrite")
|
||||
#ifdef HAVE_DXVA
|
||||
#ifdef HAVE_MSMF_DXVA
|
||||
#pragma comment(lib, "d3d11")
|
||||
// MFCreateDXGIDeviceManager() is available since Win8 only.
|
||||
// To avoid OpenCV loading failure on Win7 use dynamic detection of this symbol.
|
||||
@ -710,7 +710,7 @@ protected:
|
||||
cv::String filename;
|
||||
int camid;
|
||||
MSMFCapture_Mode captureMode;
|
||||
#ifdef HAVE_DXVA
|
||||
#ifdef HAVE_MSMF_DXVA
|
||||
_ComPtr<ID3D11Device> D3DDev;
|
||||
_ComPtr<IMFDXGIDeviceManager> D3DMgr;
|
||||
#endif
|
||||
@ -735,7 +735,7 @@ CvCapture_MSMF::CvCapture_MSMF():
|
||||
filename(""),
|
||||
camid(-1),
|
||||
captureMode(MODE_SW),
|
||||
#ifdef HAVE_DXVA
|
||||
#ifdef HAVE_MSMF_DXVA
|
||||
D3DDev(NULL),
|
||||
D3DMgr(NULL),
|
||||
#endif
|
||||
@ -774,7 +774,7 @@ void CvCapture_MSMF::close()
|
||||
|
||||
bool CvCapture_MSMF::configureHW(bool enable)
|
||||
{
|
||||
#ifdef HAVE_DXVA
|
||||
#ifdef HAVE_MSMF_DXVA
|
||||
if ((enable && D3DMgr && D3DDev) || (!enable && !D3DMgr && !D3DDev))
|
||||
return true;
|
||||
if (!pMFCreateDXGIDeviceManager_initialized)
|
||||
@ -971,7 +971,7 @@ bool CvCapture_MSMF::open(int _index)
|
||||
SUCCEEDED(srAttr->SetUINT32(MF_SOURCE_READER_ENABLE_VIDEO_PROCESSING, FALSE)) &&
|
||||
SUCCEEDED(srAttr->SetUINT32(MF_SOURCE_READER_ENABLE_ADVANCED_VIDEO_PROCESSING, TRUE)))
|
||||
{
|
||||
#ifdef HAVE_DXVA
|
||||
#ifdef HAVE_MSMF_DXVA
|
||||
if (D3DMgr)
|
||||
srAttr->SetUnknown(MF_SOURCE_READER_D3D_MANAGER, D3DMgr.Get());
|
||||
#endif
|
||||
@ -1022,7 +1022,7 @@ bool CvCapture_MSMF::open(const cv::String& _filename)
|
||||
SUCCEEDED(srAttr->SetUINT32(MF_SOURCE_READER_ENABLE_ADVANCED_VIDEO_PROCESSING, true))
|
||||
)
|
||||
{
|
||||
#ifdef HAVE_DXVA
|
||||
#ifdef HAVE_MSMF_DXVA
|
||||
if(D3DMgr)
|
||||
srAttr->SetUnknown(MF_SOURCE_READER_D3D_MANAGER, D3DMgr.Get());
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user