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:
Matthew Waters 2016-05-04 01:16:51 +10:00
parent c9d9077a5f
commit 8ccf3dc589
5 changed files with 29 additions and 19 deletions

View file

@ -291,7 +291,7 @@ gst_gl_buffer_pool_alloc (GstBufferPool * pool, GstBuffer ** buffer,
#endif
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;
if (priv->add_glsyncmeta)

View file

@ -1320,18 +1320,14 @@ gst_gl_video_allocation_params_copy_data (GstGLVideoAllocationParams * src_vid,
*/
gboolean
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;
guint n_mem, i, v, views;
guint alloc_flags = params->parent.alloc_flags;
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,
FALSE);
@ -1344,11 +1340,22 @@ gst_gl_memory_setup_buffer (GstGLMemoryAllocator * allocator,
else
views = 1;
g_return_val_if_fail (!wrapped_data
|| views * n_mem != n_wrapped_pointers, FALSE);
for (v = 0; v < views; v++) {
for (i = 0; i < n_mem; i++) {
GstGLMemory *gl_mem;
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,
(GstGLAllocationParams *) params)))

View file

@ -226,8 +226,9 @@ guint gst_gl_memory_get_texture_id (GstGLMemory * gl_me
gboolean gst_gl_memory_setup_buffer (GstGLMemoryAllocator * allocator,
GstBuffer * buffer,
GstGLVideoAllocationParams * params);
GstGLVideoAllocationParams * params,
gpointer *wrapped_data,
gsize n_wrapped_pointers);
GstGLMemoryAllocator * gst_gl_memory_allocator_get_default (GstGLContext *context);

View file

@ -315,8 +315,8 @@ _gl_memory_upload_propose_allocation (gpointer impl, GstQuery * decide_query,
gst_allocation_params_init (&params);
allocator =
GST_ALLOCATOR (gst_gl_memory_allocator_get_default (upload->
upload->context));
GST_ALLOCATOR (gst_gl_memory_allocator_get_default (upload->upload->
context));
gst_query_add_allocation_param (query, allocator, &params);
gst_object_unref (allocator);
}
@ -585,7 +585,8 @@ _egl_image_upload_perform_gl_thread (GstGLContext * context,
*image->outbuf = gst_buffer_new ();
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);
n = gst_buffer_n_memory (image->buffer);
@ -856,7 +857,8 @@ _dma_buf_upload_perform_gl_thread (GstGLContext * context,
/* FIXME: buffer pool */
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);
n = gst_buffer_n_memory (dmabuf->outbuf);
@ -1042,11 +1044,11 @@ _upload_meta_upload_propose_allocation (gpointer impl, GstQuery * decide_query,
gpointer handle;
gl_apis =
gst_gl_api_to_string (gst_gl_context_get_gl_api (upload->upload->
context));
platform =
gst_gl_platform_to_string (gst_gl_context_get_gl_platform (upload->
gst_gl_api_to_string (gst_gl_context_get_gl_api (upload->
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);
gl_context =
@ -1101,7 +1103,7 @@ _upload_meta_upload_perform (gpointer impl, GstBuffer * buffer,
/* FIXME: buffer pool */
*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);
for (i = 0; i < GST_GL_UPLOAD_MAX_PLANES; i++) {

View file

@ -1955,7 +1955,7 @@ _gen_buffer (GstGLViewConvert * viewconvert, GstBuffer ** target)
params = gst_gl_video_allocation_params_new (viewconvert->context, NULL,
&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_object_unref (allocator);
return FALSE;