mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-04 15:36:35 +00:00
glbasememory: take a pointer as the wrapped gpu handle
Allows passing arbitrary data to wrap the the specific memory implementation which is required for some memory implementations.
This commit is contained in:
parent
5228238715
commit
c9d9077a5f
6 changed files with 65 additions and 23 deletions
|
@ -1184,6 +1184,7 @@ gst_gl_video_allocation_params_free_data
|
||||||
gst_gl_video_allocation_params_init_full
|
gst_gl_video_allocation_params_init_full
|
||||||
gst_gl_video_allocation_params_new
|
gst_gl_video_allocation_params_new
|
||||||
gst_gl_video_allocation_params_new_wrapped_data
|
gst_gl_video_allocation_params_new_wrapped_data
|
||||||
|
gst_gl_video_allocation_params_new_wrapped_gl_handle
|
||||||
gst_gl_video_allocation_params_new_wrapped_texture
|
gst_gl_video_allocation_params_new_wrapped_texture
|
||||||
GstGLMemoryAllocator
|
GstGLMemoryAllocator
|
||||||
GstGLMemoryAllocatorClass
|
GstGLMemoryAllocatorClass
|
||||||
|
|
|
@ -606,7 +606,7 @@ gst_gl_allocation_params_init (GstGLAllocationParams * params,
|
||||||
gsize struct_size, guint alloc_flags, GstGLAllocationParamsCopyFunc copy,
|
gsize struct_size, guint alloc_flags, GstGLAllocationParamsCopyFunc copy,
|
||||||
GstGLAllocationParamsFreeFunc free, GstGLContext * context,
|
GstGLAllocationParamsFreeFunc free, GstGLContext * context,
|
||||||
gsize alloc_size, GstAllocationParams * alloc_params,
|
gsize alloc_size, GstAllocationParams * alloc_params,
|
||||||
gpointer wrapped_data, guint gl_handle, gpointer user_data,
|
gpointer wrapped_data, gpointer gl_handle, gpointer user_data,
|
||||||
GDestroyNotify notify)
|
GDestroyNotify notify)
|
||||||
{
|
{
|
||||||
memset (params, 0, sizeof (*params));
|
memset (params, 0, sizeof (*params));
|
||||||
|
|
|
@ -173,7 +173,7 @@ struct _GstGLAllocationParams
|
||||||
/* GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_WRAP_SYSMEM only */
|
/* GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_WRAP_SYSMEM only */
|
||||||
gpointer wrapped_data;
|
gpointer wrapped_data;
|
||||||
/* GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_WRAP_GPU_HANDLE only */
|
/* GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_WRAP_GPU_HANDLE only */
|
||||||
guint gl_handle;
|
gpointer gl_handle;
|
||||||
};
|
};
|
||||||
|
|
||||||
gboolean gst_gl_allocation_params_init (GstGLAllocationParams * params,
|
gboolean gst_gl_allocation_params_init (GstGLAllocationParams * params,
|
||||||
|
@ -185,7 +185,7 @@ gboolean gst_gl_allocation_params_init (GstGLAllocationPara
|
||||||
gsize alloc_size,
|
gsize alloc_size,
|
||||||
GstAllocationParams * alloc_params,
|
GstAllocationParams * alloc_params,
|
||||||
gpointer wrapped_data,
|
gpointer wrapped_data,
|
||||||
guint gl_handle,
|
gpointer gl_handle,
|
||||||
gpointer user_data,
|
gpointer user_data,
|
||||||
GDestroyNotify notify);
|
GDestroyNotify notify);
|
||||||
|
|
||||||
|
|
|
@ -821,7 +821,7 @@ _default_gl_tex_alloc (GstGLMemoryAllocator * allocator,
|
||||||
mem = g_new0 (GstGLMemory, 1);
|
mem = g_new0 (GstGLMemory, 1);
|
||||||
|
|
||||||
if (alloc_flags & GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_WRAP_GPU_HANDLE) {
|
if (alloc_flags & GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_WRAP_GPU_HANDLE) {
|
||||||
mem->tex_id = params->parent.gl_handle;
|
mem->tex_id = GPOINTER_TO_UINT (params->parent.gl_handle);
|
||||||
mem->texture_wrapped = TRUE;
|
mem->texture_wrapped = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1080,7 +1080,7 @@ gst_gl_video_allocation_params_init_full (GstGLVideoAllocationParams * params,
|
||||||
GstGLAllocationParamsFreeFunc free, GstGLContext * context,
|
GstGLAllocationParamsFreeFunc free, GstGLContext * context,
|
||||||
GstAllocationParams * alloc_params, GstVideoInfo * v_info,
|
GstAllocationParams * alloc_params, GstVideoInfo * v_info,
|
||||||
guint plane, GstVideoAlignment * valign, GstGLTextureTarget target,
|
guint plane, GstVideoAlignment * valign, GstGLTextureTarget target,
|
||||||
gpointer wrapped_data, guint gl_handle, gpointer user_data,
|
gpointer wrapped_data, gpointer gl_handle, gpointer user_data,
|
||||||
GDestroyNotify notify)
|
GDestroyNotify notify)
|
||||||
{
|
{
|
||||||
guint i;
|
guint i;
|
||||||
|
@ -1187,6 +1187,50 @@ gst_gl_video_allocation_params_new_wrapped_data (GstGLContext * context,
|
||||||
return params;
|
return params;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gst_gl_video_allocation_params_new_wrapped_gl_handle:
|
||||||
|
* @context: a #GstGLContext
|
||||||
|
* @alloc_params: (allow-none): the #GstAllocationParams for @tex_id
|
||||||
|
* @v_info: the #GstVideoInfo for @tex_id
|
||||||
|
* @plane: the video plane @tex_id represents
|
||||||
|
* @valign: (allow-none): any #GstVideoAlignment applied to symem mappings of @tex_id
|
||||||
|
* @target: the #GstGLTextureTarget for @tex_id
|
||||||
|
* @gl_handle: the GL handle to wrap
|
||||||
|
* @user_data: (allow-none): user data to call @notify with
|
||||||
|
* @notify: (allow-none): a #GDestroyNotify
|
||||||
|
*
|
||||||
|
* @gl_handle is defined by the specific OpenGL handle being wrapped
|
||||||
|
* For #GstGLMemory and #GstGLMemoryPBO it is an OpenGL texture id.
|
||||||
|
* Other memory types may define it to require a different type of parameter.
|
||||||
|
*
|
||||||
|
* Returns: a new #GstGLVideoAllocationParams for wrapping @gl_handle
|
||||||
|
*
|
||||||
|
* Since: 1.8
|
||||||
|
*/
|
||||||
|
GstGLVideoAllocationParams *
|
||||||
|
gst_gl_video_allocation_params_new_wrapped_gl_handle (GstGLContext * context,
|
||||||
|
GstAllocationParams * alloc_params, GstVideoInfo * v_info, guint plane,
|
||||||
|
GstVideoAlignment * valign, GstGLTextureTarget target,
|
||||||
|
gpointer gl_handle, gpointer user_data, GDestroyNotify notify)
|
||||||
|
{
|
||||||
|
GstGLVideoAllocationParams *params = g_new0 (GstGLVideoAllocationParams, 1);
|
||||||
|
|
||||||
|
if (!gst_gl_video_allocation_params_init_full (params,
|
||||||
|
sizeof (GstGLVideoAllocationParams),
|
||||||
|
GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_WRAP_GPU_HANDLE |
|
||||||
|
GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_VIDEO,
|
||||||
|
(GstGLAllocationParamsCopyFunc)
|
||||||
|
gst_gl_video_allocation_params_copy_data,
|
||||||
|
(GstGLAllocationParamsFreeFunc)
|
||||||
|
gst_gl_video_allocation_params_free_data, context, alloc_params,
|
||||||
|
v_info, plane, valign, target, NULL, gl_handle, user_data, notify)) {
|
||||||
|
g_free (params);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gst_gl_video_allocation_params_new_wrapped_texture:
|
* gst_gl_video_allocation_params_new_wrapped_texture:
|
||||||
* @context: a #GstGLContext
|
* @context: a #GstGLContext
|
||||||
|
@ -1209,22 +1253,9 @@ gst_gl_video_allocation_params_new_wrapped_texture (GstGLContext * context,
|
||||||
GstVideoAlignment * valign, GstGLTextureTarget target,
|
GstVideoAlignment * valign, GstGLTextureTarget target,
|
||||||
guint tex_id, gpointer user_data, GDestroyNotify notify)
|
guint tex_id, gpointer user_data, GDestroyNotify notify)
|
||||||
{
|
{
|
||||||
GstGLVideoAllocationParams *params = g_new0 (GstGLVideoAllocationParams, 1);
|
return gst_gl_video_allocation_params_new_wrapped_gl_handle (context,
|
||||||
|
alloc_params, v_info, plane, valign, target, GUINT_TO_POINTER (tex_id),
|
||||||
if (!gst_gl_video_allocation_params_init_full (params,
|
user_data, notify);
|
||||||
sizeof (GstGLVideoAllocationParams),
|
|
||||||
GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_WRAP_GPU_HANDLE |
|
|
||||||
GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_VIDEO,
|
|
||||||
(GstGLAllocationParamsCopyFunc)
|
|
||||||
gst_gl_video_allocation_params_copy_data,
|
|
||||||
(GstGLAllocationParamsFreeFunc)
|
|
||||||
gst_gl_video_allocation_params_free_data, context, alloc_params,
|
|
||||||
v_info, plane, valign, target, NULL, tex_id, user_data, notify)) {
|
|
||||||
g_free (params);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return params;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -106,7 +106,7 @@ gboolean gst_gl_video_allocation_params_init_full (GstGLVideoAlloc
|
||||||
GstVideoAlignment * valign,
|
GstVideoAlignment * valign,
|
||||||
GstGLTextureTarget target,
|
GstGLTextureTarget target,
|
||||||
gpointer wrapped_data,
|
gpointer wrapped_data,
|
||||||
guint gl_handle,
|
gpointer gl_handle,
|
||||||
gpointer user_data,
|
gpointer user_data,
|
||||||
GDestroyNotify notify);
|
GDestroyNotify notify);
|
||||||
GstGLVideoAllocationParams * gst_gl_video_allocation_params_new (GstGLContext * context,
|
GstGLVideoAllocationParams * gst_gl_video_allocation_params_new (GstGLContext * context,
|
||||||
|
@ -135,6 +135,16 @@ GstGLVideoAllocationParams * gst_gl_video_allocation_params_new_wrapped_texture
|
||||||
gpointer user_data,
|
gpointer user_data,
|
||||||
GDestroyNotify notify);
|
GDestroyNotify notify);
|
||||||
|
|
||||||
|
GstGLVideoAllocationParams * gst_gl_video_allocation_params_new_wrapped_gl_handle (GstGLContext * context,
|
||||||
|
GstAllocationParams * alloc_params,
|
||||||
|
GstVideoInfo * v_info,
|
||||||
|
guint plane,
|
||||||
|
GstVideoAlignment * valign,
|
||||||
|
GstGLTextureTarget target,
|
||||||
|
gpointer gl_handle,
|
||||||
|
gpointer user_data,
|
||||||
|
GDestroyNotify notify);
|
||||||
|
|
||||||
/* subclass usage */
|
/* subclass usage */
|
||||||
void gst_gl_video_allocation_params_free_data (GstGLVideoAllocationParams * params);
|
void gst_gl_video_allocation_params_free_data (GstGLVideoAllocationParams * params);
|
||||||
/* subclass usage */
|
/* subclass usage */
|
||||||
|
|
|
@ -674,7 +674,7 @@ _gl_mem_pbo_alloc (GstGLBaseMemoryAllocator * allocator,
|
||||||
mem = g_new0 (GstGLMemoryPBO, 1);
|
mem = g_new0 (GstGLMemoryPBO, 1);
|
||||||
|
|
||||||
if (alloc_flags & GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_WRAP_GPU_HANDLE) {
|
if (alloc_flags & GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_WRAP_GPU_HANDLE) {
|
||||||
mem->mem.tex_id = params->parent.gl_handle;
|
mem->mem.tex_id = GPOINTER_TO_UINT (params->parent.gl_handle);
|
||||||
mem->mem.texture_wrapped = TRUE;
|
mem->mem.texture_wrapped = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue