glmemory: add the texture type to allocate to parameters

Rather than assuming something.  e.g. zerocopy on iOS with GLES3 requires
the use of Luminance/Luminance Alpha formats and does not work with
Red/RG textures.
This commit is contained in:
Matthew Waters 2016-06-28 13:51:22 +10:00
parent 6958b7a014
commit 989200820d
18 changed files with 164 additions and 141 deletions

View file

@ -702,7 +702,8 @@ gst_gl_overlay_load_jpeg (GstGLOverlay * overlay, FILE * fp)
(GST_GL_BASE_FILTER (overlay)->context)); (GST_GL_BASE_FILTER (overlay)->context));
params = params =
gst_gl_video_allocation_params_new (GST_GL_BASE_FILTER (overlay)->context, gst_gl_video_allocation_params_new (GST_GL_BASE_FILTER (overlay)->context,
NULL, &v_info, 0, &v_align, GST_GL_TEXTURE_TARGET_2D); NULL, &v_info, 0, &v_align, GST_GL_TEXTURE_TARGET_2D,
GST_VIDEO_GL_TEXTURE_TYPE_RGBA);
overlay->image_memory = (GstGLMemory *) overlay->image_memory = (GstGLMemory *)
gst_gl_base_memory_alloc (mem_allocator, gst_gl_base_memory_alloc (mem_allocator,
(GstGLAllocationParams *) params); (GstGLAllocationParams *) params);
@ -817,7 +818,8 @@ gst_gl_overlay_load_png (GstGLOverlay * overlay, FILE * fp)
(GST_GL_BASE_FILTER (overlay)->context)); (GST_GL_BASE_FILTER (overlay)->context));
params = params =
gst_gl_video_allocation_params_new (GST_GL_BASE_FILTER (overlay)->context, gst_gl_video_allocation_params_new (GST_GL_BASE_FILTER (overlay)->context,
NULL, &v_info, 0, NULL, GST_GL_TEXTURE_TARGET_2D); NULL, &v_info, 0, NULL, GST_GL_TEXTURE_TARGET_2D,
GST_VIDEO_GL_TEXTURE_TYPE_RGBA);
overlay->image_memory = (GstGLMemory *) overlay->image_memory = (GstGLMemory *)
gst_gl_base_memory_alloc (mem_allocator, gst_gl_base_memory_alloc (mem_allocator,
(GstGLAllocationParams *) params); (GstGLAllocationParams *) params);

View file

@ -66,8 +66,8 @@ EGLDisplay
gst_gl_memory_egl_get_display (GstGLMemoryEGL * mem) gst_gl_memory_egl_get_display (GstGLMemoryEGL * mem)
{ {
g_return_val_if_fail (gst_is_gl_memory_egl (GST_MEMORY_CAST (mem)), NULL); g_return_val_if_fail (gst_is_gl_memory_egl (GST_MEMORY_CAST (mem)), NULL);
return GST_GL_CONTEXT_EGL (_gl_mem_get_parent (mem)->mem.mem.context)-> return GST_GL_CONTEXT_EGL (_gl_mem_get_parent (mem)->mem.mem.
egl_display; context)->egl_display;
} }
GstVideoGLTextureOrientation GstVideoGLTextureOrientation
@ -99,17 +99,6 @@ _gl_mem_destroy (GstGLMemoryEGL * mem)
*) mem); *) mem);
} }
static void
_gl_mem_init (GstGLMemoryEGL * mem, GstAllocator * allocator,
GstMemory * parent, GstGLContext * context, GstGLTextureTarget target,
GstAllocationParams * params, GstVideoInfo * info,
guint plane, GstVideoAlignment * valign, gpointer user_data,
GDestroyNotify notify)
{
gst_gl_memory_init ((GstGLMemory *) mem, allocator, parent,
context, target, params, info, plane, valign, user_data, notify);
}
static GstGLMemoryEGL * static GstGLMemoryEGL *
_gl_mem_egl_alloc (GstGLBaseMemoryAllocator * allocator, _gl_mem_egl_alloc (GstGLBaseMemoryAllocator * allocator,
GstGLVideoAllocationParams * params) GstGLVideoAllocationParams * params)
@ -136,10 +125,10 @@ _gl_mem_egl_alloc (GstGLBaseMemoryAllocator * allocator,
mem->image = gst_egl_image_ref (params->parent.gl_handle); mem->image = gst_egl_image_ref (params->parent.gl_handle);
} }
_gl_mem_init (mem, GST_ALLOCATOR_CAST (allocator), NULL, gst_gl_memory_init (GST_GL_MEMORY_CAST (mem), GST_ALLOCATOR_CAST (allocator),
params->parent.context, params->target, params->parent.alloc_params, NULL, params->parent.context, params->target, params->tex_type,
params->v_info, params->plane, params->valign, params->parent.user_data, params->parent.alloc_params, params->v_info, params->plane,
params->parent.notify); params->valign, params->parent.user_data, params->parent.notify);
return mem; return mem;
} }

View file

@ -132,7 +132,7 @@ gst_gl_buffer_pool_set_config (GstBufferPool * pool, GstStructure * config)
gst_buffer_pool_config_get_gl_allocation_params (config); gst_buffer_pool_config_get_gl_allocation_params (config);
if (!priv->gl_params) if (!priv->gl_params)
priv->gl_params = gst_gl_video_allocation_params_new (glpool->context, priv->gl_params = gst_gl_video_allocation_params_new (glpool->context,
&alloc_params, &info, -1, NULL, 0); &alloc_params, &info, -1, NULL, 0, 0);
max_align = alloc_params.align; max_align = alloc_params.align;
@ -262,7 +262,7 @@ gst_gl_buffer_pool_alloc (GstBufferPool * pool, GstBuffer ** buffer,
} }
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, NULL, 0)) if (!gst_gl_memory_setup_buffer (alloc, buf, priv->gl_params, NULL, NULL, 0))
goto mem_create_failed; goto mem_create_failed;
if (priv->add_glsyncmeta) if (priv->add_glsyncmeta)

View file

@ -2234,7 +2234,8 @@ _do_convert_one_view (GstGLContext * context, GstGLColorConvert * convert,
allocator = gst_allocator_find (GST_GL_MEMORY_ALLOCATOR_NAME); allocator = gst_allocator_find (GST_GL_MEMORY_ALLOCATOR_NAME);
base_mem_allocator = GST_GL_BASE_MEMORY_ALLOCATOR (allocator); base_mem_allocator = GST_GL_BASE_MEMORY_ALLOCATOR (allocator);
params = gst_gl_video_allocation_params_new (context, NULL, &temp_info, params = gst_gl_video_allocation_params_new (context, NULL, &temp_info,
0, NULL, convert->priv->to_texture_target); 0, NULL, convert->priv->to_texture_target,
GST_VIDEO_GL_TEXTURE_TYPE_RGBA);
convert->priv->out_tex[j] = convert->priv->out_tex[j] =
(GstGLMemory *) gst_gl_base_memory_alloc (base_mem_allocator, (GstGLMemory *) gst_gl_base_memory_alloc (base_mem_allocator,

View file

@ -275,8 +275,9 @@ _gl_tex_create (GstGLMemory * gl_mem, GError ** error)
void void
gst_gl_memory_init (GstGLMemory * mem, GstAllocator * allocator, gst_gl_memory_init (GstGLMemory * mem, GstAllocator * allocator,
GstMemory * parent, GstGLContext * context, GstGLTextureTarget target, GstMemory * parent, GstGLContext * context, GstGLTextureTarget target,
GstAllocationParams * params, GstVideoInfo * info, guint plane, GstVideoGLTextureType tex_type, GstAllocationParams * params,
GstVideoAlignment * valign, gpointer user_data, GDestroyNotify notify) GstVideoInfo * info, guint plane, GstVideoAlignment * valign,
gpointer user_data, GDestroyNotify notify)
{ {
const gchar *target_str; const gchar *target_str;
gsize size; gsize size;
@ -307,9 +308,7 @@ gst_gl_memory_init (GstGLMemory * mem, GstAllocator * allocator,
size = gst_gl_get_plane_data_size (info, valign, plane); size = gst_gl_get_plane_data_size (info, valign, plane);
mem->tex_target = target; mem->tex_target = target;
mem->tex_type = mem->tex_type = tex_type;
gst_gl_texture_type_from_format (context, GST_VIDEO_INFO_FORMAT (info),
plane);
mem->plane = plane; mem->plane = plane;
_calculate_unpack_length (mem, context); _calculate_unpack_length (mem, context);
@ -638,12 +637,21 @@ gst_gl_memory_copy_teximage (GstGLMemory * src, guint tex_id,
goto error; goto error;
} }
if (USING_GLES2 (src->mem.context)
&& (src->tex_type == GST_VIDEO_GL_TEXTURE_TYPE_LUMINANCE
|| src->tex_type == GST_VIDEO_GL_TEXTURE_TYPE_LUMINANCE_ALPHA)) {
GST_CAT_FIXME (GST_CAT_GL_MEMORY,
"Cannot copy Luminance/Luminance Alpha textures in GLES");
goto error;
}
if (!gst_memory_map (GST_MEMORY_CAST (src), &sinfo, if (!gst_memory_map (GST_MEMORY_CAST (src), &sinfo,
GST_MAP_READ | GST_MAP_GL)) { GST_MAP_READ | GST_MAP_GL)) {
GST_CAT_ERROR (GST_CAT_GL_MEMORY, GST_CAT_ERROR (GST_CAT_GL_MEMORY,
"Failed to map source memory for copying"); "Failed to map source memory for copying");
goto error; goto error;
} }
src_tex_id = *(guint *) sinfo.data; src_tex_id = *(guint *) sinfo.data;
GST_CAT_LOG (GST_CAT_GL_MEMORY, "copying memory %p, tex %u into " GST_CAT_LOG (GST_CAT_GL_MEMORY, "copying memory %p, tex %u into "
@ -738,22 +746,15 @@ _default_gl_tex_copy (GstGLMemory * src, gssize offset, gssize size)
dest = g_new0 (GstGLMemory, 1); dest = g_new0 (GstGLMemory, 1);
gst_gl_memory_init (dest, allocator, NULL, src->mem.context, src->tex_target, gst_gl_memory_init (dest, allocator, NULL, src->mem.context, src->tex_target,
&params, &src->info, src->plane, &src->valign, NULL, NULL); src->tex_type, &params, &src->info, src->plane, &src->valign, NULL, NULL);
if (GST_MEMORY_FLAG_IS_SET (src, GST_GL_BASE_MEMORY_TRANSFER_NEED_UPLOAD)) { if (!GST_MEMORY_FLAG_IS_SET (src, GST_GL_BASE_MEMORY_TRANSFER_NEED_UPLOAD)) {
if (!gst_gl_base_memory_memcpy ((GstGLBaseMemory *) src,
(GstGLBaseMemory *) dest, offset, size)) {
GST_CAT_WARNING (GST_CAT_GL_MEMORY, "Could not copy GL Memory");
gst_memory_unref (GST_MEMORY_CAST (dest));
return NULL;
}
} else {
GstMapInfo dinfo; GstMapInfo dinfo;
if (!gst_memory_map (GST_MEMORY_CAST (dest), &dinfo, if (!gst_memory_map (GST_MEMORY_CAST (dest), &dinfo,
GST_MAP_WRITE | GST_MAP_GL)) { GST_MAP_WRITE | GST_MAP_GL)) {
GST_CAT_WARNING (GST_CAT_GL_MEMORY, GST_CAT_WARNING (GST_CAT_GL_MEMORY,
"Failed not map destination " "for writing"); "Failed not map destination for writing");
gst_memory_unref (GST_MEMORY_CAST (dest)); gst_memory_unref (GST_MEMORY_CAST (dest));
return NULL; return NULL;
} }
@ -763,11 +764,18 @@ _default_gl_tex_copy (GstGLMemory * src, gssize offset, gssize size)
src->tex_type, src->tex_width, GL_MEM_HEIGHT (src))) { src->tex_type, src->tex_width, GL_MEM_HEIGHT (src))) {
GST_CAT_WARNING (GST_CAT_GL_MEMORY, "Could not copy GL Memory"); GST_CAT_WARNING (GST_CAT_GL_MEMORY, "Could not copy GL Memory");
gst_memory_unmap (GST_MEMORY_CAST (dest), &dinfo); gst_memory_unmap (GST_MEMORY_CAST (dest), &dinfo);
gst_memory_unref (GST_MEMORY_CAST (dest)); goto memcpy;
return NULL;
} }
gst_memory_unmap (GST_MEMORY_CAST (dest), &dinfo); gst_memory_unmap (GST_MEMORY_CAST (dest), &dinfo);
} else {
memcpy:
if (!gst_gl_base_memory_memcpy ((GstGLBaseMemory *) src,
(GstGLBaseMemory *) dest, offset, size)) {
GST_CAT_WARNING (GST_CAT_GL_MEMORY, "Could not copy GL Memory");
gst_memory_unref (GST_MEMORY_CAST (dest));
return NULL;
}
} }
return (GstMemory *) dest; return (GstMemory *) dest;
@ -826,9 +834,9 @@ _default_gl_tex_alloc (GstGLMemoryAllocator * allocator,
} }
gst_gl_memory_init (mem, GST_ALLOCATOR_CAST (allocator), NULL, gst_gl_memory_init (mem, GST_ALLOCATOR_CAST (allocator), NULL,
params->parent.context, params->target, params->parent.alloc_params, params->parent.context, params->target, params->tex_type,
params->v_info, params->plane, params->valign, params->parent.user_data, params->parent.alloc_params, params->v_info, params->plane,
params->parent.notify); params->valign, params->parent.user_data, params->parent.notify);
if (alloc_flags & GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_WRAP_GPU_HANDLE) { if (alloc_flags & GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_WRAP_GPU_HANDLE) {
GST_MINI_OBJECT_FLAG_SET (mem, GST_GL_BASE_MEMORY_TRANSFER_NEED_DOWNLOAD); GST_MINI_OBJECT_FLAG_SET (mem, GST_GL_BASE_MEMORY_TRANSFER_NEED_DOWNLOAD);
@ -1063,6 +1071,7 @@ _gst_gl_video_allocation_params_set_video_alignment (GstGLVideoAllocationParams
* @plane: the video plane @wrapped_data represents * @plane: the video plane @wrapped_data represents
* @valign: (allow-none): any #GstVideoAlignment applied to symem mappings of @wrapped_data * @valign: (allow-none): any #GstVideoAlignment applied to symem mappings of @wrapped_data
* @target: the #GstGLTextureTarget * @target: the #GstGLTextureTarget
* @tex_type: the #GstVideoGLTextureType
* @wrapped_data: (allow-none): the optional data pointer to wrap * @wrapped_data: (allow-none): the optional data pointer to wrap
* @gl_handle: the optional OpenGL handle to wrap or 0 * @gl_handle: the optional OpenGL handle to wrap or 0
* @user_data: (allow-none): user data to call @notify with * @user_data: (allow-none): user data to call @notify with
@ -1080,8 +1089,8 @@ 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, gpointer gl_handle, gpointer user_data, GstVideoGLTextureType tex_type, gpointer wrapped_data, gpointer gl_handle,
GDestroyNotify notify) gpointer user_data, GDestroyNotify notify)
{ {
guint i; guint i;
@ -1106,6 +1115,7 @@ gst_gl_video_allocation_params_init_full (GstGLVideoAllocationParams * params,
} }
_gst_gl_video_allocation_params_set_video_alignment (params, valign); _gst_gl_video_allocation_params_set_video_alignment (params, valign);
params->target = target; params->target = target;
params->tex_type = tex_type;
params->plane = plane; params->plane = plane;
return TRUE; return TRUE;
@ -1114,11 +1124,12 @@ gst_gl_video_allocation_params_init_full (GstGLVideoAllocationParams * params,
/** /**
* gst_gl_video_allocation_params_new: * gst_gl_video_allocation_params_new:
* @context: a #GstGLContext * @context: a #GstGLContext
* @alloc_params: (allow-none): the #GstAllocationParams for @wrapped_data * @alloc_params: (allow-none): the #GstAllocationParams for sysmem mappings of the texture
* @v_info: the #GstVideoInfo for @wrapped_data * @v_info: the #GstVideoInfo for the texture
* @plane: the video plane @wrapped_data represents * @plane: the video plane of @v_info to allocate
* @valign: (allow-none): any #GstVideoAlignment applied to symem mappings of @wrapped_data * @valign: (allow-none): any #GstVideoAlignment applied to symem mappings of the texture
* @target: the #GstGLTextureTarget for @wrapped_data * @target: the #GstGLTextureTarget for the created textures
* @target: the #GstVideoGLTextureType for the created textures
* *
* Returns: a new #GstGLVideoAllocationParams for allocating #GstGLMemory's * Returns: a new #GstGLVideoAllocationParams for allocating #GstGLMemory's
* *
@ -1127,7 +1138,8 @@ gst_gl_video_allocation_params_init_full (GstGLVideoAllocationParams * params,
GstGLVideoAllocationParams * GstGLVideoAllocationParams *
gst_gl_video_allocation_params_new (GstGLContext * context, gst_gl_video_allocation_params_new (GstGLContext * context,
GstAllocationParams * alloc_params, GstVideoInfo * v_info, guint plane, GstAllocationParams * alloc_params, GstVideoInfo * v_info, guint plane,
GstVideoAlignment * valign, GstGLTextureTarget target) GstVideoAlignment * valign, GstGLTextureTarget target,
GstVideoGLTextureType tex_type)
{ {
GstGLVideoAllocationParams *params = g_new0 (GstGLVideoAllocationParams, 1); GstGLVideoAllocationParams *params = g_new0 (GstGLVideoAllocationParams, 1);
@ -1139,7 +1151,7 @@ gst_gl_video_allocation_params_new (GstGLContext * context,
gst_gl_video_allocation_params_copy_data, gst_gl_video_allocation_params_copy_data,
(GstGLAllocationParamsFreeFunc) (GstGLAllocationParamsFreeFunc)
gst_gl_video_allocation_params_free_data, context, alloc_params, gst_gl_video_allocation_params_free_data, context, alloc_params,
v_info, plane, valign, target, NULL, 0, NULL, NULL)) { v_info, plane, valign, target, tex_type, NULL, 0, NULL, NULL)) {
g_free (params); g_free (params);
return NULL; return NULL;
} }
@ -1155,6 +1167,7 @@ gst_gl_video_allocation_params_new (GstGLContext * context,
* @plane: the video plane @wrapped_data represents * @plane: the video plane @wrapped_data represents
* @valign: (allow-none): any #GstVideoAlignment applied to symem mappings of @wrapped_data * @valign: (allow-none): any #GstVideoAlignment applied to symem mappings of @wrapped_data
* @target: the #GstGLTextureTarget for @wrapped_data * @target: the #GstGLTextureTarget for @wrapped_data
* @tex_type: the #GstVideoGLTextureType for @wrapped_data
* @wrapped_data: the data pointer to wrap * @wrapped_data: the data pointer to wrap
* @user_data: (allow-none): user data to call @notify with * @user_data: (allow-none): user data to call @notify with
* @notify: (allow-none): a #GDestroyNotify * @notify: (allow-none): a #GDestroyNotify
@ -1167,7 +1180,8 @@ GstGLVideoAllocationParams *
gst_gl_video_allocation_params_new_wrapped_data (GstGLContext * context, gst_gl_video_allocation_params_new_wrapped_data (GstGLContext * context,
GstAllocationParams * alloc_params, GstVideoInfo * v_info, guint plane, GstAllocationParams * alloc_params, GstVideoInfo * v_info, guint plane,
GstVideoAlignment * valign, GstGLTextureTarget target, GstVideoAlignment * valign, GstGLTextureTarget target,
gpointer wrapped_data, gpointer user_data, GDestroyNotify notify) GstVideoGLTextureType tex_type, gpointer wrapped_data, gpointer user_data,
GDestroyNotify notify)
{ {
GstGLVideoAllocationParams *params = g_new0 (GstGLVideoAllocationParams, 1); GstGLVideoAllocationParams *params = g_new0 (GstGLVideoAllocationParams, 1);
@ -1179,7 +1193,8 @@ gst_gl_video_allocation_params_new_wrapped_data (GstGLContext * context,
gst_gl_video_allocation_params_copy_data, gst_gl_video_allocation_params_copy_data,
(GstGLAllocationParamsFreeFunc) (GstGLAllocationParamsFreeFunc)
gst_gl_video_allocation_params_free_data, context, alloc_params, gst_gl_video_allocation_params_free_data, context, alloc_params,
v_info, plane, valign, target, wrapped_data, 0, user_data, notify)) { v_info, plane, valign, target, tex_type, wrapped_data, 0, user_data,
notify)) {
g_free (params); g_free (params);
return NULL; return NULL;
} }
@ -1195,6 +1210,7 @@ gst_gl_video_allocation_params_new_wrapped_data (GstGLContext * context,
* @plane: the video plane @tex_id represents * @plane: the video plane @tex_id represents
* @valign: (allow-none): any #GstVideoAlignment applied to symem mappings of @tex_id * @valign: (allow-none): any #GstVideoAlignment applied to symem mappings of @tex_id
* @target: the #GstGLTextureTarget for @tex_id * @target: the #GstGLTextureTarget for @tex_id
* @tex_type: the #GstVideoGLTextureType for @tex_id
* @gl_handle: the GL handle to wrap * @gl_handle: the GL handle to wrap
* @user_data: (allow-none): user data to call @notify with * @user_data: (allow-none): user data to call @notify with
* @notify: (allow-none): a #GDestroyNotify * @notify: (allow-none): a #GDestroyNotify
@ -1211,7 +1227,8 @@ GstGLVideoAllocationParams *
gst_gl_video_allocation_params_new_wrapped_gl_handle (GstGLContext * context, gst_gl_video_allocation_params_new_wrapped_gl_handle (GstGLContext * context,
GstAllocationParams * alloc_params, GstVideoInfo * v_info, guint plane, GstAllocationParams * alloc_params, GstVideoInfo * v_info, guint plane,
GstVideoAlignment * valign, GstGLTextureTarget target, GstVideoAlignment * valign, GstGLTextureTarget target,
gpointer gl_handle, gpointer user_data, GDestroyNotify notify) GstVideoGLTextureType tex_type, gpointer gl_handle, gpointer user_data,
GDestroyNotify notify)
{ {
GstGLVideoAllocationParams *params = g_new0 (GstGLVideoAllocationParams, 1); GstGLVideoAllocationParams *params = g_new0 (GstGLVideoAllocationParams, 1);
@ -1223,7 +1240,8 @@ gst_gl_video_allocation_params_new_wrapped_gl_handle (GstGLContext * context,
gst_gl_video_allocation_params_copy_data, gst_gl_video_allocation_params_copy_data,
(GstGLAllocationParamsFreeFunc) (GstGLAllocationParamsFreeFunc)
gst_gl_video_allocation_params_free_data, context, alloc_params, gst_gl_video_allocation_params_free_data, context, alloc_params,
v_info, plane, valign, target, NULL, gl_handle, user_data, notify)) { v_info, plane, valign, target, tex_type, NULL, gl_handle, user_data,
notify)) {
g_free (params); g_free (params);
return NULL; return NULL;
} }
@ -1239,6 +1257,7 @@ gst_gl_video_allocation_params_new_wrapped_gl_handle (GstGLContext * context,
* @plane: the video plane @tex_id represents * @plane: the video plane @tex_id represents
* @valign: (allow-none): any #GstVideoAlignment applied to symem mappings of @tex_id * @valign: (allow-none): any #GstVideoAlignment applied to symem mappings of @tex_id
* @target: the #GstGLTextureTarget for @tex_id * @target: the #GstGLTextureTarget for @tex_id
* @tex_type: the #GstGLTextureType for @tex_id
* @tex_id: the GL texture to wrap * @tex_id: the GL texture to wrap
* @user_data: (allow-none): user data to call @notify with * @user_data: (allow-none): user data to call @notify with
* @notify: (allow-none): a #GDestroyNotify * @notify: (allow-none): a #GDestroyNotify
@ -1251,11 +1270,12 @@ GstGLVideoAllocationParams *
gst_gl_video_allocation_params_new_wrapped_texture (GstGLContext * context, gst_gl_video_allocation_params_new_wrapped_texture (GstGLContext * context,
GstAllocationParams * alloc_params, GstVideoInfo * v_info, guint plane, GstAllocationParams * alloc_params, GstVideoInfo * v_info, guint plane,
GstVideoAlignment * valign, GstGLTextureTarget target, GstVideoAlignment * valign, GstGLTextureTarget target,
guint tex_id, gpointer user_data, GDestroyNotify notify) GstVideoGLTextureType tex_type, guint tex_id, gpointer user_data,
GDestroyNotify notify)
{ {
return gst_gl_video_allocation_params_new_wrapped_gl_handle (context, return gst_gl_video_allocation_params_new_wrapped_gl_handle (context,
alloc_params, v_info, plane, valign, target, GUINT_TO_POINTER (tex_id), alloc_params, v_info, plane, valign, target, tex_type,
user_data, notify); GUINT_TO_POINTER (tex_id), user_data, notify);
} }
/** /**
@ -1305,6 +1325,7 @@ gst_gl_video_allocation_params_copy_data (GstGLVideoAllocationParams * src_vid,
_gst_gl_video_allocation_params_set_video_alignment (dest_vid, _gst_gl_video_allocation_params_set_video_alignment (dest_vid,
src_vid->valign); src_vid->valign);
dest_vid->target = src_vid->target; dest_vid->target = src_vid->target;
dest_vid->tex_type = src_vid->tex_type;
dest_vid->plane = src_vid->plane; dest_vid->plane = src_vid->plane;
} }
@ -1313,6 +1334,7 @@ gst_gl_video_allocation_params_copy_data (GstGLVideoAllocationParams * src_vid,
* @allocator: the @GstGLMemoryAllocator to allocate from * @allocator: the @GstGLMemoryAllocator to allocate from
* @buffer: a #GstBuffer to setup * @buffer: a #GstBuffer to setup
* @params: the #GstGLVideoAllocationParams to allocate with * @params: the #GstGLVideoAllocationParams to allocate with
* @tex_types: (allow-none): a list of #GstVideoGLTextureType's to allocate with.
* *
* Returns: whether the buffer was correctly setup * Returns: whether the buffer was correctly setup
* *
@ -1321,7 +1343,8 @@ 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) GstVideoGLTextureType * tex_types, 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;
@ -1347,6 +1370,14 @@ gst_gl_memory_setup_buffer (GstGLMemoryAllocator * allocator,
for (i = 0; i < n_mem; i++) { for (i = 0; i < n_mem; i++) {
GstGLMemory *gl_mem; GstGLMemory *gl_mem;
if (tex_types) {
params->tex_type = tex_types[i];
} else {
params->tex_type =
gst_gl_texture_type_from_format (params->parent.context,
GST_VIDEO_INFO_FORMAT (params->v_info), i);
}
params->plane = i; params->plane = i;
if (alloc_flags & GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_WRAP_SYSMEM) { if (alloc_flags & GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_WRAP_SYSMEM) {
g_return_val_if_fail (wrapped_data != NULL, FALSE); g_return_val_if_fail (wrapped_data != NULL, FALSE);

View file

@ -92,6 +92,7 @@ struct _GstGLVideoAllocationParams
guint plane; guint plane;
GstVideoAlignment *valign; GstVideoAlignment *valign;
GstGLTextureTarget target; GstGLTextureTarget target;
GstVideoGLTextureType tex_type;
}; };
gboolean gst_gl_video_allocation_params_init_full (GstGLVideoAllocationParams * params, gboolean gst_gl_video_allocation_params_init_full (GstGLVideoAllocationParams * params,
@ -105,6 +106,7 @@ gboolean gst_gl_video_allocation_params_init_full (GstGLVideoAlloc
guint plane, guint plane,
GstVideoAlignment * valign, GstVideoAlignment * valign,
GstGLTextureTarget target, GstGLTextureTarget target,
GstVideoGLTextureType tex_type,
gpointer wrapped_data, gpointer wrapped_data,
gpointer gl_handle, gpointer gl_handle,
gpointer user_data, gpointer user_data,
@ -114,13 +116,15 @@ GstGLVideoAllocationParams * gst_gl_video_allocation_params_new (GstGLContext *
GstVideoInfo * v_info, GstVideoInfo * v_info,
guint plane, guint plane,
GstVideoAlignment * valign, GstVideoAlignment * valign,
GstGLTextureTarget target); GstGLTextureTarget target,
GstVideoGLTextureType tex_type);
GstGLVideoAllocationParams * gst_gl_video_allocation_params_new_wrapped_data (GstGLContext * context, GstGLVideoAllocationParams * gst_gl_video_allocation_params_new_wrapped_data (GstGLContext * context,
GstAllocationParams * alloc_params, GstAllocationParams * alloc_params,
GstVideoInfo * v_info, GstVideoInfo * v_info,
guint plane, guint plane,
GstVideoAlignment * valign, GstVideoAlignment * valign,
GstGLTextureTarget target, GstGLTextureTarget target,
GstVideoGLTextureType tex_type,
gpointer wrapped_data, gpointer wrapped_data,
gpointer user_data, gpointer user_data,
GDestroyNotify notify); GDestroyNotify notify);
@ -131,6 +135,7 @@ GstGLVideoAllocationParams * gst_gl_video_allocation_params_new_wrapped_texture
guint plane, guint plane,
GstVideoAlignment * valign, GstVideoAlignment * valign,
GstGLTextureTarget target, GstGLTextureTarget target,
GstVideoGLTextureType tex_type,
guint tex_id, guint tex_id,
gpointer user_data, gpointer user_data,
GDestroyNotify notify); GDestroyNotify notify);
@ -141,6 +146,7 @@ GstGLVideoAllocationParams * gst_gl_video_allocation_params_new_wrapped_gl_handl
guint plane, guint plane,
GstVideoAlignment * valign, GstVideoAlignment * valign,
GstGLTextureTarget target, GstGLTextureTarget target,
GstVideoGLTextureType tex_type,
gpointer gl_handle, gpointer gl_handle,
gpointer user_data, gpointer user_data,
GDestroyNotify notify); GDestroyNotify notify);
@ -192,6 +198,7 @@ void gst_gl_memory_init (GstGLMemory * mem,
GstMemory * parent, GstMemory * parent,
GstGLContext * context, GstGLContext * context,
GstGLTextureTarget target, GstGLTextureTarget target,
GstVideoGLTextureType tex_type,
GstAllocationParams *params, GstAllocationParams *params,
GstVideoInfo * info, GstVideoInfo * info,
guint plane, guint plane,
@ -227,6 +234,7 @@ 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,
GstVideoGLTextureType *tex_types,
gpointer *wrapped_data, gpointer *wrapped_data,
gsize n_wrapped_pointers); gsize n_wrapped_pointers);

View file

@ -217,34 +217,6 @@ _gl_mem_create (GstGLMemoryPBO * gl_mem, GError ** error)
return TRUE; return TRUE;
} }
static void
_gl_mem_init (GstGLMemoryPBO * mem, GstAllocator * allocator,
GstMemory * parent, GstGLContext * context, GstGLTextureTarget target,
GstAllocationParams * params, GstVideoInfo * info,
guint plane, GstVideoAlignment * valign, gpointer user_data,
GDestroyNotify notify)
{
gst_gl_memory_init ((GstGLMemory *) mem, allocator, parent,
context, target, params, info, plane, valign, user_data, notify);
}
static GstGLMemoryPBO *
_gl_mem_new (GstAllocator * allocator, GstMemory * parent,
GstGLContext * context, GstGLTextureTarget target,
GstAllocationParams * params, GstVideoInfo * info,
guint plane, GstVideoAlignment * valign, gpointer user_data,
GDestroyNotify notify)
{
GstGLMemoryPBO *mem;
mem = g_new0 (GstGLMemoryPBO, 1);
mem->mem.texture_wrapped = FALSE;
_gl_mem_init (mem, allocator, parent, context, target, params, info, plane,
valign, user_data, notify);
return mem;
}
static gboolean static gboolean
_read_pixels_to_pbo (GstGLMemoryPBO * gl_mem) _read_pixels_to_pbo (GstGLMemoryPBO * gl_mem)
{ {
@ -601,18 +573,12 @@ _gl_mem_copy (GstGLMemoryPBO * src, gssize offset, gssize size)
size); size);
} }
dest = (GstMemory *) _gl_mem_new (allocator, NULL, src->mem.mem.context, dest = (GstMemory *) g_new0 (GstGLMemoryPBO, 1);
src->mem.tex_target, &params, &src->mem.info, src->mem.plane, gst_gl_memory_init (GST_GL_MEMORY_CAST (dest), allocator, NULL,
&src->mem.valign, NULL, NULL); src->mem.mem.context, src->mem.tex_target, src->mem.tex_type, &params,
&src->mem.info, src->mem.plane, &src->mem.valign, NULL, NULL);
if (GST_MEMORY_FLAG_IS_SET (src, GST_GL_BASE_MEMORY_TRANSFER_NEED_UPLOAD)) { if (!GST_MEMORY_FLAG_IS_SET (src, GST_GL_BASE_MEMORY_TRANSFER_NEED_UPLOAD)) {
if (!gst_gl_base_memory_memcpy ((GstGLBaseMemory *) src,
(GstGLBaseMemory *) dest, offset, size)) {
GST_CAT_WARNING (GST_CAT_GL_MEMORY, "Could not copy GL Memory");
gst_memory_unref (GST_MEMORY_CAST (dest));
return NULL;
}
} else {
GstMapInfo dinfo; GstMapInfo dinfo;
if (!gst_memory_map (GST_MEMORY_CAST (dest), &dinfo, if (!gst_memory_map (GST_MEMORY_CAST (dest), &dinfo,
@ -628,11 +594,18 @@ _gl_mem_copy (GstGLMemoryPBO * src, gssize offset, gssize size)
src->mem.tex_type, src->mem.tex_width, GL_MEM_HEIGHT (src))) { src->mem.tex_type, src->mem.tex_width, GL_MEM_HEIGHT (src))) {
GST_CAT_WARNING (GST_CAT_GL_MEMORY, "Could not copy GL Memory"); GST_CAT_WARNING (GST_CAT_GL_MEMORY, "Could not copy GL Memory");
gst_memory_unmap (GST_MEMORY_CAST (dest), &dinfo); gst_memory_unmap (GST_MEMORY_CAST (dest), &dinfo);
gst_memory_unref (GST_MEMORY_CAST (dest)); goto memcpy;
return NULL;
} }
gst_memory_unmap (GST_MEMORY_CAST (dest), &dinfo); gst_memory_unmap (GST_MEMORY_CAST (dest), &dinfo);
} else {
memcpy:
if (!gst_gl_base_memory_memcpy ((GstGLBaseMemory *) src,
(GstGLBaseMemory *) dest, offset, size)) {
GST_CAT_WARNING (GST_CAT_GL_MEMORY, "Could not copy GL Memory");
gst_memory_unref (GST_MEMORY_CAST (dest));
return NULL;
}
} }
return dest; return dest;
@ -678,10 +651,10 @@ _gl_mem_pbo_alloc (GstGLBaseMemoryAllocator * allocator,
mem->mem.texture_wrapped = TRUE; mem->mem.texture_wrapped = TRUE;
} }
_gl_mem_init (mem, GST_ALLOCATOR_CAST (allocator), NULL, gst_gl_memory_init (GST_GL_MEMORY_CAST (mem), GST_ALLOCATOR_CAST (allocator),
params->parent.context, params->target, params->parent.alloc_params, NULL, params->parent.context, params->target, params->tex_type,
params->v_info, params->plane, params->valign, params->parent.user_data, params->parent.alloc_params, params->v_info, params->plane,
params->parent.notify); params->valign, params->parent.user_data, params->parent.notify);
if (alloc_flags & GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_WRAP_GPU_HANDLE) { if (alloc_flags & GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_WRAP_GPU_HANDLE) {
GST_MINI_OBJECT_FLAG_SET (mem, GST_GL_BASE_MEMORY_TRANSFER_NEED_DOWNLOAD); GST_MINI_OBJECT_FLAG_SET (mem, GST_GL_BASE_MEMORY_TRANSFER_NEED_DOWNLOAD);

View file

@ -356,7 +356,8 @@ gst_gl_composition_overlay_upload (GstGLCompositionOverlay * overlay,
params = gst_gl_video_allocation_params_new_wrapped_data (overlay->context, params = gst_gl_video_allocation_params_new_wrapped_data (overlay->context,
NULL, &comp_frame->info, 0, NULL, GST_GL_TEXTURE_TARGET_2D, NULL, &comp_frame->info, 0, NULL, GST_GL_TEXTURE_TARGET_2D,
comp_frame->data[0], comp_frame, _video_frame_unmap_and_free); GST_VIDEO_GL_TEXTURE_TYPE_RGBA, comp_frame->data[0], comp_frame,
_video_frame_unmap_and_free);
comp_gl_memory = comp_gl_memory =
(GstGLMemory *) gst_gl_base_memory_alloc (mem_allocator, (GstGLMemory *) gst_gl_base_memory_alloc (mem_allocator,

View file

@ -315,8 +315,8 @@ _gl_memory_upload_propose_allocation (gpointer impl, GstQuery * decide_query,
gst_allocation_params_init (&params); gst_allocation_params_init (&params);
allocator = allocator =
GST_ALLOCATOR (gst_gl_memory_allocator_get_default (upload->upload-> GST_ALLOCATOR (gst_gl_memory_allocator_get_default (upload->
context)); upload->context));
gst_query_add_allocation_param (query, allocator, &params); gst_query_add_allocation_param (query, allocator, &params);
gst_object_unref (allocator); gst_object_unref (allocator);
@ -582,9 +582,9 @@ _dma_buf_upload_accept (gpointer impl, GstBuffer * buffer, GstCaps * in_caps,
if (dmabuf->params) if (dmabuf->params)
gst_gl_allocation_params_free ((GstGLAllocationParams *) dmabuf->params); gst_gl_allocation_params_free ((GstGLAllocationParams *) dmabuf->params);
if (!(dmabuf->params = if (!(dmabuf->params =
gst_gl_video_allocation_params_new_wrapped_gl_handle (dmabuf->upload-> gst_gl_video_allocation_params_new_wrapped_gl_handle (dmabuf->
context, NULL, &dmabuf->upload->priv->in_info, -1, NULL, upload->context, NULL, &dmabuf->upload->priv->in_info, -1, NULL,
GST_GL_TEXTURE_TARGET_2D, NULL, NULL, NULL))) GST_GL_TEXTURE_TARGET_2D, 0, NULL, NULL, NULL)))
return FALSE; return FALSE;
/* Find and validate all memories */ /* Find and validate all memories */
@ -649,7 +649,7 @@ _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,
(gpointer *) dmabuf->eglimage, gst_buffer_n_memory (dmabuf->outbuf)); (gpointer *) dmabuf->eglimage, gst_buffer_n_memory (dmabuf->outbuf));
gst_object_unref (allocator); gst_object_unref (allocator);
} }
@ -785,7 +785,7 @@ _upload_meta_upload_accept (gpointer impl, GstBuffer * buffer,
if (!(upload->params = if (!(upload->params =
gst_gl_video_allocation_params_new (upload->upload->context, NULL, gst_gl_video_allocation_params_new (upload->upload->context, NULL,
&upload->upload->priv->in_info, -1, NULL, &upload->upload->priv->in_info, -1, NULL,
GST_GL_TEXTURE_TARGET_2D))) GST_GL_TEXTURE_TARGET_2D, 0)))
return FALSE; return FALSE;
if (buffer) { if (buffer) {
@ -817,11 +817,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-> gst_gl_api_to_string (gst_gl_context_get_gl_api (upload->upload->
upload->context)); context));
platform = platform =
gst_gl_platform_to_string (gst_gl_context_get_gl_platform gst_gl_platform_to_string (gst_gl_context_get_gl_platform (upload->
(upload->upload->context)); 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 =
@ -876,7 +876,8 @@ _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, NULL, 0); gst_gl_memory_setup_buffer (allocator, *outbuf, upload->params, NULL, 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++) {
@ -1067,7 +1068,7 @@ _raw_data_upload_accept (gpointer impl, GstBuffer * buffer, GstCaps * in_caps,
if (!(raw->params = if (!(raw->params =
gst_gl_video_allocation_params_new_wrapped_data (raw->upload->context, gst_gl_video_allocation_params_new_wrapped_data (raw->upload->context,
NULL, &raw->upload->priv->in_info, -1, NULL, NULL, &raw->upload->priv->in_info, -1, NULL,
GST_GL_TEXTURE_TARGET_2D, NULL, raw->in_frame, GST_GL_TEXTURE_TARGET_2D, 0, NULL, raw->in_frame,
(GDestroyNotify) _raw_upload_frame_unref))) (GDestroyNotify) _raw_upload_frame_unref)))
return FALSE; return FALSE;

View file

@ -1952,9 +1952,10 @@ _gen_buffer (GstGLViewConvert * viewconvert, GstBuffer ** target)
(viewconvert->context)); (viewconvert->context));
mem_allocator = GST_GL_MEMORY_ALLOCATOR (allocator); mem_allocator = GST_GL_MEMORY_ALLOCATOR (allocator);
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, 0);
if (!gst_gl_memory_setup_buffer (mem_allocator, *target, params, NULL, 0)) { if (!gst_gl_memory_setup_buffer (mem_allocator, *target, params, NULL, 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;
@ -2093,7 +2094,8 @@ _do_view_convert (GstGLContext * context, GstGLViewConvert * viewconvert)
GST_ALLOCATOR (gst_gl_memory_allocator_get_default (context)); GST_ALLOCATOR (gst_gl_memory_allocator_get_default (context));
base_mem_allocator = GST_GL_BASE_MEMORY_ALLOCATOR (allocator); base_mem_allocator = GST_GL_BASE_MEMORY_ALLOCATOR (allocator);
params = gst_gl_video_allocation_params_new (context, NULL, &temp_info, params = gst_gl_video_allocation_params_new (context, NULL, &temp_info,
0, NULL, viewconvert->to_texture_target); 0, NULL, viewconvert->to_texture_target,
GST_VIDEO_GL_TEXTURE_TYPE_RGBA);
priv->out_tex[j] = priv->out_tex[j] =
(GstGLMemory *) gst_gl_base_memory_alloc (base_mem_allocator, (GstGLMemory *) gst_gl_base_memory_alloc (base_mem_allocator,

View file

@ -1354,7 +1354,8 @@ retry:
(GST_GL_MEMORY_ALLOCATOR_NAME)); (GST_GL_MEMORY_ALLOCATOR_NAME));
params = gst_gl_video_allocation_params_new (self->gl_context, NULL, params = gst_gl_video_allocation_params_new (self->gl_context, NULL,
&state->info, 0, NULL, GST_GL_TEXTURE_TARGET_EXTERNAL_OES); &state->info, 0, NULL, GST_GL_TEXTURE_TARGET_EXTERNAL_OES,
GST_VIDEO_GL_TEXTURE_TYPE_RGBA);
self->oes_mem = (GstGLMemory *) gst_gl_base_memory_alloc (base_mem_alloc, self->oes_mem = (GstGLMemory *) gst_gl_base_memory_alloc (base_mem_alloc,
(GstGLAllocationParams *) params); (GstGLAllocationParams *) params);

View file

@ -160,6 +160,7 @@ static GstIOSurfaceMemory *
_io_surface_memory_new (GstGLContext * context, _io_surface_memory_new (GstGLContext * context,
IOSurfaceRef surface, IOSurfaceRef surface,
GstGLTextureTarget target, GstGLTextureTarget target,
GstVideoGLTextureType tex_type,
GstVideoInfo * info, GstVideoInfo * info,
guint plane, guint plane,
GstVideoAlignment * valign, gpointer user_data, GDestroyNotify notify) GstVideoAlignment * valign, gpointer user_data, GDestroyNotify notify)
@ -170,7 +171,7 @@ _io_surface_memory_new (GstGLContext * context,
mem = g_new0 (GstIOSurfaceMemory, 1); mem = g_new0 (GstIOSurfaceMemory, 1);
gst_gl_memory_init (&mem->gl_mem, _io_surface_memory_allocator, NULL, context, gst_gl_memory_init (&mem->gl_mem, _io_surface_memory_allocator, NULL, context,
target, NULL, info, plane, valign, user_data, notify); target, tex_type, NULL, info, plane, valign, user_data, notify);
GST_MINI_OBJECT_FLAG_SET (mem, GST_MEMORY_FLAG_READONLY); GST_MINI_OBJECT_FLAG_SET (mem, GST_MEMORY_FLAG_READONLY);
@ -184,11 +185,12 @@ GstIOSurfaceMemory *
gst_io_surface_memory_wrapped (GstGLContext * context, gst_io_surface_memory_wrapped (GstGLContext * context,
IOSurfaceRef surface, IOSurfaceRef surface,
GstGLTextureTarget target, GstGLTextureTarget target,
GstVideoGLTextureType tex_type,
GstVideoInfo * info, GstVideoInfo * info,
guint plane, guint plane,
GstVideoAlignment * valign, gpointer user_data, GDestroyNotify notify) GstVideoAlignment * valign, gpointer user_data, GDestroyNotify notify)
{ {
return _io_surface_memory_new (context, surface, target, info, return _io_surface_memory_new (context, surface, target, tex_type, info,
plane, valign, user_data, notify); plane, valign, user_data, notify);
} }

View file

@ -53,6 +53,7 @@ GstIOSurfaceMemory *
gst_io_surface_memory_wrapped (GstGLContext * context, gst_io_surface_memory_wrapped (GstGLContext * context,
IOSurfaceRef surface, IOSurfaceRef surface,
GstGLTextureTarget target, GstGLTextureTarget target,
GstVideoGLTextureType tex_type,
GstVideoInfo * info, GstVideoInfo * info,
guint plane, guint plane,
GstVideoAlignment *valign, GstVideoAlignment *valign,

View file

@ -171,8 +171,8 @@ _do_get_gl_buffer (GstGLContext * context, ContextThreadData * data)
gl_target = gst_gl_texture_target_from_gl (CVOpenGLESTextureGetTarget (texture)); gl_target = gst_gl_texture_target_from_gl (CVOpenGLESTextureGetTarget (texture));
params = gst_gl_video_allocation_params_new_wrapped_texture (cache->ctx, params = gst_gl_video_allocation_params_new_wrapped_texture (cache->ctx,
NULL, &cache->input_info, 0, NULL, gl_target, NULL, &cache->input_info, 0, NULL, gl_target,
CVOpenGLESTextureGetName (texture), texture, GST_VIDEO_GL_TEXTURE_TYPE_RGBA, CVOpenGLESTextureGetName (texture),
(GDestroyNotify) CFRelease); texture, (GDestroyNotify) CFRelease);
gst_buffer_replace_memory (output_buffer, 0, gst_buffer_replace_memory (output_buffer, 0,
(GstMemory *) gst_gl_base_memory_alloc (base_mem_alloc, (GstMemory *) gst_gl_base_memory_alloc (base_mem_alloc,
@ -197,7 +197,7 @@ _do_get_gl_buffer (GstGLContext * context, ContextThreadData * data)
gl_target = gst_gl_texture_target_from_gl (CVOpenGLESTextureGetTarget (texture)); gl_target = gst_gl_texture_target_from_gl (CVOpenGLESTextureGetTarget (texture));
params = gst_gl_video_allocation_params_new_wrapped_texture (cache->ctx, params = gst_gl_video_allocation_params_new_wrapped_texture (cache->ctx,
NULL, &cache->input_info, 0, NULL, gl_target, NULL, &cache->input_info, 0, NULL, gl_target, textype,
CVOpenGLESTextureGetName (texture), texture, CVOpenGLESTextureGetName (texture), texture,
(GDestroyNotify) CFRelease); (GDestroyNotify) CFRelease);
@ -219,7 +219,7 @@ _do_get_gl_buffer (GstGLContext * context, ContextThreadData * data)
gl_target = gst_gl_texture_target_from_gl (CVOpenGLESTextureGetTarget (texture)); gl_target = gst_gl_texture_target_from_gl (CVOpenGLESTextureGetTarget (texture));
params = gst_gl_video_allocation_params_new_wrapped_texture (cache->ctx, params = gst_gl_video_allocation_params_new_wrapped_texture (cache->ctx,
NULL, &cache->input_info, 1, NULL, gl_target, NULL, &cache->input_info, 1, NULL, gl_target, textype,
CVOpenGLESTextureGetName (texture), texture, CVOpenGLESTextureGetName (texture), texture,
(GDestroyNotify) CFRelease); (GDestroyNotify) CFRelease);
@ -255,11 +255,14 @@ _do_get_gl_buffer (GstGLContext * context, ContextThreadData * data)
gst_buffer_copy_into (data->output_buffer, data->input_buffer, GST_BUFFER_COPY_ALL, 0, -1); gst_buffer_copy_into (data->output_buffer, data->input_buffer, GST_BUFFER_COPY_ALL, 0, -1);
for (int i = 0; i < GST_VIDEO_INFO_N_PLANES (&cache->input_info); i++) { for (int i = 0; i < GST_VIDEO_INFO_N_PLANES (&cache->input_info); i++) {
GstIOSurfaceMemory *mem; GstIOSurfaceMemory *mem;
GstVideoGLTextureType tex_type =
gst_gl_texture_type_from_format (context,
GST_VIDEO_INFO_FORMAT (&cache->input_info), i);
CFRetain (pixel_buf); CFRetain (pixel_buf);
mem = gst_io_surface_memory_wrapped (cache->ctx, mem = gst_io_surface_memory_wrapped (cache->ctx,
surface, GST_GL_TEXTURE_TARGET_RECTANGLE, &cache->input_info, surface, GST_GL_TEXTURE_TARGET_RECTANGLE, tex_type,
i, NULL, pixel_buf, (GDestroyNotify) CFRelease); &cache->input_info, i, NULL, pixel_buf, (GDestroyNotify) CFRelease);
gst_buffer_replace_memory (data->output_buffer, i, (GstMemory *) mem); gst_buffer_replace_memory (data->output_buffer, i, (GstMemory *) mem);
} }

View file

@ -141,13 +141,15 @@ check_conversion (TestFrame * frames, guint size)
/* create GL buffer */ /* create GL buffer */
inbuf = gst_buffer_new (); inbuf = gst_buffer_new ();
for (j = 0; j < GST_VIDEO_INFO_N_PLANES (&in_info); j++) { for (j = 0; j < GST_VIDEO_INFO_N_PLANES (&in_info); j++) {
GstVideoGLTextureType tex_type = gst_gl_texture_type_from_format (context,
GST_VIDEO_INFO_FORMAT (&in_info), j);
GstGLVideoAllocationParams *params; GstGLVideoAllocationParams *params;
GstGLBaseMemory *mem; GstGLBaseMemory *mem;
ref_count++; ref_count++;
params = gst_gl_video_allocation_params_new_wrapped_data (context, NULL, params = gst_gl_video_allocation_params_new_wrapped_data (context, NULL,
&in_info, j, NULL, GST_GL_TEXTURE_TARGET_2D, frames[i].data[j], &in_info, j, NULL, GST_GL_TEXTURE_TARGET_2D, tex_type,
&ref_count, _frame_unref); frames[i].data[j], &ref_count, _frame_unref);
mem = gst_gl_base_memory_alloc (base_mem_alloc, mem = gst_gl_base_memory_alloc (base_mem_alloc,
(GstGLAllocationParams *) params); (GstGLAllocationParams *) params);

View file

@ -72,7 +72,7 @@ init (gpointer data)
allocator = gst_gl_memory_allocator_get_default (context); allocator = gst_gl_memory_allocator_get_default (context);
params = params =
gst_gl_video_allocation_params_new (context, NULL, &v_info, 0, NULL, gst_gl_video_allocation_params_new (context, NULL, &v_info, 0, NULL,
GST_GL_TEXTURE_TARGET_2D); GST_GL_TEXTURE_TARGET_2D, GST_VIDEO_GL_TEXTURE_TYPE_RGBA);
/* has to be called in the thread that is going to use the framebuffer */ /* has to be called in the thread that is going to use the framebuffer */
fbo = gst_gl_framebuffer_new (context); fbo = gst_gl_framebuffer_new (context);

View file

@ -75,10 +75,12 @@ GST_START_TEST (test_basic)
gst_video_info_set_format (&v_info, formats[i], width, height); gst_video_info_set_format (&v_info, formats[i], width, height);
for (j = 0; j < GST_VIDEO_INFO_N_PLANES (&v_info); j++) { for (j = 0; j < GST_VIDEO_INFO_N_PLANES (&v_info); j++) {
GstVideoGLTextureType tex_type = gst_gl_texture_type_from_format (context,
GST_VIDEO_INFO_FORMAT (&v_info), j);
GstGLVideoAllocationParams *params; GstGLVideoAllocationParams *params;
params = gst_gl_video_allocation_params_new (context, NULL, &v_info, j, params = gst_gl_video_allocation_params_new (context, NULL, &v_info, j,
NULL, GST_GL_TEXTURE_TARGET_2D); NULL, GST_GL_TEXTURE_TARGET_2D, tex_type);
mem = (GstMemory *) gst_gl_base_memory_alloc (base_mem_alloc, mem = (GstMemory *) gst_gl_base_memory_alloc (base_mem_alloc,
(GstGLAllocationParams *) params); (GstGLAllocationParams *) params);
@ -137,7 +139,7 @@ test_transfer_allocator (const gchar * allocator_name)
gst_video_info_set_format (&v_info, GST_VIDEO_FORMAT_RGBA, 1, 1); gst_video_info_set_format (&v_info, GST_VIDEO_FORMAT_RGBA, 1, 1);
params = gst_gl_video_allocation_params_new (context, NULL, &v_info, 0, params = gst_gl_video_allocation_params_new (context, NULL, &v_info, 0,
NULL, GST_GL_TEXTURE_TARGET_2D); NULL, GST_GL_TEXTURE_TARGET_2D, GST_VIDEO_GL_TEXTURE_TYPE_RGBA);
/* texture creation */ /* texture creation */
mem = (GstMemory *) gst_gl_base_memory_alloc (base_mem_alloc, mem = (GstMemory *) gst_gl_base_memory_alloc (base_mem_alloc,
@ -150,7 +152,8 @@ test_transfer_allocator (const gchar * allocator_name)
/* test wrapping raw data */ /* test wrapping raw data */
params = gst_gl_video_allocation_params_new_wrapped_data (context, NULL, params = gst_gl_video_allocation_params_new_wrapped_data (context, NULL,
&v_info, 0, NULL, GST_GL_TEXTURE_TARGET_2D, rgba_pixel, NULL, NULL); &v_info, 0, NULL, GST_GL_TEXTURE_TARGET_2D,
GST_VIDEO_GL_TEXTURE_TYPE_RGBA, rgba_pixel, NULL, NULL);
mem2 = mem2 =
(GstMemory *) gst_gl_base_memory_alloc (base_mem_alloc, (GstMemory *) gst_gl_base_memory_alloc (base_mem_alloc,
(GstGLAllocationParams *) params); (GstGLAllocationParams *) params);
@ -164,8 +167,9 @@ test_transfer_allocator (const gchar * allocator_name)
/* wrapped texture creation */ /* wrapped texture creation */
params = gst_gl_video_allocation_params_new_wrapped_texture (context, NULL, params = gst_gl_video_allocation_params_new_wrapped_texture (context, NULL,
&v_info, 0, NULL, GST_GL_TEXTURE_TARGET_2D, ((GstGLMemory *) mem)->tex_id, &v_info, 0, NULL, GST_GL_TEXTURE_TARGET_2D,
NULL, NULL); GST_VIDEO_GL_TEXTURE_TYPE_RGBA, ((GstGLMemory *) mem)->tex_id, NULL,
NULL);
mem3 = mem3 =
(GstMemory *) gst_gl_base_memory_alloc (base_mem_alloc, (GstMemory *) gst_gl_base_memory_alloc (base_mem_alloc,
(GstGLAllocationParams *) params); (GstGLAllocationParams *) params);
@ -303,7 +307,8 @@ GST_START_TEST (test_separate_transfer)
gst_video_info_set_format (&v_info, GST_VIDEO_FORMAT_RGBA, 1, 1); gst_video_info_set_format (&v_info, GST_VIDEO_FORMAT_RGBA, 1, 1);
params = gst_gl_video_allocation_params_new_wrapped_data (context, NULL, params = gst_gl_video_allocation_params_new_wrapped_data (context, NULL,
&v_info, 0, NULL, GST_GL_TEXTURE_TARGET_2D, rgba_pixel, NULL, NULL); &v_info, 0, NULL, GST_GL_TEXTURE_TARGET_2D,
GST_VIDEO_GL_TEXTURE_TYPE_RGBA, rgba_pixel, NULL, NULL);
mem = mem =
(GstMemory *) gst_gl_base_memory_alloc (base_mem_alloc, (GstMemory *) gst_gl_base_memory_alloc (base_mem_alloc,
(GstGLAllocationParams *) params); (GstGLAllocationParams *) params);

View file

@ -217,7 +217,8 @@ GST_START_TEST (test_upload_buffer)
/* create GL buffer */ /* create GL buffer */
buffer = gst_buffer_new (); buffer = gst_buffer_new ();
params = gst_gl_video_allocation_params_new_wrapped_data (context, NULL, params = gst_gl_video_allocation_params_new_wrapped_data (context, NULL,
&in_info, 0, NULL, GST_GL_TEXTURE_TARGET_2D, rgba_data, NULL, NULL); &in_info, 0, NULL, GST_GL_TEXTURE_TARGET_2D,
GST_VIDEO_GL_TEXTURE_TYPE_RGBA, rgba_data, NULL, NULL);
gl_mem = (GstGLMemory *) gst_gl_base_memory_alloc (base_mem_alloc, gl_mem = (GstGLMemory *) gst_gl_base_memory_alloc (base_mem_alloc,
(GstGLAllocationParams *) params); (GstGLAllocationParams *) params);
gst_gl_allocation_params_free ((GstGLAllocationParams *) params); gst_gl_allocation_params_free ((GstGLAllocationParams *) params);