mirror of
https://github.com/opencv/opencv.git
synced 2025-06-07 17:44:04 +08:00
implemented sample build in fallback mode without interop
This commit is contained in:
parent
f533c05644
commit
22bb5d1fcc
@ -12,7 +12,7 @@ endif()
|
|||||||
|
|
||||||
if(VA_INCLUDE_DIR)
|
if(VA_INCLUDE_DIR)
|
||||||
set(HAVE_VA TRUE)
|
set(HAVE_VA TRUE)
|
||||||
set(VA_LIBRARIES "-lva")
|
set(VA_LIBRARIES "-lva" "-lva-x11")
|
||||||
else()
|
else()
|
||||||
set(HAVE_VA FALSE)
|
set(HAVE_VA FALSE)
|
||||||
message(WARNING "libva installation is not found.")
|
message(WARNING "libva installation is not found.")
|
||||||
|
@ -22,7 +22,7 @@ if((NOT ANDROID) AND HAVE_OPENGL)
|
|||||||
add_subdirectory(opengl)
|
add_subdirectory(opengl)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(UNIX AND NOT ANDROID AND HAVE_VA_INTEL)
|
if(UNIX AND NOT ANDROID AND (HAVE_VA OR HAVE_VA_INTEL))
|
||||||
add_subdirectory(va_intel)
|
add_subdirectory(va_intel)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND)
|
|||||||
set(the_target "example_${project}_${name}")
|
set(the_target "example_${project}_${name}")
|
||||||
add_executable(${the_target} ${srcs})
|
add_executable(${the_target} ${srcs})
|
||||||
|
|
||||||
ocv_target_link_libraries(${the_target} ${OPENCV_LINKER_LIBS} ${OPENCV_VA_INTEL_SAMPLES_REQUIRED_DEPS} ${VA_INTEL_LIBRARIES})
|
ocv_target_link_libraries(${the_target} ${OPENCV_LINKER_LIBS} ${OPENCV_VA_INTEL_SAMPLES_REQUIRED_DEPS} ${VA_LIBRARIES} ${VA_INTEL_LIBRARIES})
|
||||||
|
|
||||||
set_target_properties(${the_target} PROPERTIES
|
set_target_properties(${the_target} PROPERTIES
|
||||||
OUTPUT_NAME "${project}-example-${name}"
|
OUTPUT_NAME "${project}-example-${name}"
|
||||||
|
@ -7,24 +7,38 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include "cvconfig.h"
|
||||||
|
|
||||||
#include <va/va.h>
|
#include <va/va.h>
|
||||||
#include <va/va_drm.h>
|
#if defined(HAVE_VA_INTEL)
|
||||||
|
# include <va/va_drm.h>
|
||||||
|
#elif defined(HAVE_VA)
|
||||||
|
# include <va/va_x11.h>
|
||||||
|
# include <X11/Xlib.h>
|
||||||
|
#endif //HAVE_VA_INTEL / HAVE_VA
|
||||||
|
|
||||||
|
namespace va {
|
||||||
|
|
||||||
|
#if defined(HAVE_VA_INTEL) || defined(HAVE_VA)
|
||||||
|
|
||||||
|
bool openDisplay();
|
||||||
|
void closeDisplay();
|
||||||
|
|
||||||
|
VADisplay display = NULL;
|
||||||
|
bool initialized = false;
|
||||||
|
|
||||||
|
#endif //HAVE_VA_INTEL || HAVE_VA
|
||||||
|
|
||||||
|
#if defined(HAVE_VA_INTEL)
|
||||||
|
|
||||||
#define VA_INTEL_PCI_DIR "/sys/bus/pci/devices"
|
#define VA_INTEL_PCI_DIR "/sys/bus/pci/devices"
|
||||||
#define VA_INTEL_DRI_DIR "/dev/dri/"
|
#define VA_INTEL_DRI_DIR "/dev/dri/"
|
||||||
#define VA_INTEL_PCI_DISPLAY_CONTROLLER_CLASS 0x03
|
#define VA_INTEL_PCI_DISPLAY_CONTROLLER_CLASS 0x03
|
||||||
|
|
||||||
namespace va {
|
|
||||||
|
|
||||||
static unsigned readId(const char* devName, const char* idName);
|
static unsigned readId(const char* devName, const char* idName);
|
||||||
static int findAdapter(unsigned desiredVendorId);
|
static int findAdapter(unsigned desiredVendorId);
|
||||||
|
|
||||||
bool openDisplay();
|
|
||||||
void closeDisplay();
|
|
||||||
|
|
||||||
int drmfd = -1;
|
int drmfd = -1;
|
||||||
VADisplay display = NULL;
|
|
||||||
bool initialized = false;
|
|
||||||
|
|
||||||
class Directory
|
class Directory
|
||||||
{
|
{
|
||||||
@ -205,4 +219,53 @@ void closeDisplay()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#elif defined(HAVE_VA)
|
||||||
|
|
||||||
|
static Display* x11Display = 0;
|
||||||
|
|
||||||
|
bool openDisplay()
|
||||||
|
{
|
||||||
|
if (!initialized)
|
||||||
|
{
|
||||||
|
display = 0;
|
||||||
|
|
||||||
|
x11Display = XOpenDisplay("");
|
||||||
|
if (x11Display != 0)
|
||||||
|
{
|
||||||
|
display = vaGetDisplay(x11Display);
|
||||||
|
if (display)
|
||||||
|
{
|
||||||
|
int majorVersion = 0, minorVersion = 0;
|
||||||
|
if (vaInitialize(display, &majorVersion, &minorVersion) == VA_STATUS_SUCCESS)
|
||||||
|
{
|
||||||
|
initialized = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
display = 0;
|
||||||
|
}
|
||||||
|
XCloseDisplay(x11Display);
|
||||||
|
x11Display = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false; // Can't initialize X11/VA display
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void closeDisplay()
|
||||||
|
{
|
||||||
|
if (initialized)
|
||||||
|
{
|
||||||
|
if (display)
|
||||||
|
vaTerminate(display);
|
||||||
|
if (x11Display)
|
||||||
|
XCloseDisplay(x11Display);
|
||||||
|
display = 0;
|
||||||
|
x11Display = 0;
|
||||||
|
initialized = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // HAVE_VA_INTEL / HAVE_VA
|
||||||
|
|
||||||
} // namespace va
|
} // namespace va
|
||||||
|
@ -42,6 +42,7 @@
|
|||||||
#include "opencv2/core.hpp"
|
#include "opencv2/core.hpp"
|
||||||
#include "opencv2/imgproc.hpp"
|
#include "opencv2/imgproc.hpp"
|
||||||
#include "opencv2/core/va_intel.hpp"
|
#include "opencv2/core/va_intel.hpp"
|
||||||
|
#include "cvconfig.h"
|
||||||
|
|
||||||
#define CHECK_VASTATUS(va_status,func) \
|
#define CHECK_VASTATUS(va_status,func) \
|
||||||
if (va_status != VA_STATUS_SUCCESS) { \
|
if (va_status != VA_STATUS_SUCCESS) { \
|
||||||
@ -362,14 +363,20 @@ public:
|
|||||||
{
|
{
|
||||||
int n = 0;
|
int n = 0;
|
||||||
m_files[0] = m_files[1] = 0;
|
m_files[0] = m_files[1] = 0;
|
||||||
|
#if defined(HAVE_VA_INTEL)
|
||||||
m_interop = true;
|
m_interop = true;
|
||||||
|
#elif defined(HAVE_VA)
|
||||||
|
m_interop = false;
|
||||||
|
#endif //HAVE_VA_INTEL / HAVE_VA
|
||||||
for (int i = 1; i < m_argc; ++i)
|
for (int i = 1; i < m_argc; ++i)
|
||||||
{
|
{
|
||||||
const char *arg = m_argv[i];
|
const char *arg = m_argv[i];
|
||||||
if (arg[0] == '-') // option
|
if (arg[0] == '-') // option
|
||||||
{
|
{
|
||||||
|
#if defined(HAVE_VA_INTEL)
|
||||||
if (!strcmp(arg, "-f"))
|
if (!strcmp(arg, "-f"))
|
||||||
m_interop = false;
|
m_interop = false;
|
||||||
|
#endif //HAVE_VA_INTEL
|
||||||
}
|
}
|
||||||
else // parameter
|
else // parameter
|
||||||
{
|
{
|
||||||
@ -400,8 +407,15 @@ int main(int argc, char** argv)
|
|||||||
if (!cmd.run())
|
if (!cmd.run())
|
||||||
{
|
{
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
|
#if defined(HAVE_VA_INTEL)
|
||||||
"Usage: va_intel_interop [-f] file1 file2\n\n"
|
"Usage: va_intel_interop [-f] file1 file2\n\n"
|
||||||
|
"Interop ON/OFF version\n\n"
|
||||||
"where: -f option indicates interop is off (fallback mode); interop is on by default\n"
|
"where: -f option indicates interop is off (fallback mode); interop is on by default\n"
|
||||||
|
#elif defined(HAVE_VA)
|
||||||
|
"Usage: va_intel_interop file1 file2\n\n"
|
||||||
|
"Interop OFF only version\n\n"
|
||||||
|
"where:\n"
|
||||||
|
#endif //HAVE_VA_INTEL / HAVE_VA
|
||||||
" file1 is to be created, contains original surface data (NV12)\n"
|
" file1 is to be created, contains original surface data (NV12)\n"
|
||||||
" file2 is to be created, contains processed surface data (NV12)\n");
|
" file2 is to be created, contains processed surface data (NV12)\n");
|
||||||
exit(0);
|
exit(0);
|
||||||
|
Loading…
Reference in New Issue
Block a user