mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 20:21:24 +00:00
nvcomp: Add nvCOMP library based GPU lossless compression plugin
Adding NVIDIA nvCOMP library based plugin for lossless raw video compression/decompression. To build this plugin, user should install nvCOMP SDK first and specify the SDK path via "nvcomp-sdk-path" build option or NVCOMP_SDK_PATH env. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6912>
This commit is contained in:
parent
cee01d7fbd
commit
0ed9c39835
12 changed files with 4066 additions and 0 deletions
|
@ -1,3 +1,4 @@
|
|||
subprojects/gst-plugins-bad/ext/nvcomp
|
||||
subprojects/gst-plugins-bad/ext/qt6d3d11
|
||||
subprojects/gst-plugins-bad/gst-libs/gst/cuda
|
||||
subprojects/gst-plugins-bad/gst-libs/gst/d3d11
|
||||
|
|
|
@ -38,6 +38,7 @@ subdir('mpeg2enc')
|
|||
subdir('mplex')
|
||||
subdir('musepack')
|
||||
subdir('neon')
|
||||
subdir('nvcomp')
|
||||
subdir('onnx')
|
||||
subdir('openal')
|
||||
subdir('openaptx')
|
||||
|
|
60
subprojects/gst-plugins-bad/ext/nvcomp/gstnvcomp.cpp
Normal file
60
subprojects/gst-plugins-bad/ext/nvcomp/gstnvcomp.cpp
Normal file
|
@ -0,0 +1,60 @@
|
|||
/* 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 "gstnvcomp.h"
|
||||
#include <mutex>
|
||||
|
||||
static const GEnumValue nvcomp_methods[] = {
|
||||
{GST_NV_COMP_LZ4, "LZ4", "lz4"},
|
||||
{GST_NV_COMP_SNAPPY, "SNAPPY", "snappy"},
|
||||
{GST_NV_COMP_GDEFLATE, "GDEFLATE", "gdeflate"},
|
||||
{GST_NV_COMP_DEFLATE, "DEFLATE", "deflate"},
|
||||
{GST_NV_COMP_ZSTD, "ZSTD", "zstd"},
|
||||
{GST_NV_COMP_CASCADED, "CASCADED", "cascaded"},
|
||||
{GST_NV_COMP_BITCOMP, "BITCOMP", "bitcomp"},
|
||||
{GST_NV_COMP_ANS, "ANS", "ans"},
|
||||
{0, nullptr, nullptr},
|
||||
};
|
||||
|
||||
GType
|
||||
gst_nv_comp_method_get_type (void)
|
||||
{
|
||||
static GType method_type = 0;
|
||||
static std::once_flag once;
|
||||
|
||||
std::call_once (once,[&] {
|
||||
method_type = g_enum_register_static ("GstNvCompMethod",
|
||||
nvcomp_methods);
|
||||
});
|
||||
|
||||
return method_type;
|
||||
}
|
||||
|
||||
const gchar *
|
||||
gst_nv_comp_method_to_string (GstNvCompMethod method)
|
||||
{
|
||||
if (method >= GST_NV_COMP_LAST)
|
||||
return nullptr;
|
||||
|
||||
return nvcomp_methods[method].value_nick;
|
||||
}
|
56
subprojects/gst-plugins-bad/ext/nvcomp/gstnvcomp.h
Normal file
56
subprojects/gst-plugins-bad/ext/nvcomp/gstnvcomp.h
Normal file
|
@ -0,0 +1,56 @@
|
|||
/* 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/video/video.h>
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#include <gst/cuda/gstcuda.h>
|
||||
#include <stdint.h>
|
||||
#include <nvcomp.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
enum GstNvCompMethod
|
||||
{
|
||||
GST_NV_COMP_LZ4,
|
||||
GST_NV_COMP_SNAPPY,
|
||||
GST_NV_COMP_GDEFLATE,
|
||||
GST_NV_COMP_DEFLATE,
|
||||
GST_NV_COMP_ZSTD,
|
||||
GST_NV_COMP_CASCADED,
|
||||
GST_NV_COMP_BITCOMP,
|
||||
GST_NV_COMP_ANS,
|
||||
GST_NV_COMP_LAST,
|
||||
};
|
||||
|
||||
#define GST_TYPE_NV_COMP_METHOD (gst_nv_comp_method_get_type())
|
||||
GType gst_nv_comp_method_get_type ();
|
||||
|
||||
const gchar * gst_nv_comp_method_to_string (GstNvCompMethod method);
|
||||
|
||||
#define GST_NV_COMP_HEADER_VERSION 1
|
||||
#define GST_NV_COMP_HEADER_MIN_SIZE (sizeof (guint32) * 6)
|
||||
|
||||
G_END_DECLS
|
1739
subprojects/gst-plugins-bad/ext/nvcomp/gstnvcompvideodec.cpp
Normal file
1739
subprojects/gst-plugins-bad/ext/nvcomp/gstnvcompvideodec.cpp
Normal file
File diff suppressed because it is too large
Load diff
32
subprojects/gst-plugins-bad/ext/nvcomp/gstnvcompvideodec.h
Normal file
32
subprojects/gst-plugins-bad/ext/nvcomp/gstnvcompvideodec.h
Normal file
|
@ -0,0 +1,32 @@
|
|||
/* 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/video/video.h>
|
||||
#include "gstnvcomp.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GST_TYPE_NV_COMP_VIDEO_DEC (gst_nv_comp_video_dec_get_type())
|
||||
G_DECLARE_FINAL_TYPE (GstNvCompVideoDec, gst_nv_comp_video_dec,
|
||||
GST, NV_COMP_VIDEO_DEC, GstVideoDecoder)
|
||||
|
||||
G_END_DECLS
|
2014
subprojects/gst-plugins-bad/ext/nvcomp/gstnvcompvideoenc.cpp
Normal file
2014
subprojects/gst-plugins-bad/ext/nvcomp/gstnvcompvideoenc.cpp
Normal file
File diff suppressed because it is too large
Load diff
32
subprojects/gst-plugins-bad/ext/nvcomp/gstnvcompvideoenc.h
Normal file
32
subprojects/gst-plugins-bad/ext/nvcomp/gstnvcompvideoenc.h
Normal file
|
@ -0,0 +1,32 @@
|
|||
/* 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/video/video.h>
|
||||
#include "gstnvcomp.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GST_TYPE_NV_COMP_VIDEO_ENC (gst_nv_comp_video_enc_get_type())
|
||||
G_DECLARE_FINAL_TYPE (GstNvCompVideoEnc, gst_nv_comp_video_enc,
|
||||
GST, NV_COMP_VIDEO_ENC, GstVideoEncoder)
|
||||
|
||||
G_END_DECLS
|
70
subprojects/gst-plugins-bad/ext/nvcomp/meson.build
Normal file
70
subprojects/gst-plugins-bad/ext/nvcomp/meson.build
Normal file
|
@ -0,0 +1,70 @@
|
|||
nvcomp_sources = [
|
||||
'gstnvcomp.cpp',
|
||||
'gstnvcompvideodec.cpp',
|
||||
'gstnvcompvideoenc.cpp',
|
||||
'plugin.cpp',
|
||||
]
|
||||
extra_args = ['-DGST_USE_UNSTABLE_API']
|
||||
|
||||
nvcomp_opt = get_option('nvcomp')
|
||||
if nvcomp_opt.disabled() or host_system not in ['windows', 'linux']
|
||||
subdir_done()
|
||||
endif
|
||||
|
||||
nvcomp_sdk_path = get_option('nvcomp-sdk-path')
|
||||
if nvcomp_sdk_path == ''
|
||||
nvcomp_sdk_path = run_command(python3, '-c', 'import os; print(os.environ.get("NVCOMP_SDK_PATH"))', check: false).stdout().strip()
|
||||
endif
|
||||
|
||||
if nvcomp_sdk_path == '' or nvcomp_sdk_path == 'None'
|
||||
if nvcomp_opt.enabled()
|
||||
error('nvcomp-sdk-path option must be specified for nvCOMP plugin')
|
||||
endif
|
||||
subdir_done()
|
||||
endif
|
||||
|
||||
if not gstcuda_dep.found()
|
||||
if nvcomp_opt.enabled()
|
||||
error('nvCOMP plugin was enabled explicitly, but required gstcuda was not found')
|
||||
endif
|
||||
subdir_done()
|
||||
endif
|
||||
|
||||
nvcomp_inc_dirs = [include_directories(join_paths(nvcomp_sdk_path, 'include'), './stub'),
|
||||
cuda_stubinc]
|
||||
|
||||
nvcomp_lib_path = join_paths(nvcomp_sdk_path, 'lib')
|
||||
nvcomp_lib = cc.find_library('nvcomp',
|
||||
dirs: nvcomp_lib_path, required: nvcomp_opt)
|
||||
if not nvcomp_lib.found()
|
||||
subdir_done()
|
||||
endif
|
||||
|
||||
nvcomp_bitcomp_lib = cc.find_library('nvcomp_bitcomp',
|
||||
dirs: nvcomp_lib_path, required: nvcomp_opt)
|
||||
if not nvcomp_bitcomp_lib.found()
|
||||
subdir_done()
|
||||
endif
|
||||
|
||||
nvcomp_gdeflate_lib = cc.find_library('nvcomp_gdeflate',
|
||||
dirs: nvcomp_lib_path, required: nvcomp_opt)
|
||||
if not nvcomp_gdeflate_lib.found()
|
||||
subdir_done()
|
||||
endif
|
||||
|
||||
if gstgl_dep.found()
|
||||
extra_args += ['-DHAVE_GST_GL']
|
||||
endif
|
||||
|
||||
gstnvcomp = library('gstnvcomp',
|
||||
nvcomp_sources,
|
||||
c_args : gst_plugins_bad_args + extra_args,
|
||||
cpp_args : gst_plugins_bad_args + extra_args,
|
||||
include_directories : [configinc] + nvcomp_inc_dirs,
|
||||
dependencies : [gstbase_dep, gstvideo_dep, gstcuda_dep, gstgl_dep, nvcomp_lib,
|
||||
nvcomp_bitcomp_lib, nvcomp_gdeflate_lib],
|
||||
override_options : ['cpp_std=c++17'],
|
||||
install : true,
|
||||
install_dir : plugins_install_dir,
|
||||
)
|
||||
plugins += [gstnvcomp]
|
47
subprojects/gst-plugins-bad/ext/nvcomp/plugin.cpp
Normal file
47
subprojects/gst-plugins-bad/ext/nvcomp/plugin.cpp
Normal file
|
@ -0,0 +1,47 @@
|
|||
/* 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 "gstnvcomp.h"
|
||||
#include "gstnvcompvideodec.h"
|
||||
#include "gstnvcompvideoenc.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,
|
||||
"nvcompvideodec", GST_RANK_NONE, GST_TYPE_NV_COMP_VIDEO_DEC);
|
||||
gst_element_register (plugin,
|
||||
"nvcompvideoenc", GST_RANK_NONE, GST_TYPE_NV_COMP_VIDEO_ENC);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, GST_VERSION_MINOR, nvcomp,
|
||||
"GStreamer nvCOMP plugin", plugin_init, VERSION, "LGPL",
|
||||
GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)
|
|
@ -0,0 +1,9 @@
|
|||
#pragma once
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef struct CUstream_st* cudaStream_t;
|
||||
|
||||
G_END_DECLS
|
|
@ -143,6 +143,7 @@ option('mplex', type : 'feature', value : 'auto', description : 'mplex audio/vid
|
|||
option('msdk', type : 'feature', value : 'auto', description : 'Intel Media SDK video encoder/decoder plugin')
|
||||
option('musepack', type : 'feature', value : 'auto', description : 'libmpcdec Musepack decoder plugin')
|
||||
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('onnx', type : 'feature', value : 'auto', description : 'ONNX neural network plugin')
|
||||
option('openal', type : 'feature', value : 'auto', description : 'OpenAL plugin')
|
||||
|
@ -241,6 +242,10 @@ option('sctp-internal-usrsctp', type: 'feature', value : 'enabled',
|
|||
option('mfx_api', type : 'combo', choices : ['MSDK', 'oneVPL', 'auto'], value : 'auto',
|
||||
description : 'Select MFX API to build against')
|
||||
|
||||
# nvCOMP plugin options
|
||||
option('nvcomp-sdk-path', type: 'string', value : '',
|
||||
description : 'nvCOMP SDK root directory')
|
||||
|
||||
# QSV plugin options
|
||||
option('mfx-modules-dir', type: 'string', value : '',
|
||||
description : 'libmfx runtime module dir, linux only')
|
||||
|
|
Loading…
Reference in a new issue