--- /dev/null
+# 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*
+
{'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()
-/* GStreamer
- * Copyright (C) 2019 Seungha Yang <seungha.yang@navercorp.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef __GST_CUDA_LOADER_H__
-#define __GST_CUDA_LOADER_H__
-
-#include "stub/cuda.h"
-
-#include <gst/gst.h>
+#pragma once
-G_BEGIN_DECLS
+#include "cuda-prelude.h"
+#include <nvrtc.h>
+#include <cuda.h>
+#include <cudaGL.h>
-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,
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__ */
--- /dev/null
+/* 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 <gst/gst.h>
+
+#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__ */
+
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)
{
#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 <gst/video/gstvideometa.h>
#include <gst/video/gstvideopool.h>
#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
{
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
#include "gstcudacontext.h"
#include "gstcudautils.h"
-#ifdef HAVE_NVCODEC_GST_D3D11
+#ifdef GST_CUDA_HAS_D3D
#include <gst/d3d11/gstd3d11.h>
#endif
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) ",
}
}
-#ifdef HAVE_NVCODEC_GST_D3D11
+#ifdef GST_CUDA_HAS_D3D
static gint64
gst_cuda_context_find_dxgi_adapter_luid (CUdevice cuda_device)
{
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
* 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)
* 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)
* 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)
*
* 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)
* @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)
#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 <gst/gst.h>
-#include <cuda.h>
+#include "cuda.h"
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
{
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);
#include "config.h"
#endif
+#include "cuda-gst.h"
#include "gstcudaloader.h"
#include <gmodule.h>
-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"
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;
LOAD_SYMBOL (cuGraphicsGLRegisterBuffer, CuGraphicsGLRegisterBuffer);
LOAD_SYMBOL (cuGLGetDevices, CuGLGetDevices);
-#ifdef HAVE_NVCODEC_GST_D3D11
+#ifdef GST_CUDA_HAS_D3D
/* cudaD3D11.h */
LOAD_SYMBOL (cuGraphicsD3D11RegisterResource,
CuGraphicsD3D11RegisterResource);
}
/* cudaD3D11.h */
+#ifdef GST_CUDA_HAS_D3D
CUresult CUDAAPI
CuGraphicsD3D11RegisterResource (CUgraphicsResource * pCudaResource,
gpointer pD3DResource, unsigned int Flags)
return gst_cuda_vtable.CuD3D11GetDevices (pCudaDeviceCount, pCudaDevices,
cudaDeviceCount, pD3D11Device, deviceList);
}
+#endif
--- /dev/null
+/* GStreamer
+ * Copyright (C) 2019 Seungha Yang <seungha.yang@navercorp.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#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 <gst/gst.h>
+
+G_BEGIN_DECLS
+
+GST_CUDA_API
+gboolean gst_cuda_load_library (void);
+
+G_END_DECLS
+#endif /* __GST_CUDA_LOADER_H__ */
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)
{
}
}
+/**
+ * gst_is_cuda_memory:
+ * @mem: A #GstMemory
+ *
+ * Check if @mem is a cuda memory
+ *
+ * Since: 1.22
+ */
gboolean
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)
#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 <gst/gst.h>
#include <gst/gstallocator.h>
#include <gst/video/video.h>
#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;
* 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"
* to the staging memory
* @GST_CUDA_MEMORY_TRANSFER_NEED_UPLOAD: the staging memory needs uploading
* to the device memory
+ *
+ * Since: 1.22
*/
typedef enum
{
GST_CUDA_MEMORY_TRANSFER_NEED_UPLOAD = (GST_MEMORY_FLAG_LAST << 1)
} GstCudaMemoryTransfer;
+/**
+ * GstCudaMemory:
+ *
+ * Since: 1.22
+ */
struct _GstCudaMemory
{
GstMemory mem;
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);
#include "config.h"
#endif
+#include "cuda-gst.h"
#include "gstcudanvrtc.h"
GST_DEBUG_CATEGORY_STATIC (gst_cuda_nvrtc_debug);
}
}
+/**
+ * gst_cuda_nvrtc_compile:
+ * @source: Source code to compile
+ *
+ * Since: 1.22
+ */
gchar *
gst_cuda_nvrtc_compile (const gchar * source)
{
#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 <gst/gst.h>
#include "gstcudaloader.h"
#include "gstnvrtcloader.h"
G_BEGIN_DECLS
+GST_CUDA_API
gchar * gst_cuda_nvrtc_compile (const gchar * source);
G_END_DECLS
#include <gst/gl/gstglfuncs.h>
#endif
-#ifdef HAVE_NVCODEC_GST_D3D11
+#ifdef GST_CUDA_HAS_D3D
#include <gst/d3d11/gstd3d11.h>
#endif
* 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,
* 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,
*
* Returns: Whether the @query was successfully responded to from the passed
* @context.
+ *
+ * Since: 1.22
*/
gboolean
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)
* @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)
*
* Returns: a new #GstCudaGraphicsResource.
* Free with gst_cuda_graphics_resource_free
+ *
+ * Since: 1.22
*/
GstCudaGraphicsResource *
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 *
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 *
return TRUE;
}
+#endif
/**
* gst_cuda_graphics_resource_unregister: (skip)
* 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)
/**
* 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,
/**
* 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,
}
#endif
-#ifdef HAVE_NVCODEC_GST_D3D11
+#ifdef GST_CUDA_HAS_D3D
static void
unregister_d3d11_resource (GstCudaGraphicsResource * resource)
{
* @resource: a #GstCudaGraphicsResource
*
* Free @resource
+ *
+ * Since: 1.22
*/
void
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
}
#endif
-#ifdef HAVE_NVCODEC_GST_D3D11
+#ifdef GST_CUDA_HAS_D3D
static gboolean
ensure_d3d11_interop (GstCudaContext * context, GstD3D11Device * device)
{
{
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;
}
#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)) {
#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 <gst/gst.h>
#include <gst/video/video.h>
+#include "cuda-gst.h"
#include "gstcudaloader.h"
#include "gstcudacontext.h"
+#include "gstcudamemory.h"
G_BEGIN_DECLS
/**
* 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
*/
/**
* 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,
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,
GST_CUDA_GRAPHICS_RESOURCE_D3D11_RESOURCE = 2,
} GstCudaGraphicsResourceType;
+/**
+ * GstCudaGraphicsResource:
+ *
+ * Since: 1.22
+ */
typedef struct _GstCudaGraphicsResource
{
GstCudaContext *cuda_context;
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,
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,
#include "config.h"
#endif
+#include "cuda-gst.h"
#include "gstnvrtcloader.h"
#include "gstcudaloader.h"
#include <gmodule.h>
-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"
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)
{
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");
#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 <gst/gst.h>
#include <nvrtc.h>
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__ */
--- /dev/null
+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)
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,
#define cuMemcpy2D cuMemcpy2D_v2
#define cuMemcpy2DAsync cuMemcpy2DAsync_v2
#define cuMemFree cuMemFree_v2
-#define cuGLGetDevices cuGLGetDevices_v2
#define CU_TRSF_READ_AS_INTEGER 1
--- /dev/null
+#ifndef __GST_CUDA_GLSTUB_H__
+#define __GST_CUDA_GLSTUB_H__
+
+#include <glib.h>
+
+G_BEGIN_DECLS
+typedef enum
+{
+ CU_GL_DEVICE_LIST_ALL = 0x01,
+} CUGLDeviceList;
+
+#define cuGLGetDevices cuGLGetDevices_v2
+
+G_END_DECLS
+
+#endif /* __GST_CUDA_GLSTUB_H__ */
subdir('codecparsers')
subdir('codecs')
subdir('d3d11')
+# cuda can depend on d3d11
+subdir('cuda')
subdir('insertbin')
subdir('interfaces')
subdir('isoff')
#endif
#include "cuda-converter.h"
-#include "gstcudautils.h"
-#include "gstcudaloader.h"
-#include "gstcudanvrtc.h"
+#include <gst/cuda/gstcudautils.h>
+#include <gst/cuda/gstcudaloader.h>
+#include <gst/cuda/gstcudanvrtc.h>
#include <string.h>
#define CUDA_BLOCK_X 16
#define __GST_CUDA_CONVERTER_H__
#include <gst/video/video.h>
-#include "gstcudacontext.h"
-#include "gstcudamemory.h"
+#include <gst/cuda/gstcudacontext.h>
+#include <gst/cuda/gstcudamemory.h>
G_BEGIN_DECLS
#endif
#include "gstcudabasefilter.h"
-#include "gstcudautils.h"
#include "gstcudaformat.h"
+#include <gst/cuda/gstcudautils.h>
+
#include <string.h>
GST_DEBUG_CATEGORY_STATIC (gst_cuda_base_filter_debug);
# include <config.h>
#endif
+#include <gst/cuda/gstcudautils.h>
+
#include "gstcudabasetransform.h"
-#include "gstcudautils.h"
GST_DEBUG_CATEGORY_STATIC (gst_cuda_base_transform_debug);
#define GST_CAT_DEFAULT gst_cuda_base_transform_debug
#include <gst/gst.h>
#include <gst/base/gstbasetransform.h>
#include <gst/video/video.h>
-#include "gstcudacontext.h"
-#include "gstcudabufferpool.h"
+#include <gst/cuda/gstcudacontext.h>
+#include <gst/cuda/gstcudabufferpool.h>
G_BEGIN_DECLS
# include <config.h>
#endif
+#include <gst/cuda/gstcudautils.h>
+
#include "gstcudaconvert.h"
-#include "gstcudautils.h"
GST_DEBUG_CATEGORY_STATIC (gst_cuda_convert_debug);
#define GST_CAT_DEFAULT gst_cuda_convert_debug
#include "config.h"
#endif
+#include <gst/cuda/gstcudaloader.h>
+#include <gst/cuda/gstnvrtcloader.h>
+#include <gst/cuda/gstcudanvrtc.h>
+
#include "gstcudafilter.h"
-#include "gstcudaloader.h"
-#include "gstnvrtcloader.h"
-#include "gstcudanvrtc.h"
#include "gstcudaconvert.h"
#include "gstcudascale.h"
#include "gstcudabasetransform.h"
#include "gstcudamemorycopy.h"
#include "gstcudaformat.h"
-#include "gstcudautils.h"
+#include <gst/cuda/gstcudautils.h>
#ifdef HAVE_NVCODEC_NVMM
#include "gstcudanvmm.h"
#endif
#ifdef HAVE_NVCODEC_GST_GL
#include <gst/gl/gl.h>
#endif
-#ifdef HAVE_NVCODEC_GST_D3D11
+#ifdef GST_CUDA_HAS_D3D
#include <gst/d3d11/gstd3d11.h>
#endif
GstGLContext *gl_context;
GstGLContext *other_gl_context;
#endif
-#ifdef HAVE_NVCODEC_GST_D3D11
+#ifdef GST_CUDA_HAS_D3D
GstD3D11Device *d3d11_device;
#endif
};
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
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
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
}
#endif
-#ifdef HAVE_NVCODEC_GST_D3D11
+#ifdef GST_CUDA_HAS_D3D
static gboolean
gst_cuda_memory_copy_ensure_d3d11_interop (GstCudaContext * context,
GstD3D11Device * device)
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)) {
#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
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)) {
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);
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)) {
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)
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
} 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) {
} 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) {
#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;
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));
#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
#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
# include <config.h>
#endif
+#include <gst/cuda/gstcudautils.h>
+
#include "gstcudascale.h"
-#include "gstcudautils.h"
GST_DEBUG_CATEGORY_STATIC (gst_cuda_scale_debug);
#define GST_CAT_DEFAULT gst_cuda_scale_debug
#define __GST_CUVID_LOADER_H__
#include <gst/gst.h>
-#include "stub/cuda.h"
+#include "cuda.h"
#include "nvcuvid.h"
G_BEGIN_DECLS
#endif
#include "gstnvbaseenc.h"
-#include "gstcudautils.h"
-#include "gstcudabufferpool.h"
+#include <gst/cuda/gstcudautils.h>
+#include <gst/cuda/gstcudabufferpool.h>
#include <gst/pbutils/codec-utils.h>
#include "gstnvenc.h"
#include <gst/video/gstvideoencoder.h>
-#include "gstcudacontext.h"
+#include <gst/cuda/gstcudacontext.h>
#define GST_TYPE_NV_BASE_ENC \
(gst_nv_base_enc_get_type())
#include "config.h"
#endif
+#include <gst/cuda/gstcudautils.h>
+#include <gst/cuda/gstcudabufferpool.h>
+
+#include "gstcuvidloader.h"
#include "gstnvdec.h"
-#include "gstcudautils.h"
-#include "gstcudabufferpool.h"
#include <string.h>
#include <gst/gl/gstglfuncs.h>
#endif
+#include "nvcuvid.h"
#include <gst/video/video.h>
#include <gst/codecparsers/gsth264parser.h>
#include <gst/codecparsers/gsth265parser.h>
-#include "gstcuvidloader.h"
-#include "gstcudaloader.h"
-#include "gstcudacontext.h"
+#include <gst/cuda/gstcudaloader.h>
+#include <gst/cuda/gstcudacontext.h>
G_BEGIN_DECLS
#include <gst/gl/gstglfuncs.h>
#endif
-#include "gstcudamemory.h"
+#include <gst/cuda/gstcudamemory.h>
+#include <gst/cuda/gstcudabufferpool.h>
#include "gstnvdecoder.h"
-#include "gstcudabufferpool.h"
#include <string.h>
GST_DEBUG_CATEGORY_EXTERN (gst_nv_decoder_debug);
#include <gst/gst.h>
#include <gst/video/video.h>
-#include "gstcudautils.h"
+#include <gst/cuda/gstcudautils.h>
#include "gstcuvidloader.h"
G_BEGIN_DECLS
#include "gstnvenc.h"
#include "gstnvh264enc.h"
#include "gstnvh265enc.h"
-#include "gstcudabufferpool.h"
+#include <gst/cuda/gstcudautils.h>
+#include <gst/cuda/gstcudabufferpool.h>
#include <gmodule.h>
#include <gst/gst.h>
#include <gst/video/video.h>
+#include <gst/cuda/gstcudaloader.h>
-#include "gstcudaloader.h"
#include "nvEncodeAPI.h"
G_BEGIN_DECLS
#endif
#include "gstnvencoder.h"
-#include "gstcudautils.h"
-#include "gstcudamemory.h"
-#include "gstcudabufferpool.h"
+
+#include <gst/cuda/gstcudautils.h>
+#include <gst/cuda/gstcudamemory.h>
+#include <gst/cuda/gstcudabufferpool.h>
#include <string.h>
-#ifdef HAVE_NVCODEC_GST_D3D11
+#ifdef GST_CUDA_HAS_D3D
#include <gst/d3d11/gstd3d11.h>
#endif
struct _GstNvEncoderPrivate
{
GstCudaContext *context;
-#ifdef HAVE_NVCODEC_GST_D3D11
+#ifdef GST_CUDA_HAS_D3D
GstD3D11Device *device;
#endif
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);
{
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;
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) {
return TRUE;
}
-#ifdef HAVE_NVCODEC_GST_D3D11
+#ifdef GST_CUDA_HAS_D3D
static gboolean
gst_nv_encoder_open_d3d11_device (GstNvEncoder * self)
{
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);
}
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
{
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);
}
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");
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);
return TRUE;
}
-#ifdef HAVE_NVCODEC_GST_D3D11
+#ifdef GST_CUDA_HAS_D3D
static GstBufferPool *
gst_nv_encoder_create_d3d11_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
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)
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,
#include <gst/gst.h>
#include <gst/video/video.h>
-#ifdef HAVE_NVCODEC_GST_D3D11
+#ifdef GST_CUDA_HAS_D3D
#include <gst/d3d11/gstd3d11.h>
#endif
#include "nvEncodeAPI.h"
#include "gstnvenc.h"
-#include "gstcudamemory.h"
+#include <gst/cuda/gstcudamemory.h>
G_BEGIN_DECLS
#include "config.h"
#endif
+#include <gst/cuda/gstcudautils.h>
+
#include "gstnvh264dec.h"
-#include "gstcudautils.h"
#include "gstnvdecoder.h"
#include <string.h>
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));
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)
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);
#include "config.h"
#endif
+#include <gst/cuda/gstcudautils.h>
#include "gstnvh265dec.h"
-#include "gstcudautils.h"
#include "gstnvdecoder.h"
#include <string.h>
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));
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)
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);
#include "config.h"
#endif
+#include <gst/cuda/gstcudautils.h>
+
#include "gstnvvp8dec.h"
-#include "gstcudautils.h"
#include "gstnvdecoder.h"
#include <string.h>
#include "config.h"
#endif
+#include <gst/cuda/gstcudautils.h>
+
#include "gstnvvp9dec.h"
-#include "gstcudautils.h"
#include "gstnvdecoder.h"
#include <string.h>
'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',
subdir_done()
endif
-plugin_incdirs = [configinc, include_directories('./stub')]
+plugin_incdirs = [configinc, cuda_stubinc]
extra_args = ['-DGST_USE_UNSTABLE_API']
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'
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,
)
#include "gstnvdecoder.h"
#include "gstcudamemorycopy.h"
#include "gstcudafilter.h"
-#include "gstcudamemory.h"
+#include <gst/cuda/gstcudamemory.h>
#ifdef HAVE_NVCODEC_NVMM
#include "gstcudanvmm.h"
#endif
-#ifdef HAVE_NVCODEC_GST_D3D11
+#ifdef GST_CUDA_HAS_D3D
#include <gst/d3d11/gstd3d11.h>
#endif
#include "gstnvh264encoder.h"
}
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;
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)