summaryrefslogtreecommitdiff
path: root/sys/nvdec
diff options
context:
space:
mode:
authorSeungha Yang <seungha.yang@navercorp.com>2018-11-22 00:22:25 +0900
committerTim-Philipp Müller <tim@centricular.com>2018-11-25 23:31:37 +0000
commit4e314d6f80515501906599f548e88e2e4f2d9452 (patch)
tree45d67abeeeca7b0459aeddefe4c38f9afdcc61b5 /sys/nvdec
parent67a84254aef632f5d765726939544dff014c14ea (diff)
downloadgstreamer-plugins-bad-4e314d6f80515501906599f548e88e2e4f2d9452.tar.gz
nvdec: Drop dynlink interface and use NVIDIA CODEC SDK instead
dynlink_* was introduced since CUDA Toolkit 9.x but it's deprecated from 10.0. Instead of using #ifdef hack, shipping nvidia headers of NVIDA CODEC SDK can make build/code simple
Diffstat (limited to 'sys/nvdec')
-rw-r--r--sys/nvdec/Makefile.am7
-rw-r--r--sys/nvdec/dynlink_cuda.c122
-rw-r--r--sys/nvdec/dynlink_nvcuvid.c105
-rw-r--r--sys/nvdec/gstnvdec.c8
-rw-r--r--sys/nvdec/gstnvdec.h13
5 files changed, 1 insertions, 254 deletions
diff --git a/sys/nvdec/Makefile.am b/sys/nvdec/Makefile.am
index 1fd7efa24..ca40fc3d4 100644
--- a/sys/nvdec/Makefile.am
+++ b/sys/nvdec/Makefile.am
@@ -4,11 +4,6 @@ libgstnvdec_la_SOURCES = \
gstnvdec.c \
plugin.c
-if USE_DYNLINK_NVDEC
-libgstnvdec_la_SOURCES += dynlink_nvcuvid.c
-libgstnvdec_la_SOURCES += dynlink_cuda.c
-endif
-
noinst_HEADERS = \
gstnvdec.h
@@ -26,8 +21,6 @@ libgstnvdec_la_LIBADD = \
$(GST_VIDEO_LIBS) \
$(GST_LIBS)
-if !USE_DYNLINK_NVDEC
libgstnvdec_la_LIBADD += $(CUDA_LIBS) -lnvcuvid
-endif
libgstnvdec_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
diff --git a/sys/nvdec/dynlink_cuda.c b/sys/nvdec/dynlink_cuda.c
deleted file mode 100644
index 995481b64..000000000
--- a/sys/nvdec/dynlink_cuda.c
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Copyright 2018 Red Hat, Inc. and/or its affiliates.
- *
- * 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.
- */
-
-#include <gst/gst.h>
-#include <gst/gl/gstglfuncs.h>
-#include <dynlink_cuda.h>
-#include <gmodule.h>
-
-/* Types that are missing from included headers */
-typedef CUresult CUDAAPI tcuGetErrorName (CUresult error, const char **pStr);
-typedef CUresult CUDAAPI tcuGetErrorString (CUresult error, const char **pStr);
-typedef CUresult CUDAAPI tcuGraphicsGLRegisterImage (CUgraphicsResource *
- pCudaResource, GLuint image, GLenum target, unsigned int Flags);
-
-tcuInit *_cuInit;
-tcuDriverGetVersion *cuDriverGetVersion;
-tcuCtxCreate *cuCtxCreate;
-tcuCtxDestroy *cuCtxDestroy;
-tcuCtxPopCurrent *cuCtxPopCurrent;
-tcuMemcpy2D *cuMemcpy2D;
-tcuGraphicsUnregisterResource *cuGraphicsUnregisterResource;
-tcuGraphicsSubResourceGetMappedArray *cuGraphicsSubResourceGetMappedArray;
-tcuGraphicsMapResources *cuGraphicsMapResources;
-tcuGraphicsUnmapResources *cuGraphicsUnmapResources;
-
-tcuGetErrorName *cuGetErrorName;
-tcuGetErrorString *cuGetErrorString;
-tcuGraphicsGLRegisterImage *cuGraphicsGLRegisterImage;
-
-#if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
-static char CudaLibName[] = "nvcuda.dll";
-#elif defined(__unix__)
-static char CudaLibName[] = "libcuda.so";
-#endif
-
-#define STRINGIFY(X) #X
-#define GET_PROC(name) \
- if (!g_module_symbol (module, #name, (gpointer *)&name)) { \
- GST_ERROR("%s", g_module_error()); \
- g_module_close(module); \
- return CUDA_ERROR_UNKNOWN; \
- }
-
-#define GET_PROC_V2(name) \
- if(!g_module_symbol (module, STRINGIFY(name##_v2), (gpointer *)&name)) { \
- GST_ERROR("%s", g_module_error()); \
- g_module_close(module); \
- return CUDA_ERROR_UNKNOWN; \
- }
-
-CUresult CUDAAPI
-cuInit (unsigned int Flags, int cudaVersion, void *pHandleDriver)
-{
- GModule *module;
- int driverVer = 1000;
-
- module = g_module_open (CudaLibName, G_MODULE_BIND_LAZY);
- if (module == NULL) {
- GST_ERROR ("%s", g_module_error ());
- return CUDA_ERROR_UNKNOWN;
- }
- //Init
- g_module_symbol (module, "cuInit", (gpointer *) & _cuInit);
- if (_cuInit == NULL || _cuInit (Flags) != CUDA_SUCCESS) {
- GST_ERROR ("Failed to init cuda\n");
- return CUDA_ERROR_UNKNOWN;
- }
-
- GET_PROC (cuDriverGetVersion);
- if (cuDriverGetVersion == NULL
- || cuDriverGetVersion (&driverVer) != CUDA_SUCCESS) {
- GST_ERROR ("Failed to get cuda version\n");
- return CUDA_ERROR_UNKNOWN;
- }
-
- if (cudaVersion < 4000 || __CUDA_API_VERSION < 4000) {
- GST_ERROR ("cuda version or cuda api version is too old\n");
- return CUDA_ERROR_UNKNOWN;
- }
-
- GET_PROC (cuCtxDestroy);
- GET_PROC (cuCtxPopCurrent);
- GET_PROC (cuGetErrorName);
- GET_PROC (cuGetErrorString);
-
- GET_PROC_V2 (cuCtxDestroy);
- GET_PROC_V2 (cuCtxPopCurrent);
- GET_PROC_V2 (cuCtxCreate);
- GET_PROC_V2 (cuMemcpy2D);
- GET_PROC (cuGraphicsGLRegisterImage);
- GET_PROC (cuGraphicsGLRegisterImage);
- GET_PROC (cuGraphicsUnregisterResource);
- GET_PROC (cuGraphicsSubResourceGetMappedArray);
- GET_PROC (cuGraphicsMapResources);
- GET_PROC (cuGraphicsUnmapResources);
-
- return CUDA_SUCCESS;
-}
diff --git a/sys/nvdec/dynlink_nvcuvid.c b/sys/nvdec/dynlink_nvcuvid.c
deleted file mode 100644
index 35a1a07c9..000000000
--- a/sys/nvdec/dynlink_nvcuvid.c
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Copyright 2018 Red Hat, Inc. and/or its affiliates.
- *
- * 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.
- */
-
-#include <gst/gst.h>
-#include "dynlink_nvcuvid.h"
-#include <gmodule.h>
-
-tcuvidCreateVideoParser *cuvidCreateVideoParser;
-tcuvidParseVideoData *cuvidParseVideoData;
-tcuvidDestroyVideoParser *cuvidDestroyVideoParser;
-tcuvidCreateDecoder *cuvidCreateDecoder;
-tcuvidDestroyDecoder *cuvidDestroyDecoder;
-tcuvidDecodePicture *cuvidDecodePicture;
-tcuvidMapVideoFrame *cuvidMapVideoFrame;
-tcuvidUnmapVideoFrame *cuvidUnmapVideoFrame;
-#if defined(__x86_64) || defined(AMD64) || defined(_M_AMD64)
-tcuvidMapVideoFrame64 *cuvidMapVideoFrame64;
-tcuvidUnmapVideoFrame64 *cuvidUnmapVideoFrame64;
-#endif
-tcuvidCtxLockCreate *cuvidCtxLockCreate;
-tcuvidCtxLockDestroy *cuvidCtxLockDestroy;
-tcuvidCtxLock *cuvidCtxLock;
-tcuvidCtxUnlock *cuvidCtxUnlock;
-
-#if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
-static char CudaLibName[] = "nvcuvid.dll";
-#elif defined(__unix__)
-static char CudaLibName[] = "libnvcuvid.so";
-#endif
-
-#define STRINGIFY(X) #X
-#define GET_PROC(name) \
- if (!g_module_symbol (module, #name, (gpointer *)&name)) { \
- GST_ERROR("%s", g_module_error()); \
- g_module_close(module); \
- return CUDA_ERROR_UNKNOWN; \
- }
-
-#define GET_PROC_V2(name) \
- if(!g_module_symbol (module, STRINGIFY(name##_v2), (gpointer *)&name)) { \
- GST_ERROR("%s", g_module_error()); \
- g_module_close(module); \
- return CUDA_ERROR_UNKNOWN; \
- }
-
-CUresult CUDAAPI
-cuvidInit (unsigned int Flags)
-{
- GModule *module;
-
- module = g_module_open (CudaLibName, G_MODULE_BIND_LAZY);
- if (module == NULL) {
- GST_ERROR ("%s", g_module_error ());
- return CUDA_ERROR_UNKNOWN;
- }
-
- GET_PROC (cuvidCreateVideoParser);
- GET_PROC (cuvidParseVideoData);
- GET_PROC (cuvidDestroyVideoParser);
-
- GET_PROC (cuvidCreateDecoder);
- GET_PROC (cuvidDestroyDecoder);
- GET_PROC (cuvidDecodePicture);
-
-#if defined(__x86_64) || defined(AMD64) || defined(_M_AMD64)
- GET_PROC (cuvidMapVideoFrame64);
- GET_PROC (cuvidUnmapVideoFrame64);
- cuvidMapVideoFrame = cuvidMapVideoFrame64;
- cuvidUnmapVideoFrame = cuvidUnmapVideoFrame64;
-#else
- GET_PROC (cuvidMapVideoFrame);
- GET_PROC (cuvidUnmapVideoFrame);
-#endif
-
- GET_PROC (cuvidCtxLockCreate);
- GET_PROC (cuvidCtxLockDestroy);
- GET_PROC (cuvidCtxLock);
- GET_PROC (cuvidCtxUnlock);
-
- return CUDA_SUCCESS;
-}
diff --git a/sys/nvdec/gstnvdec.c b/sys/nvdec/gstnvdec.c
index 119ed132f..2d7c66402 100644
--- a/sys/nvdec/gstnvdec.c
+++ b/sys/nvdec/gstnvdec.c
@@ -97,16 +97,8 @@ gst_nvdec_cuda_context_class_init (GstNvDecCudaContextClass * klass)
static void
gst_nvdec_cuda_context_init (GstNvDecCudaContext * self)
{
-#ifdef HAVE_DYNLINK_HEADERS_NVDEC
- if (!cuda_OK (cuInit (0, __CUDA_API_VERSION, NULL)))
- GST_ERROR ("failed to init CUDA");
-
- if (!cuda_OK (cuvidInit (0)))
- GST_ERROR ("failed to init cuvid");
-#else
if (!cuda_OK (cuInit (0)))
GST_ERROR ("failed to init CUDA");
-#endif
if (!cuda_OK (cuCtxCreate (&self->context, CU_CTX_SCHED_AUTO, 0)))
GST_ERROR ("failed to create CUDA context");
diff --git a/sys/nvdec/gstnvdec.h b/sys/nvdec/gstnvdec.h
index 335c71371..a643b1bf4 100644
--- a/sys/nvdec/gstnvdec.h
+++ b/sys/nvdec/gstnvdec.h
@@ -30,19 +30,8 @@
#include <gst/gl/gl.h>
#include <gst/gl/gstglfuncs.h>
-#ifdef HAVE_DYNLINK_HEADERS_NVDEC
-#include <dynlink_nvcuvid.h>
-#else
-#include <nvcuvid.h>
+#include "nvcuvid.h"
#include <cudaGL.h>
-#endif
-
-#ifdef HAVE_DYNLINK_HEADERS_NVDEC
-/* missing from dynlink headers */
-CUresult CUDAAPI (*cuGetErrorName)(CUresult error, const char **pStr);
-CUresult CUDAAPI (*cuGetErrorString)(CUresult error, const char **pStr);
-CUresult CUDAAPI (*cuGraphicsGLRegisterImage)(CUgraphicsResource *pCudaResource, GLuint image, GLenum target, unsigned int Flags);
-#endif
G_BEGIN_DECLS