Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion include/dlstreamer/openvino/context.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (C) 2022-2025 Intel Corporation
* Copyright (C) 2022-2026 Intel Corporation
*
* SPDX-License-Identifier: MIT
******************************************************************************/
Expand All @@ -15,6 +15,7 @@
#else
#include <openvino/runtime/intel_gpu/ocl/va.hpp>
#endif
#include <openvino/runtime/intel_npu/properties.hpp>

namespace dlstreamer {

Expand Down Expand Up @@ -108,7 +109,11 @@ using OpenVINOContextPtr = std::shared_ptr<OpenVINOContext>;
#include "dlstreamer/openvino/mappers/cpu_to_openvino.h"
#include "dlstreamer/openvino/mappers/opencl_to_openvino.h"
#include "dlstreamer/openvino/mappers/openvino_to_cpu.h"
#ifndef _WIN32
#include "dlstreamer/openvino/mappers/vaapi_to_openvino.h"
#else
#include "dlstreamer/openvino/mappers/d3d11_to_openvino.h"
#endif

namespace dlstreamer {

Expand All @@ -121,8 +126,13 @@ MemoryMapperPtr OpenVINOContext::get_mapper(const ContextPtr &input_context, con
auto output_type = output_context ? output_context->memory_type() : MemoryType::CPU;
if (input_type == MemoryType::CPU && output_type == MemoryType::OpenVINO)
return std::make_shared<MemoryMapperCPUToOpenVINO>(input_context, output_context);
#ifndef _WIN32
if (input_type == MemoryType::VAAPI && output_type == MemoryType::OpenVINO)
return std::make_shared<MemoryMapperVAAPIToOpenVINO>(input_context, output_context);
#else
if (input_type == MemoryType::D3D11 && output_type == MemoryType::OpenVINO)
return std::make_shared<MemoryMapperD3D11ToOpenVINO>(input_context, output_context);
#endif
if (input_type == MemoryType::OpenCL && output_type == MemoryType::OpenVINO)
return std::make_shared<MemoryMapperOpenCLToOpenVINO>(input_context, output_context);
if (input_type == MemoryType::OpenVINO && output_type == MemoryType::CPU)
Expand Down
83 changes: 83 additions & 0 deletions include/dlstreamer/openvino/mappers/d3d11_to_openvino.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/*******************************************************************************
* Copyright (C) 2026 Intel Corporation
*
* SPDX-License-Identifier: MIT
******************************************************************************/

#pragma once

#include "dlstreamer/base/memory_mapper.h"
#include "dlstreamer/d3d11/tensor.h"
#include "dlstreamer/openvino/context.h"
#include "dlstreamer/openvino/tensor.h"

#include <openvino/runtime/intel_gpu/remote_properties.hpp>

namespace dlstreamer {

class MemoryMapperD3D11ToOpenVINO : public BaseMemoryMapper {
public:
MemoryMapperD3D11ToOpenVINO(const ContextPtr &input_context, const ContextPtr &output_context)
: BaseMemoryMapper(input_context, output_context) {
_ov_context = *ptr_cast<OpenVINOContext>(output_context);
}

FramePtr map(FramePtr src, AccessMode /*mode*/) override {
// Only NV12 supported currently
DLS_CHECK(static_cast<ImageFormat>(src->format()) == ImageFormat::NV12);

ov::TensorVector y_ov_tensors, uv_ov_tensors;
y_ov_tensors.reserve(src->num_tensors());
uv_ov_tensors.reserve(src->num_tensors());

// Convert DLS tensors w/D3D11 texture to OV remote tensors
for (auto dls_tensor : src) {
auto d3d11_tensor = ptr_cast<D3D11Tensor>(dls_tensor);
// Skip planes other than y - we don't need them for creating OV tensors.
if (d3d11_tensor->plane_index() != 0)
continue;
auto [yt, uvt] = convert_to_ov_tensors(*d3d11_tensor);
y_ov_tensors.push_back(yt);
uv_ov_tensors.push_back(uvt);
}

TensorPtr res_y_tensor, res_uv_tensor;
if (y_ov_tensors.size() > 1) {
res_y_tensor = std::make_shared<OpenVINOTensorBatch>(std::move(y_ov_tensors), _output_context);
res_uv_tensor = std::make_shared<OpenVINOTensorBatch>(std::move(uv_ov_tensors), _output_context);
} else {
res_y_tensor = std::make_shared<OpenVINOTensor>(y_ov_tensors.front(), _output_context);
res_uv_tensor = std::make_shared<OpenVINOTensor>(uv_ov_tensors.front(), _output_context);
}

auto res_frame =
std::make_shared<BaseFrame>(src->media_type(), src->format(), TensorVector{res_y_tensor, res_uv_tensor});
res_frame->set_parent(src);
return res_frame;
}

private:
std::pair<ov::RemoteTensor, ov::RemoteTensor> convert_to_ov_tensors(D3D11Tensor &d3d11_tensor) {
auto d3d11_texture = d3d11_tensor.d3d11_texture();
auto &info = d3d11_tensor.info();
dlstreamer::ImageInfo image_info(info);
auto width = image_info.width();
auto height = image_info.height();

ov::AnyMap tensor_params = {{ov::intel_gpu::shared_mem_type.name(), "VA_SURFACE"},
{ov::intel_gpu::dev_object_handle.name(), static_cast<void *>(d3d11_texture)},
{ov::intel_gpu::va_plane.name(), uint32_t(0)}};
auto y_tensor = _ov_context.create_tensor(ov::element::u8, {1, 1, height, width}, tensor_params);

// FIXME: should we get width/height from second tensor ?
tensor_params[ov::intel_gpu::va_plane.name()] = uint32_t(1);
auto uv_tensor = _ov_context.create_tensor(ov::element::u8, {1, 2, height / 2, width / 2}, tensor_params);

return {y_tensor, uv_tensor};
}

private:
ov::RemoteContext _ov_context;
};

} // namespace dlstreamer
15 changes: 6 additions & 9 deletions src/monolithic/gst/common/gva_caps.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (C) 2018-2025 Intel Corporation
* Copyright (C) 2018-2026 Intel Corporation
*
* SPDX-License-Identifier: MIT
******************************************************************************/
Expand All @@ -18,21 +18,18 @@

#define SYSTEM_MEM_CAPS GST_VIDEO_CAPS_MAKE("{ BGRx, BGRA, BGR, NV12, I420 }") "; "

#ifdef ENABLE_VAAPI
#if defined(ENABLE_VAAPI) && !defined(_WIN32)
#define VASURFACE_CAPS GST_VIDEO_CAPS_MAKE_WITH_FEATURES(VASURFACE_FEATURE_STR, "{ NV12 }") "; "
#define VAMEMORY_CAPS GST_VIDEO_CAPS_MAKE_WITH_FEATURES(VAMEMORY_FEATURE_STR, "{ NV12 }") "; "
#else
#define VASURFACE_CAPS
#endif

#ifdef ENABLE_VAAPI
#define DMA_BUFFER_CAPS GST_VIDEO_CAPS_MAKE_WITH_FEATURES(DMABUF_FEATURE_STR, "{ DMA_DRM }") "; "
#else
#define VASURFACE_CAPS
#define VAMEMORY_CAPS
#define DMA_BUFFER_CAPS
#endif

#ifdef _MSC_VER
#define D3D11MEMORY_CAPS GST_VIDEO_CAPS_MAKE_WITH_FEATURES(D3D11MEMORY_FEATURE_STR, "{ NV12 }") "; "
#ifdef _WIN32
#define D3D11MEMORY_CAPS GST_VIDEO_CAPS_MAKE_WITH_FEATURES(D3D11MEMORY_FEATURE_STR, "{ NV12,BGRA }") "; "
#else
#define D3D11MEMORY_CAPS
#endif
Expand Down
9 changes: 0 additions & 9 deletions src/monolithic/gst/elements/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ find_package(PkgConfig REQUIRED)
pkg_check_modules(GSTREAMER gstreamer-1.0>=1.16 REQUIRED)
pkg_check_modules(GSTVIDEO gstreamer-video-1.0>=1.16 REQUIRED)
pkg_check_modules(GSTALLOC gstreamer-allocators-1.0 REQUIRED)
pkg_search_module(VA va libva REQUIRED)
if(NOT MSVC)
pkg_check_modules(GSTVA REQUIRED IMPORTED_TARGET gstreamer-va-1.0)
endif()
Expand Down Expand Up @@ -118,14 +117,6 @@ if(${ENABLE_AUDIO_INFERENCE_ELEMENTS})
target_link_libraries(${TARGET_NAME} PRIVATE ${GSTAUDIO_LIBRARIES})
endif()

if(${ENABLE_VAAPI})
target_link_libraries(${TARGET_NAME} PRIVATE image_inference_async)
endif()

if(WIN32)
target_link_libraries(${TARGET_NAME} PRIVATE d3d11_wrapper image_inference_async_d3d11)
endif()

add_subdirectory(gvaattachroi)
add_subdirectory(gvametapublish)
add_subdirectory(gvapython)
Expand Down
5 changes: 1 addition & 4 deletions src/monolithic/gst/elements/gvaattachroi/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
# ==============================================================================
# Copyright (C) 2021-2025 Intel Corporation
# Copyright (C) 2021-2026 Intel Corporation
#
# SPDX-License-Identifier: MIT
# ==============================================================================

set (TARGET_NAME "gvaattachroi")

find_package(PkgConfig REQUIRED)
pkg_search_module(VA va libva REQUIRED)
pkg_check_modules(GSTREAMER gstreamer-1.0>=1.14 REQUIRED)
pkg_check_modules(GSTVIDEO gstreamer-video-1.0>=1.14 REQUIRED)
pkg_check_modules(GSTALLOC gstreamer-allocators-1.0 REQUIRED)
Expand Down Expand Up @@ -35,8 +34,6 @@ target_include_directories(${TARGET_NAME}
${CMAKE_CURRENT_SOURCE_DIR}
)

target_link_directories(${TARGET_NAME} PUBLIC ${VA_LIBRARY_DIRS})

target_link_libraries(${TARGET_NAME}
PRIVATE
${GSTREAMER_LIBRARIES}
Expand Down
5 changes: 1 addition & 4 deletions src/monolithic/gst/elements/gvametapublish/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
# ==============================================================================
# Copyright (C) 2021-2025 Intel Corporation
# Copyright (C) 2021-2026 Intel Corporation
#
# SPDX-License-Identifier: MIT
# ==============================================================================

set (TARGET_NAME "gvametapublish")

find_package(PkgConfig REQUIRED)
pkg_search_module(VA va libva REQUIRED)
pkg_check_modules(GSTREAMER gstreamer-1.0>=1.16 REQUIRED)


Expand Down Expand Up @@ -40,8 +39,6 @@ PRIVATE
${GSTREAMER_INCLUDE_DIRS}
)

target_link_directories(${TARGET_NAME} PUBLIC ${VA_LIBRARY_DIRS})

target_link_libraries(${TARGET_NAME}
PRIVATE
gstvideoanalyticsmeta
Expand Down
5 changes: 1 addition & 4 deletions src/monolithic/gst/elements/gvapython/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
# ==============================================================================
# Copyright (C) 2020-2025 Intel Corporation
# Copyright (C) 2020-2026 Intel Corporation
#
# SPDX-License-Identifier: MIT
# ==============================================================================

set (TARGET_NAME "gvapython")

find_package(PkgConfig REQUIRED)
pkg_search_module(VA va libva REQUIRED)
pkg_check_modules(GLIB2 glib-2.0 REQUIRED)
pkg_check_modules(GSTREAMER gstreamer-1.0>=1.16 REQUIRED)
pkg_check_modules(PYGOBJECT pygobject-3.0)
Expand Down Expand Up @@ -38,8 +37,6 @@ PRIVATE
${PYGOBJECT_INCLUDE_DIRS}
)

target_link_directories(${TARGET_NAME} PUBLIC ${VA_LIBRARY_DIRS})

target_link_libraries(${TARGET_NAME}
PRIVATE
${GSTREAMER_LIBRARIES}
Expand Down
3 changes: 0 additions & 3 deletions src/monolithic/gst/elements/gvarealsense/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

set(TARGET_NAME "gvarealsense")

pkg_search_module(VA va libva REQUIRED)
find_package(OpenCV REQUIRED core imgproc)
find_package(realsense2)

Expand Down Expand Up @@ -35,8 +34,6 @@ target_include_directories(${TARGET_NAME}
${GSTALLOC_INCLUDE_DIRS}
)

target_link_directories(${TARGET_NAME} PUBLIC ${VA_LIBRARY_DIRS})

target_link_libraries(${TARGET_NAME}
PRIVATE
${GSTREAMER_LIBRARIES}
Expand Down
4 changes: 1 addition & 3 deletions src/monolithic/gst/elements/gvatrack/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ==============================================================================
# Copyright (C) 2020-2025 Intel Corporation
# Copyright (C) 2020-2026 Intel Corporation
#
# SPDX-License-Identifier: MIT
# ==============================================================================
Expand All @@ -9,7 +9,6 @@ set (TARGET_NAME "gvatrack")
find_package(OpenCV REQUIRED core imgproc)
find_package(OpenVINO REQUIRED)
find_package(PkgConfig REQUIRED)
pkg_search_module(VA va libva REQUIRED)
pkg_check_modules(GSTREAMER gstreamer-1.0>=1.16 REQUIRED)

file (GLOB_RECURSE MAIN_SRC
Expand Down Expand Up @@ -37,7 +36,6 @@ PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/vas/modules/platform/inc
${CMAKE_CURRENT_SOURCE_DIR}/vas/modules/kernels/kalman_filter/inc
${CMAKE_CURRENT_SOURCE_DIR}/vas/modules/components/ot/inc
${VA_INCLUDE_DIRS}
)

target_link_libraries(${TARGET_NAME}
Expand Down
6 changes: 3 additions & 3 deletions src/monolithic/gst/elements/gvatrack/gstgvatrack.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (C) 2018-2025 Intel Corporation
* Copyright (C) 2018-2026 Intel Corporation
*
* SPDX-License-Identifier: MIT
******************************************************************************/
Expand All @@ -15,7 +15,7 @@
#include <dlstreamer/gst/context.h>
#include <dlstreamer/memory_mapper_factory.h>

#ifdef ENABLE_VAAPI
#if !defined(_WIN32) && defined(ENABLE_VAAPI)
#include <dlstreamer/vaapi/context.h>
#endif

Expand Down Expand Up @@ -66,7 +66,7 @@ static dlstreamer::MemoryMapperPtr create_mapper(GstGvaTrack *gva_track, dlstrea
if (!gpu_device)
return BufferMapperFactory::createMapper(InferenceBackend::MemoryType::SYSTEM);

#ifdef ENABLE_VAAPI
#if !defined(_WIN32) && defined(ENABLE_VAAPI)
// GPU tracker expects VASurface or VAMemory as input.
if (gva_track->caps_feature == VA_SURFACE_CAPS_FEATURE || gva_track->caps_feature == VA_MEMORY_CAPS_FEATURE)
return BufferMapperFactory::createMapper(InferenceBackend::MemoryType::VAAPI, context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,9 @@
#include "gstgvawatermarkimpl.h"
#include "gvawatermarkcaps.h"

#ifndef _MSC_VER
#ifndef _WIN32
#include <dlstreamer/image_info.h>
#include <gmodule.h>
#else
// On Windows try to include libva headers if available; otherwise fall back to minimal constants.
#if __has_include(<va/va.h>)
#include <va/va.h>
#endif
#ifndef VA_INVALID_SURFACE
#define VA_INVALID_SURFACE (-1)
#endif
#endif

#include <gst/allocators/gstdmabuf.h>
Expand All @@ -35,17 +27,23 @@
#include "utils.h"
#include "video_frame.h"

#ifndef _WIN32
#ifdef ENABLE_VAAPI
#include <dlstreamer/vaapi/mappers/vaapi_to_dma.h>
#endif
#else
#include <dlstreamer/gst/mappers/gst_to_d3d11.h>
#define GST_USE_UNSTABLE_API
#include <gst/d3d11/gstd3d11.h>
#endif

#include "renderer/color_converter.h"
#include "renderer/cpu/create_renderer.h"

#include <exception>
#include <string>
#include <typeinfo>
#ifndef ENABLE_VAAPI
#if !defined(ENABLE_VAAPI) || defined(_WIN32)
// VAAPI disabled: provide minimal stub types/constants to satisfy signatures without libva.
#ifndef VA_INVALID_SURFACE
#define VA_INVALID_SURFACE (-1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@
#ifndef _MSC_VER
#include <dlstreamer/gst/context.h>
#include <dlstreamer/vaapi/context.h>
#include <va/va.h>
#include <opencv2/core/va_intel.hpp>
#endif

#include <opencv2/core.hpp>
#include <opencv2/core/ocl.hpp>
#include <opencv2/core/va_intel.hpp>
#include <opencv2/imgproc.hpp>

G_BEGIN_DECLS
Expand Down
4 changes: 2 additions & 2 deletions src/monolithic/gst/inference_elements/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ==============================================================================
# Copyright (C) 2018-2025 Intel Corporation
# Copyright (C) 2018-2026 Intel Corporation
#
# SPDX-License-Identifier: MIT
# ==============================================================================
Expand Down Expand Up @@ -93,7 +93,7 @@ PUBLIC
model_proc
)

if(${ENABLE_VAAPI})
if(${ENABLE_VAAPI} AND NOT(WIN32))
target_link_libraries(${TARGET_NAME} PRIVATE va_api_wrapper image_inference_async)
endif()

Expand Down
Loading
Loading