mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-19 13:55:41 +00:00
glmemory: add wrapped data pointers to setup_buffer
Allows creating wrapped memories with GstGLAllocationParams. The wrapped pointers will be set in the parameters before being passed to the memory allocation function.
This commit is contained in:
parent
c9d9077a5f
commit
8ccf3dc589
5 changed files with 29 additions and 19 deletions
|
@ -291,7 +291,7 @@ gst_gl_buffer_pool_alloc (GstBufferPool * pool, GstBuffer ** buffer,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
alloc = GST_GL_MEMORY_ALLOCATOR (priv->allocator);
|
alloc = GST_GL_MEMORY_ALLOCATOR (priv->allocator);
|
||||||
if (!gst_gl_memory_setup_buffer (alloc, buf, priv->gl_params))
|
if (!gst_gl_memory_setup_buffer (alloc, buf, priv->gl_params, NULL, 0))
|
||||||
goto mem_create_failed;
|
goto mem_create_failed;
|
||||||
|
|
||||||
if (priv->add_glsyncmeta)
|
if (priv->add_glsyncmeta)
|
||||||
|
|
|
@ -1320,18 +1320,14 @@ gst_gl_video_allocation_params_copy_data (GstGLVideoAllocationParams * src_vid,
|
||||||
*/
|
*/
|
||||||
gboolean
|
gboolean
|
||||||
gst_gl_memory_setup_buffer (GstGLMemoryAllocator * allocator,
|
gst_gl_memory_setup_buffer (GstGLMemoryAllocator * allocator,
|
||||||
GstBuffer * buffer, GstGLVideoAllocationParams * params)
|
GstBuffer * buffer, GstGLVideoAllocationParams * params,
|
||||||
|
gpointer * wrapped_data, gsize n_wrapped_pointers)
|
||||||
{
|
{
|
||||||
GstGLBaseMemoryAllocator *base_allocator;
|
GstGLBaseMemoryAllocator *base_allocator;
|
||||||
guint n_mem, i, v, views;
|
guint n_mem, i, v, views;
|
||||||
guint alloc_flags = params->parent.alloc_flags;
|
guint alloc_flags = params->parent.alloc_flags;
|
||||||
|
|
||||||
g_return_val_if_fail (params != NULL, FALSE);
|
g_return_val_if_fail (params != NULL, FALSE);
|
||||||
g_return_val_if_fail ((alloc_flags &
|
|
||||||
GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_WRAP_SYSMEM)
|
|
||||||
== 0, FALSE);
|
|
||||||
g_return_val_if_fail ((params->parent.alloc_flags &
|
|
||||||
GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_WRAP_GPU_HANDLE) == 0, FALSE);
|
|
||||||
g_return_val_if_fail (alloc_flags & GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_VIDEO,
|
g_return_val_if_fail (alloc_flags & GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_VIDEO,
|
||||||
FALSE);
|
FALSE);
|
||||||
|
|
||||||
|
@ -1344,11 +1340,22 @@ gst_gl_memory_setup_buffer (GstGLMemoryAllocator * allocator,
|
||||||
else
|
else
|
||||||
views = 1;
|
views = 1;
|
||||||
|
|
||||||
|
g_return_val_if_fail (!wrapped_data
|
||||||
|
|| views * n_mem != n_wrapped_pointers, FALSE);
|
||||||
|
|
||||||
for (v = 0; v < views; v++) {
|
for (v = 0; v < views; v++) {
|
||||||
for (i = 0; i < n_mem; i++) {
|
for (i = 0; i < n_mem; i++) {
|
||||||
GstGLMemory *gl_mem;
|
GstGLMemory *gl_mem;
|
||||||
|
|
||||||
params->plane = i;
|
params->plane = i;
|
||||||
|
if (alloc_flags & GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_WRAP_SYSMEM) {
|
||||||
|
g_return_val_if_fail (wrapped_data != NULL, FALSE);
|
||||||
|
params->parent.wrapped_data = wrapped_data[i];
|
||||||
|
} else if (alloc_flags &
|
||||||
|
GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_WRAP_GPU_HANDLE) {
|
||||||
|
g_return_val_if_fail (wrapped_data != NULL, FALSE);
|
||||||
|
params->parent.gl_handle = wrapped_data[i];
|
||||||
|
}
|
||||||
|
|
||||||
if (!(gl_mem = (GstGLMemory *) gst_gl_base_memory_alloc (base_allocator,
|
if (!(gl_mem = (GstGLMemory *) gst_gl_base_memory_alloc (base_allocator,
|
||||||
(GstGLAllocationParams *) params)))
|
(GstGLAllocationParams *) params)))
|
||||||
|
|
|
@ -226,8 +226,9 @@ guint gst_gl_memory_get_texture_id (GstGLMemory * gl_me
|
||||||
|
|
||||||
gboolean gst_gl_memory_setup_buffer (GstGLMemoryAllocator * allocator,
|
gboolean gst_gl_memory_setup_buffer (GstGLMemoryAllocator * allocator,
|
||||||
GstBuffer * buffer,
|
GstBuffer * buffer,
|
||||||
GstGLVideoAllocationParams * params);
|
GstGLVideoAllocationParams * params,
|
||||||
|
gpointer *wrapped_data,
|
||||||
|
gsize n_wrapped_pointers);
|
||||||
|
|
||||||
GstGLMemoryAllocator * gst_gl_memory_allocator_get_default (GstGLContext *context);
|
GstGLMemoryAllocator * gst_gl_memory_allocator_get_default (GstGLContext *context);
|
||||||
|
|
||||||
|
|
|
@ -315,8 +315,8 @@ _gl_memory_upload_propose_allocation (gpointer impl, GstQuery * decide_query,
|
||||||
gst_allocation_params_init (¶ms);
|
gst_allocation_params_init (¶ms);
|
||||||
|
|
||||||
allocator =
|
allocator =
|
||||||
GST_ALLOCATOR (gst_gl_memory_allocator_get_default (upload->
|
GST_ALLOCATOR (gst_gl_memory_allocator_get_default (upload->upload->
|
||||||
upload->context));
|
context));
|
||||||
gst_query_add_allocation_param (query, allocator, ¶ms);
|
gst_query_add_allocation_param (query, allocator, ¶ms);
|
||||||
gst_object_unref (allocator);
|
gst_object_unref (allocator);
|
||||||
}
|
}
|
||||||
|
@ -585,7 +585,8 @@ _egl_image_upload_perform_gl_thread (GstGLContext * context,
|
||||||
*image->outbuf = gst_buffer_new ();
|
*image->outbuf = gst_buffer_new ();
|
||||||
gst_buffer_add_parent_buffer_meta (*image->outbuf, image->buffer);
|
gst_buffer_add_parent_buffer_meta (*image->outbuf, image->buffer);
|
||||||
|
|
||||||
gst_gl_memory_setup_buffer (allocator, *image->outbuf, image->params);
|
gst_gl_memory_setup_buffer (allocator, *image->outbuf, image->params, NULL,
|
||||||
|
0);
|
||||||
gst_object_unref (allocator);
|
gst_object_unref (allocator);
|
||||||
|
|
||||||
n = gst_buffer_n_memory (image->buffer);
|
n = gst_buffer_n_memory (image->buffer);
|
||||||
|
@ -856,7 +857,8 @@ _dma_buf_upload_perform_gl_thread (GstGLContext * context,
|
||||||
|
|
||||||
/* FIXME: buffer pool */
|
/* FIXME: buffer pool */
|
||||||
dmabuf->outbuf = gst_buffer_new ();
|
dmabuf->outbuf = gst_buffer_new ();
|
||||||
gst_gl_memory_setup_buffer (allocator, dmabuf->outbuf, dmabuf->params);
|
gst_gl_memory_setup_buffer (allocator, dmabuf->outbuf, dmabuf->params, NULL,
|
||||||
|
0);
|
||||||
gst_object_unref (allocator);
|
gst_object_unref (allocator);
|
||||||
|
|
||||||
n = gst_buffer_n_memory (dmabuf->outbuf);
|
n = gst_buffer_n_memory (dmabuf->outbuf);
|
||||||
|
@ -1042,11 +1044,11 @@ _upload_meta_upload_propose_allocation (gpointer impl, GstQuery * decide_query,
|
||||||
gpointer handle;
|
gpointer handle;
|
||||||
|
|
||||||
gl_apis =
|
gl_apis =
|
||||||
gst_gl_api_to_string (gst_gl_context_get_gl_api (upload->upload->
|
gst_gl_api_to_string (gst_gl_context_get_gl_api (upload->
|
||||||
context));
|
|
||||||
platform =
|
|
||||||
gst_gl_platform_to_string (gst_gl_context_get_gl_platform (upload->
|
|
||||||
upload->context));
|
upload->context));
|
||||||
|
platform =
|
||||||
|
gst_gl_platform_to_string (gst_gl_context_get_gl_platform
|
||||||
|
(upload->upload->context));
|
||||||
handle = (gpointer) gst_gl_context_get_gl_context (upload->upload->context);
|
handle = (gpointer) gst_gl_context_get_gl_context (upload->upload->context);
|
||||||
|
|
||||||
gl_context =
|
gl_context =
|
||||||
|
@ -1101,7 +1103,7 @@ _upload_meta_upload_perform (gpointer impl, GstBuffer * buffer,
|
||||||
|
|
||||||
/* FIXME: buffer pool */
|
/* FIXME: buffer pool */
|
||||||
*outbuf = gst_buffer_new ();
|
*outbuf = gst_buffer_new ();
|
||||||
gst_gl_memory_setup_buffer (allocator, *outbuf, upload->params);
|
gst_gl_memory_setup_buffer (allocator, *outbuf, upload->params, NULL, 0);
|
||||||
gst_object_unref (allocator);
|
gst_object_unref (allocator);
|
||||||
|
|
||||||
for (i = 0; i < GST_GL_UPLOAD_MAX_PLANES; i++) {
|
for (i = 0; i < GST_GL_UPLOAD_MAX_PLANES; i++) {
|
||||||
|
|
|
@ -1955,7 +1955,7 @@ _gen_buffer (GstGLViewConvert * viewconvert, GstBuffer ** target)
|
||||||
params = gst_gl_video_allocation_params_new (viewconvert->context, NULL,
|
params = gst_gl_video_allocation_params_new (viewconvert->context, NULL,
|
||||||
&viewconvert->out_info, 0, NULL, viewconvert->to_texture_target);
|
&viewconvert->out_info, 0, NULL, viewconvert->to_texture_target);
|
||||||
|
|
||||||
if (!gst_gl_memory_setup_buffer (mem_allocator, *target, params)) {
|
if (!gst_gl_memory_setup_buffer (mem_allocator, *target, params, NULL, 0)) {
|
||||||
gst_gl_allocation_params_free ((GstGLAllocationParams *) params);
|
gst_gl_allocation_params_free ((GstGLAllocationParams *) params);
|
||||||
gst_object_unref (allocator);
|
gst_object_unref (allocator);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
Loading…
Reference in a new issue