nvdswrapper: Add NVIDIA DeepStream wrapper plugin

Adding a NVIDIA DeepStream SDK based plugin with a dewarp element

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7357>
This commit is contained in:
Seungha Yang 2024-08-13 01:03:56 +09:00 committed by GStreamer Marge Bot
parent 519d86d9f3
commit a830c58139
8 changed files with 1175 additions and 0 deletions

View file

@ -1,4 +1,5 @@
subprojects/gst-plugins-bad/ext/nvcomp
subprojects/gst-plugins-bad/ext/nvdswrapper
subprojects/gst-plugins-bad/ext/qt6d3d11
subprojects/gst-plugins-bad/gst-libs/gst/cuda
subprojects/gst-plugins-bad/gst-libs/gst/d3d11

View file

@ -41,6 +41,7 @@ subdir('mplex')
subdir('musepack')
subdir('neon')
subdir('nvcomp')
subdir('nvdswrapper')
subdir('onnx')
subdir('openal')
subdir('openaptx')

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,31 @@
/* GStreamer
* Copyright (C) 2024 Seungha Yang <seungha@centricular.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#pragma once
#include <gst/gst.h>
#include <gst/base/gstbasetransform.h>
G_BEGIN_DECLS
#define GST_TYPE_NV_DS_DEWARP (gst_nv_ds_dewarp_get_type())
G_DECLARE_FINAL_TYPE (GstNvDsDewarp, gst_nv_ds_dewarp,
GST, NV_DS_DEWARP, GstBaseTransform)
G_END_DECLS

View file

@ -0,0 +1,69 @@
nvdswrapper_sources = [
'plugin.cpp',
'gstnvdsdewarp.cpp',
]
extra_args = ['-DGST_USE_UNSTABLE_API']
nvdswrapper_opt = get_option('nvdswrapper')
if nvdswrapper_opt.disabled() or host_system != 'linux'
subdir_done()
endif
if not gstcuda_dep.found()
if nvdswrapper_opt.enabled()
error('nvdswrapper plugin was enabled explicitly, but required gstcuda was not found')
endif
subdir_done()
endif
have_sdk_header = false
nvds_inc = []
nvds_dewarper_lib = dependency('', required : false)
nvds_include_path = get_option('nvds-include-path')
if nvds_include_path != ''
nvds_inc = [include_directories(nvds_include_path)]
if cc.has_header('NVWarp360.h', include_directories: nvds_inc)
have_sdk_header = true
endif
endif
if not have_sdk_header
if cc.has_header('/opt/nvidia/deepstream/deepstream/sources/includes/NVWarp360.h')
nvds_inc = [include_directories('/opt/nvidia/deepstream/deepstream/sources/includes')]
else
if nvdswrapper_opt.enabled()
error('Could not find required header: "NVWarp360.h"')
endif
subdir_done()
endif
endif
nvds_lib_path = get_option('nvds-lib-path')
if nvds_lib_path != ''
nvds_dewarper_lib = cc.find_library('libnvds_dewarper.so', dirs: nvds_lib_path, required: false)
endif
if not nvds_dewarper_lib.found()
nvds_lib_path = '/opt/nvidia/deepstream/deepstream/lib'
nvds_dewarper_lib = cc.find_library('nvds_dewarper', dirs: nvds_lib_path, required: false)
if not nvds_dewarper_lib.found()
if nvdswrapper_opt.enabled()
error('Could not find required library: "nvds_dewarper"')
endif
subdir_done()
endif
endif
nvds_inc += [include_directories('stub'), cuda_stubinc]
gstnvdswrapper = library('gstnvdswrapper',
nvdswrapper_sources,
c_args : gst_plugins_bad_args + extra_args,
cpp_args : gst_plugins_bad_args + extra_args,
include_directories : [configinc] + nvds_inc,
dependencies : [gstbase_dep, gstvideo_dep, gstcuda_dep, nvds_dewarper_lib],
install : true,
install_dir : plugins_install_dir,
)
plugins += [gstnvdswrapper]

View file

@ -0,0 +1,46 @@
/* GStreamer
* Copyright (C) 2024 Seungha Yang <seungha@centricular.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <gst/gst.h>
#include <gst/cuda/gstcuda.h>
#include "gstnvdsdewarp.h"
static gboolean
plugin_init (GstPlugin * plugin)
{
if (!gst_cuda_load_library ()) {
gst_plugin_add_status_warning (plugin, "CUDA library was not found.");
return TRUE;
}
gst_element_register (plugin, "nvdsdewarp", GST_RANK_NONE,
GST_TYPE_NV_DS_DEWARP);
return TRUE;
}
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
GST_VERSION_MINOR,
nvdswrapper,
"NVIDIA DeepStream wrapper plugin",
plugin_init, VERSION, "LGPL", GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)

View file

@ -0,0 +1,18 @@
#pragma once
#include <glib.h>
G_BEGIN_DECLS
typedef struct CUstream_st* cudaStream_t;
typedef unsigned long long cudaTextureObject_t;
typedef unsigned long long cudaSurfaceObject_t;
typedef struct _dim3
{
unsigned int x;
unsigned int y;
unsigned int z;
} dim3;
G_END_DECLS

View file

@ -148,6 +148,7 @@ option('musepack', type : 'feature', value : 'auto', description : 'libmpcdec Mu
option('neon', type : 'feature', value : 'auto', description : 'NEON HTTP source plugin')
option('nvcomp', type : 'feature', value : 'auto', description : 'NVIDIA nvCOMP compression/decompression plugin')
option('nvcodec', type : 'feature', value : 'auto', description : 'NVIDIA GPU codec plugin')
option('nvdswrapper', type : 'feature', value : 'auto', description : 'NVIDIA DeepStream SDK wrapper plugin')
option('onnx', type : 'feature', value : 'auto', description : 'ONNX neural network plugin')
option('openal', type : 'feature', value : 'auto', description : 'OpenAL plugin')
option('openexr', type : 'feature', value : 'auto', description : 'OpenEXR plugin')
@ -249,6 +250,12 @@ option('mfx_api', type : 'combo', choices : ['MSDK', 'oneVPL', 'auto'], value :
option('nvcomp-sdk-path', type: 'string', value : '',
description : 'nvCOMP SDK root directory')
# nvdswrapper plugin options
option('nvds-include-path', type: 'string', value : '',
description : 'DeepStream SDK include directory')
option('nvds-lib-path', type: 'string', value : '',
description : 'DeepStream SDK library directory')
# QSV plugin options
option('mfx-modules-dir', type: 'string', value : '',
description : 'libmfx runtime module dir, linux only')