summaryrefslogtreecommitdiff
path: root/gst-libs/gst
diff options
context:
space:
mode:
authorMatthew Waters <matthew@centricular.com>2016-06-28 13:51:22 +1000
committerMatthew Waters <matthew@centricular.com>2016-06-29 18:04:28 +1000
commit989200820d43c78fb179d7984827800d83787390 (patch)
tree4e26370accaa68b3e7b96610aed3b518c57766f9 /gst-libs/gst
parent6958b7a0147334e6d02c30f6f236fbd7e1089081 (diff)
downloadgstreamer-plugins-bad-989200820d43c78fb179d7984827800d83787390.tar.gz
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.
Diffstat (limited to 'gst-libs/gst')
-rw-r--r--gst-libs/gst/gl/egl/gstglmemoryegl.c23
-rw-r--r--gst-libs/gst/gl/gstglbufferpool.c4
-rw-r--r--gst-libs/gst/gl/gstglcolorconvert.c3
-rw-r--r--gst-libs/gst/gl/gstglmemory.c105
-rw-r--r--gst-libs/gst/gl/gstglmemory.h10
-rw-r--r--gst-libs/gst/gl/gstglmemorypbo.c63
-rw-r--r--gst-libs/gst/gl/gstgloverlaycompositor.c3
-rw-r--r--gst-libs/gst/gl/gstglupload.c27
-rw-r--r--gst-libs/gst/gl/gstglviewconvert.c8
9 files changed, 126 insertions, 120 deletions
diff --git a/gst-libs/gst/gl/egl/gstglmemoryegl.c b/gst-libs/gst/gl/egl/gstglmemoryegl.c
index 15008c13e..0094c34c3 100644
--- a/gst-libs/gst/gl/egl/gstglmemoryegl.c
+++ b/gst-libs/gst/gl/egl/gstglmemoryegl.c
@@ -66,8 +66,8 @@ EGLDisplay
gst_gl_memory_egl_get_display (GstGLMemoryEGL * mem)
{
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)->
- egl_display;
+ return GST_GL_CONTEXT_EGL (_gl_mem_get_parent (mem)->mem.mem.
+ context)->egl_display;
}
GstVideoGLTextureOrientation
@@ -99,17 +99,6 @@ _gl_mem_destroy (GstGLMemoryEGL * 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 *
_gl_mem_egl_alloc (GstGLBaseMemoryAllocator * allocator,
GstGLVideoAllocationParams * params)
@@ -136,10 +125,10 @@ _gl_mem_egl_alloc (GstGLBaseMemoryAllocator * allocator,
mem->image = gst_egl_image_ref (params->parent.gl_handle);
}
- _gl_mem_init (mem, GST_ALLOCATOR_CAST (allocator), NULL,
- params->parent.context, params->target, params->parent.alloc_params,
- params->v_info, params->plane, params->valign, params->parent.user_data,
- params->parent.notify);
+ gst_gl_memory_init (GST_GL_MEMORY_CAST (mem), GST_ALLOCATOR_CAST (allocator),
+ NULL, params->parent.context, params->target, params->tex_type,
+ params->parent.alloc_params, params->v_info, params->plane,
+ params->valign, params->parent.user_data, params->parent.notify);
return mem;
}
diff --git a/gst-libs/gst/gl/gstglbufferpool.c b/gst-libs/gst/gl/gstglbufferpool.c
index 222baba74..218169aa8 100644
--- a/gst-libs/gst/gl/gstglbufferpool.c
+++ b/gst-libs/gst/gl/gstglbufferpool.c
@@ -132,7 +132,7 @@ gst_gl_buffer_pool_set_config (GstBufferPool * pool, GstStructure * config)
gst_buffer_pool_config_get_gl_allocation_params (config);
if (!priv->gl_params)
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;
@@ -262,7 +262,7 @@ gst_gl_buffer_pool_alloc (GstBufferPool * pool, GstBuffer ** buffer,
}
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;
if (priv->add_glsyncmeta)
diff --git a/gst-libs/gst/gl/gstglcolorconvert.c b/gst-libs/gst/gl/gstglcolorconvert.c
index 0c6a69ff9..adc54fc23 100644
--- a/gst-libs/gst/gl/gstglcolorconvert.c
+++ b/gst-libs/gst/gl/gstglcolorconvert.c
@@ -2234,7 +2234,8 @@ _do_convert_one_view (GstGLContext * context, GstGLColorConvert * convert,
allocator = gst_allocator_find (GST_GL_MEMORY_ALLOCATOR_NAME);
base_mem_allocator = GST_GL_BASE_MEMORY_ALLOCATOR (allocator);
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] =
(GstGLMemory *) gst_gl_base_memory_alloc (base_mem_allocator,
diff --git a/gst-libs/gst/gl/gstglmemory.c b/gst-libs/gst/gl/gstglmemory.c
index 20e1a64fc..73c3b591f 100644
--- a/gst-libs/gst/gl/gstglmemory.c
+++ b/gst-libs/gst/gl/gstglmemory.c
@@ -275,8 +275,9 @@ _gl_tex_create (GstGLMemory * gl_mem, GError ** error)
void
gst_gl_memory_init (GstGLMemory * mem, GstAllocator * allocator,
GstMemory * parent, GstGLContext * context, GstGLTextureTarget target,
- GstAllocationParams * params, GstVideoInfo * info, guint plane,
- GstVideoAlignment * valign, gpointer user_data, GDestroyNotify notify)
+ GstVideoGLTextureType tex_type, GstAllocationParams * params,
+ GstVideoInfo * info, guint plane, GstVideoAlignment * valign,
+ gpointer user_data, GDestroyNotify notify)
{
const gchar *target_str;
gsize size;
@@ -307,9 +308,7 @@ gst_gl_memory_init (GstGLMemory * mem, GstAllocator * allocator,
size = gst_gl_get_plane_data_size (info, valign, plane);
mem->tex_target = target;
- mem->tex_type =
- gst_gl_texture_type_from_format (context, GST_VIDEO_INFO_FORMAT (info),
- plane);
+ mem->tex_type = tex_type;
mem->plane = plane;
_calculate_unpack_length (mem, context);
@@ -638,12 +637,21 @@ gst_gl_memory_copy_teximage (GstGLMemory * src, guint tex_id,
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,
GST_MAP_READ | GST_MAP_GL)) {
GST_CAT_ERROR (GST_CAT_GL_MEMORY,
"Failed to map source memory for copying");
goto error;
}
+
src_tex_id = *(guint *) sinfo.data;
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);
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_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 {
+ if (!GST_MEMORY_FLAG_IS_SET (src, GST_GL_BASE_MEMORY_TRANSFER_NEED_UPLOAD)) {
GstMapInfo dinfo;
if (!gst_memory_map (GST_MEMORY_CAST (dest), &dinfo,
GST_MAP_WRITE | GST_MAP_GL)) {
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));
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))) {
GST_CAT_WARNING (GST_CAT_GL_MEMORY, "Could not copy GL Memory");
gst_memory_unmap (GST_MEMORY_CAST (dest), &dinfo);
- gst_memory_unref (GST_MEMORY_CAST (dest));
- return NULL;
+ goto memcpy;
}
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;
@@ -826,9 +834,9 @@ _default_gl_tex_alloc (GstGLMemoryAllocator * allocator,
}
gst_gl_memory_init (mem, GST_ALLOCATOR_CAST (allocator), NULL,
- params->parent.context, params->target, params->parent.alloc_params,
- params->v_info, params->plane, params->valign, params->parent.user_data,
- params->parent.notify);
+ params->parent.context, params->target, params->tex_type,
+ params->parent.alloc_params, params->v_info, params->plane,
+ params->valign, params->parent.user_data, params->parent.notify);
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);
@@ -1063,6 +1071,7 @@ _gst_gl_video_allocation_params_set_video_alignment (GstGLVideoAllocationParams
* @plane: the video plane @wrapped_data represents
* @valign: (allow-none): any #GstVideoAlignment applied to symem mappings of @wrapped_data
* @target: the #GstGLTextureTarget
+ * @tex_type: the #GstVideoGLTextureType
* @wrapped_data: (allow-none): the optional data pointer to wrap
* @gl_handle: the optional OpenGL handle to wrap or 0
* @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,
GstAllocationParams * alloc_params, GstVideoInfo * v_info,
guint plane, GstVideoAlignment * valign, GstGLTextureTarget target,
- gpointer wrapped_data, gpointer gl_handle, gpointer user_data,
- GDestroyNotify notify)
+ GstVideoGLTextureType tex_type, gpointer wrapped_data, gpointer gl_handle,
+ gpointer user_data, GDestroyNotify notify)
{
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);
params->target = target;
+ params->tex_type = tex_type;
params->plane = plane;
return TRUE;
@@ -1114,11 +1124,12 @@ gst_gl_video_allocation_params_init_full (GstGLVideoAllocationParams * params,
/**
* gst_gl_video_allocation_params_new:
* @context: a #GstGLContext
- * @alloc_params: (allow-none): the #GstAllocationParams for @wrapped_data
- * @v_info: the #GstVideoInfo for @wrapped_data
- * @plane: the video plane @wrapped_data represents
- * @valign: (allow-none): any #GstVideoAlignment applied to symem mappings of @wrapped_data
- * @target: the #GstGLTextureTarget for @wrapped_data
+ * @alloc_params: (allow-none): the #GstAllocationParams for sysmem mappings of the texture
+ * @v_info: the #GstVideoInfo for the texture
+ * @plane: the video plane of @v_info to allocate
+ * @valign: (allow-none): any #GstVideoAlignment applied to symem mappings of the texture
+ * @target: the #GstGLTextureTarget for the created textures
+ * @target: the #GstVideoGLTextureType for the created textures
*
* Returns: a new #GstGLVideoAllocationParams for allocating #GstGLMemory's
*
@@ -1127,7 +1138,8 @@ gst_gl_video_allocation_params_init_full (GstGLVideoAllocationParams * params,
GstGLVideoAllocationParams *
gst_gl_video_allocation_params_new (GstGLContext * context,
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);
@@ -1139,7 +1151,7 @@ gst_gl_video_allocation_params_new (GstGLContext * context,
gst_gl_video_allocation_params_copy_data,
(GstGLAllocationParamsFreeFunc)
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);
return NULL;
}
@@ -1155,6 +1167,7 @@ gst_gl_video_allocation_params_new (GstGLContext * context,
* @plane: the video plane @wrapped_data represents
* @valign: (allow-none): any #GstVideoAlignment applied to symem mappings of @wrapped_data
* @target: the #GstGLTextureTarget for @wrapped_data
+ * @tex_type: the #GstVideoGLTextureType for @wrapped_data
* @wrapped_data: the data pointer to wrap
* @user_data: (allow-none): user data to call @notify with
* @notify: (allow-none): a #GDestroyNotify
@@ -1167,7 +1180,8 @@ GstGLVideoAllocationParams *
gst_gl_video_allocation_params_new_wrapped_data (GstGLContext * context,
GstAllocationParams * alloc_params, GstVideoInfo * v_info, guint plane,
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);
@@ -1179,7 +1193,8 @@ gst_gl_video_allocation_params_new_wrapped_data (GstGLContext * context,
gst_gl_video_allocation_params_copy_data,
(GstGLAllocationParamsFreeFunc)
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);
return NULL;
}
@@ -1195,6 +1210,7 @@ gst_gl_video_allocation_params_new_wrapped_data (GstGLContext * context,
* @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
+ * @tex_type: the #GstVideoGLTextureType 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
@@ -1211,7 +1227,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)
+ GstVideoGLTextureType tex_type, gpointer gl_handle, gpointer user_data,
+ GDestroyNotify notify)
{
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,
(GstGLAllocationParamsFreeFunc)
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);
return NULL;
}
@@ -1239,6 +1257,7 @@ gst_gl_video_allocation_params_new_wrapped_gl_handle (GstGLContext * context,
* @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
+ * @tex_type: the #GstGLTextureType for @tex_id
* @tex_id: the GL texture to wrap
* @user_data: (allow-none): user data to call @notify with
* @notify: (allow-none): a #GDestroyNotify
@@ -1251,11 +1270,12 @@ GstGLVideoAllocationParams *
gst_gl_video_allocation_params_new_wrapped_texture (GstGLContext * context,
GstAllocationParams * alloc_params, GstVideoInfo * v_info, guint plane,
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,
- alloc_params, v_info, plane, valign, target, GUINT_TO_POINTER (tex_id),
- user_data, notify);
+ alloc_params, v_info, plane, valign, target, tex_type,
+ 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,
src_vid->valign);
dest_vid->target = src_vid->target;
+ dest_vid->tex_type = src_vid->tex_type;
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
* @buffer: a #GstBuffer to setup
* @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
*
@@ -1321,7 +1343,8 @@ gst_gl_video_allocation_params_copy_data (GstGLVideoAllocationParams * src_vid,
gboolean
gst_gl_memory_setup_buffer (GstGLMemoryAllocator * allocator,
GstBuffer * buffer, GstGLVideoAllocationParams * params,
- gpointer * wrapped_data, gsize n_wrapped_pointers)
+ GstVideoGLTextureType * tex_types, gpointer * wrapped_data,
+ gsize n_wrapped_pointers)
{
GstGLBaseMemoryAllocator *base_allocator;
guint n_mem, i, v, views;
@@ -1347,6 +1370,14 @@ gst_gl_memory_setup_buffer (GstGLMemoryAllocator * allocator,
for (i = 0; i < n_mem; i++) {
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;
if (alloc_flags & GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_WRAP_SYSMEM) {
g_return_val_if_fail (wrapped_data != NULL, FALSE);
diff --git a/gst-libs/gst/gl/gstglmemory.h b/gst-libs/gst/gl/gstglmemory.h
index c180c8342..f36f64beb 100644
--- a/gst-libs/gst/gl/gstglmemory.h
+++ b/gst-libs/gst/gl/gstglmemory.h
@@ -92,6 +92,7 @@ struct _GstGLVideoAllocationParams
guint plane;
GstVideoAlignment *valign;
GstGLTextureTarget target;
+ GstVideoGLTextureType tex_type;
};
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,
GstVideoAlignment * valign,
GstGLTextureTarget target,
+ GstVideoGLTextureType tex_type,
gpointer wrapped_data,
gpointer gl_handle,
gpointer user_data,
@@ -114,13 +116,15 @@ GstGLVideoAllocationParams * gst_gl_video_allocation_params_new (GstGLContext *
GstVideoInfo * v_info,
guint plane,
GstVideoAlignment * valign,
- GstGLTextureTarget target);
+ GstGLTextureTarget target,
+ GstVideoGLTextureType tex_type);
GstGLVideoAllocationParams * gst_gl_video_allocation_params_new_wrapped_data (GstGLContext * context,
GstAllocationParams * alloc_params,
GstVideoInfo * v_info,
guint plane,
GstVideoAlignment * valign,
GstGLTextureTarget target,
+ GstVideoGLTextureType tex_type,
gpointer wrapped_data,
gpointer user_data,
GDestroyNotify notify);
@@ -131,6 +135,7 @@ GstGLVideoAllocationParams * gst_gl_video_allocation_params_new_wrapped_texture
guint plane,
GstVideoAlignment * valign,
GstGLTextureTarget target,
+ GstVideoGLTextureType tex_type,
guint tex_id,
gpointer user_data,
GDestroyNotify notify);
@@ -141,6 +146,7 @@ GstGLVideoAllocationParams * gst_gl_video_allocation_params_new_wrapped_gl_handl
guint plane,
GstVideoAlignment * valign,
GstGLTextureTarget target,
+ GstVideoGLTextureType tex_type,
gpointer gl_handle,
gpointer user_data,
GDestroyNotify notify);
@@ -192,6 +198,7 @@ void gst_gl_memory_init (GstGLMemory * mem,
GstMemory * parent,
GstGLContext * context,
GstGLTextureTarget target,
+ GstVideoGLTextureType tex_type,
GstAllocationParams *params,
GstVideoInfo * info,
guint plane,
@@ -227,6 +234,7 @@ guint gst_gl_memory_get_texture_id (GstGLMemory * gl_me
gboolean gst_gl_memory_setup_buffer (GstGLMemoryAllocator * allocator,
GstBuffer * buffer,
GstGLVideoAllocationParams * params,
+ GstVideoGLTextureType *tex_types,
gpointer *wrapped_data,
gsize n_wrapped_pointers);
diff --git a/gst-libs/gst/gl/gstglmemorypbo.c b/gst-libs/gst/gl/gstglmemorypbo.c
index 30b9ecb46..e749488ca 100644
--- a/gst-libs/gst/gl/gstglmemorypbo.c
+++ b/gst-libs/gst/gl/gstglmemorypbo.c
@@ -217,34 +217,6 @@ _gl_mem_create (GstGLMemoryPBO * gl_mem, GError ** error)
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
_read_pixels_to_pbo (GstGLMemoryPBO * gl_mem)
{
@@ -601,18 +573,12 @@ _gl_mem_copy (GstGLMemoryPBO * src, gssize offset, gssize size)
size);
}
- dest = (GstMemory *) _gl_mem_new (allocator, NULL, src->mem.mem.context,
- src->mem.tex_target, &params, &src->mem.info, src->mem.plane,
- &src->mem.valign, NULL, NULL);
+ dest = (GstMemory *) g_new0 (GstGLMemoryPBO, 1);
+ gst_gl_memory_init (GST_GL_MEMORY_CAST (dest), allocator, 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_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 {
+ if (!GST_MEMORY_FLAG_IS_SET (src, GST_GL_BASE_MEMORY_TRANSFER_NEED_UPLOAD)) {
GstMapInfo 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))) {
GST_CAT_WARNING (GST_CAT_GL_MEMORY, "Could not copy GL Memory");
gst_memory_unmap (GST_MEMORY_CAST (dest), &dinfo);
- gst_memory_unref (GST_MEMORY_CAST (dest));
- return NULL;
+ goto memcpy;
}
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;
@@ -678,10 +651,10 @@ _gl_mem_pbo_alloc (GstGLBaseMemoryAllocator * allocator,
mem->mem.texture_wrapped = TRUE;
}
- _gl_mem_init (mem, GST_ALLOCATOR_CAST (allocator), NULL,
- params->parent.context, params->target, params->parent.alloc_params,
- params->v_info, params->plane, params->valign, params->parent.user_data,
- params->parent.notify);
+ gst_gl_memory_init (GST_GL_MEMORY_CAST (mem), GST_ALLOCATOR_CAST (allocator),
+ NULL, params->parent.context, params->target, params->tex_type,
+ params->parent.alloc_params, params->v_info, params->plane,
+ params->valign, params->parent.user_data, params->parent.notify);
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);
diff --git a/gst-libs/gst/gl/gstgloverlaycompositor.c b/gst-libs/gst/gl/gstgloverlaycompositor.c
index f7d0639d1..f6548a06b 100644
--- a/gst-libs/gst/gl/gstgloverlaycompositor.c
+++ b/gst-libs/gst/gl/gstgloverlaycompositor.c
@@ -356,7 +356,8 @@ gst_gl_composition_overlay_upload (GstGLCompositionOverlay * overlay,
params = gst_gl_video_allocation_params_new_wrapped_data (overlay->context,
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 =
(GstGLMemory *) gst_gl_base_memory_alloc (mem_allocator,
diff --git a/gst-libs/gst/gl/gstglupload.c b/gst-libs/gst/gl/gstglupload.c
index b68f7f16d..2fd8793b2 100644
--- a/gst-libs/gst/gl/gstglupload.c
+++ b/gst-libs/gst/gl/gstglupload.c
@@ -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);
@@ -582,9 +582,9 @@ _dma_buf_upload_accept (gpointer impl, GstBuffer * buffer, GstCaps * in_caps,
if (dmabuf->params)
gst_gl_allocation_params_free ((GstGLAllocationParams *) dmabuf->params);
if (!(dmabuf->params =
- gst_gl_video_allocation_params_new_wrapped_gl_handle (dmabuf->upload->
- context, NULL, &dmabuf->upload->priv->in_info, -1, NULL,
- GST_GL_TEXTURE_TARGET_2D, NULL, NULL, NULL)))
+ gst_gl_video_allocation_params_new_wrapped_gl_handle (dmabuf->
+ upload->context, NULL, &dmabuf->upload->priv->in_info, -1, NULL,
+ GST_GL_TEXTURE_TARGET_2D, 0, NULL, NULL, NULL)))
return FALSE;
/* Find and validate all memories */
@@ -649,7 +649,7 @@ _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,
(gpointer *) dmabuf->eglimage, gst_buffer_n_memory (dmabuf->outbuf));
gst_object_unref (allocator);
}
@@ -785,7 +785,7 @@ _upload_meta_upload_accept (gpointer impl, GstBuffer * buffer,
if (!(upload->params =
gst_gl_video_allocation_params_new (upload->upload->context, NULL,
&upload->upload->priv->in_info, -1, NULL,
- GST_GL_TEXTURE_TARGET_2D)))
+ GST_GL_TEXTURE_TARGET_2D, 0)))
return FALSE;
if (buffer) {
@@ -817,11 +817,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));
+ 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));
+ 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 =
@@ -876,7 +876,8 @@ _upload_meta_upload_perform (gpointer impl, GstBuffer * buffer,
/* FIXME: buffer pool */
*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);
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 =
gst_gl_video_allocation_params_new_wrapped_data (raw->upload->context,
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)))
return FALSE;
diff --git a/gst-libs/gst/gl/gstglviewconvert.c b/gst-libs/gst/gl/gstglviewconvert.c
index 2fcbb81d9..0d5026083 100644
--- a/gst-libs/gst/gl/gstglviewconvert.c
+++ b/gst-libs/gst/gl/gstglviewconvert.c
@@ -1952,9 +1952,10 @@ _gen_buffer (GstGLViewConvert * viewconvert, GstBuffer ** target)
(viewconvert->context));
mem_allocator = GST_GL_MEMORY_ALLOCATOR (allocator);
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_object_unref (allocator);
return FALSE;
@@ -2093,7 +2094,8 @@ _do_view_convert (GstGLContext * context, GstGLViewConvert * viewconvert)
GST_ALLOCATOR (gst_gl_memory_allocator_get_default (context));
base_mem_allocator = GST_GL_BASE_MEMORY_ALLOCATOR (allocator);
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] =
(GstGLMemory *) gst_gl_base_memory_alloc (base_mem_allocator,