mirror of
https://github.com/opencv/opencv.git
synced 2026-07-30 07:43:03 +04:00
Copy mpashchenkov's changes
Minor refactoring Partially address review comments Move DX-related stuff from the sample to a default source Simplify the default OneVPL config Address minor review comments Add class for the default VPL source WIP: Add initial stub for tests with description Removing default vpl source and minor refactoring Refactor default files Fix build and application crash Address review comments Add test on VPL + OCL interaction compared to CPU behavior Fix test
This commit is contained in:
@@ -65,7 +65,6 @@ MediaFrame::View VPLMediaFrameCPUAdapter::access(MediaFrame::Access) {
|
||||
|
||||
cv::util::any VPLMediaFrameCPUAdapter::blobParams() const {
|
||||
throw std::runtime_error("VPLMediaFrameCPUAdapter::blobParams() is not implemented");
|
||||
return {};
|
||||
}
|
||||
|
||||
void VPLMediaFrameCPUAdapter::serialize(cv::gapi::s11n::IOStream&) {
|
||||
|
||||
@@ -114,17 +114,24 @@ MediaFrame::View VPLMediaFrameDX11Adapter::access(MediaFrame::Access mode) {
|
||||
}
|
||||
}
|
||||
|
||||
cv::util::any VPLMediaFrameDX11Adapter::blobParams() const {
|
||||
/*GAPI_Assert(false && "VPLMediaFrameDX11Adapter::blobParams() is not fully integrated"
|
||||
"in OpenVINO InferenceEngine and would be temporary disable.");*/
|
||||
#ifdef HAVE_INF_ENGINE
|
||||
mfxHDLPair VPLMediaFrameDX11Adapter::getHandle() const {
|
||||
auto surface_ptr_copy = get_surface();
|
||||
Surface::data_t& data = surface_ptr_copy->get_data();
|
||||
const Surface::info_t& info = surface_ptr_copy->get_info();
|
||||
const Surface::data_t& data = surface_ptr_copy->get_data();
|
||||
NativeHandleAdapter* native_handle_getter = reinterpret_cast<NativeHandleAdapter*>(data.MemId);
|
||||
|
||||
mfxHDLPair handle{};
|
||||
native_handle_getter->get_handle(data.MemId, reinterpret_cast<mfxHDL&>(handle));
|
||||
return handle;
|
||||
}
|
||||
|
||||
cv::util::any VPLMediaFrameDX11Adapter::blobParams() const {
|
||||
/*GAPI_Assert(false && "VPLMediaFrameDX11Adapter::blobParams() is not fully integrated"
|
||||
"in OpenVINO InferenceEngine and would be temporary disable.");*/
|
||||
#ifdef HAVE_INF_ENGINE
|
||||
mfxHDLPair handle = getHandle();
|
||||
|
||||
auto surface_ptr_copy = get_surface();
|
||||
const Surface::info_t& info = surface_ptr_copy->get_info();
|
||||
|
||||
GAPI_Assert(frame_desc.fmt == MediaFormat::NV12 &&
|
||||
"blobParams() for VPLMediaFrameDX11Adapter supports NV12 only");
|
||||
|
||||
@@ -37,6 +37,11 @@ public:
|
||||
GAPI_EXPORTS ~VPLMediaFrameDX11Adapter();
|
||||
MediaFrame::View access(MediaFrame::Access) override;
|
||||
|
||||
// FIXME: Consider a better solution since this approach
|
||||
// is not easily extendable for other adapters (oclcore.cpp)
|
||||
// FIXME: Use with caution since the handle might become invalid
|
||||
// due to reference counting
|
||||
mfxHDLPair getHandle() const;
|
||||
// The default implementation does nothing
|
||||
cv::util::any blobParams() const override;
|
||||
void serialize(cv::gapi::s11n::IOStream&) override;
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace gapi {
|
||||
namespace wip {
|
||||
namespace onevpl {
|
||||
|
||||
class PlatformSpecificParams;
|
||||
struct PlatformSpecificParams;
|
||||
std::vector<CfgParam> update_param_with_accel_type(std::vector<CfgParam> &¶m_array, AccelType type);
|
||||
|
||||
struct GAPI_EXPORTS CfgParamDeviceSelector final: public IDeviceSelector {
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
// This file is part of OpenCV project.
|
||||
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||
// of this distribution and at http://opencv.org/license.html.
|
||||
//
|
||||
// Copyright (C) 2022 Intel Corporation
|
||||
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
|
||||
#include <opencv2/gapi/streaming/onevpl/default.hpp>
|
||||
#include <opencv2/gapi/streaming/onevpl/cfg_params.hpp>
|
||||
#include <opencv2/gapi/streaming/onevpl/device_selector_interface.hpp>
|
||||
|
||||
#include "cfg_param_device_selector.hpp"
|
||||
|
||||
#ifdef HAVE_ONEVPL
|
||||
|
||||
namespace cv {
|
||||
namespace gapi {
|
||||
namespace wip {
|
||||
namespace onevpl {
|
||||
|
||||
std::shared_ptr<IDeviceSelector> getDefaultDeviceSelector(const std::vector<CfgParam>& cfg_params) {
|
||||
std::shared_ptr<CfgParamDeviceSelector> default_accel_contex(new CfgParamDeviceSelector(cfg_params));
|
||||
|
||||
return default_accel_contex;
|
||||
}
|
||||
|
||||
} // namespace onevpl
|
||||
} // namespace wip
|
||||
} // namespace gapi
|
||||
} // namespace cv
|
||||
|
||||
#else // HAVE_ONEVPL
|
||||
|
||||
namespace cv {
|
||||
namespace gapi {
|
||||
namespace wip {
|
||||
namespace onevpl {
|
||||
|
||||
std::shared_ptr<IDeviceSelector> getDefaultDeviceSelector(const std::vector<CfgParam>&) {
|
||||
std::cerr << "Cannot utilize getDefaultVPLDeviceAndCtx without HAVE_ONEVPL enabled" << std::endl;
|
||||
util::throw_error(std::logic_error("Cannot utilize getDefaultVPLDeviceAndCtx without HAVE_ONEVPL enabled"));
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
} // namespace onevpl
|
||||
} // namespace wip
|
||||
} // namespace gapi
|
||||
} // namespace cv
|
||||
|
||||
#endif // HAVE_ONEVPL
|
||||
@@ -251,7 +251,8 @@ VPLLegacyDecodeEngine::SessionParam VPLLegacyDecodeEngine::prepare_session_param
|
||||
|
||||
}
|
||||
|
||||
decRequest.Type |= MFX_MEMTYPE_EXTERNAL_FRAME | MFX_MEMTYPE_FROM_DECODE | MFX_MEMTYPE_FROM_VPPIN;
|
||||
decRequest.Type |= MFX_MEMTYPE_EXTERNAL_FRAME | MFX_MEMTYPE_FROM_DECODE |
|
||||
MFX_MEMTYPE_FROM_VPPIN | MFX_MEMTYPE_SHARED_RESOURCE;
|
||||
VPLAccelerationPolicy::pool_key_t decode_pool_key =
|
||||
acceleration_policy->create_surface_pool(decRequest, mfxDecParams.mfx.FrameInfo);
|
||||
|
||||
|
||||
@@ -281,7 +281,7 @@ pp_session VPPPreprocEngine::initialize_preproc(const pp_params& initial_frame_p
|
||||
vppRequests[1].AllocId = std::numeric_limits<uint16_t>::max() - request_id++;
|
||||
GAPI_Assert(request_id != std::numeric_limits<uint16_t>::max() && "Something wrong");
|
||||
|
||||
vppRequests[1].Type |= MFX_MEMTYPE_FROM_VPPIN;
|
||||
vppRequests[1].Type |= MFX_MEMTYPE_FROM_VPPIN | MFX_MEMTYPE_SHARED_RESOURCE;
|
||||
vpp_out_pool_key = acceleration_policy->create_surface_pool(vppRequests[1],
|
||||
mfxVPPParams.vpp.Out);
|
||||
|
||||
|
||||
@@ -429,4 +429,5 @@ std::string ext_mem_frame_type_to_cstr(int type) {
|
||||
} // namespace wip
|
||||
} // namespace gapi
|
||||
} // namespace cv
|
||||
|
||||
#endif // HAVE_ONEVPL
|
||||
|
||||
Reference in New Issue
Block a user