From 9ffb67478fd42319b3dd42c43026daaf6587a0e2 Mon Sep 17 00:00:00 2001 From: SergeyIvanov87 Date: Wed, 13 Jul 2022 18:49:48 +0300 Subject: [PATCH] Address several comments --- .../opencv2/gapi/streaming/onevpl/accel_types.hpp | 3 +-- modules/gapi/samples/onevpl_infer_single_roi.cpp | 2 +- .../streaming/onevpl/cfg_param_device_selector.cpp | 14 +++++++------- .../streaming/onevpl/cfg_param_device_selector.hpp | 4 ++-- .../streaming/onevpl/device_selector_interface.cpp | 3 +-- 5 files changed, 12 insertions(+), 14 deletions(-) diff --git a/modules/gapi/include/opencv2/gapi/streaming/onevpl/accel_types.hpp b/modules/gapi/include/opencv2/gapi/streaming/onevpl/accel_types.hpp index 119188d96a..b670aebd1d 100644 --- a/modules/gapi/include/opencv2/gapi/streaming/onevpl/accel_types.hpp +++ b/modules/gapi/include/opencv2/gapi/streaming/onevpl/accel_types.hpp @@ -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 Device create_vaapi_device(Device::Ptr device_ptr, - const std::string& device_name, - int file_description = -1); + const std::string& device_name); GAPI_EXPORTS Context create_vaapi_context(Context::Ptr ctx_ptr); } // namespace onevpl } // namespace wip diff --git a/modules/gapi/samples/onevpl_infer_single_roi.cpp b/modules/gapi/samples/onevpl_infer_single_roi.cpp index 80b1499f30..4734b12f3f 100644 --- a/modules/gapi/samples/onevpl_infer_single_roi.cpp +++ b/modules/gapi/samples/onevpl_infer_single_roi.cpp @@ -557,7 +557,7 @@ int main(int argc, char *argv[]) { } gpu_accel_device = cv::util::make_optional( cv::gapi::wip::onevpl::create_vaapi_device(reinterpret_cast(va_handle), - "GPU", device_fd)); + "GPU")); gpu_accel_ctx = cv::util::make_optional( cv::gapi::wip::onevpl::create_vaapi_context(nullptr)); #endif // defined(HAVE_VA) || defined(HAVE_VA_INTEL) diff --git a/modules/gapi/src/streaming/onevpl/cfg_param_device_selector.cpp b/modules/gapi/src/streaming/onevpl/cfg_param_device_selector.cpp index 050c744447..68d4fce1b9 100644 --- a/modules/gapi/src/streaming/onevpl/cfg_param_device_selector.cpp +++ b/modules/gapi/src/streaming/onevpl/cfg_param_device_selector.cpp @@ -48,21 +48,21 @@ namespace gapi { namespace wip { namespace onevpl { #ifdef __linux__ -struct Aux { - ~Aux() { +struct PlatformSpecificParams { + ~PlatformSpecificParams() { for (int fd : fds) { close(fd); } } - void remember_fd(int fd) { + void track_fd(int fd) { fds.insert(fd); } private: std::set fds; }; #else -struct Aux {}; +struct PlatformSpecificParams {}; #endif std::vector update_param_with_accel_type(std::vector &¶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 // 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 - //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 // future utilization - platform_specific_data.reset (new Aux); - platform_specific_data->remember_fd(device_fd); + platform_specific_data.reset (new PlatformSpecificParams); + platform_specific_data->track_fd(device_fd); suggested_device = IDeviceSelector::create(va_handle, "GPU", AccelType::VAAPI); suggested_context = IDeviceSelector::create(nullptr, AccelType::VAAPI); diff --git a/modules/gapi/src/streaming/onevpl/cfg_param_device_selector.hpp b/modules/gapi/src/streaming/onevpl/cfg_param_device_selector.hpp index 14c3998f13..f7672ce924 100644 --- a/modules/gapi/src/streaming/onevpl/cfg_param_device_selector.hpp +++ b/modules/gapi/src/streaming/onevpl/cfg_param_device_selector.hpp @@ -20,7 +20,7 @@ namespace gapi { namespace wip { namespace onevpl { -class Aux; +class PlatformSpecificParams; std::vector update_param_with_accel_type(std::vector &¶m_array, AccelType type); struct GAPI_EXPORTS CfgParamDeviceSelector final: public IDeviceSelector { @@ -40,7 +40,7 @@ struct GAPI_EXPORTS CfgParamDeviceSelector final: public IDeviceSelector { private: Device suggested_device; Context suggested_context; - std::unique_ptr platform_specific_data; + std::unique_ptr platform_specific_data; }; } // namespace onevpl } // namespace wip diff --git a/modules/gapi/src/streaming/onevpl/device_selector_interface.cpp b/modules/gapi/src/streaming/onevpl/device_selector_interface.cpp index ecc02cd830..9e192cf0a4 100644 --- a/modules/gapi/src/streaming/onevpl/device_selector_interface.cpp +++ b/modules/gapi/src/streaming/onevpl/device_selector_interface.cpp @@ -120,8 +120,7 @@ Context create_dx11_context(Context::Ptr ctx_ptr) { } Device create_vaapi_device(Device::Ptr device_ptr, - const std::string& device_name, - int /*file_description*/) { + const std::string& device_name) { return detail::DeviceContextCreator::create_entity(device_ptr, device_name, AccelType::VAAPI);