mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 06:54:49 +00:00
cudamemory: Allow nullptr allocator object
The GstCudaAllocator object doesn't hold any device object. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3629>
This commit is contained in:
parent
0a81c8deb3
commit
9eaae61a44
3 changed files with 14 additions and 14 deletions
|
@ -30,7 +30,6 @@ GST_DEBUG_CATEGORY_STATIC (gst_cuda_buffer_pool_debug);
|
||||||
|
|
||||||
struct _GstCudaBufferPoolPrivate
|
struct _GstCudaBufferPoolPrivate
|
||||||
{
|
{
|
||||||
GstCudaAllocator *allocator;
|
|
||||||
GstVideoInfo info;
|
GstVideoInfo info;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -74,15 +73,7 @@ gst_cuda_buffer_pool_set_config (GstBufferPool * pool, GstStructure * config)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_clear_object (&priv->allocator);
|
mem = gst_cuda_allocator_alloc (NULL, self->context, &info);
|
||||||
priv->allocator = (GstCudaAllocator *)
|
|
||||||
gst_allocator_find (GST_CUDA_MEMORY_TYPE_NAME);
|
|
||||||
if (!priv->allocator) {
|
|
||||||
GST_WARNING_OBJECT (self, "CudaAllocator is unavailable");
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
mem = gst_cuda_allocator_alloc (priv->allocator, self->context, &info);
|
|
||||||
if (!mem) {
|
if (!mem) {
|
||||||
GST_WARNING_OBJECT (self, "Failed to allocate memory");
|
GST_WARNING_OBJECT (self, "Failed to allocate memory");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -111,7 +102,7 @@ gst_cuda_buffer_pool_alloc (GstBufferPool * pool, GstBuffer ** buffer,
|
||||||
GstMemory *mem;
|
GstMemory *mem;
|
||||||
GstCudaMemory *cmem;
|
GstCudaMemory *cmem;
|
||||||
|
|
||||||
mem = gst_cuda_allocator_alloc (priv->allocator, self->context, &priv->info);
|
mem = gst_cuda_allocator_alloc (NULL, self->context, &priv->info);
|
||||||
if (!mem) {
|
if (!mem) {
|
||||||
GST_WARNING_OBJECT (pool, "Cannot create CUDA memory");
|
GST_WARNING_OBJECT (pool, "Cannot create CUDA memory");
|
||||||
return GST_FLOW_ERROR;
|
return GST_FLOW_ERROR;
|
||||||
|
@ -161,9 +152,7 @@ static void
|
||||||
gst_cuda_buffer_pool_dispose (GObject * object)
|
gst_cuda_buffer_pool_dispose (GObject * object)
|
||||||
{
|
{
|
||||||
GstCudaBufferPool *self = GST_CUDA_BUFFER_POOL_CAST (object);
|
GstCudaBufferPool *self = GST_CUDA_BUFFER_POOL_CAST (object);
|
||||||
GstCudaBufferPoolPrivate *priv = self->priv;
|
|
||||||
|
|
||||||
gst_clear_object (&priv->allocator);
|
|
||||||
gst_clear_object (&self->context);
|
gst_clear_object (&self->context);
|
||||||
|
|
||||||
G_OBJECT_CLASS (parent_class)->dispose (object);
|
G_OBJECT_CLASS (parent_class)->dispose (object);
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
#include "gstcudaloader.h"
|
#include "gstcudaloader.h"
|
||||||
#include "gstcudacontext.h"
|
#include "gstcudacontext.h"
|
||||||
#include "gstcudautils.h"
|
#include "gstcudautils.h"
|
||||||
|
#include "gstcudamemory.h"
|
||||||
|
|
||||||
#ifdef GST_CUDA_HAS_D3D
|
#ifdef GST_CUDA_HAS_D3D
|
||||||
#include <gst/d3d11/gstd3d11.h>
|
#include <gst/d3d11/gstd3d11.h>
|
||||||
|
@ -99,6 +100,8 @@ gst_cuda_context_class_init (GstCudaContextClass * klass)
|
||||||
GST_PARAM_CONDITIONALLY_AVAILABLE | G_PARAM_READABLE |
|
GST_PARAM_CONDITIONALLY_AVAILABLE | G_PARAM_READABLE |
|
||||||
G_PARAM_STATIC_STRINGS));
|
G_PARAM_STATIC_STRINGS));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
gst_cuda_memory_init_once ();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -462,6 +462,7 @@ gst_cuda_memory_init_once (void)
|
||||||
_gst_cuda_allocator =
|
_gst_cuda_allocator =
|
||||||
(GstAllocator *) g_object_new (GST_TYPE_CUDA_ALLOCATOR, NULL);
|
(GstAllocator *) g_object_new (GST_TYPE_CUDA_ALLOCATOR, NULL);
|
||||||
gst_object_ref_sink (_gst_cuda_allocator);
|
gst_object_ref_sink (_gst_cuda_allocator);
|
||||||
|
gst_object_ref (_gst_cuda_allocator);
|
||||||
|
|
||||||
gst_allocator_register (GST_CUDA_MEMORY_TYPE_NAME, _gst_cuda_allocator);
|
gst_allocator_register (GST_CUDA_MEMORY_TYPE_NAME, _gst_cuda_allocator);
|
||||||
g_once_init_leave (&_init, 1);
|
g_once_init_leave (&_init, 1);
|
||||||
|
@ -485,6 +486,11 @@ gst_is_cuda_memory (GstMemory * mem)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gst_cuda_allocator_alloc:
|
* gst_cuda_allocator_alloc:
|
||||||
|
* @allocator: (transfer none) (allow-none): a #GstCudaAllocator
|
||||||
|
* @context: (transfer none): a #GstCudaContext
|
||||||
|
* @info: a #GstVideoInfo
|
||||||
|
*
|
||||||
|
* Returns: (transfer full) (nullable): a newly allocated #GstCudaMemory
|
||||||
*
|
*
|
||||||
* Since: 1.22
|
* Since: 1.22
|
||||||
*/
|
*/
|
||||||
|
@ -494,10 +500,12 @@ gst_cuda_allocator_alloc (GstCudaAllocator * allocator,
|
||||||
{
|
{
|
||||||
guint alloc_height;
|
guint alloc_height;
|
||||||
|
|
||||||
g_return_val_if_fail (GST_IS_CUDA_ALLOCATOR (allocator), NULL);
|
|
||||||
g_return_val_if_fail (GST_IS_CUDA_CONTEXT (context), NULL);
|
g_return_val_if_fail (GST_IS_CUDA_CONTEXT (context), NULL);
|
||||||
g_return_val_if_fail (info != NULL, NULL);
|
g_return_val_if_fail (info != NULL, NULL);
|
||||||
|
|
||||||
|
if (!allocator)
|
||||||
|
allocator = (GstCudaAllocator *) _gst_cuda_allocator;
|
||||||
|
|
||||||
alloc_height = GST_VIDEO_INFO_HEIGHT (info);
|
alloc_height = GST_VIDEO_INFO_HEIGHT (info);
|
||||||
|
|
||||||
/* make sure valid height for subsampled formats */
|
/* make sure valid height for subsampled formats */
|
||||||
|
|
Loading…
Reference in a new issue