From c033f8fad2fd8e7ac9232f43bf11811fd3b2c4bb Mon Sep 17 00:00:00 2001 From: Thibault Saunier Date: Wed, 8 Dec 2021 11:48:08 +0000 Subject: [PATCH] cuda: Factor out a public GstCUDA library So applications and elements implemented outside GStreamer can reuse our infrastructure Part-of: --- .../gst-plugins-bad/docs/libs/cuda/index.md | 7 ++ .../gst-plugins-bad/docs/libs/cuda/sitemap.txt | 1 + subprojects/gst-plugins-bad/docs/meson.build | 1 + .../gst/cuda/cuda-gst.h} | 119 +++++++++++++++------ .../gst-libs/gst/cuda/cuda-prelude.h | 36 +++++++ .../gst/cuda}/gstcudabufferpool.c | 8 ++ .../gst/cuda}/gstcudabufferpool.h | 17 ++- .../nvcodec => gst-libs/gst/cuda}/gstcudacontext.c | 33 ++++-- .../nvcodec => gst-libs/gst/cuda}/gstcudacontext.h | 33 +++++- .../nvcodec => gst-libs/gst/cuda}/gstcudaloader.c | 26 ++++- .../gst-libs/gst/cuda/gstcudaloader.h | 40 +++++++ .../nvcodec => gst-libs/gst/cuda}/gstcudamemory.c | 20 ++++ .../nvcodec => gst-libs/gst/cuda}/gstcudamemory.h | 45 ++++++++ .../nvcodec => gst-libs/gst/cuda}/gstcudanvrtc.c | 7 ++ .../nvcodec => gst-libs/gst/cuda}/gstcudanvrtc.h | 7 ++ .../nvcodec => gst-libs/gst/cuda}/gstcudautils.c | 52 ++++++--- .../nvcodec => gst-libs/gst/cuda}/gstcudautils.h | 86 ++++++++++++++- .../nvcodec => gst-libs/gst/cuda}/gstnvrtcloader.c | 23 +++- .../nvcodec => gst-libs/gst/cuda}/gstnvrtcloader.h | 32 ++---- .../gst-plugins-bad/gst-libs/gst/cuda/meson.build | 101 +++++++++++++++++ .../{sys/nvcodec => gst-libs/gst/cuda}/stub/cuda.h | 6 -- .../gst-libs/gst/cuda/stub/cudaGL.h | 16 +++ .../nvcodec => gst-libs/gst/cuda}/stub/nvrtc.h | 0 .../gst-plugins-bad/gst-libs/gst/meson.build | 2 + .../gst-plugins-bad/sys/nvcodec/cuda-converter.c | 6 +- .../gst-plugins-bad/sys/nvcodec/cuda-converter.h | 4 +- .../sys/nvcodec/gstcudabasefilter.c | 3 +- .../sys/nvcodec/gstcudabasetransform.c | 3 +- .../sys/nvcodec/gstcudabasetransform.h | 4 +- .../gst-plugins-bad/sys/nvcodec/gstcudaconvert.c | 3 +- .../gst-plugins-bad/sys/nvcodec/gstcudafilter.c | 7 +- .../sys/nvcodec/gstcudamemorycopy.c | 40 +++---- .../gst-plugins-bad/sys/nvcodec/gstcudascale.c | 3 +- .../gst-plugins-bad/sys/nvcodec/gstcuvidloader.h | 2 +- .../gst-plugins-bad/sys/nvcodec/gstnvbaseenc.c | 4 +- .../gst-plugins-bad/sys/nvcodec/gstnvbaseenc.h | 2 +- subprojects/gst-plugins-bad/sys/nvcodec/gstnvdec.c | 6 +- subprojects/gst-plugins-bad/sys/nvcodec/gstnvdec.h | 6 +- .../gst-plugins-bad/sys/nvcodec/gstnvdecoder.c | 4 +- .../gst-plugins-bad/sys/nvcodec/gstnvdecoder.h | 2 +- subprojects/gst-plugins-bad/sys/nvcodec/gstnvenc.c | 3 +- subprojects/gst-plugins-bad/sys/nvcodec/gstnvenc.h | 2 +- .../gst-plugins-bad/sys/nvcodec/gstnvencoder.cpp | 37 +++---- .../gst-plugins-bad/sys/nvcodec/gstnvencoder.h | 4 +- .../gst-plugins-bad/sys/nvcodec/gstnvh264dec.c | 3 +- .../sys/nvcodec/gstnvh264encoder.cpp | 4 +- .../gst-plugins-bad/sys/nvcodec/gstnvh264encoder.h | 2 +- .../gst-plugins-bad/sys/nvcodec/gstnvh265dec.c | 2 +- .../sys/nvcodec/gstnvh265encoder.cpp | 4 +- .../gst-plugins-bad/sys/nvcodec/gstnvh265encoder.h | 2 +- .../gst-plugins-bad/sys/nvcodec/gstnvvp8dec.c | 3 +- .../gst-plugins-bad/sys/nvcodec/gstnvvp9dec.c | 3 +- .../gst-plugins-bad/sys/nvcodec/meson.build | 13 +-- subprojects/gst-plugins-bad/sys/nvcodec/plugin.c | 6 +- .../gst-plugins-base/gst-libs/gst/gl/meson.build | 5 +- 55 files changed, 721 insertions(+), 189 deletions(-) create mode 100644 subprojects/gst-plugins-bad/docs/libs/cuda/index.md create mode 100644 subprojects/gst-plugins-bad/docs/libs/cuda/sitemap.txt rename subprojects/gst-plugins-bad/{sys/nvcodec/gstcudaloader.h => gst-libs/gst/cuda/cuda-gst.h} (79%) create mode 100644 subprojects/gst-plugins-bad/gst-libs/gst/cuda/cuda-prelude.h rename subprojects/gst-plugins-bad/{sys/nvcodec => gst-libs/gst/cuda}/gstcudabufferpool.c (96%) rename subprojects/gst-plugins-bad/{sys/nvcodec => gst-libs/gst/cuda}/gstcudabufferpool.h (87%) rename subprojects/gst-plugins-bad/{sys/nvcodec => gst-libs/gst/cuda}/gstcudacontext.c (97%) rename subprojects/gst-plugins-bad/{sys/nvcodec => gst-libs/gst/cuda}/gstcudacontext.h (85%) rename subprojects/gst-plugins-bad/{sys/nvcodec => gst-libs/gst/cuda}/gstcudaloader.c (97%) create mode 100644 subprojects/gst-plugins-bad/gst-libs/gst/cuda/gstcudaloader.h rename subprojects/gst-plugins-bad/{sys/nvcodec => gst-libs/gst/cuda}/gstcudamemory.c (97%) rename subprojects/gst-plugins-bad/{sys/nvcodec => gst-libs/gst/cuda}/gstcudamemory.h (85%) rename subprojects/gst-plugins-bad/{sys/nvcodec => gst-libs/gst/cuda}/gstcudanvrtc.c (96%) rename subprojects/gst-plugins-bad/{sys/nvcodec => gst-libs/gst/cuda}/gstcudanvrtc.h (82%) rename subprojects/gst-plugins-bad/{sys/nvcodec => gst-libs/gst/cuda}/gstcudautils.c (98%) rename subprojects/gst-plugins-bad/{sys/nvcodec => gst-libs/gst/cuda}/gstcudautils.h (73%) rename subprojects/gst-plugins-bad/{sys/nvcodec => gst-libs/gst/cuda}/gstnvrtcloader.c (91%) rename subprojects/gst-plugins-bad/{sys/nvcodec => gst-libs/gst/cuda}/gstnvrtcloader.h (52%) create mode 100644 subprojects/gst-plugins-bad/gst-libs/gst/cuda/meson.build rename subprojects/gst-plugins-bad/{sys/nvcodec => gst-libs/gst/cuda}/stub/cuda.h (97%) create mode 100644 subprojects/gst-plugins-bad/gst-libs/gst/cuda/stub/cudaGL.h rename subprojects/gst-plugins-bad/{sys/nvcodec => gst-libs/gst/cuda}/stub/nvrtc.h (100%) diff --git a/subprojects/gst-plugins-bad/docs/libs/cuda/index.md b/subprojects/gst-plugins-bad/docs/libs/cuda/index.md new file mode 100644 index 0000000..51acb2c --- /dev/null +++ b/subprojects/gst-plugins-bad/docs/libs/cuda/index.md @@ -0,0 +1,7 @@ +# Cuda library + +This library should be linked to by getting cflags and libs from +gstreamer-cuda-{{ gst_api_version.md }}.pc + +> NOTE: This library API is considered *unstable* + diff --git a/subprojects/gst-plugins-bad/docs/libs/cuda/sitemap.txt b/subprojects/gst-plugins-bad/docs/libs/cuda/sitemap.txt new file mode 100644 index 0000000..4f91fcd --- /dev/null +++ b/subprojects/gst-plugins-bad/docs/libs/cuda/sitemap.txt @@ -0,0 +1 @@ +gi-index diff --git a/subprojects/gst-plugins-bad/docs/meson.build b/subprojects/gst-plugins-bad/docs/meson.build index e3f952c..5d96bf3 100644 --- a/subprojects/gst-plugins-bad/docs/meson.build +++ b/subprojects/gst-plugins-bad/docs/meson.build @@ -125,6 +125,7 @@ if build_gir {'name': 'audio', 'gir': audio_gir, 'lib': gstbadaudio_dep, 'prefix': 'bad-'}, {'name': 'transcoder', 'gir': transcoder_gir, 'lib': gst_transcoder_dep}, {'name': 'codecs', 'gir': codecs_gir, 'lib': gstcodecs_dep}, + {'name': 'cuda', 'gir': gst_cuda_gir, 'lib': gstcuda_dep}, ] if gstopencv_dep.found() diff --git a/subprojects/gst-plugins-bad/sys/nvcodec/gstcudaloader.h b/subprojects/gst-plugins-bad/gst-libs/gst/cuda/cuda-gst.h similarity index 79% rename from subprojects/gst-plugins-bad/sys/nvcodec/gstcudaloader.h rename to subprojects/gst-plugins-bad/gst-libs/gst/cuda/cuda-gst.h index 3d3253b..48e5709 100644 --- a/subprojects/gst-plugins-bad/sys/nvcodec/gstcudaloader.h +++ b/subprojects/gst-plugins-bad/gst-libs/gst/cuda/cuda-gst.h @@ -1,141 +1,153 @@ -/* GStreamer - * Copyright (C) 2019 Seungha Yang - * - * 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. - */ - -#ifndef __GST_CUDA_LOADER_H__ -#define __GST_CUDA_LOADER_H__ - -#include "stub/cuda.h" - -#include +#pragma once -G_BEGIN_DECLS +#include "cuda-prelude.h" +#include +#include +#include -gboolean gst_cuda_load_library (void); +G_BEGIN_DECLS /* cuda.h */ +GST_CUDA_API CUresult CUDAAPI CuInit (unsigned int Flags); +GST_CUDA_API CUresult CUDAAPI CuGetErrorName (CUresult error, const char **pStr); +GST_CUDA_API CUresult CUDAAPI CuGetErrorString (CUresult error, const char **pStr); +GST_CUDA_API CUresult CUDAAPI CuCtxCreate (CUcontext * pctx, unsigned int flags, CUdevice dev); +GST_CUDA_API CUresult CUDAAPI CuCtxDestroy (CUcontext ctx); +GST_CUDA_API CUresult CUDAAPI CuCtxPopCurrent (CUcontext * pctx); +GST_CUDA_API CUresult CUDAAPI CuCtxPushCurrent (CUcontext ctx); +GST_CUDA_API CUresult CUDAAPI CuCtxEnablePeerAccess (CUcontext peerContext, unsigned int Flags); +GST_CUDA_API CUresult CUDAAPI CuCtxDisablePeerAccess (CUcontext peerContext); +GST_CUDA_API CUresult CUDAAPI CuGraphicsMapResources (unsigned int count, CUgraphicsResource * resources, CUstream hStream); +GST_CUDA_API CUresult CUDAAPI CuGraphicsUnmapResources (unsigned int count, CUgraphicsResource * resources, CUstream hStream); -CUresult CUDAAPI CuGraphicsResourceSetMapFlags (CUgraphicsResource resource, - unsigned int flags); - +GST_CUDA_API CUresult CUDAAPI CuGraphicsSubResourceGetMappedArray (CUarray * pArray, CUgraphicsResource resource, unsigned int arrayIndex, unsigned int mipLevel); +GST_CUDA_API CUresult CUDAAPI CuGraphicsResourceGetMappedPointer (CUdeviceptr * pDevPtr, size_t * pSize, CUgraphicsResource resource); +GST_CUDA_API CUresult CUDAAPI CuGraphicsUnregisterResource (CUgraphicsResource resource); +GST_CUDA_API CUresult CUDAAPI CuMemAlloc (CUdeviceptr * dptr, unsigned int bytesize); +GST_CUDA_API CUresult CUDAAPI CuMemAllocPitch (CUdeviceptr * dptr, size_t * pPitch, size_t WidthInBytes, size_t Height, unsigned int ElementSizeBytes); +GST_CUDA_API CUresult CUDAAPI CuMemAllocHost (void **pp, unsigned int bytesize); +GST_CUDA_API CUresult CUDAAPI CuMemcpy2D (const CUDA_MEMCPY2D * pCopy); +GST_CUDA_API CUresult CUDAAPI CuMemcpy2DAsync (const CUDA_MEMCPY2D *pCopy, CUstream hStream); +GST_CUDA_API CUresult CUDAAPI CuMemFree (CUdeviceptr dptr); +GST_CUDA_API CUresult CUDAAPI CuMemFreeHost (void *p); +GST_CUDA_API CUresult CUDAAPI CuStreamCreate (CUstream *phStream, unsigned int Flags); +GST_CUDA_API CUresult CUDAAPI CuStreamDestroy (CUstream hStream); +GST_CUDA_API CUresult CUDAAPI CuStreamSynchronize (CUstream hStream); +GST_CUDA_API CUresult CUDAAPI CuDeviceGet (CUdevice * device, int ordinal); +GST_CUDA_API CUresult CUDAAPI CuDeviceGetCount (int *count); +GST_CUDA_API CUresult CUDAAPI CuDeviceGetName (char *name, int len, CUdevice dev); +GST_CUDA_API CUresult CUDAAPI CuDeviceGetAttribute (int *pi, CUdevice_attribute attrib, CUdevice dev); +GST_CUDA_API CUresult CUDAAPI CuDeviceCanAccessPeer (int *canAccessPeer, CUdevice dev, CUdevice peerDev); +GST_CUDA_API CUresult CUDAAPI CuDriverGetVersion (int * driverVersion); +GST_CUDA_API CUresult CUDAAPI CuModuleLoadData (CUmodule* module, const void *image); +GST_CUDA_API CUresult CUDAAPI CuModuleUnload (CUmodule module); +GST_CUDA_API CUresult CUDAAPI CuModuleGetFunction (CUfunction* hfunc, CUmodule hmod, const char* name); +GST_CUDA_API CUresult CUDAAPI CuTexObjectCreate (CUtexObject *pTexObject, const CUDA_RESOURCE_DESC *pResDesc, const CUDA_TEXTURE_DESC *pTexDesc, const CUDA_RESOURCE_VIEW_DESC *pResViewDesc); +GST_CUDA_API CUresult CUDAAPI CuTexObjectDestroy (CUtexObject texObject); +GST_CUDA_API CUresult CUDAAPI CuLaunchKernel (CUfunction f, unsigned int gridDimX, unsigned int gridDimY, @@ -149,33 +161,78 @@ CUresult CUDAAPI CuLaunchKernel (CUfunction f, void **extra); /* cudaGL.h */ +GST_CUDA_API CUresult CUDAAPI CuGraphicsGLRegisterImage (CUgraphicsResource * pCudaResource, unsigned int image, unsigned int target, unsigned int Flags); +GST_CUDA_API CUresult CUDAAPI CuGraphicsGLRegisterBuffer (CUgraphicsResource * pCudaResource, unsigned int buffer, unsigned int Flags); +GST_CUDA_API +CUresult CUDAAPI CuGraphicsResourceSetMapFlags (CUgraphicsResource resource, + unsigned int flags); + +GST_CUDA_API CUresult CUDAAPI CuGLGetDevices (unsigned int * pCudaDeviceCount, CUdevice * pCudaDevices, unsigned int cudaDeviceCount, CUGLDeviceList deviceList); + +#ifdef GST_CUDA_HAS_D3D /* cudaD3D11.h */ +GST_CUDA_API CUresult CUDAAPI CuGraphicsD3D11RegisterResource(CUgraphicsResource * pCudaResource, gpointer pD3DResource, unsigned int Flags); +GST_CUDA_API CUresult CUDAAPI CuD3D11GetDevice(CUdevice * device, gpointer pAdapter); +GST_CUDA_API CUresult CUDAAPI CuD3D11GetDevices(unsigned int * pCudaDeviceCount, CUdevice* pCudaDevices, unsigned int cudaDeviceCount, gpointer pD3D11Device, CUD3D11DeviceList deviceList); +#endif + +/* nvrtc.h */ +GST_CUDA_API +nvrtcResult NvrtcCompileProgram (nvrtcProgram prog, + int numOptions, + const char** options); + +GST_CUDA_API +nvrtcResult NvrtcCreateProgram (nvrtcProgram* prog, + const char* src, + const char* name, + int numHeaders, + const char** headers, + const char** includeNames); + +GST_CUDA_API +nvrtcResult NvrtcDestroyProgram (nvrtcProgram* prog); + +GST_CUDA_API +nvrtcResult NvrtcGetPTX (nvrtcProgram prog, + char* ptx); + +GST_CUDA_API +nvrtcResult NvrtcGetPTXSize (nvrtcProgram prog, + size_t* ptxSizeRet); + +GST_CUDA_API +nvrtcResult NvrtcGetProgramLog (nvrtcProgram prog, + char* log); + +GST_CUDA_API +nvrtcResult NvrtcGetProgramLogSize (nvrtcProgram prog, + size_t* logSizeRet); G_END_DECLS -#endif /* __GST_CUDA_LOADER_H__ */ diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/cuda/cuda-prelude.h b/subprojects/gst-plugins-bad/gst-libs/gst/cuda/cuda-prelude.h new file mode 100644 index 0000000..8dc35bd --- /dev/null +++ b/subprojects/gst-plugins-bad/gst-libs/gst/cuda/cuda-prelude.h @@ -0,0 +1,36 @@ +/* GStreamer Cuda Library + * Copyright (C) 2021 GStreamer developers + * + * -prelude.h: prelude include header for gst-cuda library + * + * 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. + */ + +#ifndef __GST_CUDA_PRELUDE_H__ +#define __GST_CUDA_PRELUDE_H__ + +#include + +#ifndef GST_CUDA_API +# ifdef BUILDING_GST_CUDA +# define GST_CUDA_API GST_API_EXPORT /* from config.h */ +# else +# define GST_CUDA_API GST_API_IMPORT +# endif +#endif + +#endif /* __GST_CUDA_PRELUDE_H__ */ + diff --git a/subprojects/gst-plugins-bad/sys/nvcodec/gstcudabufferpool.c b/subprojects/gst-plugins-bad/gst-libs/gst/cuda/gstcudabufferpool.c similarity index 96% rename from subprojects/gst-plugins-bad/sys/nvcodec/gstcudabufferpool.c rename to subprojects/gst-plugins-bad/gst-libs/gst/cuda/gstcudabufferpool.c index bd2a248..fe3f633 100644 --- a/subprojects/gst-plugins-bad/sys/nvcodec/gstcudabufferpool.c +++ b/subprojects/gst-plugins-bad/gst-libs/gst/cuda/gstcudabufferpool.c @@ -134,6 +134,14 @@ gst_cuda_buffer_pool_alloc (GstBufferPool * pool, GstBuffer ** buffer, return GST_FLOW_OK; } +/** + * gst_cuda_buffer_pool_new: + * @context: The #GstCudaContext to use for the new buffer pool + * + * Returns: A newly created #GstCudaBufferPool + * + * Since: 1.22 + */ GstBufferPool * gst_cuda_buffer_pool_new (GstCudaContext * context) { diff --git a/subprojects/gst-plugins-bad/sys/nvcodec/gstcudabufferpool.h b/subprojects/gst-plugins-bad/gst-libs/gst/cuda/gstcudabufferpool.h similarity index 87% rename from subprojects/gst-plugins-bad/sys/nvcodec/gstcudabufferpool.h rename to subprojects/gst-plugins-bad/gst-libs/gst/cuda/gstcudabufferpool.h index 7f6075f..216f516 100644 --- a/subprojects/gst-plugins-bad/sys/nvcodec/gstcudabufferpool.h +++ b/subprojects/gst-plugins-bad/gst-libs/gst/cuda/gstcudabufferpool.h @@ -20,6 +20,12 @@ #ifndef __GST_CUDA_BUFFER_POOL_H__ #define __GST_CUDA_BUFFER_POOL_H__ +#ifndef GST_USE_UNSTABLE_API +#warning "The Cuda library from gst-plugins-bad is unstable API and may change in future." +#warning "You can define GST_USE_UNSTABLE_API to avoid this warning." +#endif + +#include "cuda-prelude.h" #include #include @@ -33,14 +39,21 @@ G_BEGIN_DECLS #define GST_CUDA_BUFFER_POOL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GST_TYPE_CUDA_BUFFER_POOL,GstCudaBufferPoolClass)) #define GST_IS_CUDA_BUFFER_POOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj),GST_TYPE_CUDA_BUFFER_POOL)) #define GST_IS_CUDA_BUFFER_POOL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_CUDA_BUFFER_POOL)) +/** + * GST_CUDA_BUFFER_POOL_CAST: + * + * Since: 1.22 + */ #define GST_CUDA_BUFFER_POOL_CAST(obj) ((GstCudaBufferPool*)(obj)) typedef struct _GstCudaBufferPool GstCudaBufferPool; typedef struct _GstCudaBufferPoolClass GstCudaBufferPoolClass; typedef struct _GstCudaBufferPoolPrivate GstCudaBufferPoolPrivate; -/* +/** * GstCudaBufferPool: + * + * Since: 1.22 */ struct _GstCudaBufferPool { @@ -59,8 +72,10 @@ struct _GstCudaBufferPoolClass GstBufferPoolClass parent_class; }; +GST_CUDA_API GType gst_cuda_buffer_pool_get_type (void); +GST_CUDA_API GstBufferPool * gst_cuda_buffer_pool_new (GstCudaContext * context); G_END_DECLS diff --git a/subprojects/gst-plugins-bad/sys/nvcodec/gstcudacontext.c b/subprojects/gst-plugins-bad/gst-libs/gst/cuda/gstcudacontext.c similarity index 97% rename from subprojects/gst-plugins-bad/sys/nvcodec/gstcudacontext.c rename to subprojects/gst-plugins-bad/gst-libs/gst/cuda/gstcudacontext.c index 5f0c611..ff2a256 100644 --- a/subprojects/gst-plugins-bad/sys/nvcodec/gstcudacontext.c +++ b/subprojects/gst-plugins-bad/gst-libs/gst/cuda/gstcudacontext.c @@ -25,7 +25,7 @@ #include "gstcudacontext.h" #include "gstcudautils.h" -#ifdef HAVE_NVCODEC_GST_D3D11 +#ifdef GST_CUDA_HAS_D3D #include #endif @@ -76,16 +76,23 @@ gst_cuda_context_class_init (GstCudaContextClass * klass) gobject_class->set_property = gst_cuda_context_set_property; gobject_class->get_property = gst_cuda_context_get_property; - gobject_class->constructed = gst_cuda_context_constructed; gobject_class->finalize = gst_cuda_context_finalize; + gobject_class->constructed = gst_cuda_context_constructed; + /** + * GstCudaContext::cuda-device-id: + * + * The GPU index to use for the context. + * + * Since: 1.22 + */ g_object_class_install_property (gobject_class, PROP_DEVICE_ID, g_param_spec_uint ("cuda-device-id", "Cuda Device ID", "Set the GPU device to use for operations", 0, G_MAXUINT, 0, G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); -#ifdef HAVE_NVCODEC_GST_D3D11 +#ifdef GST_CUDA_HAS_D3D g_object_class_install_property (gobject_class, PROP_DXGI_ADAPTER_LUID, g_param_spec_int64 ("dxgi-adapter-luid", "DXGI Adapter LUID", "Associated DXGI Adapter LUID (Locally Unique Identifier) ", @@ -145,7 +152,7 @@ gst_cuda_context_get_property (GObject * object, guint prop_id, } } -#ifdef HAVE_NVCODEC_GST_D3D11 +#ifdef GST_CUDA_HAS_D3D static gint64 gst_cuda_context_find_dxgi_adapter_luid (CUdevice cuda_device) { @@ -246,7 +253,7 @@ gst_cuda_context_constructed (GObject * object) priv->context = cuda_ctx; priv->device = cdev; -#ifdef HAVE_NVCODEC_GST_D3D11 +#ifdef GST_CUDA_HAS_D3D priv->dxgi_adapter_luid = gst_cuda_context_find_dxgi_adapter_luid (cdev); #endif @@ -393,6 +400,8 @@ gst_cuda_context_new (guint device_id) * so all CUDA functions that operate on the current context are affected. * * Returns: %TRUE if @ctx was pushed without error. + * + * Since: 1.22 */ gboolean gst_cuda_context_push (GstCudaContext * ctx) @@ -409,6 +418,8 @@ gst_cuda_context_push (GstCudaContext * ctx) * Pops the current CUDA context from CPU thread * * Returns: %TRUE if @ctx was pushed without error. + * + * Since: 1.22 */ gboolean gst_cuda_context_pop (CUcontext * cuda_ctx) @@ -423,7 +434,9 @@ gst_cuda_context_pop (CUcontext * cuda_ctx) * Get CUDA device context. Caller must not modify and/or destroy * returned device context. * - * Returns: the #CUcontext of @ctx + * Returns: the `CUcontext` of @ctx + * + * Since: 1.22 */ gpointer gst_cuda_context_get_handle (GstCudaContext * ctx) @@ -440,7 +453,9 @@ gst_cuda_context_get_handle (GstCudaContext * ctx) * * Get required texture alignment by device * - * Returns: the #CUcontext of @ctx + * Returns: the `CUcontext` of @ctx + * + * Since: 1.22 */ gint gst_cuda_context_get_texture_alignment (GstCudaContext * ctx) @@ -457,8 +472,10 @@ gst_cuda_context_get_texture_alignment (GstCudaContext * ctx) * @peer: a #GstCudaContext * * Query whether @ctx can access any memory which belongs to @peer directly. - + * * Returns: %TRUE if @ctx can access @peer directly + * + * Since: 1.22 */ gboolean gst_cuda_context_can_access_peer (GstCudaContext * ctx, GstCudaContext * peer) diff --git a/subprojects/gst-plugins-bad/sys/nvcodec/gstcudacontext.h b/subprojects/gst-plugins-bad/gst-libs/gst/cuda/gstcudacontext.h similarity index 85% rename from subprojects/gst-plugins-bad/sys/nvcodec/gstcudacontext.h rename to subprojects/gst-plugins-bad/gst-libs/gst/cuda/gstcudacontext.h index 2536296..5fac068 100644 --- a/subprojects/gst-plugins-bad/sys/nvcodec/gstcudacontext.h +++ b/subprojects/gst-plugins-bad/gst-libs/gst/cuda/gstcudacontext.h @@ -20,8 +20,14 @@ #ifndef __GST_CUDA_CONTEXT_H__ #define __GST_CUDA_CONTEXT_H__ +#ifndef GST_USE_UNSTABLE_API +#warning "The Cuda library from gst-plugins-bad is unstable API and may change in future." +#warning "You can define GST_USE_UNSTABLE_API to avoid this warning." +#endif + +#include "cuda-prelude.h" #include -#include +#include "cuda.h" G_BEGIN_DECLS @@ -31,16 +37,29 @@ G_BEGIN_DECLS #define GST_CUDA_CONTEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GST_TYPE_CUDA_CONTEXT,GstCudaContextClass)) #define GST_IS_CUDA_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj),GST_TYPE_CUDA_CONTEXT)) #define GST_IS_CUDA_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_CUDA_CONTEXT)) + +/** + * GST_CUDA_CONTEXT_CAST: + * + * Since: 1.22 + */ #define GST_CUDA_CONTEXT_CAST(obj) ((GstCudaContext*)(obj)) +/** + * GST_CUDA_CONTEXT_TYPE: + * + * Since: 1.22 + */ #define GST_CUDA_CONTEXT_TYPE "gst.cuda.context" typedef struct _GstCudaContext GstCudaContext; typedef struct _GstCudaContextClass GstCudaContextClass; typedef struct _GstCudaContextPrivate GstCudaContextPrivate; -/* +/** * GstCudaContext: + * + * Since: 1.22 */ struct _GstCudaContext { @@ -50,26 +69,30 @@ struct _GstCudaContext GstCudaContextPrivate *priv; }; -/* - * GstCudaContextClass: - */ struct _GstCudaContextClass { GstObjectClass parent_class; }; +GST_CUDA_API GType gst_cuda_context_get_type (void); +GST_CUDA_API GstCudaContext * gst_cuda_context_new (guint device_id); +GST_CUDA_API gboolean gst_cuda_context_push (GstCudaContext * ctx); +GST_CUDA_API gboolean gst_cuda_context_pop (CUcontext * cuda_ctx); +GST_CUDA_API gpointer gst_cuda_context_get_handle (GstCudaContext * ctx); +GST_CUDA_API gint gst_cuda_context_get_texture_alignment (GstCudaContext * ctx); +GST_CUDA_API gboolean gst_cuda_context_can_access_peer (GstCudaContext * ctx, GstCudaContext * peer); diff --git a/subprojects/gst-plugins-bad/sys/nvcodec/gstcudaloader.c b/subprojects/gst-plugins-bad/gst-libs/gst/cuda/gstcudaloader.c similarity index 97% rename from subprojects/gst-plugins-bad/sys/nvcodec/gstcudaloader.c rename to subprojects/gst-plugins-bad/gst-libs/gst/cuda/gstcudaloader.c index d9ea49a..064987f 100644 --- a/subprojects/gst-plugins-bad/sys/nvcodec/gstcudaloader.c +++ b/subprojects/gst-plugins-bad/gst-libs/gst/cuda/gstcudaloader.c @@ -21,11 +21,12 @@ #include "config.h" #endif +#include "cuda-gst.h" #include "gstcudaloader.h" #include -GST_DEBUG_CATEGORY_EXTERN (gst_nvcodec_debug); -#define GST_CAT_DEFAULT gst_nvcodec_debug +GST_DEBUG_CATEGORY (gst_cudaloader_debug); +#define GST_CAT_DEFAULT gst_cudaloader_debug #ifndef G_OS_WIN32 #define CUDA_LIBNAME "libcuda.so.1" @@ -134,12 +135,29 @@ typedef struct _GstNvCodecCudaVTable static GstNvCodecCudaVTable gst_cuda_vtable = { 0, }; +/** + * gst_cuda_load_library: + * + * Loads the cuda library + * + * Returns: %TRUE if the libcuda could be loaded %FALSE otherwise + * + * Since: 1.22 + */ gboolean gst_cuda_load_library (void) { GModule *module; const gchar *filename = CUDA_LIBNAME; GstNvCodecCudaVTable *vtable; + static gsize debug_initialized = FALSE; + + if (g_once_init_enter (&debug_initialized)) { + GST_DEBUG_CATEGORY_INIT (gst_cudaloader_debug, "cudaloader", 0, + "cudaloader"); + + g_once_init_leave (&debug_initialized, TRUE); + } if (gst_cuda_vtable.loaded) return TRUE; @@ -205,7 +223,7 @@ gst_cuda_load_library (void) LOAD_SYMBOL (cuGraphicsGLRegisterBuffer, CuGraphicsGLRegisterBuffer); LOAD_SYMBOL (cuGLGetDevices, CuGLGetDevices); -#ifdef HAVE_NVCODEC_GST_D3D11 +#ifdef GST_CUDA_HAS_D3D /* cudaD3D11.h */ LOAD_SYMBOL (cuGraphicsD3D11RegisterResource, CuGraphicsD3D11RegisterResource); @@ -572,6 +590,7 @@ CuGLGetDevices (unsigned int *pCudaDeviceCount, CUdevice * pCudaDevices, } /* cudaD3D11.h */ +#ifdef GST_CUDA_HAS_D3D CUresult CUDAAPI CuGraphicsD3D11RegisterResource (CUgraphicsResource * pCudaResource, gpointer pD3DResource, unsigned int Flags) @@ -601,3 +620,4 @@ CuD3D11GetDevices (unsigned int *pCudaDeviceCount, return gst_cuda_vtable.CuD3D11GetDevices (pCudaDeviceCount, pCudaDevices, cudaDeviceCount, pD3D11Device, deviceList); } +#endif diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/cuda/gstcudaloader.h b/subprojects/gst-plugins-bad/gst-libs/gst/cuda/gstcudaloader.h new file mode 100644 index 0000000..24a36ee --- /dev/null +++ b/subprojects/gst-plugins-bad/gst-libs/gst/cuda/gstcudaloader.h @@ -0,0 +1,40 @@ +/* GStreamer + * Copyright (C) 2019 Seungha Yang + * + * 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. + */ + +#ifndef __GST_CUDA_LOADER_H__ +#define __GST_CUDA_LOADER_H__ + +#ifndef GST_USE_UNSTABLE_API +#warning "The Cuda library from gst-plugins-bad is unstable API and may change in future." +#warning "You can define GST_USE_UNSTABLE_API to avoid this warning." +#endif + +#include "cuda.h" +#include "cudaGL.h" + +#include "cuda-prelude.h" +#include + +G_BEGIN_DECLS + +GST_CUDA_API +gboolean gst_cuda_load_library (void); + +G_END_DECLS +#endif /* __GST_CUDA_LOADER_H__ */ diff --git a/subprojects/gst-plugins-bad/sys/nvcodec/gstcudamemory.c b/subprojects/gst-plugins-bad/gst-libs/gst/cuda/gstcudamemory.c similarity index 97% rename from subprojects/gst-plugins-bad/sys/nvcodec/gstcudamemory.c rename to subprojects/gst-plugins-bad/gst-libs/gst/cuda/gstcudamemory.c index d0e4fa6..06adc4b 100644 --- a/subprojects/gst-plugins-bad/sys/nvcodec/gstcudamemory.c +++ b/subprojects/gst-plugins-bad/gst-libs/gst/cuda/gstcudamemory.c @@ -420,6 +420,13 @@ cuda_mem_copy (GstMemory * mem, gssize offset, gssize size) return copy; } +/** + * gst_cuda_memory_init_once: + * + * Ensures that the #GstCudaAllocator is initialized and ready to be used. + * + * Since: 1.22 + */ void gst_cuda_memory_init_once (void) { @@ -435,6 +442,14 @@ gst_cuda_memory_init_once (void) } } +/** + * gst_is_cuda_memory: + * @mem: A #GstMemory + * + * Check if @mem is a cuda memory + * + * Since: 1.22 + */ gboolean gst_is_cuda_memory (GstMemory * mem) { @@ -442,6 +457,11 @@ gst_is_cuda_memory (GstMemory * mem) GST_IS_CUDA_ALLOCATOR (mem->allocator); } +/** + * gst_cuda_allocator_alloc: + * + * Since: 1.22 + */ GstMemory * gst_cuda_allocator_alloc (GstCudaAllocator * allocator, GstCudaContext * context, const GstVideoInfo * info) diff --git a/subprojects/gst-plugins-bad/sys/nvcodec/gstcudamemory.h b/subprojects/gst-plugins-bad/gst-libs/gst/cuda/gstcudamemory.h similarity index 85% rename from subprojects/gst-plugins-bad/sys/nvcodec/gstcudamemory.h rename to subprojects/gst-plugins-bad/gst-libs/gst/cuda/gstcudamemory.h index e0c24fe..666e33f 100644 --- a/subprojects/gst-plugins-bad/sys/nvcodec/gstcudamemory.h +++ b/subprojects/gst-plugins-bad/gst-libs/gst/cuda/gstcudamemory.h @@ -20,6 +20,12 @@ #ifndef __GST_CUDA_MEMORY_H__ #define __GST_CUDA_MEMORY_H__ +#ifndef GST_USE_UNSTABLE_API +#warning "The Cuda library from gst-plugins-bad is unstable API and may change in future." +#warning "You can define GST_USE_UNSTABLE_API to avoid this warning." +#endif + +#include "cuda-prelude.h" #include #include #include @@ -34,9 +40,26 @@ G_BEGIN_DECLS #define GST_CUDA_ALLOCATOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GST_TYPE_CUDA_ALLOCATOR,GstCudaAllocatorClass)) #define GST_IS_CUDA_ALLOCATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_CUDA_ALLOCATOR)) #define GST_IS_CUDA_ALLOCATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_CUDA_ALLOCATOR)) +/** + * GST_CUDA_ALLOCATOR_CAST: + * + * Since: 1.22 + */ #define GST_CUDA_ALLOCATOR_CAST(obj) ((GstCudaAllocator *)(obj)) +/** + * GST_CUDA_MEMORY_CAST: + * + * Since: 1.22 + */ #define GST_CUDA_MEMORY_CAST(mem) ((GstCudaMemory *) (mem)) +/** + * GstCudaAllocator: + * + * A #GstAllocator subclass for cuda memory + * + * Since: 1.22 + */ typedef struct _GstCudaAllocator GstCudaAllocator; typedef struct _GstCudaAllocatorClass GstCudaAllocatorClass; @@ -54,15 +77,26 @@ typedef struct _GstCudaMemoryPrivate GstCudaMemoryPrivate; * Conversely, combining #GST_MAP_CUDA with * #GST_MAP_READ has the same semantics as though you are reading from * CUDA device/host memory + * + * Since: 1.22 */ #define GST_MAP_CUDA (GST_MAP_FLAG_LAST << 1) +/** + * GST_CUDA_MEMORY_TYPE_NAME: + * + * Name of cuda memory type + * + * Since: 1.22 + */ #define GST_CUDA_MEMORY_TYPE_NAME "gst.cuda.memory" /** * GST_CAPS_FEATURE_MEMORY_CUDA_MEMORY: * * Name of the caps feature for indicating the use of #GstCudaMemory + * + * Since: 1.22 */ #define GST_CAPS_FEATURE_MEMORY_CUDA_MEMORY "memory:CUDAMemory" @@ -72,6 +106,8 @@ typedef struct _GstCudaMemoryPrivate GstCudaMemoryPrivate; * to the staging memory * @GST_CUDA_MEMORY_TRANSFER_NEED_UPLOAD: the staging memory needs uploading * to the device memory + * + * Since: 1.22 */ typedef enum { @@ -79,6 +115,11 @@ typedef enum GST_CUDA_MEMORY_TRANSFER_NEED_UPLOAD = (GST_MEMORY_FLAG_LAST << 1) } GstCudaMemoryTransfer; +/** + * GstCudaMemory: + * + * Since: 1.22 + */ struct _GstCudaMemory { GstMemory mem; @@ -102,12 +143,16 @@ struct _GstCudaAllocatorClass GstAllocatorClass parent_class; }; +GST_CUDA_API void gst_cuda_memory_init_once (void); +GST_CUDA_API gboolean gst_is_cuda_memory (GstMemory * mem); +GST_CUDA_API GType gst_cuda_allocator_get_type (void); +GST_CUDA_API GstMemory * gst_cuda_allocator_alloc (GstCudaAllocator * allocator, GstCudaContext * context, const GstVideoInfo * info); diff --git a/subprojects/gst-plugins-bad/sys/nvcodec/gstcudanvrtc.c b/subprojects/gst-plugins-bad/gst-libs/gst/cuda/gstcudanvrtc.c similarity index 96% rename from subprojects/gst-plugins-bad/sys/nvcodec/gstcudanvrtc.c rename to subprojects/gst-plugins-bad/gst-libs/gst/cuda/gstcudanvrtc.c index 381c698..cad0708 100644 --- a/subprojects/gst-plugins-bad/sys/nvcodec/gstcudanvrtc.c +++ b/subprojects/gst-plugins-bad/gst-libs/gst/cuda/gstcudanvrtc.c @@ -21,6 +21,7 @@ #include "config.h" #endif +#include "cuda-gst.h" #include "gstcudanvrtc.h" GST_DEBUG_CATEGORY_STATIC (gst_cuda_nvrtc_debug); @@ -39,6 +40,12 @@ _init_debug (void) } } +/** + * gst_cuda_nvrtc_compile: + * @source: Source code to compile + * + * Since: 1.22 + */ gchar * gst_cuda_nvrtc_compile (const gchar * source) { diff --git a/subprojects/gst-plugins-bad/sys/nvcodec/gstcudanvrtc.h b/subprojects/gst-plugins-bad/gst-libs/gst/cuda/gstcudanvrtc.h similarity index 82% rename from subprojects/gst-plugins-bad/sys/nvcodec/gstcudanvrtc.h rename to subprojects/gst-plugins-bad/gst-libs/gst/cuda/gstcudanvrtc.h index 4734023..19013b1 100644 --- a/subprojects/gst-plugins-bad/sys/nvcodec/gstcudanvrtc.h +++ b/subprojects/gst-plugins-bad/gst-libs/gst/cuda/gstcudanvrtc.h @@ -20,12 +20,19 @@ #ifndef __GST_CUDA_NVRTC_H__ #define __GST_CUDA_NVRTC_H__ +#ifndef GST_USE_UNSTABLE_API +#warning "The Cuda library from gst-plugins-bad is unstable API and may change in future." +#warning "You can define GST_USE_UNSTABLE_API to avoid this warning." +#endif + +#include "cuda-prelude.h" #include #include "gstcudaloader.h" #include "gstnvrtcloader.h" G_BEGIN_DECLS +GST_CUDA_API gchar * gst_cuda_nvrtc_compile (const gchar * source); G_END_DECLS diff --git a/subprojects/gst-plugins-bad/sys/nvcodec/gstcudautils.c b/subprojects/gst-plugins-bad/gst-libs/gst/cuda/gstcudautils.c similarity index 98% rename from subprojects/gst-plugins-bad/sys/nvcodec/gstcudautils.c rename to subprojects/gst-plugins-bad/gst-libs/gst/cuda/gstcudautils.c index d2a74d4..0447647 100644 --- a/subprojects/gst-plugins-bad/sys/nvcodec/gstcudautils.c +++ b/subprojects/gst-plugins-bad/gst-libs/gst/cuda/gstcudautils.c @@ -29,7 +29,7 @@ #include #endif -#ifdef HAVE_NVCODEC_GST_D3D11 +#ifdef GST_CUDA_HAS_D3D #include #endif @@ -189,6 +189,8 @@ context_set_cuda_context (GstContext * context, GstCudaContext * cuda_ctx) * necessary for #GstCudaContext. * * Returns: whether a #GstCudaContext exists in @cuda_ctx + * + * Since: 1.22 */ gboolean gst_cuda_ensure_element_context (GstElement * element, gint device_id, @@ -253,6 +255,8 @@ gst_cuda_ensure_element_context (GstElement * element, gint device_id, * Retrieves the #GstCudaContext in @context and places the result in @cuda_ctx. * * Returns: whether the @cuda_ctx could be set successfully + * + * Since: 1.22 */ gboolean gst_cuda_handle_set_context (GstElement * element, @@ -305,6 +309,8 @@ gst_cuda_handle_set_context (GstElement * element, * * Returns: Whether the @query was successfully responded to from the passed * @context. + * + * Since: 1.22 */ gboolean gst_cuda_handle_context_query (GstElement * element, @@ -347,10 +353,12 @@ gst_cuda_handle_context_query (GstElement * element, /** * gst_context_new_cuda_context: - * @cuda_ctx: (transfer none) a #GstCudaContext + * @cuda_ctx: (transfer none): a #GstCudaContext * * Returns: (transfer full) (nullable): a new #GstContext embedding the @cuda_ctx * or %NULL + * + * Since: 1.22 */ GstContext * gst_context_new_cuda_context (GstCudaContext * cuda_ctx) @@ -391,6 +399,8 @@ init_cuda_quark_once (void) * @id: a #GstCudaQuarkId * * Returns: the GQuark for given @id or 0 if @id is unknown value + * + * Since: 1.22 */ GQuark gst_cuda_quark_from_id (GstCudaQuarkId id) @@ -413,6 +423,8 @@ gst_cuda_quark_from_id (GstCudaQuarkId id) * * Returns: a new #GstCudaGraphicsResource. * Free with gst_cuda_graphics_resource_free + * + * Since: 1.22 */ GstCudaGraphicsResource * gst_cuda_graphics_resource_new (GstCudaContext * @@ -436,13 +448,15 @@ gst_cuda_graphics_resource_new (GstCudaContext * * gst_cuda_graphics_resource_register_gl_buffer: (skip) * @resource a #GstCudaGraphicsResource * @buffer: a GL buffer object - * @flags: a #CUgraphicsRegisterFlags + * @flags: a `CUgraphicsRegisterFlags` * * Register the @buffer for access by CUDA. * Must be called from the gl context thread with current cuda context was * pushed on the current thread * * Returns: whether @buffer was registered or not + * + * Since: 1.22 */ gboolean gst_cuda_graphics_resource_register_gl_buffer (GstCudaGraphicsResource * @@ -467,17 +481,20 @@ gst_cuda_graphics_resource_register_gl_buffer (GstCudaGraphicsResource * return TRUE; } +#ifdef GST_CUDA_HAS_D3D /** * gst_cuda_graphics_resource_register_d3d11_resource: (skip) * @resource a #GstCudaGraphicsResource * @d3d11_resource: a ID3D11Resource - * @flags: a #CUgraphicsRegisterFlags + * @flags: a CUgraphicsRegisterFlags * * Register the @d3d11_resource for accessing by CUDA. * Must be called with d3d11 device lock with current cuda context was * pushed on the current thread * * Returns: whether @d3d11_resource was registered or not + * + * Since: 1.22 */ gboolean gst_cuda_graphics_resource_register_d3d11_resource (GstCudaGraphicsResource * @@ -502,6 +519,7 @@ gst_cuda_graphics_resource_register_d3d11_resource (GstCudaGraphicsResource * return TRUE; } +#endif /** * gst_cuda_graphics_resource_unregister: (skip) @@ -511,6 +529,8 @@ gst_cuda_graphics_resource_register_d3d11_resource (GstCudaGraphicsResource * * For GL resource, this method must be called from gl context thread. * Also, current cuda context should be pushed on the current thread * before calling this method. + * + * Since: 1.22 */ void gst_cuda_graphics_resource_unregister (GstCudaGraphicsResource * resource) @@ -532,12 +552,14 @@ gst_cuda_graphics_resource_unregister (GstCudaGraphicsResource * resource) /** * gst_cuda_graphics_resource_map: (skip) * @resource: a #GstCudaGraphicsResource - * @stream: a #CUstream - * @flags: a #CUgraphicsMapResourceFlags + * @stream: a CUstream + * @flags: a CUgraphicsMapResourceFlags * * Map previously registered resource with map flags * - * Returns: the #CUgraphicsResource if successful or %NULL when failed + * Returns: the `CUgraphicsResource` if successful or %NULL when failed + * + * Since: 1.22 */ CUgraphicsResource gst_cuda_graphics_resource_map (GstCudaGraphicsResource * resource, @@ -566,9 +588,11 @@ gst_cuda_graphics_resource_map (GstCudaGraphicsResource * resource, /** * gst_cuda_graphics_resource_unmap: (skip) * @resource: a #GstCudaGraphicsResource - * @stream: a #CUstream + * @stream: a `CUstream` * * Unmap previously mapped resource + * + * Since: 1.22 */ void gst_cuda_graphics_resource_unmap (GstCudaGraphicsResource * resource, @@ -607,7 +631,7 @@ unregister_resource_from_gl_thread (GstGLContext * gl_context, } #endif -#ifdef HAVE_NVCODEC_GST_D3D11 +#ifdef GST_CUDA_HAS_D3D static void unregister_d3d11_resource (GstCudaGraphicsResource * resource) { @@ -634,6 +658,8 @@ unregister_d3d11_resource (GstCudaGraphicsResource * resource) * @resource: a #GstCudaGraphicsResource * * Free @resource + * + * Since: 1.22 */ void gst_cuda_graphics_resource_free (GstCudaGraphicsResource * resource) @@ -648,7 +674,7 @@ gst_cuda_graphics_resource_free (GstCudaGraphicsResource * resource) resource); } else #endif -#ifdef HAVE_NVCODEC_GST_D3D11 +#ifdef GST_CUDA_HAS_D3D if (resource->type == GST_CUDA_GRAPHICS_RESOURCE_D3D11_RESOURCE) { unregister_d3d11_resource (resource); } else @@ -1250,7 +1276,7 @@ cuda_copy_gl_interop (GstBuffer * dst_buf, const GstVideoInfo * dst_info, } #endif -#ifdef HAVE_NVCODEC_GST_D3D11 +#ifdef GST_CUDA_HAS_D3D static gboolean ensure_d3d11_interop (GstCudaContext * context, GstD3D11Device * device) { @@ -1454,7 +1480,7 @@ gst_cuda_buffer_copy (GstBuffer * dst, GstCudaBufferCopyType dst_type, { gboolean use_copy_2d = FALSE; GstMemory *dst_mem, *src_mem; -#ifdef HAVE_NVCODEC_GST_D3D11 +#ifdef GST_CUDA_HAS_D3D D3D11_TEXTURE2D_DESC desc; #endif GstCudaContext *cuda_context; @@ -1524,7 +1550,7 @@ gst_cuda_buffer_copy (GstBuffer * dst, GstCudaBufferCopyType dst_type, } #endif -#ifdef HAVE_NVCODEC_GST_D3D11 +#ifdef GST_CUDA_HAS_D3D if (src_type == GST_CUDA_BUFFER_COPY_D3D11 && gst_is_d3d11_memory (src_mem) && gst_d3d11_memory_get_texture_desc (GST_D3D11_MEMORY_CAST (src_mem), &desc) && desc.Usage == D3D11_USAGE_DEFAULT && gst_is_cuda_memory (dst_mem)) { diff --git a/subprojects/gst-plugins-bad/sys/nvcodec/gstcudautils.h b/subprojects/gst-plugins-bad/gst-libs/gst/cuda/gstcudautils.h similarity index 73% rename from subprojects/gst-plugins-bad/sys/nvcodec/gstcudautils.h rename to subprojects/gst-plugins-bad/gst-libs/gst/cuda/gstcudautils.h index e4ee4d7..417abca 100644 --- a/subprojects/gst-plugins-bad/sys/nvcodec/gstcudautils.h +++ b/subprojects/gst-plugins-bad/gst-libs/gst/cuda/gstcudautils.h @@ -20,10 +20,18 @@ #ifndef __GST_CUDA_UTILS_H__ #define __GST_CUDA_UTILS_H__ +#ifndef GST_USE_UNSTABLE_API +#warning "The Cuda library from gst-plugins-bad is unstable API and may change in future." +#warning "You can define GST_USE_UNSTABLE_API to avoid this warning." +#endif + +#include "cuda-prelude.h" #include #include +#include "cuda-gst.h" #include "gstcudaloader.h" #include "gstcudacontext.h" +#include "gstcudamemory.h" G_BEGIN_DECLS @@ -47,7 +55,7 @@ _gst_cuda_debug(CUresult result, GstDebugCategory * category, /** * gst_cuda_result: - * @result: CUDA device API return code #CUresult + * @result: CUDA device API return code `CUresult` * * Returns: %TRUE if CUDA device API call result is CUDA_SUCCESS */ @@ -64,14 +72,22 @@ _gst_cuda_debug(CUresult result, GstDebugCategory * category, /** * gst_cuda_result: - * @result: CUDA device API return code #CUresult + * @result: CUDA device API return code `CUresult` * * Returns: %TRUE if CUDA device API call result is CUDA_SUCCESS + * + * Since: 1.22 */ #define gst_cuda_result(result) \ _gst_cuda_debug(result, NULL, __FILE__, GST_FUNCTION, __LINE__) #endif +/** + * GstCudaQuarkId: + * + * Since: 1.22 + */ + typedef enum { GST_CUDA_QUARK_GRAPHICS_RESOURCE = 0, @@ -80,6 +96,14 @@ typedef enum GST_CUDA_QUARK_MAX = 1 } GstCudaQuarkId; +/** + * GstCudaGraphicsResourceType: + * @GST_CUDA_GRAPHICS_RESSOURCE_NONE: Ressource represents a CUDA buffer. + * @GST_CUDA_GRAPHICS_RESSOURCE_GL_BUFFER: Ressource represents a GL buffer. + * @GST_CUDA_GRAPHICS_RESSOURCE_D3D11_RESOURCE: Ressource represents a D3D resource. + * + * Since: 1.22 + */ typedef enum { GST_CUDA_GRAPHICS_RESOURCE_NONE = 0, @@ -87,6 +111,11 @@ typedef enum GST_CUDA_GRAPHICS_RESOURCE_D3D11_RESOURCE = 2, } GstCudaGraphicsResourceType; +/** + * GstCudaGraphicsResource: + * + * Since: 1.22 + */ typedef struct _GstCudaGraphicsResource { GstCudaContext *cuda_context; @@ -101,46 +130,70 @@ typedef struct _GstCudaGraphicsResource gboolean mapped; } GstCudaGraphicsResource; +GST_CUDA_API gboolean gst_cuda_ensure_element_context (GstElement * element, gint device_id, GstCudaContext ** cuda_ctx); +GST_CUDA_API gboolean gst_cuda_handle_set_context (GstElement * element, GstContext * context, gint device_id, GstCudaContext ** cuda_ctx); +GST_CUDA_API gboolean gst_cuda_handle_context_query (GstElement * element, GstQuery * query, GstCudaContext * cuda_ctx); -GstContext * gst_context_new_cuda_context (GstCudaContext * context); +GST_CUDA_API +GstContext * gst_context_new_cuda_context (GstCudaContext * cuda_ctx); +GST_CUDA_API GQuark gst_cuda_quark_from_id (GstCudaQuarkId id); +GST_CUDA_API GstCudaGraphicsResource * gst_cuda_graphics_resource_new (GstCudaContext * context, GstObject * graphics_context, GstCudaGraphicsResourceType type); +GST_CUDA_API gboolean gst_cuda_graphics_resource_register_gl_buffer (GstCudaGraphicsResource * resource, guint buffer, CUgraphicsRegisterFlags flags); +#ifdef GST_CUDA_HAS_D3D +GST_CUDA_API gboolean gst_cuda_graphics_resource_register_d3d11_resource (GstCudaGraphicsResource * resource, gpointer d3d11_resource, CUgraphicsRegisterFlags flags); +#endif +GST_CUDA_API void gst_cuda_graphics_resource_unregister (GstCudaGraphicsResource * resource); +GST_CUDA_API CUgraphicsResource gst_cuda_graphics_resource_map (GstCudaGraphicsResource * resource, CUstream stream, CUgraphicsMapResourceFlags flags); +GST_CUDA_API void gst_cuda_graphics_resource_unmap (GstCudaGraphicsResource * resource, CUstream stream); +GST_CUDA_API void gst_cuda_graphics_resource_free (GstCudaGraphicsResource * resource); +/** + * GstCudaBufferCopyType: + * GST_CUDA_BUFFER_COPY_SYSTEM: Copy from/to system memory + * GST_CUDA_BUFFER_COPY_CUDA: Copy from/to cuda memory + * GST_CUDA_BUFFER_COPY_GL: Copy from/to GL memory + * GST_CUDA_BUFFER_COPY_D3D11: Copy from/to D3D11 memory + * GST_CUDA_BUFFER_COPY_NVMM: Copy from/to NVMM memory + * + * Since: 1.22 + */ typedef enum { GST_CUDA_BUFFER_COPY_SYSTEM, @@ -150,8 +203,35 @@ typedef enum GST_CUDA_BUFFER_COPY_NVMM, } GstCudaBufferCopyType; +/** + * gst_cuda_buffery_copy_type_to_string: + * @type: The #GstCudaBufferCopyType to get name from + * + * Returns: The human readable name of @type + * + * Since: 1.22 + */ +GST_CUDA_API const gchar * gst_cuda_buffery_copy_type_to_string (GstCudaBufferCopyType type); +/** + * gst_cuda_buffer_copy: + * @dst: The buffer into which to copy @src content + * @dst_type: The #GstCudaBufferCopyType to copy @src into + * @dst_info: #GstVideoInfo defining @dst + * @src: The source buffer to copy + * @src_type: The #GstCudaBufferCopyType @src is in + * @src_info: $GstVideoInfo defining @src + * @context: The #GstCudaContext to use to copy @src into @dst + * @stream: The @CUStream to use to copy @src into @dst + * + * Copies @src into @dst with the specified arguments. + * + * Returns: %TRUE if the buffer could be copied %FALSE otherwise + * + * Since: 1.22 + */ +GST_CUDA_API gboolean gst_cuda_buffer_copy (GstBuffer * dst, GstCudaBufferCopyType dst_type, const GstVideoInfo * dst_info, diff --git a/subprojects/gst-plugins-bad/sys/nvcodec/gstnvrtcloader.c b/subprojects/gst-plugins-bad/gst-libs/gst/cuda/gstnvrtcloader.c similarity index 91% rename from subprojects/gst-plugins-bad/sys/nvcodec/gstnvrtcloader.c rename to subprojects/gst-plugins-bad/gst-libs/gst/cuda/gstnvrtcloader.c index 4861cde..3f151de 100644 --- a/subprojects/gst-plugins-bad/sys/nvcodec/gstnvrtcloader.c +++ b/subprojects/gst-plugins-bad/gst-libs/gst/cuda/gstnvrtcloader.c @@ -21,13 +21,14 @@ #include "config.h" #endif +#include "cuda-gst.h" #include "gstnvrtcloader.h" #include "gstcudaloader.h" #include -GST_DEBUG_CATEGORY_EXTERN (gst_nvcodec_debug); -#define GST_CAT_DEFAULT gst_nvcodec_debug +GST_DEBUG_CATEGORY (gst_nvrtcloader_debug); +#define GST_CAT_DEFAULT gst_nvrtcloader_debug #ifndef G_OS_WIN32 #define NVRTC_LIBNAME "libnvrtc.so" @@ -63,6 +64,15 @@ typedef struct _GstNvCodecNvrtcVtahle static GstNvCodecNvrtcVtahle gst_nvrtc_vtable = { 0, }; +/** + * gst_nvrtc_load_library: + * + * Loads the nvrtc library. + * + * Returns: %TRUE if the library could be loaded, %FALSE otherwise + * + * Since: 1.22 + */ gboolean gst_nvrtc_load_library (void) { @@ -72,10 +82,19 @@ gst_nvrtc_load_library (void) const gchar *fname; gint cuda_version; GstNvCodecNvrtcVtahle *vtable; + static gsize debug_initialized = FALSE; if (gst_nvrtc_vtable.loaded) return TRUE; + + if (g_once_init_enter (&debug_initialized)) { + GST_DEBUG_CATEGORY_INIT (gst_nvrtcloader_debug, "nvrtcloader", 0, + "nvrtcloader"); + + g_once_init_leave (&debug_initialized, TRUE); + } + CuDriverGetVersion (&cuda_version); fname = filename_env = g_getenv ("GST_NVCODEC_NVRTC_LIBNAME"); diff --git a/subprojects/gst-plugins-bad/sys/nvcodec/gstnvrtcloader.h b/subprojects/gst-plugins-bad/gst-libs/gst/cuda/gstnvrtcloader.h similarity index 52% rename from subprojects/gst-plugins-bad/sys/nvcodec/gstnvrtcloader.h rename to subprojects/gst-plugins-bad/gst-libs/gst/cuda/gstnvrtcloader.h index 2f680bb..d654940 100644 --- a/subprojects/gst-plugins-bad/sys/nvcodec/gstnvrtcloader.h +++ b/subprojects/gst-plugins-bad/gst-libs/gst/cuda/gstnvrtcloader.h @@ -20,37 +20,19 @@ #ifndef __GST_NVRTC_LOADER_H__ #define __GST_NVRTC_LOADER_H__ +#ifndef GST_USE_UNSTABLE_API +#warning "The Cuda library from gst-plugins-bad is unstable API and may change in future." +#warning "You can define GST_USE_UNSTABLE_API to avoid this warning." +#endif + +#include "cuda-prelude.h" #include #include G_BEGIN_DECLS +GST_CUDA_API gboolean gst_nvrtc_load_library (void); -nvrtcResult NvrtcCompileProgram (nvrtcProgram prog, - int numOptions, - const char** options); - -nvrtcResult NvrtcCreateProgram (nvrtcProgram* prog, - const char* src, - const char* name, - int numHeaders, - const char** headers, - const char** includeNames); - -nvrtcResult NvrtcDestroyProgram (nvrtcProgram* prog); - -nvrtcResult NvrtcGetPTX (nvrtcProgram prog, - char* ptx); - -nvrtcResult NvrtcGetPTXSize (nvrtcProgram prog, - size_t* ptxSizeRet); - -nvrtcResult NvrtcGetProgramLog (nvrtcProgram prog, - char* log); - -nvrtcResult NvrtcGetProgramLogSize (nvrtcProgram prog, - size_t* logSizeRet); - G_END_DECLS #endif /* __GST_NVRTC_LOADER_H__ */ diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/cuda/meson.build b/subprojects/gst-plugins-bad/gst-libs/gst/cuda/meson.build new file mode 100644 index 0000000..ec06c71 --- /dev/null +++ b/subprojects/gst-plugins-bad/gst-libs/gst/cuda/meson.build @@ -0,0 +1,101 @@ +cuda_sources = [ + 'gstcudaloader.c', + 'gstcudacontext.c', + 'gstcudautils.c', + 'gstcudamemory.c', + 'gstcudabufferpool.c', + 'gstcudanvrtc.c', + 'gstnvrtcloader.c', +] + +cuda_headers = [ + 'cuda-prelude.h', + 'cuda-gst.h', + 'gstcudabufferpool.h', + 'gstcudacontext.h', + 'gstcudaloader.h', + 'gstcudamemory.h', + 'gstcudanvrtc.h', + 'gstcudautils.h', + 'gstnvrtcloader.h', +] + +cuda_stubinc = include_directories('./stub') +extra_c_args = ['-DGST_USE_UNSTABLE_API'] + +if gstgl_dep.found() + extra_c_args += ['-DHAVE_NVCODEC_GST_GL=1'] +endif + +if gstd3d11_dep.found() + extra_c_args += ['-DGST_CUDA_HAS_D3D=1', '-DCOBJMACROS'] +endif + +pkg_name = 'gstreamer-cuda-' + api_version +gstcuda= library('gstcuda-' + api_version, + cuda_sources, + c_args : gst_plugins_bad_args + extra_c_args + ['-DGST_USE_UNSTABLE_API', '-DBUILDING_GST_CUDA', '-DG_LOG_DOMAIN="GStreamer-Cuda"'], + cpp_args : gst_plugins_bad_args, + include_directories : [configinc, libsinc, cuda_stubinc], + version : libversion, + soversion : soversion, + install : true, + dependencies : [gstbase_dep, gmodule_dep, gstvideo_dep, gstglproto_dep, gstd3d11_dep] +) + +gen_sources = [] +library_def = {'lib': gstcuda} +if build_gir + gir_includes = ['Gst-1.0', 'GstBase-1.0', 'GstVideo-1.0', 'CudaGst-1.0'] + if gstglproto_dep.found() + gir_includes += ['GstGL-1.0'] + endif + cuda_gir = { + 'sources' : files('stub/cuda.h', 'stub/cudaGL.h'), + 'namespace' : 'CudaGst', + 'nsversion' : api_version, + 'identifier_prefix' : 'CU', + 'symbol_prefix' : 'cu', + 'export_packages' : pkg_name, + 'includes' : [], + 'install' : true, + 'extra_args' : [], + 'dependencies' : [], + } + gir = { + 'sources' : cuda_sources + cuda_headers, + 'namespace' : 'GstCuda', + 'nsversion' : api_version, + 'identifier_prefix' : 'Gst', + 'symbol_prefix' : 'gst', + 'export_packages' : pkg_name, + 'includes' : gir_includes, + 'install' : true, + 'extra_args' : gir_init_section + ['-DGST_USE_UNSTABLE_API'], + 'dependencies' : [gstbase_dep, gstvideo_dep, gstglproto_dep], + } + if not static_build + cudagst_gir = gnome.generate_gir(gstcuda, kwargs: cuda_gir) + + gir += {'includes': gir['includes'] + [cudagst_gir[0]]} + gst_cuda_gir = gnome.generate_gir(gstcuda, kwargs: gir) + gen_sources += gst_cuda_gir + endif + + library_def += {'gir': [gir, cuda_gir]} +endif +libraries += [[pkg_name, library_def]] + +pkgconfig.generate(gstcuda, + libraries : [gstbase_dep, gmodule_dep, gstvideo_dep, gstglproto_dep], + variables : pkgconfig_variables, + subdirs : pkgconfig_subdirs, + name : pkg_name, + description : 'Unstable library to work with CUDA inside GStreamer', +) + +install_headers(cuda_headers, subdir : 'gstreamer-1.0/gst/cuda') +gstcuda_dep = declare_dependency(link_with : gstcuda, + include_directories : [libsinc], + dependencies : [gstbase_dep, gmodule_dep, gstvideo_dep, gstglproto_dep], + sources: gen_sources) diff --git a/subprojects/gst-plugins-bad/sys/nvcodec/stub/cuda.h b/subprojects/gst-plugins-bad/gst-libs/gst/cuda/stub/cuda.h similarity index 97% rename from subprojects/gst-plugins-bad/sys/nvcodec/stub/cuda.h rename to subprojects/gst-plugins-bad/gst-libs/gst/cuda/stub/cuda.h index 2187510..8455a68 100644 --- a/subprojects/gst-plugins-bad/sys/nvcodec/stub/cuda.h +++ b/subprojects/gst-plugins-bad/gst-libs/gst/cuda/stub/cuda.h @@ -134,11 +134,6 @@ typedef struct typedef enum { - CU_GL_DEVICE_LIST_ALL = 0x01, -} CUGLDeviceList; - -typedef enum -{ CU_D3D11_DEVICE_LIST_ALL = 0x01, CU_D3D11_DEVICE_LIST_CURRENT_FRAME = 0x02, CU_D3D11_DEVICE_LIST_NEXT_FRAME = 0x03, @@ -225,7 +220,6 @@ typedef struct #define cuMemcpy2D cuMemcpy2D_v2 #define cuMemcpy2DAsync cuMemcpy2DAsync_v2 #define cuMemFree cuMemFree_v2 -#define cuGLGetDevices cuGLGetDevices_v2 #define CU_TRSF_READ_AS_INTEGER 1 diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/cuda/stub/cudaGL.h b/subprojects/gst-plugins-bad/gst-libs/gst/cuda/stub/cudaGL.h new file mode 100644 index 0000000..d06a279 --- /dev/null +++ b/subprojects/gst-plugins-bad/gst-libs/gst/cuda/stub/cudaGL.h @@ -0,0 +1,16 @@ +#ifndef __GST_CUDA_GLSTUB_H__ +#define __GST_CUDA_GLSTUB_H__ + +#include + +G_BEGIN_DECLS +typedef enum +{ + CU_GL_DEVICE_LIST_ALL = 0x01, +} CUGLDeviceList; + +#define cuGLGetDevices cuGLGetDevices_v2 + +G_END_DECLS + +#endif /* __GST_CUDA_GLSTUB_H__ */ diff --git a/subprojects/gst-plugins-bad/sys/nvcodec/stub/nvrtc.h b/subprojects/gst-plugins-bad/gst-libs/gst/cuda/stub/nvrtc.h similarity index 100% rename from subprojects/gst-plugins-bad/sys/nvcodec/stub/nvrtc.h rename to subprojects/gst-plugins-bad/gst-libs/gst/cuda/stub/nvrtc.h diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/meson.build b/subprojects/gst-plugins-bad/gst-libs/gst/meson.build index 77dadcf..515f981 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/meson.build +++ b/subprojects/gst-plugins-bad/gst-libs/gst/meson.build @@ -6,6 +6,8 @@ subdir('basecamerabinsrc') subdir('codecparsers') subdir('codecs') subdir('d3d11') +# cuda can depend on d3d11 +subdir('cuda') subdir('insertbin') subdir('interfaces') subdir('isoff') diff --git a/subprojects/gst-plugins-bad/sys/nvcodec/cuda-converter.c b/subprojects/gst-plugins-bad/sys/nvcodec/cuda-converter.c index 5752343..597d25b 100644 --- a/subprojects/gst-plugins-bad/sys/nvcodec/cuda-converter.c +++ b/subprojects/gst-plugins-bad/sys/nvcodec/cuda-converter.c @@ -46,9 +46,9 @@ #endif #include "cuda-converter.h" -#include "gstcudautils.h" -#include "gstcudaloader.h" -#include "gstcudanvrtc.h" +#include +#include +#include #include #define CUDA_BLOCK_X 16 diff --git a/subprojects/gst-plugins-bad/sys/nvcodec/cuda-converter.h b/subprojects/gst-plugins-bad/sys/nvcodec/cuda-converter.h index 5149ab0..82c5f16 100644 --- a/subprojects/gst-plugins-bad/sys/nvcodec/cuda-converter.h +++ b/subprojects/gst-plugins-bad/sys/nvcodec/cuda-converter.h @@ -21,8 +21,8 @@ #define __GST_CUDA_CONVERTER_H__ #include -#include "gstcudacontext.h" -#include "gstcudamemory.h" +#include +#include G_BEGIN_DECLS diff --git a/subprojects/gst-plugins-bad/sys/nvcodec/gstcudabasefilter.c b/subprojects/gst-plugins-bad/sys/nvcodec/gstcudabasefilter.c index 911552e..a0c1dfa 100644 --- a/subprojects/gst-plugins-bad/sys/nvcodec/gstcudabasefilter.c +++ b/subprojects/gst-plugins-bad/sys/nvcodec/gstcudabasefilter.c @@ -32,8 +32,9 @@ #endif #include "gstcudabasefilter.h" -#include "gstcudautils.h" #include "gstcudaformat.h" +#include + #include GST_DEBUG_CATEGORY_STATIC (gst_cuda_base_filter_debug); diff --git a/subprojects/gst-plugins-bad/sys/nvcodec/gstcudabasetransform.c b/subprojects/gst-plugins-bad/sys/nvcodec/gstcudabasetransform.c index 841e748..1200d18 100644 --- a/subprojects/gst-plugins-bad/sys/nvcodec/gstcudabasetransform.c +++ b/subprojects/gst-plugins-bad/sys/nvcodec/gstcudabasetransform.c @@ -29,8 +29,9 @@ # include #endif +#include + #include "gstcudabasetransform.h" -#include "gstcudautils.h" GST_DEBUG_CATEGORY_STATIC (gst_cuda_base_transform_debug); #define GST_CAT_DEFAULT gst_cuda_base_transform_debug diff --git a/subprojects/gst-plugins-bad/sys/nvcodec/gstcudabasetransform.h b/subprojects/gst-plugins-bad/sys/nvcodec/gstcudabasetransform.h index 93e366d..da0cce8 100644 --- a/subprojects/gst-plugins-bad/sys/nvcodec/gstcudabasetransform.h +++ b/subprojects/gst-plugins-bad/sys/nvcodec/gstcudabasetransform.h @@ -23,8 +23,8 @@ #include #include #include -#include "gstcudacontext.h" -#include "gstcudabufferpool.h" +#include +#include G_BEGIN_DECLS diff --git a/subprojects/gst-plugins-bad/sys/nvcodec/gstcudaconvert.c b/subprojects/gst-plugins-bad/sys/nvcodec/gstcudaconvert.c index 39a0703..089b552 100644 --- a/subprojects/gst-plugins-bad/sys/nvcodec/gstcudaconvert.c +++ b/subprojects/gst-plugins-bad/sys/nvcodec/gstcudaconvert.c @@ -41,8 +41,9 @@ # include #endif +#include + #include "gstcudaconvert.h" -#include "gstcudautils.h" GST_DEBUG_CATEGORY_STATIC (gst_cuda_convert_debug); #define GST_CAT_DEFAULT gst_cuda_convert_debug diff --git a/subprojects/gst-plugins-bad/sys/nvcodec/gstcudafilter.c b/subprojects/gst-plugins-bad/sys/nvcodec/gstcudafilter.c index eadf1c6..4d04bb0 100644 --- a/subprojects/gst-plugins-bad/sys/nvcodec/gstcudafilter.c +++ b/subprojects/gst-plugins-bad/sys/nvcodec/gstcudafilter.c @@ -21,10 +21,11 @@ #include "config.h" #endif +#include +#include +#include + #include "gstcudafilter.h" -#include "gstcudaloader.h" -#include "gstnvrtcloader.h" -#include "gstcudanvrtc.h" #include "gstcudaconvert.h" #include "gstcudascale.h" diff --git a/subprojects/gst-plugins-bad/sys/nvcodec/gstcudamemorycopy.c b/subprojects/gst-plugins-bad/sys/nvcodec/gstcudamemorycopy.c index 7466ebe..b362cd4 100644 --- a/subprojects/gst-plugins-bad/sys/nvcodec/gstcudamemorycopy.c +++ b/subprojects/gst-plugins-bad/sys/nvcodec/gstcudamemorycopy.c @@ -33,7 +33,7 @@ #include "gstcudabasetransform.h" #include "gstcudamemorycopy.h" #include "gstcudaformat.h" -#include "gstcudautils.h" +#include #ifdef HAVE_NVCODEC_NVMM #include "gstcudanvmm.h" #endif @@ -41,7 +41,7 @@ #ifdef HAVE_NVCODEC_GST_GL #include #endif -#ifdef HAVE_NVCODEC_GST_D3D11 +#ifdef GST_CUDA_HAS_D3D #include #endif @@ -67,7 +67,7 @@ struct _GstCudaMemoryCopy GstGLContext *gl_context; GstGLContext *other_gl_context; #endif -#ifdef HAVE_NVCODEC_GST_D3D11 +#ifdef GST_CUDA_HAS_D3D GstD3D11Device *d3d11_device; #endif }; @@ -158,7 +158,7 @@ gst_cuda_memory_copy_set_context (GstElement * element, GstContext * context) static gboolean gst_cuda_memory_copy_transform_stop (GstBaseTransform * trans) { -#if defined(HAVE_NVCODEC_GST_GL) || defined(HAVE_NVCODEC_GST_D3D11) +#if defined(HAVE_NVCODEC_GST_GL) || defined(GST_CUDA_HAS_D3D) GstCudaMemoryCopy *self = GST_CUDA_MEMORY_COPY (trans); # ifdef HAVE_NVCODEC_GST_GL @@ -166,7 +166,7 @@ gst_cuda_memory_copy_transform_stop (GstBaseTransform * trans) gst_clear_object (&self->gl_context); gst_clear_object (&self->other_gl_context); # endif -# ifdef HAVE_NVCODEC_GST_D3D11 +# ifdef GST_CUDA_HAS_D3D gst_clear_object (&self->d3d11_device); # endif #endif @@ -244,7 +244,7 @@ create_transform_caps (GstCaps * caps, gboolean to_cuda) new_caps = _set_caps_features (caps, GST_CAPS_FEATURE_MEMORY_GL_MEMORY); ret = gst_caps_merge (ret, new_caps); #endif -#ifdef HAVE_NVCODEC_GST_D3D11 +#ifdef GST_CUDA_HAS_D3D new_caps = _set_caps_features (caps, GST_CAPS_FEATURE_MEMORY_D3D11_MEMORY); ret = gst_caps_merge (ret, new_caps); #endif @@ -368,7 +368,7 @@ gst_cuda_memory_copy_ensure_gl_context (GstCudaMemoryCopy * self) } #endif -#ifdef HAVE_NVCODEC_GST_D3D11 +#ifdef GST_CUDA_HAS_D3D static gboolean gst_cuda_memory_copy_ensure_d3d11_interop (GstCudaContext * context, GstD3D11Device * device) @@ -462,7 +462,7 @@ gst_cuda_memory_copy_propose_allocation (GstBaseTransform * trans, pool = gst_gl_buffer_pool_new (self->gl_context); #endif -#ifdef HAVE_NVCODEC_GST_D3D11 +#ifdef GST_CUDA_HAS_D3D } else if (features && gst_caps_features_contains (features, GST_CAPS_FEATURE_MEMORY_D3D11_MEMORY) && gst_cuda_memory_copy_ensure_d3d11_context (self)) { @@ -554,7 +554,7 @@ gst_cuda_memory_copy_decide_allocation (GstBaseTransform * trans, #ifdef HAVE_NVCODEC_GST_GL gboolean need_gl = FALSE; #endif -#ifdef HAVE_NVCODEC_GST_D3D11 +#ifdef GST_CUDA_HAS_D3D gboolean need_d3d11 = FALSE; #endif #ifdef HAVE_NVCODEC_NVMM @@ -578,7 +578,7 @@ gst_cuda_memory_copy_decide_allocation (GstBaseTransform * trans, need_gl = TRUE; } #endif -#ifdef HAVE_NVCODEC_GST_D3D11 +#ifdef GST_CUDA_HAS_D3D else if (features && gst_caps_features_contains (features, GST_CAPS_FEATURE_MEMORY_D3D11_MEMORY) && gst_cuda_memory_copy_ensure_d3d11_context (self)) { @@ -632,7 +632,7 @@ gst_cuda_memory_copy_decide_allocation (GstBaseTransform * trans, pool = gst_gl_buffer_pool_new (self->gl_context); } #endif -#ifdef HAVE_NVCODEC_GST_D3D11 +#ifdef GST_CUDA_HAS_D3D else if (need_d3d11) { GST_DEBUG_OBJECT (self, "creating d3d11 pool"); pool = gst_d3d11_buffer_pool_new (self->d3d11_device); @@ -711,7 +711,7 @@ static gboolean gst_cuda_memory_copy_query (GstBaseTransform * trans, GstPadDirection direction, GstQuery * query) { -#if defined(HAVE_NVCODEC_GST_GL) || defined(HAVE_NVCODEC_GST_D3D11) +#if defined(HAVE_NVCODEC_GST_GL) || defined(GST_CUDA_HAS_D3D) GstCudaMemoryCopy *self = GST_CUDA_MEMORY_COPY (trans); switch (GST_QUERY_TYPE (query)) { @@ -724,7 +724,7 @@ gst_cuda_memory_copy_query (GstBaseTransform * trans, if (ret) return TRUE; # endif -# ifdef HAVE_NVCODEC_GST_D3D11 +# ifdef GST_CUDA_HAS_D3D ret = gst_d3d11_handle_context_query (GST_ELEMENT (self), query, self->d3d11_device); if (ret) @@ -787,7 +787,7 @@ gst_cuda_memory_copy_transform (GstBaseTransform * trans, GstBuffer * inbuf, GstCudaBufferCopyType in_type = GST_CUDA_BUFFER_COPY_SYSTEM; GstCudaBufferCopyType out_type = GST_CUDA_BUFFER_COPY_SYSTEM; gboolean use_device_copy = FALSE; -#ifdef HAVE_NVCODEC_GST_D3D11 +#ifdef GST_CUDA_HAS_D3D D3D11_TEXTURE2D_DESC desc; #endif @@ -816,7 +816,7 @@ gst_cuda_memory_copy_transform (GstBaseTransform * trans, GstBuffer * inbuf, } else if (self->gl_context && gst_is_gl_memory_pbo (in_mem)) { in_type = GST_CUDA_BUFFER_COPY_GL; #endif -#ifdef HAVE_NVCODEC_GST_D3D11 +#ifdef GST_CUDA_HAS_D3D } else if (self->d3d11_device && gst_is_d3d11_memory (in_mem) && gst_d3d11_memory_get_texture_desc (GST_D3D11_MEMORY_CAST (in_mem), &desc) && desc.Usage == D3D11_USAGE_DEFAULT) { @@ -836,7 +836,7 @@ gst_cuda_memory_copy_transform (GstBaseTransform * trans, GstBuffer * inbuf, } else if (self->gl_context && gst_is_gl_memory_pbo (out_mem)) { out_type = GST_CUDA_BUFFER_COPY_GL; #endif -#ifdef HAVE_NVCODEC_GST_D3D11 +#ifdef GST_CUDA_HAS_D3D } else if (self->d3d11_device && gst_is_d3d11_memory (out_mem) && gst_d3d11_memory_get_texture_desc (GST_D3D11_MEMORY_CAST (out_mem), &desc) && desc.Usage == D3D11_USAGE_DEFAULT) { @@ -1030,7 +1030,7 @@ gst_cuda_memory_copy_register (GstPlugin * plugin, guint rank) #ifdef HAVE_NVCODEC_GST_GL GstCaps *gl_caps; #endif -#ifdef HAVE_NVCODEC_GST_D3D11 +#ifdef GST_CUDA_HAS_D3D GstCaps *d3d11_caps; #endif GstCaps *upload_sink_caps; @@ -1059,7 +1059,7 @@ gst_cuda_memory_copy_register (GstPlugin * plugin, guint rank) gst_caps_from_string (GST_VIDEO_CAPS_MAKE_WITH_FEATURES (GST_CAPS_FEATURE_MEMORY_GL_MEMORY, GST_CUDA_GL_FORMATS)); #endif -#ifdef HAVE_NVCODEC_GST_D3D11 +#ifdef GST_CUDA_HAS_D3D d3d11_caps = gst_caps_from_string (GST_VIDEO_CAPS_MAKE_WITH_FEATURES (GST_CAPS_FEATURE_MEMORY_D3D11_MEMORY, GST_CUDA_D3D11_FORMATS)); @@ -1069,7 +1069,7 @@ gst_cuda_memory_copy_register (GstPlugin * plugin, guint rank) #ifdef HAVE_NVCODEC_GST_GL upload_sink_caps = gst_caps_merge (upload_sink_caps, gst_caps_copy (gl_caps)); #endif -#ifdef HAVE_NVCODEC_GST_D3D11 +#ifdef GST_CUDA_HAS_D3D upload_sink_caps = gst_caps_merge (upload_sink_caps, gst_caps_copy (d3d11_caps)); #endif @@ -1105,7 +1105,7 @@ gst_cuda_memory_copy_register (GstPlugin * plugin, guint rank) #ifdef HAVE_NVCODEC_GST_GL download_src_caps = gst_caps_merge (download_src_caps, gl_caps); #endif -#ifdef HAVE_NVCODEC_GST_D3D11 +#ifdef GST_CUDA_HAS_D3D download_src_caps = gst_caps_merge (download_src_caps, d3d11_caps); #endif #ifdef HAVE_NVCODEC_NVMM diff --git a/subprojects/gst-plugins-bad/sys/nvcodec/gstcudascale.c b/subprojects/gst-plugins-bad/sys/nvcodec/gstcudascale.c index ea89265..06fb782 100644 --- a/subprojects/gst-plugins-bad/sys/nvcodec/gstcudascale.c +++ b/subprojects/gst-plugins-bad/sys/nvcodec/gstcudascale.c @@ -50,8 +50,9 @@ # include #endif +#include + #include "gstcudascale.h" -#include "gstcudautils.h" GST_DEBUG_CATEGORY_STATIC (gst_cuda_scale_debug); #define GST_CAT_DEFAULT gst_cuda_scale_debug diff --git a/subprojects/gst-plugins-bad/sys/nvcodec/gstcuvidloader.h b/subprojects/gst-plugins-bad/sys/nvcodec/gstcuvidloader.h index 6fe4d54..ccf4bdf 100644 --- a/subprojects/gst-plugins-bad/sys/nvcodec/gstcuvidloader.h +++ b/subprojects/gst-plugins-bad/sys/nvcodec/gstcuvidloader.h @@ -21,7 +21,7 @@ #define __GST_CUVID_LOADER_H__ #include -#include "stub/cuda.h" +#include "cuda.h" #include "nvcuvid.h" G_BEGIN_DECLS diff --git a/subprojects/gst-plugins-bad/sys/nvcodec/gstnvbaseenc.c b/subprojects/gst-plugins-bad/sys/nvcodec/gstnvbaseenc.c index b57ba23..aa48baa 100644 --- a/subprojects/gst-plugins-bad/sys/nvcodec/gstnvbaseenc.c +++ b/subprojects/gst-plugins-bad/sys/nvcodec/gstnvbaseenc.c @@ -22,8 +22,8 @@ #endif #include "gstnvbaseenc.h" -#include "gstcudautils.h" -#include "gstcudabufferpool.h" +#include +#include #include diff --git a/subprojects/gst-plugins-bad/sys/nvcodec/gstnvbaseenc.h b/subprojects/gst-plugins-bad/sys/nvcodec/gstnvbaseenc.h index 7c289fc..ee384ee 100644 --- a/subprojects/gst-plugins-bad/sys/nvcodec/gstnvbaseenc.h +++ b/subprojects/gst-plugins-bad/sys/nvcodec/gstnvbaseenc.h @@ -23,7 +23,7 @@ #include "gstnvenc.h" #include -#include "gstcudacontext.h" +#include #define GST_TYPE_NV_BASE_ENC \ (gst_nv_base_enc_get_type()) diff --git a/subprojects/gst-plugins-bad/sys/nvcodec/gstnvdec.c b/subprojects/gst-plugins-bad/sys/nvcodec/gstnvdec.c index 950f889..854c6ba 100644 --- a/subprojects/gst-plugins-bad/sys/nvcodec/gstnvdec.c +++ b/subprojects/gst-plugins-bad/sys/nvcodec/gstnvdec.c @@ -29,9 +29,11 @@ #include "config.h" #endif +#include +#include + +#include "gstcuvidloader.h" #include "gstnvdec.h" -#include "gstcudautils.h" -#include "gstcudabufferpool.h" #include diff --git a/subprojects/gst-plugins-bad/sys/nvcodec/gstnvdec.h b/subprojects/gst-plugins-bad/sys/nvcodec/gstnvdec.h index dfb9528..ea8b18e 100644 --- a/subprojects/gst-plugins-bad/sys/nvcodec/gstnvdec.h +++ b/subprojects/gst-plugins-bad/sys/nvcodec/gstnvdec.h @@ -33,12 +33,12 @@ #include #endif +#include "nvcuvid.h" #include #include #include -#include "gstcuvidloader.h" -#include "gstcudaloader.h" -#include "gstcudacontext.h" +#include +#include G_BEGIN_DECLS diff --git a/subprojects/gst-plugins-bad/sys/nvcodec/gstnvdecoder.c b/subprojects/gst-plugins-bad/sys/nvcodec/gstnvdecoder.c index 1c5ae8e..0ebeb01 100644 --- a/subprojects/gst-plugins-bad/sys/nvcodec/gstnvdecoder.c +++ b/subprojects/gst-plugins-bad/sys/nvcodec/gstnvdecoder.c @@ -50,9 +50,9 @@ #include #endif -#include "gstcudamemory.h" +#include +#include #include "gstnvdecoder.h" -#include "gstcudabufferpool.h" #include GST_DEBUG_CATEGORY_EXTERN (gst_nv_decoder_debug); diff --git a/subprojects/gst-plugins-bad/sys/nvcodec/gstnvdecoder.h b/subprojects/gst-plugins-bad/sys/nvcodec/gstnvdecoder.h index 947ed74..6fcba2d 100644 --- a/subprojects/gst-plugins-bad/sys/nvcodec/gstnvdecoder.h +++ b/subprojects/gst-plugins-bad/sys/nvcodec/gstnvdecoder.h @@ -22,7 +22,7 @@ #include #include -#include "gstcudautils.h" +#include #include "gstcuvidloader.h" G_BEGIN_DECLS diff --git a/subprojects/gst-plugins-bad/sys/nvcodec/gstnvenc.c b/subprojects/gst-plugins-bad/sys/nvcodec/gstnvenc.c index a3e1a42..fed7201 100644 --- a/subprojects/gst-plugins-bad/sys/nvcodec/gstnvenc.c +++ b/subprojects/gst-plugins-bad/sys/nvcodec/gstnvenc.c @@ -24,7 +24,8 @@ #include "gstnvenc.h" #include "gstnvh264enc.h" #include "gstnvh265enc.h" -#include "gstcudabufferpool.h" +#include +#include #include diff --git a/subprojects/gst-plugins-bad/sys/nvcodec/gstnvenc.h b/subprojects/gst-plugins-bad/sys/nvcodec/gstnvenc.h index 4437386..a2e5781 100644 --- a/subprojects/gst-plugins-bad/sys/nvcodec/gstnvenc.h +++ b/subprojects/gst-plugins-bad/sys/nvcodec/gstnvenc.h @@ -22,8 +22,8 @@ #include #include +#include -#include "gstcudaloader.h" #include "nvEncodeAPI.h" G_BEGIN_DECLS diff --git a/subprojects/gst-plugins-bad/sys/nvcodec/gstnvencoder.cpp b/subprojects/gst-plugins-bad/sys/nvcodec/gstnvencoder.cpp index 33d534e..de1b1c8 100644 --- a/subprojects/gst-plugins-bad/sys/nvcodec/gstnvencoder.cpp +++ b/subprojects/gst-plugins-bad/sys/nvcodec/gstnvencoder.cpp @@ -22,12 +22,13 @@ #endif #include "gstnvencoder.h" -#include "gstcudautils.h" -#include "gstcudamemory.h" -#include "gstcudabufferpool.h" + +#include +#include +#include #include -#ifdef HAVE_NVCODEC_GST_D3D11 +#ifdef GST_CUDA_HAS_D3D #include #endif @@ -57,7 +58,7 @@ GST_DEBUG_CATEGORY_STATIC (gst_nv_encoder_debug); struct _GstNvEncoderPrivate { GstCudaContext *context; -#ifdef HAVE_NVCODEC_GST_D3D11 +#ifdef GST_CUDA_HAS_D3D GstD3D11Device *device; #endif @@ -179,7 +180,7 @@ gst_nv_encoder_set_context (GstElement * element, GstContext * context) GstNvEncoder *self = GST_NV_ENCODER (element); GstNvEncoderPrivate *priv = self->priv; -#ifdef HAVE_NVCODEC_GST_D3D11 +#ifdef GST_CUDA_HAS_D3D if (priv->d3d11_mode) { gst_d3d11_handle_set_context_for_adapter_luid (element, context, priv->dxgi_adapter_luid, &priv->device); @@ -224,7 +225,7 @@ gst_nv_encoder_device_lock (GstNvEncoder * self) { GstNvEncoderPrivate *priv = self->priv; -#ifdef HAVE_NVCODEC_GST_D3D11 +#ifdef GST_CUDA_HAS_D3D if (priv->d3d11_mode) { gst_d3d11_device_lock (priv->device); return TRUE; @@ -237,7 +238,7 @@ gst_nv_encoder_device_lock (GstNvEncoder * self) static gboolean gst_nv_encoder_device_unlock (GstNvEncoder * self) { -#ifdef HAVE_NVCODEC_GST_D3D11 +#ifdef GST_CUDA_HAS_D3D GstNvEncoderPrivate *priv = self->priv; if (priv->d3d11_mode) { @@ -338,7 +339,7 @@ gst_nv_encoder_drain (GstNvEncoder * self, gboolean locked) return TRUE; } -#ifdef HAVE_NVCODEC_GST_D3D11 +#ifdef GST_CUDA_HAS_D3D static gboolean gst_nv_encoder_open_d3d11_device (GstNvEncoder * self) { @@ -374,7 +375,7 @@ gst_nv_encoder_open (GstVideoEncoder * encoder) GstNvEncoder *self = GST_NV_ENCODER (encoder); GstNvEncoderPrivate *priv = self->priv; -#ifdef HAVE_NVCODEC_GST_D3D11 +#ifdef GST_CUDA_HAS_D3D if (priv->d3d11_mode) { return gst_nv_encoder_open_d3d11_device (self); } @@ -396,7 +397,7 @@ gst_nv_encoder_close (GstVideoEncoder * encoder) GstNvEncoderPrivate *priv = self->priv; gst_clear_object (&priv->context); -#ifdef HAVE_NVCODEC_GST_D3D11 +#ifdef GST_CUDA_HAS_D3D gst_clear_object (&priv->device); #endif @@ -423,7 +424,7 @@ gst_nv_encoder_handle_context_query (GstNvEncoder * self, GstQuery * query) { GstNvEncoderPrivate *priv = self->priv; -#ifdef HAVE_NVCODEC_GST_D3D11 +#ifdef GST_CUDA_HAS_D3D if (priv->d3d11_mode) { return gst_d3d11_handle_context_query (GST_ELEMENT (self), query, priv->device); @@ -493,7 +494,7 @@ gst_nv_encoder_propose_allocation (GstVideoEncoder * encoder, GstQuery * query) } features = gst_caps_get_features (caps, 0); -#ifdef HAVE_NVCODEC_GST_D3D11 +#ifdef GST_CUDA_HAS_D3D if (priv->d3d11_mode && features && gst_caps_features_contains (features, GST_CAPS_FEATURE_MEMORY_D3D11_MEMORY)) { GST_DEBUG_OBJECT (self, "upstream support d3d11 memory"); @@ -967,7 +968,7 @@ gst_nv_encoder_open_encode_session (GstNvEncoder * self, gpointer * session) session_params.apiVersion = gst_nvenc_get_api_version (); NVENCSTATUS status; -#ifdef HAVE_NVCODEC_GST_D3D11 +#ifdef GST_CUDA_HAS_D3D if (priv->d3d11_mode) { session_params.deviceType = NV_ENC_DEVICE_TYPE_DIRECTX; session_params.device = gst_d3d11_device_get_device_handle (priv->device); @@ -988,7 +989,7 @@ gst_nv_encoder_open_encode_session (GstNvEncoder * self, gpointer * session) return TRUE; } -#ifdef HAVE_NVCODEC_GST_D3D11 +#ifdef GST_CUDA_HAS_D3D static GstBufferPool * gst_nv_encoder_create_d3d11_pool (GstNvEncoder * self, GstVideoCodecState * state) @@ -1033,7 +1034,7 @@ gst_nv_encoder_create_pool (GstNvEncoder * self, GstVideoCodecState * state) GstNvEncoderPrivate *priv = self->priv; GstStructure *config; GstBufferPool *pool = NULL; -#ifdef HAVE_NVCODEC_GST_D3D11 +#ifdef GST_CUDA_HAS_D3D if (priv->d3d11_mode) return gst_nv_encoder_create_d3d11_pool (self, state); #endif @@ -1402,7 +1403,7 @@ gst_nv_encoder_prepare_task_input_cuda (GstNvEncoder * self, return GST_FLOW_OK; } -#ifdef HAVE_NVCODEC_GST_D3D11 +#ifdef GST_CUDA_HAS_D3D static GstBuffer * gst_nv_encoder_copy_d3d11 (GstNvEncoder * self, GstBuffer * src_buffer, GstBufferPool * pool, gboolean shared) @@ -1679,7 +1680,7 @@ gst_nv_encoder_prepare_task_input (GstNvEncoder * self, const GstVideoInfo * info, GstBuffer * buffer, gpointer session, GstBufferPool * pool, GstNvEncoderTask * task) { -#ifdef HAVE_NVCODEC_GST_D3D11 +#ifdef GST_CUDA_HAS_D3D GstNvEncoderPrivate *priv = self->priv; if (priv->d3d11_mode) { return gst_nv_encoder_prepare_task_input_d3d11 (self, info, buffer, diff --git a/subprojects/gst-plugins-bad/sys/nvcodec/gstnvencoder.h b/subprojects/gst-plugins-bad/sys/nvcodec/gstnvencoder.h index f597991..f862701 100644 --- a/subprojects/gst-plugins-bad/sys/nvcodec/gstnvencoder.h +++ b/subprojects/gst-plugins-bad/sys/nvcodec/gstnvencoder.h @@ -22,7 +22,7 @@ #include #include -#ifdef HAVE_NVCODEC_GST_D3D11 +#ifdef GST_CUDA_HAS_D3D #include #endif @@ -30,7 +30,7 @@ #include "nvEncodeAPI.h" #include "gstnvenc.h" -#include "gstcudamemory.h" +#include G_BEGIN_DECLS diff --git a/subprojects/gst-plugins-bad/sys/nvcodec/gstnvh264dec.c b/subprojects/gst-plugins-bad/sys/nvcodec/gstnvh264dec.c index 5e44fda..8b37b6f 100644 --- a/subprojects/gst-plugins-bad/sys/nvcodec/gstnvh264dec.c +++ b/subprojects/gst-plugins-bad/sys/nvcodec/gstnvh264dec.c @@ -74,8 +74,9 @@ #include "config.h" #endif +#include + #include "gstnvh264dec.h" -#include "gstcudautils.h" #include "gstnvdecoder.h" #include diff --git a/subprojects/gst-plugins-bad/sys/nvcodec/gstnvh264encoder.cpp b/subprojects/gst-plugins-bad/sys/nvcodec/gstnvh264encoder.cpp index 08d16bd..c18b0e7 100644 --- a/subprojects/gst-plugins-bad/sys/nvcodec/gstnvh264encoder.cpp +++ b/subprojects/gst-plugins-bad/sys/nvcodec/gstnvh264encoder.cpp @@ -1741,7 +1741,7 @@ gst_nv_h264_encoder_create_class_data (GstObject * device, gpointer session, system_caps = gst_caps_from_string (sink_caps_str.c_str ()); sink_caps = gst_caps_copy (system_caps); -#ifdef HAVE_NVCODEC_GST_D3D11 +#ifdef GST_CUDA_HAS_D3D if (d3d11_mode) { gst_caps_set_features (sink_caps, 0, gst_caps_features_new (GST_CAPS_FEATURE_MEMORY_D3D11_MEMORY, NULL)); @@ -1843,7 +1843,7 @@ gst_nv_h264_encoder_register_cuda (GstPlugin * plugin, GstCudaContext * context, g_free (feature_name); } -#ifdef HAVE_NVCODEC_GST_D3D11 +#ifdef GST_CUDA_HAS_D3D void gst_nv_h264_encoder_register_d3d11 (GstPlugin * plugin, GstD3D11Device * device, guint rank) diff --git a/subprojects/gst-plugins-bad/sys/nvcodec/gstnvh264encoder.h b/subprojects/gst-plugins-bad/sys/nvcodec/gstnvh264encoder.h index b46abde..77d4088 100644 --- a/subprojects/gst-plugins-bad/sys/nvcodec/gstnvh264encoder.h +++ b/subprojects/gst-plugins-bad/sys/nvcodec/gstnvh264encoder.h @@ -27,7 +27,7 @@ void gst_nv_h264_encoder_register_cuda (GstPlugin * plugin, GstCudaContext * context, guint rank); -#ifdef HAVE_NVCODEC_GST_D3D11 +#ifdef GST_CUDA_HAS_D3D void gst_nv_h264_encoder_register_d3d11 (GstPlugin * plugin, GstD3D11Device * device, guint rank); diff --git a/subprojects/gst-plugins-bad/sys/nvcodec/gstnvh265dec.c b/subprojects/gst-plugins-bad/sys/nvcodec/gstnvh265dec.c index 8bc60a6..d6c3d56 100644 --- a/subprojects/gst-plugins-bad/sys/nvcodec/gstnvh265dec.c +++ b/subprojects/gst-plugins-bad/sys/nvcodec/gstnvh265dec.c @@ -74,8 +74,8 @@ #include "config.h" #endif +#include #include "gstnvh265dec.h" -#include "gstcudautils.h" #include "gstnvdecoder.h" #include diff --git a/subprojects/gst-plugins-bad/sys/nvcodec/gstnvh265encoder.cpp b/subprojects/gst-plugins-bad/sys/nvcodec/gstnvh265encoder.cpp index d55a37d..865b377 100644 --- a/subprojects/gst-plugins-bad/sys/nvcodec/gstnvh265encoder.cpp +++ b/subprojects/gst-plugins-bad/sys/nvcodec/gstnvh265encoder.cpp @@ -1752,7 +1752,7 @@ gst_nv_h265_encoder_create_class_data (GstObject * device, gpointer session, system_caps = gst_caps_from_string (sink_caps_str.c_str ()); sink_caps = gst_caps_copy (system_caps); -#ifdef HAVE_NVCODEC_GST_D3D11 +#ifdef GST_CUDA_HAS_D3D if (d3d11_mode) { gst_caps_set_features (sink_caps, 0, gst_caps_features_new (GST_CAPS_FEATURE_MEMORY_D3D11_MEMORY, NULL)); @@ -1854,7 +1854,7 @@ gst_nv_h265_encoder_register_cuda (GstPlugin * plugin, GstCudaContext * context, g_free (feature_name); } -#ifdef HAVE_NVCODEC_GST_D3D11 +#ifdef GST_CUDA_HAS_D3D void gst_nv_h265_encoder_register_d3d11 (GstPlugin * plugin, GstD3D11Device * device, guint rank) diff --git a/subprojects/gst-plugins-bad/sys/nvcodec/gstnvh265encoder.h b/subprojects/gst-plugins-bad/sys/nvcodec/gstnvh265encoder.h index a29fc54..fb2771f 100644 --- a/subprojects/gst-plugins-bad/sys/nvcodec/gstnvh265encoder.h +++ b/subprojects/gst-plugins-bad/sys/nvcodec/gstnvh265encoder.h @@ -27,7 +27,7 @@ void gst_nv_h265_encoder_register_cuda (GstPlugin * plugin, GstCudaContext * context, guint rank); -#ifdef HAVE_NVCODEC_GST_D3D11 +#ifdef GST_CUDA_HAS_D3D void gst_nv_h265_encoder_register_d3d11 (GstPlugin * plugin, GstD3D11Device * device, guint rank); diff --git a/subprojects/gst-plugins-bad/sys/nvcodec/gstnvvp8dec.c b/subprojects/gst-plugins-bad/sys/nvcodec/gstnvvp8dec.c index 6f06045..2fb5443 100644 --- a/subprojects/gst-plugins-bad/sys/nvcodec/gstnvvp8dec.c +++ b/subprojects/gst-plugins-bad/sys/nvcodec/gstnvvp8dec.c @@ -21,8 +21,9 @@ #include "config.h" #endif +#include + #include "gstnvvp8dec.h" -#include "gstcudautils.h" #include "gstnvdecoder.h" #include diff --git a/subprojects/gst-plugins-bad/sys/nvcodec/gstnvvp9dec.c b/subprojects/gst-plugins-bad/sys/nvcodec/gstnvvp9dec.c index 4663691..6840ac0 100644 --- a/subprojects/gst-plugins-bad/sys/nvcodec/gstnvvp9dec.c +++ b/subprojects/gst-plugins-bad/sys/nvcodec/gstnvvp9dec.c @@ -21,8 +21,9 @@ #include "config.h" #endif +#include + #include "gstnvvp9dec.h" -#include "gstcudautils.h" #include "gstnvdecoder.h" #include diff --git a/subprojects/gst-plugins-bad/sys/nvcodec/meson.build b/subprojects/gst-plugins-bad/sys/nvcodec/meson.build index 39d06de..50e2978 100644 --- a/subprojects/gst-plugins-bad/sys/nvcodec/meson.build +++ b/subprojects/gst-plugins-bad/sys/nvcodec/meson.build @@ -4,20 +4,13 @@ nvcodec_sources = [ 'gstnvbaseenc.c', 'gstnvh264enc.c', 'gstnvh265enc.c', - 'gstcudaloader.c', 'gstnvdec.c', 'gstcuvidloader.c', - 'gstcudacontext.c', - 'gstcudautils.c', 'gstnvdecoder.c', 'gstnvh264dec.c', 'gstnvh265dec.c', - 'gstcudamemory.c', - 'gstcudabufferpool.c', 'gstcudabasetransform.c', 'gstcudamemorycopy.c', - 'gstcudanvrtc.c', - 'gstnvrtcloader.c', 'cuda-converter.c', 'gstcudafilter.c', 'gstcudabasefilter.c', @@ -38,7 +31,7 @@ if get_option('nvcodec').disabled() subdir_done() endif -plugin_incdirs = [configinc, include_directories('./stub')] +plugin_incdirs = [configinc, cuda_stubinc] extra_args = ['-DGST_USE_UNSTABLE_API'] if gstgl_dep.found() @@ -46,7 +39,7 @@ if gstgl_dep.found() endif if gstd3d11_dep.found() - extra_args += ['-DHAVE_NVCODEC_GST_D3D11=1', '-DCOBJMACROS'] + extra_args += ['-DGST_CUDA_HAS_D3D=1', '-DCOBJMACROS'] endif if host_system == 'linux' @@ -84,7 +77,7 @@ gstnvcodec = library('gstnvcodec', cpp_args : gst_plugins_bad_args + extra_args, override_options: override_opt, include_directories : plugin_incdirs, - dependencies : [gstbase_dep, gstvideo_dep, gstpbutils_dep, gstgl_dep, gstglproto_dep, gmodule_dep, gstcodecs_dep, gstd3d11_dep], + dependencies : [gstbase_dep, gstvideo_dep, gstpbutils_dep, gstgl_dep, gstglproto_dep, gmodule_dep, gstcodecs_dep, gstd3d11_dep, gstcuda_dep], install : true, install_dir : plugins_install_dir, ) diff --git a/subprojects/gst-plugins-bad/sys/nvcodec/plugin.c b/subprojects/gst-plugins-bad/sys/nvcodec/plugin.c index 2df7529..3d74c3f 100644 --- a/subprojects/gst-plugins-bad/sys/nvcodec/plugin.c +++ b/subprojects/gst-plugins-bad/sys/nvcodec/plugin.c @@ -38,12 +38,12 @@ #include "gstnvdecoder.h" #include "gstcudamemorycopy.h" #include "gstcudafilter.h" -#include "gstcudamemory.h" +#include #ifdef HAVE_NVCODEC_NVMM #include "gstcudanvmm.h" #endif -#ifdef HAVE_NVCODEC_GST_D3D11 +#ifdef GST_CUDA_HAS_D3D #include #endif #include "gstnvh264encoder.h" @@ -235,7 +235,7 @@ plugin_init (GstPlugin * plugin) } if (nvenc_available) { -#ifdef HAVE_NVCODEC_GST_D3D11 +#ifdef GST_CUDA_HAS_D3D if (g_win32_check_windows_version (6, 0, 0, G_WIN32_OS_ANY)) { gint64 adapter_luid; GstD3D11Device *d3d11_device; diff --git a/subprojects/gst-plugins-base/gst-libs/gst/gl/meson.build b/subprojects/gst-plugins-base/gst-libs/gst/gl/meson.build index 6acf5e3..66e2e4f 100644 --- a/subprojects/gst-plugins-base/gst-libs/gst/gl/meson.build +++ b/subprojects/gst-plugins-base/gst-libs/gst/gl/meson.build @@ -1109,7 +1109,10 @@ if build_gstgl include_directories : [libsinc, compat_includes], sources: gen_sources, dependencies : [video_dep, gst_base_dep]) - gstglproto_dep = declare_dependency(dependencies : [gstgl_dep] + gl_lib_deps) + gstglproto_dep = declare_dependency( + dependencies : [gstgl_dep] + gl_lib_deps, + sources: gen_sources + ) meson.override_dependency('gstreamer-gl-1.0', gstgl_dep) meson.override_dependency('gstreamer-gl-prototypes-1.0', gstglproto_dep) -- 2.7.4