mirror of
https://github.com/opencv/opencv.git
synced 2026-07-29 15:23:05 +04:00
Merge pull request #21883 from SergeyIvanov87:gapi_vpl_linux
G-API: VPL Source turn on Linux CPU version * Turn on linux compilation * Apply comments * Change new files headline * Add license header
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
#include "streaming/onevpl/accelerators/accel_policy_cpu.hpp"
|
||||
#include "streaming/onevpl/accelerators/surface/cpu_frame_adapter.hpp"
|
||||
#include "streaming/onevpl/accelerators/surface/surface.hpp"
|
||||
#include "streaming/onevpl/utils.hpp"
|
||||
#include "logger.hpp"
|
||||
|
||||
#ifdef _WIN32
|
||||
@@ -22,7 +23,7 @@ namespace gapi {
|
||||
namespace wip {
|
||||
namespace onevpl {
|
||||
namespace utils {
|
||||
mfxU32 GetSurfaceSize_(mfxU32 FourCC, mfxU32 width, mfxU32 height) {
|
||||
static mfxU32 GetSurfaceSize_(mfxU32 FourCC, mfxU32 width, mfxU32 height) {
|
||||
mfxU32 nbytes = 0;
|
||||
|
||||
mfxU32 half_width = width / 2;
|
||||
@@ -47,10 +48,10 @@ mfxU32 GetSurfaceSize_(mfxU32 FourCC, mfxU32 width, mfxU32 height) {
|
||||
return nbytes;
|
||||
}
|
||||
|
||||
surface_ptr_t create_surface_RGB4_(mfxFrameInfo frameInfo,
|
||||
std::shared_ptr<void> out_buf_ptr,
|
||||
size_t out_buf_ptr_offset,
|
||||
size_t out_buf_size)
|
||||
static surface_ptr_t create_surface_RGB4_(mfxFrameInfo frameInfo,
|
||||
std::shared_ptr<void> out_buf_ptr,
|
||||
size_t out_buf_ptr_offset,
|
||||
size_t out_buf_size)
|
||||
{
|
||||
mfxU8* buf = reinterpret_cast<mfxU8*>(out_buf_ptr.get());
|
||||
mfxU16 surfW = frameInfo.Width * 4;
|
||||
@@ -80,10 +81,10 @@ surface_ptr_t create_surface_RGB4_(mfxFrameInfo frameInfo,
|
||||
return Surface::create_surface(std::move(handle), out_buf_ptr);
|
||||
}
|
||||
|
||||
surface_ptr_t create_surface_other_(mfxFrameInfo frameInfo,
|
||||
std::shared_ptr<void> out_buf_ptr,
|
||||
size_t out_buf_ptr_offset,
|
||||
size_t out_buf_size)
|
||||
static surface_ptr_t create_surface_other_(mfxFrameInfo frameInfo,
|
||||
std::shared_ptr<void> out_buf_ptr,
|
||||
size_t out_buf_ptr_offset,
|
||||
size_t out_buf_size)
|
||||
{
|
||||
mfxU8* buf = reinterpret_cast<mfxU8*>(out_buf_ptr.get());
|
||||
mfxU16 surfH = frameInfo.Height;
|
||||
@@ -155,8 +156,12 @@ VPLCPUAccelerationPolicy::create_surface_pool(size_t pool_size, size_t surface_s
|
||||
GAPI_LOG_DEBUG(nullptr, "page size: " << page_size_bytes << ", preallocated_raw_bytes: " << preallocated_raw_bytes);
|
||||
preallocated_pool_memory_ptr = _aligned_malloc(preallocated_raw_bytes, page_size_bytes);
|
||||
#else
|
||||
GAPI_Assert(false && "Compatibility is not tested for systems differ than \"_WIN32\". "
|
||||
"Please feel free to set it up under OPENCV contribution policy");
|
||||
int err = posix_memalign(&preallocated_pool_memory_ptr, page_size_bytes, preallocated_raw_bytes);
|
||||
if (err) {
|
||||
GAPI_LOG_WARNING(nullptr, "Cannot allocate aligned memory, size: " << preallocated_raw_bytes <<
|
||||
", alignment: " << page_size_bytes << ", error: " <<
|
||||
strerror(err));
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!preallocated_pool_memory_ptr) {
|
||||
@@ -173,8 +178,9 @@ VPLCPUAccelerationPolicy::create_surface_pool(size_t pool_size, size_t surface_s
|
||||
GAPI_LOG_INFO(nullptr, "Released workspace memory: " << ptr);
|
||||
ptr = nullptr;
|
||||
#else
|
||||
GAPI_Assert(false && "Not implemented for systems differ than \"_WIN32\". "
|
||||
"Please feel free to set it up under OPENCV contribution policy");
|
||||
free(ptr);
|
||||
GAPI_LOG_INFO(nullptr, "Released workspace memory: " << ptr);
|
||||
ptr = nullptr;
|
||||
#endif
|
||||
|
||||
});
|
||||
@@ -220,10 +226,8 @@ VPLCPUAccelerationPolicy::create_surface_pool(const mfxFrameAllocRequest& alloc_
|
||||
info.Width,
|
||||
info.Height);
|
||||
if (!singleSurfaceSize) {
|
||||
throw std::runtime_error("Cannot determine surface size for: fourCC: " +
|
||||
std::to_string(info.FourCC) +
|
||||
", width: " + std::to_string(info.Width) +
|
||||
", height: " + std::to_string(info.Height));
|
||||
throw std::runtime_error("Cannot determine surface size from frame: " +
|
||||
mfx_frame_info_to_string(info));
|
||||
}
|
||||
|
||||
auto surface_creator =
|
||||
|
||||
@@ -13,8 +13,7 @@
|
||||
#include "streaming/onevpl/utils.hpp"
|
||||
#include "logger.hpp"
|
||||
|
||||
#ifdef HAVE_DIRECTX
|
||||
#ifdef HAVE_D3D11
|
||||
#if defined(HAVE_DIRECTX) && defined(HAVE_D3D11)
|
||||
#pragma comment(lib,"d3d11.lib")
|
||||
|
||||
#define D3D11_NO_HELPERS
|
||||
@@ -441,6 +440,52 @@ mfxStatus VPLDX11AccelerationPolicy::on_free(mfxFrameAllocResponse *response) {
|
||||
} // namespace wip
|
||||
} // namespace gapi
|
||||
} // namespace cv
|
||||
#endif // HAVE_D3D11
|
||||
#endif // HAVE_DIRECTX
|
||||
|
||||
#else // #if defined(HAVE_DIRECTX) && defined(HAVE_D3D11)
|
||||
|
||||
namespace cv {
|
||||
namespace gapi {
|
||||
namespace wip {
|
||||
namespace onevpl {
|
||||
VPLDX11AccelerationPolicy::VPLDX11AccelerationPolicy(device_selector_ptr_t selector) :
|
||||
VPLAccelerationPolicy(selector) {
|
||||
GAPI_Assert(false && "VPLDX11AccelerationPolicy unavailable in current configuration");
|
||||
}
|
||||
|
||||
VPLDX11AccelerationPolicy::~VPLDX11AccelerationPolicy() = default;
|
||||
|
||||
void VPLDX11AccelerationPolicy::init(session_t ) {
|
||||
GAPI_Assert(false && "VPLDX11AccelerationPolicy unavailable in current configuration");
|
||||
}
|
||||
|
||||
void VPLDX11AccelerationPolicy::deinit(session_t) {
|
||||
GAPI_Assert(false && "VPLDX11AccelerationPolicy unavailable in current configuration");
|
||||
}
|
||||
|
||||
VPLDX11AccelerationPolicy::pool_key_t VPLDX11AccelerationPolicy::create_surface_pool(const mfxFrameAllocRequest&,
|
||||
mfxFrameInfo&) {
|
||||
GAPI_Assert(false && "VPLDX11AccelerationPolicy unavailable in current configuration");
|
||||
}
|
||||
|
||||
VPLDX11AccelerationPolicy::surface_weak_ptr_t VPLDX11AccelerationPolicy::get_free_surface(pool_key_t) {
|
||||
GAPI_Assert(false && "VPLDX11AccelerationPolicy unavailable in current configuration");
|
||||
}
|
||||
|
||||
size_t VPLDX11AccelerationPolicy::get_free_surface_count(pool_key_t) const {
|
||||
GAPI_Assert(false && "VPLDX11AccelerationPolicy unavailable in current configuration");
|
||||
}
|
||||
|
||||
size_t VPLDX11AccelerationPolicy::get_surface_count(pool_key_t) const {
|
||||
GAPI_Assert(false && "VPLDX11AccelerationPolicy unavailable in current configuration");
|
||||
}
|
||||
|
||||
cv::MediaFrame::AdapterPtr VPLDX11AccelerationPolicy::create_frame_adapter(pool_key_t,
|
||||
const FrameConstructorArgs &) {
|
||||
GAPI_Assert(false && "VPLDX11AccelerationPolicy unavailable in current configuration");
|
||||
}
|
||||
} // namespace onevpl
|
||||
} // namespace wip
|
||||
} // namespace gapi
|
||||
} // namespace cv
|
||||
#endif // #if defined(HAVE_DIRECTX) && defined(HAVE_D3D11)
|
||||
#endif // HAVE_ONEVPL
|
||||
|
||||
@@ -15,8 +15,7 @@
|
||||
#include "streaming/onevpl/accelerators/surface/surface_pool.hpp"
|
||||
#include "streaming/onevpl/accelerators/dx11_alloc_resource.hpp"
|
||||
|
||||
#ifdef HAVE_DIRECTX
|
||||
#ifdef HAVE_D3D11
|
||||
#if defined(HAVE_DIRECTX) && defined(HAVE_D3D11)
|
||||
#define D3D11_NO_HELPERS
|
||||
#define NOMINMAX
|
||||
#include <d3d11.h>
|
||||
@@ -24,7 +23,9 @@
|
||||
#include "opencv2/core/directx.hpp"
|
||||
#ifdef HAVE_OPENCL
|
||||
#include <CL/cl_d3d11.h>
|
||||
#endif
|
||||
#endif // HAVE_OPENCL
|
||||
#undef NOMINMAX
|
||||
#endif // HAVE_DIRECTX && HAVE_D3D11
|
||||
|
||||
namespace cv {
|
||||
namespace gapi {
|
||||
@@ -51,6 +52,8 @@ struct GAPI_EXPORTS VPLDX11AccelerationPolicy final: public VPLAccelerationPolic
|
||||
cv::MediaFrame::AdapterPtr create_frame_adapter(pool_key_t key,
|
||||
const FrameConstructorArgs ¶ms) override;
|
||||
private:
|
||||
#ifdef HAVE_DIRECTX
|
||||
#ifdef HAVE_D3D11
|
||||
ID3D11Device *hw_handle;
|
||||
ID3D11DeviceContext* device_context;
|
||||
|
||||
@@ -75,14 +78,13 @@ private:
|
||||
std::map<alloc_id_t, allocation_t> allocation_table;
|
||||
|
||||
std::map<pool_key_t, pool_t> pool_table;
|
||||
#endif // HAVE_D3D11
|
||||
#endif // HAVE_DIRECTX
|
||||
};
|
||||
} // namespace onevpl
|
||||
} // namespace wip
|
||||
} // namespace gapi
|
||||
} // namespace cv
|
||||
#undef NOMINMAX
|
||||
#endif // HAVE_D3D11
|
||||
#endif // HAVE_DIRECTX
|
||||
|
||||
#endif // HAVE_ONEVPL
|
||||
#endif // GAPI_STREAMING_ONEVPL_ACCELERATORS_ACCEL_POLICY_DX11_HPP
|
||||
|
||||
@@ -0,0 +1,150 @@
|
||||
// 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.
|
||||
|
||||
#ifdef HAVE_ONEVPL
|
||||
#include <cstdlib>
|
||||
#include <exception>
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __linux__
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#endif // __linux__
|
||||
|
||||
#include "streaming/onevpl/accelerators/accel_policy_va_api.hpp"
|
||||
#include "streaming/onevpl/accelerators/accel_policy_cpu.hpp"
|
||||
#include "streaming/onevpl/utils.hpp"
|
||||
#include "logger.hpp"
|
||||
|
||||
namespace cv {
|
||||
namespace gapi {
|
||||
namespace wip {
|
||||
namespace onevpl {
|
||||
#ifdef __linux__
|
||||
VPLVAAPIAccelerationPolicy::VPLVAAPIAccelerationPolicy(device_selector_ptr_t selector) :
|
||||
VPLAccelerationPolicy(selector),
|
||||
cpu_dispatcher(new VPLCPUAccelerationPolicy(selector)),
|
||||
va_handle(),
|
||||
device_fd(-1) {
|
||||
#if defined(HAVE_VA) || defined(HAVE_VA_INTEL)
|
||||
// TODO Move it out in device selector
|
||||
device_fd = open("/dev/dri/renderD128", O_RDWR);
|
||||
if (device_fd < 0) {
|
||||
GAPI_LOG_WARNING(nullptr, "VAAPI device descriptor \"/dev/dri/renderD128\" has not found");
|
||||
throw std::runtime_error("cannot open VAAPI device");
|
||||
}
|
||||
va_handle = vaGetDisplayDRM(device_fd);
|
||||
if (!va_handle) {
|
||||
GAPI_LOG_WARNING(nullptr, "VAAPI device vaGetDisplayDRM failed, error: " << strerror(errno));
|
||||
close(device_fd);
|
||||
throw std::runtime_error("vaGetDisplayDRM failed");
|
||||
}
|
||||
int major_version = 0, minor_version = 0;
|
||||
VAStatus status {};
|
||||
status = vaInitialize(va_handle, &major_version, &minor_version);
|
||||
if (VA_STATUS_SUCCESS != status) {
|
||||
GAPI_LOG_WARNING(nullptr, "Cannot initialize VAAPI device, error: " << vaErrorStr(status));
|
||||
close(device_fd);
|
||||
throw std::runtime_error("vaInitialize failed");
|
||||
}
|
||||
GAPI_LOG_INFO(nullptr, "created");
|
||||
#else // defined(HAVE_VA) || defined(HAVE_VA_INTEL)
|
||||
GAPI_Assert(false && "VPLVAAPIAccelerationPolicy unavailable in current configuration");
|
||||
#endif // defined(HAVE_VA) || defined(HAVE_VA_INTEL)
|
||||
}
|
||||
|
||||
VPLVAAPIAccelerationPolicy::~VPLVAAPIAccelerationPolicy() {
|
||||
vaTerminate(va_handle);
|
||||
close(device_fd);
|
||||
GAPI_LOG_INFO(nullptr, "destroyed");
|
||||
}
|
||||
|
||||
void VPLVAAPIAccelerationPolicy::init(session_t session) {
|
||||
GAPI_LOG_INFO(nullptr, "session: " << session);
|
||||
|
||||
cpu_dispatcher->init(session);
|
||||
mfxStatus sts = MFXVideoCORE_SetHandle(session,
|
||||
static_cast<mfxHandleType>(MFX_HANDLE_VA_DISPLAY),
|
||||
va_handle);
|
||||
if (sts != MFX_ERR_NONE)
|
||||
{
|
||||
throw std::logic_error("Cannot create VPLVAAPIAccelerationPolicy, MFXVideoCORE_SetHandle error: " +
|
||||
mfxstatus_to_string(sts));
|
||||
}
|
||||
GAPI_LOG_INFO(nullptr, "finished successfully, session: " << session);
|
||||
}
|
||||
|
||||
void VPLVAAPIAccelerationPolicy::deinit(session_t session) {
|
||||
GAPI_LOG_INFO(nullptr, "session: " << session);
|
||||
}
|
||||
|
||||
VPLVAAPIAccelerationPolicy::pool_key_t
|
||||
VPLVAAPIAccelerationPolicy::create_surface_pool(const mfxFrameAllocRequest& alloc_request, mfxFrameInfo& info) {
|
||||
|
||||
return cpu_dispatcher->create_surface_pool(alloc_request, info);
|
||||
}
|
||||
|
||||
VPLVAAPIAccelerationPolicy::surface_weak_ptr_t VPLVAAPIAccelerationPolicy::get_free_surface(pool_key_t key) {
|
||||
return cpu_dispatcher->get_free_surface(key);
|
||||
}
|
||||
|
||||
size_t VPLVAAPIAccelerationPolicy::get_free_surface_count(pool_key_t key) const {
|
||||
return cpu_dispatcher->get_free_surface_count(key);
|
||||
}
|
||||
|
||||
size_t VPLVAAPIAccelerationPolicy::get_surface_count(pool_key_t key) const {
|
||||
return cpu_dispatcher->get_surface_count(key);
|
||||
}
|
||||
|
||||
cv::MediaFrame::AdapterPtr VPLVAAPIAccelerationPolicy::create_frame_adapter(pool_key_t key,
|
||||
const FrameConstructorArgs ¶ms) {
|
||||
return cpu_dispatcher->create_frame_adapter(key, params);
|
||||
}
|
||||
|
||||
#else // __linux__
|
||||
|
||||
VPLVAAPIAccelerationPolicy::VPLVAAPIAccelerationPolicy(device_selector_ptr_t selector) :
|
||||
VPLAccelerationPolicy(selector) {
|
||||
GAPI_Assert(false && "VPLVAAPIAccelerationPolicy unavailable in current configuration");
|
||||
}
|
||||
|
||||
VPLVAAPIAccelerationPolicy::~VPLVAAPIAccelerationPolicy() = default;
|
||||
|
||||
void VPLVAAPIAccelerationPolicy::init(session_t ) {
|
||||
GAPI_Assert(false && "VPLVAAPIAccelerationPolicy unavailable in current configuration");
|
||||
}
|
||||
|
||||
void VPLVAAPIAccelerationPolicy::deinit(session_t) {
|
||||
GAPI_Assert(false && "VPLVAAPIAccelerationPolicy unavailable in current configuration");
|
||||
}
|
||||
|
||||
VPLVAAPIAccelerationPolicy::pool_key_t VPLVAAPIAccelerationPolicy::create_surface_pool(const mfxFrameAllocRequest&,
|
||||
mfxFrameInfo&) {
|
||||
GAPI_Assert(false && "VPLVAAPIAccelerationPolicy unavailable in current configuration");
|
||||
}
|
||||
|
||||
VPLVAAPIAccelerationPolicy::surface_weak_ptr_t VPLVAAPIAccelerationPolicy::get_free_surface(pool_key_t) {
|
||||
GAPI_Assert(false && "VPLVAAPIAccelerationPolicy unavailable in current configuration");
|
||||
}
|
||||
|
||||
size_t VPLVAAPIAccelerationPolicy::get_free_surface_count(pool_key_t) const {
|
||||
GAPI_Assert(false && "VPLVAAPIAccelerationPolicy unavailable in current configuration");
|
||||
}
|
||||
|
||||
size_t VPLVAAPIAccelerationPolicy::get_surface_count(pool_key_t) const {
|
||||
GAPI_Assert(false && "VPLVAAPIAccelerationPolicy unavailable in current configuration");
|
||||
}
|
||||
|
||||
cv::MediaFrame::AdapterPtr VPLVAAPIAccelerationPolicy::create_frame_adapter(pool_key_t,
|
||||
const FrameConstructorArgs &) {
|
||||
GAPI_Assert(false && "VPLVAAPIAccelerationPolicy unavailable in current configuration");
|
||||
}
|
||||
#endif // __linux__
|
||||
} // namespace onevpl
|
||||
} // namespace wip
|
||||
} // namespace gapi
|
||||
} // namespace cv
|
||||
#endif // HAVE_ONEVPL
|
||||
@@ -0,0 +1,62 @@
|
||||
// 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.
|
||||
|
||||
#ifndef GAPI_STREAMING_ONEVPL_ACCELERATORS_ACCEL_POLICY_VA_API_HPP
|
||||
#define GAPI_STREAMING_ONEVPL_ACCELERATORS_ACCEL_POLICY_VA_API_HPP
|
||||
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
#include "opencv2/gapi/own/exports.hpp" // GAPI_EXPORTS
|
||||
|
||||
#ifdef HAVE_ONEVPL
|
||||
#include "streaming/onevpl/accelerators/accel_policy_interface.hpp"
|
||||
#include "streaming/onevpl/accelerators/surface/surface_pool.hpp"
|
||||
|
||||
#ifdef __linux__
|
||||
#if defined(HAVE_VA) || defined(HAVE_VA_INTEL)
|
||||
#include "va/va.h"
|
||||
#include "va/va_drm.h"
|
||||
#else
|
||||
typedef void* VADisplay;
|
||||
#endif // defined(HAVE_VA) || defined(HAVE_VA_INTEL)
|
||||
#endif // __linux__
|
||||
|
||||
namespace cv {
|
||||
namespace gapi {
|
||||
namespace wip {
|
||||
namespace onevpl {
|
||||
|
||||
// GAPI_EXPORTS for tests
|
||||
struct GAPI_EXPORTS VPLVAAPIAccelerationPolicy final : public VPLAccelerationPolicy
|
||||
{
|
||||
VPLVAAPIAccelerationPolicy(device_selector_ptr_t selector);
|
||||
~VPLVAAPIAccelerationPolicy();
|
||||
|
||||
using pool_t = CachedPool;
|
||||
|
||||
void init(session_t session) override;
|
||||
void deinit(session_t session) override;
|
||||
pool_key_t create_surface_pool(const mfxFrameAllocRequest& alloc_request, mfxFrameInfo& info) override;
|
||||
surface_weak_ptr_t get_free_surface(pool_key_t key) override;
|
||||
size_t get_free_surface_count(pool_key_t key) const override;
|
||||
size_t get_surface_count(pool_key_t key) const override;
|
||||
|
||||
cv::MediaFrame::AdapterPtr create_frame_adapter(pool_key_t key,
|
||||
const FrameConstructorArgs& args) override;
|
||||
|
||||
private:
|
||||
std::unique_ptr<VPLAccelerationPolicy> cpu_dispatcher;
|
||||
#ifdef __linux__
|
||||
VADisplay va_handle;
|
||||
int device_fd; // TODO Move it out in device selector
|
||||
#endif // __linux__
|
||||
};
|
||||
} // namespace onevpl
|
||||
} // namespace wip
|
||||
} // namespace gapi
|
||||
} // namespace cv
|
||||
|
||||
#endif // HAVE_ONEVPL
|
||||
#endif // GAPI_STREAMING_ONEVPL_ACCELERATORS_ACCEL_POLICY_VA_API_HPP
|
||||
@@ -59,7 +59,7 @@ std::shared_ptr<Surface> BaseFrameAdapter::surface() {
|
||||
return parent_surface_ptr;
|
||||
}
|
||||
|
||||
const BaseFrameAdapter::SessionHandle BaseFrameAdapter::get_session_handle() const {
|
||||
BaseFrameAdapter::SessionHandle BaseFrameAdapter::get_session_handle() const {
|
||||
return parent_handle;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ public:
|
||||
using SessionHandle = mfxSession;
|
||||
|
||||
const std::shared_ptr<Surface>& get_surface() const;
|
||||
const SessionHandle get_session_handle() const;
|
||||
SessionHandle get_session_handle() const;
|
||||
|
||||
cv::GFrameDesc meta() const override;
|
||||
AccelType accel_type() const;
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
#ifdef HAVE_ONEVPL
|
||||
#include "streaming/onevpl/onevpl_export.hpp"
|
||||
|
||||
#ifdef HAVE_DIRECTX
|
||||
#ifdef HAVE_D3D11
|
||||
#ifdef HAVE_INF_ENGINE
|
||||
// For IE classes (ParamMap, etc)
|
||||
#include <inference_engine.hpp>
|
||||
@@ -202,4 +204,6 @@ DXGI_FORMAT VPLMediaFrameDX11Adapter::get_dx11_color_format(uint32_t mfx_fourcc)
|
||||
} // namespace wip
|
||||
} // namespace gapi
|
||||
} // namespace cv
|
||||
#endif // HAVE_D3D11
|
||||
#endif // HAVE_DIRECTX
|
||||
#endif // HAVE_ONEVPL
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
//
|
||||
// Copyright (C) 2021 Intel Corporation
|
||||
|
||||
#include <opencv2/gapi/own/assert.hpp>
|
||||
#include "streaming/onevpl/accelerators/surface/surface.hpp"
|
||||
#include "logger.hpp"
|
||||
|
||||
@@ -20,12 +21,12 @@ Surface::Surface(std::unique_ptr<handle_t>&& surf, std::shared_ptr<void> associa
|
||||
mirrored_locked_count() {
|
||||
|
||||
GAPI_Assert(mfx_surface && "Surface is nullptr");
|
||||
GAPI_LOG_DEBUG(nullptr, "create surface: " << mfx_surface <<
|
||||
GAPI_LOG_DEBUG(nullptr, "create surface: " << get_handle() <<
|
||||
", locked count: " << mfx_surface->Data.Locked);
|
||||
}
|
||||
|
||||
Surface::~Surface() {
|
||||
GAPI_LOG_DEBUG(nullptr, "destroy surface: " << mfx_surface <<
|
||||
GAPI_LOG_DEBUG(nullptr, "destroy surface: " << get_handle() <<
|
||||
", worspace memory counter: " <<
|
||||
workspace_memory_ptr.use_count());
|
||||
}
|
||||
@@ -60,7 +61,7 @@ size_t Surface::get_locks_count() const {
|
||||
|
||||
size_t Surface::obtain_lock() {
|
||||
size_t locked_count = mirrored_locked_count.fetch_add(1);
|
||||
GAPI_LOG_DEBUG(nullptr, "surface: " << mfx_surface.get() <<
|
||||
GAPI_LOG_DEBUG(nullptr, "surface: " << get_handle() <<
|
||||
", locked times: " << locked_count + 1);
|
||||
return locked_count; // return preceding value
|
||||
}
|
||||
@@ -68,7 +69,7 @@ size_t Surface::obtain_lock() {
|
||||
size_t Surface::release_lock() {
|
||||
size_t locked_count = mirrored_locked_count.fetch_sub(1);
|
||||
GAPI_Assert(locked_count && "Surface lock counter is invalid");
|
||||
GAPI_LOG_DEBUG(nullptr, "surface: " << mfx_surface.get() <<
|
||||
GAPI_LOG_DEBUG(nullptr, "surface: " << get_handle() <<
|
||||
", locked times: " << locked_count - 1);
|
||||
return locked_count; // return preceding value
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#include <opencv2/gapi/own/assert.hpp>
|
||||
#include "streaming/onevpl/accelerators/surface/surface_pool.hpp"
|
||||
#include "streaming/onevpl/accelerators/surface/surface.hpp"
|
||||
#include "logger.hpp"
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <opencv2/gapi/own/assert.hpp>
|
||||
#include <opencv2/gapi/util/variant.hpp>
|
||||
|
||||
#include <opencv2/gapi/streaming/onevpl/device_selector_interface.hpp>
|
||||
#include "streaming/onevpl/cfg_param_device_selector.hpp"
|
||||
#include "streaming/onevpl/cfg_params_parser.hpp"
|
||||
#include "streaming/onevpl/utils.hpp"
|
||||
@@ -26,25 +27,27 @@
|
||||
#pragma comment(lib, "dxgi")
|
||||
#undef D3D11_NO_HELPERS
|
||||
#undef NOMINMAX
|
||||
#endif // HAVE_D3D11
|
||||
#endif // HAVE_DIRECTX
|
||||
|
||||
#include <codecvt>
|
||||
#include "opencv2/core/directx.hpp"
|
||||
#ifdef HAVE_OPENCL
|
||||
#include <CL/cl_d3d11.h>
|
||||
#endif
|
||||
|
||||
namespace cv {
|
||||
namespace gapi {
|
||||
namespace wip {
|
||||
namespace onevpl {
|
||||
|
||||
std::vector<CfgParam> insertCfgparam(std::vector<CfgParam> &¶m_array, AccelType type) {
|
||||
static std::vector<CfgParam> insertCfgparam(std::vector<CfgParam> &¶m_array, AccelType type) {
|
||||
switch (type) {
|
||||
case AccelType::HOST:
|
||||
break;
|
||||
case AccelType::DX11:
|
||||
param_array.push_back(CfgParam::create_acceleration_mode(MFX_ACCEL_MODE_VIA_D3D11));
|
||||
break;
|
||||
case AccelType::VAAPI:
|
||||
param_array.push_back(CfgParam::create_acceleration_mode(MFX_IMPL_VIA_VAAPI));
|
||||
break;
|
||||
default:
|
||||
GAPI_DbgAssert(false && "Unexpected AccelType");
|
||||
break;
|
||||
@@ -71,8 +74,7 @@ CfgParamDeviceSelector::CfgParamDeviceSelector(const CfgParams& cfg_params) :
|
||||
|
||||
switch(accel_mode.Data.U32) {
|
||||
case MFX_ACCEL_MODE_VIA_D3D11: {
|
||||
#ifdef HAVE_DIRECTX
|
||||
#ifdef HAVE_D3D11
|
||||
#if defined(HAVE_DIRECTX) && defined(HAVE_D3D11)
|
||||
ID3D11Device *hw_handle = nullptr;
|
||||
ID3D11DeviceContext* device_context = nullptr;
|
||||
|
||||
@@ -141,14 +143,17 @@ CfgParamDeviceSelector::CfgParamDeviceSelector(const CfgParams& cfg_params) :
|
||||
|
||||
suggested_device = IDeviceSelector::create<Device>(hw_handle, "GPU", AccelType::DX11);
|
||||
suggested_context = IDeviceSelector::create<Context>(device_context, AccelType::DX11);
|
||||
#else
|
||||
#else // defined(HAVE_DIRECTX) && defined(HAVE_D3D11)
|
||||
GAPI_LOG_WARNING(nullptr, "Unavailable \"" << CfgParam::acceleration_mode_name() << ": MFX_ACCEL_MODE_VIA_D3D11\""
|
||||
"was chosen for current project configuration");
|
||||
throw std::logic_error(std::string("Unsupported \"") +
|
||||
CfgParam::acceleration_mode_name() +
|
||||
": MFX_ACCEL_MODE_VIA_D3D11\"");
|
||||
#endif // HAVE_DIRECTX
|
||||
#endif // HAVE_D3D11
|
||||
#endif // defined(HAVE_DIRECTX) && defined(HAVE_D3D11)
|
||||
break;
|
||||
}
|
||||
case MFX_IMPL_VIA_VAAPI : {
|
||||
GAPI_LOG_WARNING(nullptr, "TODO MFX_IMPL_VIA_VAAPI falls back to CPU case")
|
||||
break;
|
||||
}
|
||||
case MFX_ACCEL_MODE_NA: {
|
||||
@@ -198,10 +203,10 @@ CfgParamDeviceSelector::CfgParamDeviceSelector(Device::Ptr device_ptr,
|
||||
}
|
||||
mfxVariant accel_mode = cfg_param_to_mfx_variant(*accel_mode_it);
|
||||
|
||||
cv::util::suppress_unused_warning(device_id);
|
||||
switch(accel_mode.Data.U32) {
|
||||
case MFX_ACCEL_MODE_VIA_D3D11: {
|
||||
#ifdef HAVE_DIRECTX
|
||||
#ifdef HAVE_D3D11
|
||||
#if defined(HAVE_DIRECTX) && defined(HAVE_D3D11)
|
||||
suggested_device = IDeviceSelector::create<Device>(device_ptr, device_id, AccelType::DX11);
|
||||
ID3D11Device* dx_device_ptr =
|
||||
reinterpret_cast<ID3D11Device*>(suggested_device.get_ptr());
|
||||
@@ -220,14 +225,13 @@ CfgParamDeviceSelector::CfgParamDeviceSelector(Device::Ptr device_ptr,
|
||||
}
|
||||
|
||||
dx_ctx_ptr->AddRef();
|
||||
#else
|
||||
#else // defined(HAVE_DIRECTX) && defined(HAVE_D3D11)
|
||||
GAPI_LOG_WARNING(nullptr, "Unavailable \"" << CfgParam::acceleration_mode_name() <<
|
||||
": MFX_ACCEL_MODE_VIA_D3D11\""
|
||||
"was chosen for current project configuration");
|
||||
throw std::logic_error(std::string("Unsupported \"") +
|
||||
CfgParam::acceleration_mode_name() + ": MFX_ACCEL_MODE_VIA_D3D11\"");
|
||||
#endif // HAVE_DIRECTX
|
||||
#endif // HAVE_D3D11
|
||||
#endif // #if defined(HAVE_DIRECTX) && defined(HAVE_D3D11)
|
||||
break;
|
||||
}
|
||||
case MFX_ACCEL_MODE_NA: {
|
||||
@@ -253,8 +257,7 @@ CfgParamDeviceSelector::CfgParamDeviceSelector(const Device &device,
|
||||
|
||||
switch(device.get_type()) {
|
||||
case AccelType::DX11: {
|
||||
#ifdef HAVE_DIRECTX
|
||||
#ifdef HAVE_D3D11
|
||||
#if defined(HAVE_DIRECTX) && defined(HAVE_D3D11)
|
||||
ID3D11Device* dx_device_ptr =
|
||||
reinterpret_cast<ID3D11Device*>(suggested_device.get_ptr());
|
||||
dx_device_ptr->AddRef();
|
||||
@@ -272,15 +275,17 @@ CfgParamDeviceSelector::CfgParamDeviceSelector(const Device &device,
|
||||
|
||||
dx_ctx_ptr->AddRef();
|
||||
break;
|
||||
#else
|
||||
#else // defined(HAVE_DIRECTX) && defined(HAVE_D3D11)
|
||||
GAPI_LOG_WARNING(nullptr, "Unavailable \"" << CfgParam::acceleration_mode_name() <<
|
||||
": MFX_ACCEL_MODE_VIA_D3D11\""
|
||||
"was chosen for current project configuration");
|
||||
throw std::logic_error(std::string("Unsupported \"") +
|
||||
CfgParam::acceleration_mode_name() + ": MFX_ACCEL_MODE_VIA_D3D11\"");
|
||||
#endif // HAVE_DIRECTX
|
||||
#endif // HAVE_D3D11
|
||||
#endif // defined(HAVE_DIRECTX) && defined(HAVE_D3D11)
|
||||
}
|
||||
case AccelType::VAAPI:
|
||||
GAPI_LOG_WARNING(nullptr, "TODO MFX_IMPL_VIA_VAAPI falls back to CPU case")
|
||||
break;
|
||||
case AccelType::HOST:
|
||||
break;
|
||||
default:
|
||||
@@ -299,14 +304,12 @@ CfgParamDeviceSelector::~CfgParamDeviceSelector() {
|
||||
//nothing to do
|
||||
break;
|
||||
case AccelType::DX11: {
|
||||
#ifdef HAVE_DIRECTX
|
||||
#ifdef HAVE_D3D11
|
||||
#if defined(HAVE_DIRECTX) && defined(HAVE_D3D11)
|
||||
ID3D11DeviceContext* device_ctx_ptr =
|
||||
reinterpret_cast<ID3D11DeviceContext*>(suggested_context.get_ptr());
|
||||
device_ctx_ptr->Release();
|
||||
device_ctx_ptr = nullptr;
|
||||
#endif // HAVE_DIRECTX
|
||||
#endif // HAVE_D3D11
|
||||
#endif // defined(HAVE_DIRECTX) && defined(HAVE_D3D11)
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@@ -322,13 +325,11 @@ CfgParamDeviceSelector::~CfgParamDeviceSelector() {
|
||||
//nothing to do
|
||||
break;
|
||||
case AccelType::DX11: {
|
||||
#ifdef HAVE_DIRECTX
|
||||
#ifdef HAVE_D3D11
|
||||
#if defined(HAVE_DIRECTX) && defined(HAVE_D3D11)
|
||||
ID3D11Device* device_ptr = reinterpret_cast<ID3D11Device*>(suggested_device.get_ptr());
|
||||
device_ptr->Release();
|
||||
device_ptr = nullptr;
|
||||
#endif // HAVE_DIRECTX
|
||||
#endif // HAVE_D3D11
|
||||
#endif // defined(HAVE_DIRECTX) && defined(HAVE_D3D11)
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@@ -337,7 +338,7 @@ CfgParamDeviceSelector::~CfgParamDeviceSelector() {
|
||||
}
|
||||
|
||||
CfgParamDeviceSelector::DeviceScoreTable CfgParamDeviceSelector::select_devices() const {
|
||||
return {std::make_pair(Score::MaxActivePriority, suggested_device)};
|
||||
return {std::make_pair(Score::Type(Score::MaxActivePriority), suggested_device)};
|
||||
}
|
||||
|
||||
CfgParamDeviceSelector::DeviceContexts CfgParamDeviceSelector::select_context() {
|
||||
@@ -348,6 +349,4 @@ CfgParamDeviceSelector::DeviceContexts CfgParamDeviceSelector::select_context()
|
||||
} // namespace wip
|
||||
} // namespace gapi
|
||||
} // namespace cv
|
||||
#endif // HAVE_D3D11
|
||||
#endif // HAVE_DIRECTX
|
||||
#endif // HAVE_ONEVPL
|
||||
|
||||
@@ -87,15 +87,15 @@ std::vector<ValueType> get_params_from_string(const std::string& str) {
|
||||
|
||||
ParamCreator<ValueType> creator;
|
||||
if (name == CfgParam::implementation_name()) {
|
||||
ret.push_back(creator.create<mfxU32>(name, cstr_to_mfx_impl(value.c_str())));
|
||||
ret.push_back(creator.template create<mfxU32>(name, cstr_to_mfx_impl(value.c_str())));
|
||||
} else if (name == CfgParam::decoder_id_name()) {
|
||||
ret.push_back(creator.create<mfxU32>(name, cstr_to_mfx_codec_id(value.c_str())));
|
||||
ret.push_back(creator.template create<mfxU32>(name, cstr_to_mfx_codec_id(value.c_str())));
|
||||
} else if (name == CfgParam::acceleration_mode_name()) {
|
||||
ret.push_back(creator.create<mfxU32>(name, cstr_to_mfx_accel_mode(value.c_str())));
|
||||
ret.push_back(creator.template create<mfxU32>(name, cstr_to_mfx_accel_mode(value.c_str())));
|
||||
} else if (name == "mfxImplDescription.ApiVersion.Version") {
|
||||
ret.push_back(creator.create<mfxU32>(name, cstr_to_mfx_version(value.c_str())));
|
||||
ret.push_back(creator.template create<mfxU32>(name, cstr_to_mfx_version(value.c_str())));
|
||||
} else if ((name == CfgParam::frames_pool_size_name()) || (name == CfgParam::vpp_frames_pool_size_name())) {
|
||||
ret.push_back(creator.create(name, strtoull_or_throw(value.c_str()), false));
|
||||
ret.push_back(creator.create(name, static_cast<mfxU32>(strtoull_or_throw(value.c_str()), false)));
|
||||
} else if ((name == CfgParam::vpp_in_width_name()) || (name == CfgParam::vpp_in_height_name()) ||
|
||||
(name == CfgParam::vpp_in_crop_w_name()) || (name == CfgParam::vpp_in_crop_h_name()) ||
|
||||
(name == CfgParam::vpp_in_crop_x_name()) || (name == CfgParam::vpp_in_crop_y_name()) ||
|
||||
@@ -186,7 +186,7 @@ unsigned long strtoul_or_throw(const char* str) {
|
||||
errno = 0;
|
||||
unsigned long ret = strtoul(str, &end_ptr, 10);
|
||||
if ((end_ptr == str) ||
|
||||
((ret == ULONG_MAX || ret == LONG_MIN) && errno == ERANGE)) {
|
||||
((ret == ULONG_MAX) && errno == ERANGE)) {
|
||||
// nothing parsed from the string, handle errors or exit
|
||||
GAPI_LOG_WARNING(nullptr, "strtoul failed for: " << str);
|
||||
GAPI_Assert(false && "strtoul_or_throw");
|
||||
@@ -199,7 +199,7 @@ size_t strtoull_or_throw(const char* str) {
|
||||
errno = 0;
|
||||
size_t ret = strtoull(str, &end_ptr, 10);
|
||||
if ((end_ptr == str) ||
|
||||
((ret == LONG_MAX || ret == LONG_MIN) && errno == ERANGE)) {
|
||||
((ret == ULLONG_MAX) && errno == ERANGE)) {
|
||||
// nothing parsed from the string, handle errors or exit
|
||||
GAPI_LOG_WARNING(nullptr, "strtoull failed for: " << str);
|
||||
GAPI_Assert(false && "strtoull_or_throw");
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#pragma comment(lib, "mfreadwrite.lib")
|
||||
#endif // _WIN32
|
||||
|
||||
#include <opencv2/gapi/own/assert.hpp>
|
||||
#include "streaming/onevpl/demux/async_mfp_demux_data_provider.hpp"
|
||||
#include "logger.hpp"
|
||||
|
||||
@@ -807,7 +808,7 @@ bool MFPAsyncDemuxDataProvider::fetch_bitstream_data(std::shared_ptr<mfx_bitstre
|
||||
return false;
|
||||
}
|
||||
|
||||
bool MFPAsyncDemuxDataProvider::empty() const override {
|
||||
bool MFPAsyncDemuxDataProvider::empty() const {
|
||||
GAPI_Assert(false && "Unsupported: Microsoft Media Foundation is not available");
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#ifdef HAVE_ONEVPL
|
||||
#include "streaming/onevpl/onevpl_export.hpp"
|
||||
#include <opencv2/gapi/streaming/onevpl/data_provider_interface.hpp>
|
||||
|
||||
#ifdef _WIN32
|
||||
#define NOMINMAX
|
||||
@@ -28,7 +29,6 @@
|
||||
#include <wmcodecdsp.h>
|
||||
#undef NOMINMAX
|
||||
|
||||
#include <opencv2/gapi/streaming/onevpl/data_provider_interface.hpp>
|
||||
#include "streaming/onevpl/data_provider_defines.hpp"
|
||||
#include "streaming/onevpl/utils.hpp"
|
||||
|
||||
|
||||
@@ -20,6 +20,8 @@ const char* to_cstring(AccelType type) {
|
||||
return "HOST";
|
||||
case AccelType::DX11:
|
||||
return "DX11";
|
||||
case AccelType::VAAPI:
|
||||
return "VAAPI";
|
||||
default:
|
||||
GAPI_DbgAssert(false && "Unexpected AccelType");
|
||||
break;
|
||||
|
||||
@@ -175,6 +175,7 @@ VPLLegacyDecodeEngine::SessionParam VPLLegacyDecodeEngine::prepare_session_param
|
||||
|
||||
// Prepare video param
|
||||
mfxVideoParam mfxDecParams {};
|
||||
memset(&mfxDecParams, 0, sizeof(mfxDecParams));
|
||||
mfxDecParams.mfx.CodecId = decoder_id_name;
|
||||
|
||||
// set memory stream direction according to acceleration policy device type
|
||||
@@ -253,7 +254,8 @@ VPLLegacyDecodeEngine::SessionParam VPLLegacyDecodeEngine::prepare_session_param
|
||||
|
||||
// Input parameters finished, now initialize decode
|
||||
// create decoder for session according to header recovered from source file
|
||||
|
||||
GAPI_LOG_INFO(nullptr, "Initialize decoder for session: " << mfx_session <<
|
||||
", frame info: " << mfx_frame_info_to_string(mfxDecParams.mfx.FrameInfo));
|
||||
sts = MFXVideoDECODE_Init(mfx_session, &mfxDecParams);
|
||||
if (MFX_ERR_NONE != sts) {
|
||||
throw std::runtime_error("Error initializing Decode, error: " +
|
||||
|
||||
@@ -21,6 +21,9 @@ namespace gapi {
|
||||
namespace wip {
|
||||
namespace onevpl {
|
||||
class Surface;
|
||||
struct VPLAccelerationPolicy;
|
||||
class VPLLegacyDecodeEngine;
|
||||
|
||||
class GAPI_EXPORTS LegacyDecodeSession : public EngineSession {
|
||||
public:
|
||||
friend class VPLLegacyDecodeEngine;
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "opencv2/gapi/util/optional.hpp"
|
||||
#include "opencv2/gapi/own/exports.hpp" // GAPI_EXPORTS
|
||||
#include <opencv2/gapi/streaming/onevpl/data_provider_interface.hpp>
|
||||
#include "streaming/onevpl/data_provider_defines.hpp"
|
||||
@@ -31,7 +32,7 @@ namespace onevpl {
|
||||
struct GAPI_EXPORTS DecoderParams {
|
||||
std::shared_ptr<IDataProvider::mfx_bitstream> stream;
|
||||
mfxVideoParam param;
|
||||
cv::optional<size_t> preallocated_frames_count;
|
||||
cv::util::optional<size_t> preallocated_frames_count;
|
||||
};
|
||||
|
||||
struct GAPI_EXPORTS TranscoderParams {
|
||||
|
||||
@@ -34,8 +34,8 @@ bool FrameInfoComparator::equal_to(const mfxFrameInfo& lhs, const mfxFrameInfo&
|
||||
return lhs == rhs;
|
||||
}
|
||||
|
||||
void apply_roi(mfxFrameSurface1* surface_handle,
|
||||
const cv::util::optional<cv::Rect> &opt_roi) {
|
||||
static void apply_roi(mfxFrameSurface1* surface_handle,
|
||||
const cv::util::optional<cv::Rect> &opt_roi) {
|
||||
if (opt_roi.has_value()) {
|
||||
const cv::Rect &roi = opt_roi.value();
|
||||
surface_handle->Info.CropX = static_cast<mfxU16>(roi.x);
|
||||
@@ -176,7 +176,8 @@ pp_session VPPPreprocEngine::initialize_preproc(const pp_params& initial_frame_p
|
||||
const vpp_pp_params ¶ms = initial_frame_param.get<vpp_pp_params>();
|
||||
|
||||
// adjust preprocessing settings
|
||||
mfxVideoParam mfxVPPParams{0};
|
||||
mfxVideoParam mfxVPPParams{};
|
||||
memset(&mfxVPPParams, 0, sizeof(mfxVideoParam));
|
||||
// NB: IN params for VPP session must be equal to decoded surface params
|
||||
mfxVPPParams.vpp.In = params.info;
|
||||
|
||||
|
||||
@@ -16,12 +16,18 @@ namespace gapi {
|
||||
namespace wip {
|
||||
namespace onevpl {
|
||||
struct vpp_pp_params {
|
||||
vpp_pp_params() : handle(), info(), reserved() {}
|
||||
vpp_pp_params(mfxSession s, mfxFrameInfo i, void *r = nullptr) :
|
||||
handle(s), info(i), reserved(r) {}
|
||||
mfxSession handle;
|
||||
mfxFrameInfo info;
|
||||
void *reserved = nullptr;
|
||||
};
|
||||
|
||||
struct vpp_pp_session {
|
||||
vpp_pp_session() : handle(), reserved() {}
|
||||
vpp_pp_session(std::shared_ptr<EngineSession> h, void *r = nullptr) :
|
||||
handle(h), reserved(r) {}
|
||||
std::shared_ptr<EngineSession> handle;
|
||||
void *reserved = nullptr;
|
||||
};
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include <queue>
|
||||
#include <opencv2/gapi/streaming/onevpl/cfg_params.hpp>
|
||||
#include <opencv2/gapi/garg.hpp>
|
||||
#include "streaming/onevpl/engine/engine_session.hpp"
|
||||
#include "opencv2/gapi/own/exports.hpp" // GAPI_EXPORTS
|
||||
|
||||
|
||||
@@ -269,7 +269,8 @@ VPLLegacyTranscodeEngine::initialize_session(mfxSession mfx_session,
|
||||
const auto& mfxDecParams = decode_params.decoder_params.param;
|
||||
|
||||
// NB: create transcode params: Out = In by default, In = initially decoded
|
||||
mfxVideoParam mfxVPPParams{0};
|
||||
mfxVideoParam mfxVPPParams{};
|
||||
memset(&mfxVPPParams, 0, sizeof(mfxVPPParams));
|
||||
mfxVPPParams.vpp.In = mfxDecParams.mfx.FrameInfo;
|
||||
mfxVPPParams.vpp.Out = mfxVPPParams.vpp.In;
|
||||
|
||||
@@ -366,6 +367,8 @@ VPLLegacyTranscodeEngine::initialize_session(mfxSession mfx_session,
|
||||
VPLAccelerationPolicy::pool_key_t vpp_out_pool_key =
|
||||
acceleration_policy->create_surface_pool(vppRequests[1], mfxVPPParams.vpp.Out);
|
||||
|
||||
GAPI_LOG_INFO(nullptr, "Initialize VPP for session: " << mfx_session <<
|
||||
", out frame info: " << mfx_frame_info_to_string(mfxVPPParams.vpp.Out));
|
||||
sts = MFXVideoVPP_Init(mfx_session, &mfxVPPParams);
|
||||
if (MFX_ERR_NONE != sts) {
|
||||
GAPI_LOG_WARNING(nullptr, "cannot Init VPP");
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace gapi {
|
||||
namespace wip {
|
||||
namespace onevpl {
|
||||
class Surface;
|
||||
|
||||
class VPLLegacyTranscodeEngine;
|
||||
class GAPI_EXPORTS LegacyTranscodeSession : public LegacyDecodeSession {
|
||||
public:
|
||||
friend class VPLLegacyTranscodeEngine;
|
||||
|
||||
@@ -10,9 +10,11 @@
|
||||
#endif // defined(_MSC_VER)
|
||||
|
||||
#ifdef HAVE_ONEVPL
|
||||
#if defined(MFX_VERSION)
|
||||
#if (MFX_VERSION >= 2000)
|
||||
#include <vpl/mfxdispatcher.h>
|
||||
#endif // MFX_VERSION
|
||||
#endif // defined(MFX_VERSION)
|
||||
|
||||
#include <vpl/mfx.h>
|
||||
#include <vpl/mfxvideo.h>
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "streaming/onevpl/engine/transcode/transcode_engine_legacy.hpp"
|
||||
#include "streaming/onevpl/accelerators/accel_policy_dx11.hpp"
|
||||
#include "streaming/onevpl/accelerators/accel_policy_cpu.hpp"
|
||||
#include "streaming/onevpl/accelerators/accel_policy_va_api.hpp"
|
||||
#include "streaming/onevpl/utils.hpp"
|
||||
#include "streaming/onevpl/cfg_params_parser.hpp"
|
||||
#include "streaming/onevpl/data_provider_defines.hpp"
|
||||
@@ -294,6 +295,12 @@ std::unique_ptr<VPLAccelerationPolicy> GSource::Priv::initializeHWAccel(std::sha
|
||||
ret = std::move(cand);
|
||||
break;
|
||||
}
|
||||
case MFX_ACCEL_MODE_VIA_VAAPI:
|
||||
{
|
||||
std::unique_ptr<VPLVAAPIAccelerationPolicy> cand(new VPLVAAPIAccelerationPolicy(selector));
|
||||
ret = std::move(cand);
|
||||
break;
|
||||
}
|
||||
case MFX_ACCEL_MODE_NA:
|
||||
{
|
||||
std::unique_ptr<VPLCPUAccelerationPolicy> cand(new VPLCPUAccelerationPolicy(selector));
|
||||
|
||||
@@ -357,7 +357,7 @@ std::string mfxstatus_to_string(mfxStatus err) {
|
||||
}
|
||||
|
||||
std::string ret("<unknown ");
|
||||
ret += std::to_string(err) + ">";
|
||||
ret += std::to_string(static_cast<size_t>(err)) + ">";
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -384,7 +384,7 @@ std::string mfx_frame_info_to_string(const mfxFrameInfo &info) {
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
int compare(const mfxFrameInfo &lhs, const mfxFrameInfo &rhs) {
|
||||
static int compare(const mfxFrameInfo &lhs, const mfxFrameInfo &rhs) {
|
||||
//NB: mfxFrameInfo is a `packed` struct declared in VPL
|
||||
return memcmp(&lhs, &rhs, sizeof(mfxFrameInfo));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user