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