mirror of
https://github.com/opencv/opencv.git
synced 2024-11-24 03:00:14 +08:00
Address several comments
This commit is contained in:
parent
1dee848d3e
commit
9ffb67478f
@ -66,8 +66,7 @@ GAPI_EXPORTS Device create_dx11_device(Device::Ptr device_ptr,
|
|||||||
GAPI_EXPORTS Context create_dx11_context(Context::Ptr ctx_ptr);
|
GAPI_EXPORTS Context create_dx11_context(Context::Ptr ctx_ptr);
|
||||||
|
|
||||||
GAPI_EXPORTS Device create_vaapi_device(Device::Ptr device_ptr,
|
GAPI_EXPORTS Device create_vaapi_device(Device::Ptr device_ptr,
|
||||||
const std::string& device_name,
|
const std::string& device_name);
|
||||||
int file_description = -1);
|
|
||||||
GAPI_EXPORTS Context create_vaapi_context(Context::Ptr ctx_ptr);
|
GAPI_EXPORTS Context create_vaapi_context(Context::Ptr ctx_ptr);
|
||||||
} // namespace onevpl
|
} // namespace onevpl
|
||||||
} // namespace wip
|
} // namespace wip
|
||||||
|
@ -557,7 +557,7 @@ int main(int argc, char *argv[]) {
|
|||||||
}
|
}
|
||||||
gpu_accel_device = cv::util::make_optional(
|
gpu_accel_device = cv::util::make_optional(
|
||||||
cv::gapi::wip::onevpl::create_vaapi_device(reinterpret_cast<void*>(va_handle),
|
cv::gapi::wip::onevpl::create_vaapi_device(reinterpret_cast<void*>(va_handle),
|
||||||
"GPU", device_fd));
|
"GPU"));
|
||||||
gpu_accel_ctx = cv::util::make_optional(
|
gpu_accel_ctx = cv::util::make_optional(
|
||||||
cv::gapi::wip::onevpl::create_vaapi_context(nullptr));
|
cv::gapi::wip::onevpl::create_vaapi_context(nullptr));
|
||||||
#endif // defined(HAVE_VA) || defined(HAVE_VA_INTEL)
|
#endif // defined(HAVE_VA) || defined(HAVE_VA_INTEL)
|
||||||
|
@ -48,21 +48,21 @@ namespace gapi {
|
|||||||
namespace wip {
|
namespace wip {
|
||||||
namespace onevpl {
|
namespace onevpl {
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
struct Aux {
|
struct PlatformSpecificParams {
|
||||||
~Aux() {
|
~PlatformSpecificParams() {
|
||||||
for (int fd : fds) {
|
for (int fd : fds) {
|
||||||
close(fd);
|
close(fd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void remember_fd(int fd) {
|
void track_fd(int fd) {
|
||||||
fds.insert(fd);
|
fds.insert(fd);
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
std::set<int> fds;
|
std::set<int> fds;
|
||||||
};
|
};
|
||||||
#else
|
#else
|
||||||
struct Aux {};
|
struct PlatformSpecificParams {};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::vector<CfgParam> update_param_with_accel_type(std::vector<CfgParam> &¶m_array, AccelType type) {
|
std::vector<CfgParam> update_param_with_accel_type(std::vector<CfgParam> &¶m_array, AccelType type) {
|
||||||
@ -238,11 +238,11 @@ CfgParamDeviceSelector::CfgParamDeviceSelector(const CfgParams& cfg_params) :
|
|||||||
// Unfortunately VAAPI doesn't provide API for extracting initial FD value from VADisplay, which
|
// Unfortunately VAAPI doesn't provide API for extracting initial FD value from VADisplay, which
|
||||||
// value is stored as VADisplay fields, by the way. But, because we here are only one creator
|
// value is stored as VADisplay fields, by the way. But, because we here are only one creator
|
||||||
// of VAAPI device then we will need make cleanup for all allocated resources by ourselfs
|
// of VAAPI device then we will need make cleanup for all allocated resources by ourselfs
|
||||||
//and FD is definitely must be utilized. So, let's use complementary struct `Aux` which
|
//and FD is definitely must be utilized. So, let's use complementary struct `PlatformSpecificParams` which
|
||||||
// represent some kind of 'platform specific data' and which will store opened FD for
|
// represent some kind of 'platform specific data' and which will store opened FD for
|
||||||
// future utilization
|
// future utilization
|
||||||
platform_specific_data.reset (new Aux);
|
platform_specific_data.reset (new PlatformSpecificParams);
|
||||||
platform_specific_data->remember_fd(device_fd);
|
platform_specific_data->track_fd(device_fd);
|
||||||
|
|
||||||
suggested_device = IDeviceSelector::create<Device>(va_handle, "GPU", AccelType::VAAPI);
|
suggested_device = IDeviceSelector::create<Device>(va_handle, "GPU", AccelType::VAAPI);
|
||||||
suggested_context = IDeviceSelector::create<Context>(nullptr, AccelType::VAAPI);
|
suggested_context = IDeviceSelector::create<Context>(nullptr, AccelType::VAAPI);
|
||||||
|
@ -20,7 +20,7 @@ namespace gapi {
|
|||||||
namespace wip {
|
namespace wip {
|
||||||
namespace onevpl {
|
namespace onevpl {
|
||||||
|
|
||||||
class Aux;
|
class PlatformSpecificParams;
|
||||||
std::vector<CfgParam> update_param_with_accel_type(std::vector<CfgParam> &¶m_array, AccelType type);
|
std::vector<CfgParam> update_param_with_accel_type(std::vector<CfgParam> &¶m_array, AccelType type);
|
||||||
|
|
||||||
struct GAPI_EXPORTS CfgParamDeviceSelector final: public IDeviceSelector {
|
struct GAPI_EXPORTS CfgParamDeviceSelector final: public IDeviceSelector {
|
||||||
@ -40,7 +40,7 @@ struct GAPI_EXPORTS CfgParamDeviceSelector final: public IDeviceSelector {
|
|||||||
private:
|
private:
|
||||||
Device suggested_device;
|
Device suggested_device;
|
||||||
Context suggested_context;
|
Context suggested_context;
|
||||||
std::unique_ptr<Aux> platform_specific_data;
|
std::unique_ptr<PlatformSpecificParams> platform_specific_data;
|
||||||
};
|
};
|
||||||
} // namespace onevpl
|
} // namespace onevpl
|
||||||
} // namespace wip
|
} // namespace wip
|
||||||
|
@ -120,8 +120,7 @@ Context create_dx11_context(Context::Ptr ctx_ptr) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Device create_vaapi_device(Device::Ptr device_ptr,
|
Device create_vaapi_device(Device::Ptr device_ptr,
|
||||||
const std::string& device_name,
|
const std::string& device_name) {
|
||||||
int /*file_description*/) {
|
|
||||||
return detail::DeviceContextCreator::create_entity<Device>(device_ptr,
|
return detail::DeviceContextCreator::create_entity<Device>(device_ptr,
|
||||||
device_name,
|
device_name,
|
||||||
AccelType::VAAPI);
|
AccelType::VAAPI);
|
||||||
|
Loading…
Reference in New Issue
Block a user