mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-23 10:11:08 +00:00
nvdec: New plugin for NVIDIA hardware video decode
https://bugzilla.gnome.org/show_bug.cgi?id=781537
This commit is contained in:
parent
ed5d677dce
commit
ab9d87f168
6 changed files with 1255 additions and 5 deletions
35
configure.ac
35
configure.ac
|
@ -1912,9 +1912,9 @@ AC_SUBST(LIBUDEV_LIBS)
|
|||
AC_SUBST(LIBUSB_CFLAGS)
|
||||
AC_SUBST(LIBUSB_LIBS)
|
||||
|
||||
dnl *** NVENC ***
|
||||
translit(dnm, m, l) AM_CONDITIONAL(USE_NVENC, true)
|
||||
AG_GST_CHECK_FEATURE(NVENC, [NVIDIA Encode API], nvenc, [
|
||||
dnl *** CUDA ***
|
||||
translit(dnm, m, l) AM_CONDITIONAL(USE_CUDA, true)
|
||||
AG_GST_CHECK_FEATURE(CUDA, [NVIDIA CUDA API],, [
|
||||
AC_ARG_WITH([cuda-prefix],
|
||||
AS_HELP_STRING([--with-cuda-prefix],
|
||||
[Use the provided prefix for detecting the cuda installation]),
|
||||
|
@ -1958,7 +1958,35 @@ AG_GST_CHECK_FEATURE(NVENC, [NVIDIA Encode API], nvenc, [
|
|||
AC_CHECK_LIB(cuda,cuInit,[HAVE_CUDA_LIB="yes"], [
|
||||
AC_MSG_WARN([Could not find cuda library])])
|
||||
LIBS="$save_LIBS"
|
||||
])
|
||||
|
||||
dnl *** NVDEC ***
|
||||
translit(dnm, m, l) AM_CONDITIONAL(USE_NVDEC, true)
|
||||
AG_GST_CHECK_FEATURE(NVDEC, [nvdec], nvdec, [
|
||||
HAVE_NVCUVID_H=no
|
||||
save_CPPFLAGS="$CPPFLAGS"
|
||||
CPPFLAGS="$CUDA_CFLAGS $save_CPPFLAGS"
|
||||
AC_CHECK_HEADER([nvcuvid.h], [HAVE_NVCUVID_H=yes],
|
||||
AC_MSG_WARN([Could not find nvcuvid.h]))
|
||||
CPPFLAGS=$save_CPPFLAGS
|
||||
|
||||
HAVE_NVCUVID=no
|
||||
save_LIBS="$LIBS"
|
||||
LIBS="$CUDA_LIBS $save_LIBS"
|
||||
AC_CHECK_LIB(nvcuvid, cuvidCtxLock, [HAVE_NVCUVID=yes],
|
||||
AC_MSG_WARN([Could not find library nvcuvid]))
|
||||
LIBS="$save_LIBS"
|
||||
|
||||
if test "x$HAVE_NVCUVID_H" = "xyes" -a "x$HAVE_NVCUVID" = "xyes"; then
|
||||
HAVE_NVDEC=yes
|
||||
else
|
||||
HAVE_NVDEC=no
|
||||
fi
|
||||
])
|
||||
|
||||
dnl *** NVENC ***
|
||||
translit(dnm, m, l) AM_CONDITIONAL(USE_NVENC, true)
|
||||
AG_GST_CHECK_FEATURE(NVENC, [NVIDIA Encode API], nvenc, [
|
||||
dnl nvEncodeAPI.h header
|
||||
HAVE_NVENCODEAPI_H=no
|
||||
AC_ARG_VAR(NVENCODE_CFLAGS, [C compiler flags for NvEncodeAPI.h])
|
||||
|
@ -3628,6 +3656,7 @@ sys/dvb/Makefile
|
|||
sys/fbdev/Makefile
|
||||
sys/kms/Makefile
|
||||
sys/msdk/Makefile
|
||||
sys/nvdec/Makefile
|
||||
sys/nvenc/Makefile
|
||||
sys/opensles/Makefile
|
||||
sys/shm/Makefile
|
||||
|
|
|
@ -106,6 +106,12 @@ else
|
|||
UVCH264_DIR=
|
||||
endif
|
||||
|
||||
if USE_NVDEC
|
||||
NVDEC_DIR=nvdec
|
||||
else
|
||||
NVDEC_DIR=
|
||||
endif
|
||||
|
||||
if USE_NVENC
|
||||
NVENC_DIR=nvenc
|
||||
else
|
||||
|
@ -124,10 +130,10 @@ else
|
|||
MSDK_DIR=
|
||||
endif
|
||||
|
||||
SUBDIRS = $(ACM_DIR) $(ANDROID_MEDIA_DIR) $(APPLE_MEDIA_DIR) $(BLUEZ_DIR) $(D3DVIDEOSINK_DIR) $(DECKLINK_DIR) $(DIRECTSOUND_DIR) $(WINKS_DIR) $(DVB_DIR) $(FBDEV_DIR) $(KMS_DIR) $(OPENSLES_DIR) $(SHM_DIR) $(UVCH264_DIR) $(VCD_DIR) $(VDPAU_DIR) $(WININET_DIR) $(WINSCREENCAP_DIR) $(WASAPI_DIR) $(NVENC_DIR) $(TINYALSA_DIR) $(MSDK_DIR)
|
||||
SUBDIRS = $(ACM_DIR) $(ANDROID_MEDIA_DIR) $(APPLE_MEDIA_DIR) $(BLUEZ_DIR) $(D3DVIDEOSINK_DIR) $(DECKLINK_DIR) $(DIRECTSOUND_DIR) $(WINKS_DIR) $(DVB_DIR) $(FBDEV_DIR) $(KMS_DIR) $(OPENSLES_DIR) $(SHM_DIR) $(UVCH264_DIR) $(VCD_DIR) $(VDPAU_DIR) $(WININET_DIR) $(WINSCREENCAP_DIR) $(WASAPI_DIR) $(NVDEC_DIR) $(NVENC_DIR) $(TINYALSA_DIR) $(MSDK_DIR)
|
||||
|
||||
DIST_SUBDIRS = acmenc acmmp3dec androidmedia applemedia bluez d3dvideosink decklink directsound dvb fbdev kms dshowdecwrapper dshowsrcwrapper dshowvideosink \
|
||||
opensles shm uvch264 vcd vdpau wasapi winks winscreencap \
|
||||
nvenc tinyalsa msdk
|
||||
nvdec nvenc tinyalsa msdk
|
||||
|
||||
include $(top_srcdir)/common/parallel-subdirs.mak
|
||||
|
|
24
sys/nvdec/Makefile.am
Normal file
24
sys/nvdec/Makefile.am
Normal file
|
@ -0,0 +1,24 @@
|
|||
plugin_LTLIBRARIES = libgstnvdec.la
|
||||
|
||||
libgstnvdec_la_SOURCES = \
|
||||
gstnvdec.c \
|
||||
plugin.c
|
||||
|
||||
noinst_HEADERS = \
|
||||
gstnvdec.h
|
||||
|
||||
libgstnvdec_la_CFLAGS = \
|
||||
-I$(top_srcdir)/gst-libs \
|
||||
$(GST_CFLAGS) \
|
||||
$(GST_PBUTILS_CFLAGS) \
|
||||
$(GST_VIDEO_CFLAGS) \
|
||||
$(CUDA_CFLAGS)
|
||||
|
||||
libgstnvdec_la_LIBADD = \
|
||||
$(GST_LIBS) \
|
||||
$(GST_PBUTILS_LIBS) \
|
||||
$(GST_VIDEO_LIBS) \
|
||||
$(CUDA_LIBS) -lnvcuvid \
|
||||
$(top_builddir)/gst-libs/gst/gl/libgstgl-$(GST_API_VERSION).la
|
||||
|
||||
libgstnvdec_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
|
1054
sys/nvdec/gstnvdec.c
Normal file
1054
sys/nvdec/gstnvdec.c
Normal file
File diff suppressed because it is too large
Load diff
94
sys/nvdec/gstnvdec.h
Normal file
94
sys/nvdec/gstnvdec.h
Normal file
|
@ -0,0 +1,94 @@
|
|||
/*
|
||||
* Copyright (C) 2017 Ericsson AB. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer
|
||||
* in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef __GST_NVDEC_H__
|
||||
#define __GST_NVDEC_H__
|
||||
|
||||
#include <gst/gl/gl.h>
|
||||
#include <nvcuvid.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef struct _GstNvDecCudaContext GstNvDecCudaContext;
|
||||
typedef struct _GstNvDecCudaContextClass GstNvDecCudaContextClass;
|
||||
|
||||
struct _GstNvDecCudaContext
|
||||
{
|
||||
GObject parent;
|
||||
|
||||
CUcontext context;
|
||||
CUvideoctxlock lock;
|
||||
};
|
||||
|
||||
struct _GstNvDecCudaContextClass
|
||||
{
|
||||
GObjectClass parent_class;
|
||||
};
|
||||
|
||||
GType gst_nvdec_cuda_context_get_type (void);
|
||||
|
||||
|
||||
#define GST_TYPE_NVDEC (gst_nvdec_get_type())
|
||||
#define GST_NVDEC(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_NVDEC, GstNvDec))
|
||||
#define GST_NVDEC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_NVDEC, GstNvDecClass))
|
||||
#define GST_IS_NVDEC(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_NVDEC))
|
||||
#define GST_IS_NVDEC_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_NVDEC))
|
||||
|
||||
typedef struct _GstNvDec GstNvDec;
|
||||
typedef struct _GstNvDecClass GstNvDecClass;
|
||||
|
||||
struct _GstNvDec
|
||||
{
|
||||
GstVideoDecoder parent;
|
||||
|
||||
GstGLDisplay *gl_display;
|
||||
GstGLContext *gl_context;
|
||||
GstGLContext *other_gl_context;
|
||||
|
||||
GstNvDecCudaContext *cuda_context;
|
||||
CUvideoparser parser;
|
||||
CUvideodecoder decoder;
|
||||
GAsyncQueue *decode_queue;
|
||||
|
||||
guint width;
|
||||
guint height;
|
||||
guint fps_n;
|
||||
guint fps_d;
|
||||
GstClockTime min_latency;
|
||||
GstVideoCodecState *input_state;
|
||||
};
|
||||
|
||||
struct _GstNvDecClass
|
||||
{
|
||||
GstVideoDecoderClass parent_class;
|
||||
};
|
||||
|
||||
GType gst_nvdec_get_type (void);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GST_NVDEC_H__ */
|
43
sys/nvdec/plugin.c
Normal file
43
sys/nvdec/plugin.c
Normal file
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
* Copyright (C) 2017 Ericsson AB. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer
|
||||
* in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "gstnvdec.h"
|
||||
|
||||
static gboolean
|
||||
plugin_init (GstPlugin * plugin)
|
||||
{
|
||||
return gst_element_register (plugin, "nvdec", GST_RANK_PRIMARY,
|
||||
GST_TYPE_NVDEC);
|
||||
}
|
||||
|
||||
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, GST_VERSION_MINOR, nvdec,
|
||||
"GStreamer NVDEC plugin", plugin_init, VERSION, "BSD",
|
||||
GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)
|
Loading…
Reference in a new issue