mirror of
https://github.com/opencv/opencv.git
synced 2025-06-07 17:44:04 +08:00
samples(va): fix build warnings, use cv::format()
This commit is contained in:
parent
3dd55d284d
commit
a40d308d6a
@ -10,6 +10,8 @@
|
|||||||
#include <va/va.h>
|
#include <va/va.h>
|
||||||
# include <va/va_drm.h>
|
# include <va/va_drm.h>
|
||||||
|
|
||||||
|
#include "opencv2/core.hpp" // cv::format()
|
||||||
|
|
||||||
namespace va {
|
namespace va {
|
||||||
|
|
||||||
bool openDisplay();
|
bool openDisplay();
|
||||||
@ -70,10 +72,9 @@ static unsigned readId(const char* devName, const char* idName)
|
|||||||
{
|
{
|
||||||
long int id = 0;
|
long int id = 0;
|
||||||
|
|
||||||
char fileName[256];
|
std::string fileName = cv::format("%s/%s/%s", VA_INTEL_PCI_DIR, devName, idName);
|
||||||
snprintf(fileName, sizeof(fileName), "%s/%s/%s", VA_INTEL_PCI_DIR, devName, idName);
|
|
||||||
|
|
||||||
FILE* file = fopen(fileName, "r");
|
FILE* file = fopen(fileName.c_str(), "r");
|
||||||
if (file)
|
if (file)
|
||||||
{
|
{
|
||||||
char str[16] = "";
|
char str[16] = "";
|
||||||
@ -100,9 +101,8 @@ static int findAdapter(unsigned desiredVendorId)
|
|||||||
unsigned vendorId = readId(name, "vendor");
|
unsigned vendorId = readId(name, "vendor");
|
||||||
if (vendorId == desiredVendorId)
|
if (vendorId == desiredVendorId)
|
||||||
{
|
{
|
||||||
char subdirName[256];
|
std::string subdirName = cv::format("%s/%s/%s", VA_INTEL_PCI_DIR, name, "drm");
|
||||||
snprintf(subdirName, sizeof(subdirName), "%s/%s/%s", VA_INTEL_PCI_DIR, name, "drm");
|
Directory subdir(subdirName.c_str());
|
||||||
Directory subdir(subdirName);
|
|
||||||
for (int j = 0; j < subdir.count(); ++j)
|
for (int j = 0; j < subdir.count(); ++j)
|
||||||
{
|
{
|
||||||
if (!strncmp(subdir[j]->d_name, "card", 4))
|
if (!strncmp(subdir[j]->d_name, "card", 4))
|
||||||
@ -130,18 +130,12 @@ public:
|
|||||||
numbers[1] = adapterIndex;
|
numbers[1] = adapterIndex;
|
||||||
for (int i = 0; i < NUM_NODES; ++i)
|
for (int i = 0; i < NUM_NODES; ++i)
|
||||||
{
|
{
|
||||||
int sz = sizeof(VA_INTEL_DRI_DIR) + strlen(names[i]) + 3;
|
paths[i] = cv::format("%s%s%d", VA_INTEL_DRI_DIR, names[i], numbers[i]);
|
||||||
paths[i] = new char [sz];
|
|
||||||
snprintf(paths[i], sz, "%s%s%d", VA_INTEL_DRI_DIR, names[i], numbers[i]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
~NodeInfo()
|
~NodeInfo()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < NUM_NODES; ++i)
|
// nothing
|
||||||
{
|
|
||||||
delete paths[i];
|
|
||||||
paths[i] = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
int count() const
|
int count() const
|
||||||
{
|
{
|
||||||
@ -149,10 +143,10 @@ public:
|
|||||||
}
|
}
|
||||||
const char* path(int index) const
|
const char* path(int index) const
|
||||||
{
|
{
|
||||||
return ((index >= 0) && (index < NUM_NODES)) ? paths[index] : 0;
|
return ((index >= 0) && (index < NUM_NODES)) ? paths[index].c_str() : 0;
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
char* paths[NUM_NODES];
|
std::string paths[NUM_NODES];
|
||||||
};
|
};
|
||||||
|
|
||||||
static bool openDeviceIntel();
|
static bool openDeviceIntel();
|
||||||
|
Loading…
Reference in New Issue
Block a user