Commit 5feca50f authored by Alexey Ershov's avatar Alexey Ershov

changed device detection procedure, added resizing surface to bigger size

removed unused context_id2; changed blur size 7x7 to 3x3; added short comments
removed unnecessary call to convertFromVASurface()
replaced dumpSurface() with writeImage()
added infile cmdline parameter, input image loaded by imread()
parent 95339827
......@@ -12,7 +12,7 @@ endif()
if(VA_INCLUDE_DIR)
set(HAVE_VA TRUE)
set(VA_LIBRARIES "-lva" "-lva-x11")
set(VA_LIBRARIES "-lva" "-lva-drm")
else()
set(HAVE_VA FALSE)
message(WARNING "libva installation is not found.")
......
......@@ -10,27 +10,16 @@
#include "cvconfig.h"
#include <va/va.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_DRI_DIR "/dev/dri/"
#define VA_INTEL_PCI_DISPLAY_CONTROLLER_CLASS 0x03
......@@ -161,93 +150,74 @@ private:
char* paths[NUM_NODES];
};
bool openDisplay()
static bool openDeviceIntel();
static bool openDeviceGeneric();
static bool openDeviceIntel()
{
if (!initialized)
{
const unsigned IntelVendorID = 0x8086;
const unsigned IntelVendorID = 0x8086;
drmfd = -1;
display = 0;
int adapterIndex = findAdapter(IntelVendorID);
if (adapterIndex >= 0)
{
NodeInfo nodes(adapterIndex);
int adapterIndex = findAdapter(IntelVendorID);
if (adapterIndex >= 0)
for (int i = 0; i < nodes.count(); ++i)
{
NodeInfo nodes(adapterIndex);
for (int i = 0; i < nodes.count(); ++i)
drmfd = open(nodes.path(i), O_RDWR);
if (drmfd >= 0)
{
drmfd = open(nodes.path(i), O_RDWR);
if (drmfd >= 0)
{
display = vaGetDisplayDRM(drmfd);
if (display)
{
int majorVersion = 0, minorVersion = 0;
if (vaInitialize(display, &majorVersion, &minorVersion) == VA_STATUS_SUCCESS)
{
initialized = true;
return true;
}
display = 0;
}
close(drmfd);
drmfd = -1;
}
display = vaGetDisplayDRM(drmfd);
if (display)
return true;
close(drmfd);
drmfd = -1;
}
}
if (adapterIndex < 0)
return false; // Can't find Intel display adapter
if ((drmfd < 0) || !display)
return false; // Can't load VA display
}
return true;
return false;
}
void closeDisplay()
static bool openDeviceGeneric()
{
if (initialized)
static const char* device_paths[] = { "/dev/dri/renderD128", "/dev/dri/card0" };
static const int num_devices = sizeof(device_paths) / sizeof(device_paths[0]);
for (int i = 0; i < num_devices; ++i)
{
if (display)
vaTerminate(display);
drmfd = open(device_paths[i], O_RDWR);
if (drmfd >= 0)
{
display = vaGetDisplayDRM(drmfd);
if (display)
return true;
close(drmfd);
display = 0;
drmfd = -1;
initialized = false;
drmfd = -1;
}
}
return false;
}
#elif defined(HAVE_VA)
static Display* x11Display = 0;
bool openDisplay()
{
if (!initialized)
{
drmfd = -1;
display = 0;
x11Display = XOpenDisplay("");
if (x11Display != 0)
if (openDeviceIntel() || openDeviceGeneric())
{
display = vaGetDisplay(x11Display);
if (display)
int majorVersion = 0, minorVersion = 0;
if (vaInitialize(display, &majorVersion, &minorVersion) == VA_STATUS_SUCCESS)
{
int majorVersion = 0, minorVersion = 0;
if (vaInitialize(display, &majorVersion, &minorVersion) == VA_STATUS_SUCCESS)
{
initialized = true;
return true;
}
display = 0;
initialized = true;
return true;
}
XCloseDisplay(x11Display);
x11Display = 0;
close(drmfd);
display = 0;
drmfd = -1;
}
return false; // Can't initialize X11/VA display
return false; // Can't open VA display
}
return true;
}
......@@ -258,14 +228,12 @@ void closeDisplay()
{
if (display)
vaTerminate(display);
if (x11Display)
XCloseDisplay(x11Display);
if (drmfd >= 0)
close(drmfd);
display = 0;
x11Display = 0;
drmfd = -1;
initialized = false;
}
}
#endif // HAVE_VA_INTEL / HAVE_VA
} // namespace va
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment