mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-02 21:48:55 +00:00
glmemory: add gst_gl_memory_allocator_get_default
Add gst_gl_memory_allocator_get_default to get the default allocator based on the opengl version. Allows us to stop hardcoding the PBO allocator which isn't supported on gles2. Fixes GL upload on iOS9 among other things.
This commit is contained in:
parent
a3ebe19d87
commit
6961945110
8 changed files with 42 additions and 15 deletions
|
@ -698,8 +698,8 @@ gst_gl_overlay_load_jpeg (GstGLOverlay * overlay, FILE * fp)
|
|||
gst_video_info_align (&v_info, &v_align);
|
||||
|
||||
mem_allocator =
|
||||
GST_GL_BASE_MEMORY_ALLOCATOR (gst_allocator_find
|
||||
(GST_GL_MEMORY_PBO_ALLOCATOR_NAME));
|
||||
GST_GL_BASE_MEMORY_ALLOCATOR (gst_gl_memory_allocator_get_default
|
||||
(GST_GL_BASE_FILTER (overlay)->context));
|
||||
params =
|
||||
gst_gl_video_allocation_params_new (GST_GL_BASE_FILTER (overlay)->context,
|
||||
NULL, &v_info, 0, &v_align, GST_GL_TEXTURE_TARGET_2D);
|
||||
|
@ -813,8 +813,8 @@ gst_gl_overlay_load_png (GstGLOverlay * overlay, FILE * fp)
|
|||
|
||||
gst_video_info_set_format (&v_info, GST_VIDEO_FORMAT_RGBA, width, height);
|
||||
mem_allocator =
|
||||
GST_GL_BASE_MEMORY_ALLOCATOR (gst_allocator_find
|
||||
(GST_GL_MEMORY_PBO_ALLOCATOR_NAME));
|
||||
GST_GL_BASE_MEMORY_ALLOCATOR (gst_gl_memory_allocator_get_default
|
||||
(GST_GL_BASE_FILTER (overlay)->context));
|
||||
params =
|
||||
gst_gl_video_allocation_params_new (GST_GL_BASE_FILTER (overlay)->context,
|
||||
NULL, &v_info, 0, NULL, GST_GL_TEXTURE_TARGET_2D);
|
||||
|
|
|
@ -122,7 +122,8 @@ gst_gl_buffer_pool_set_config (GstBufferPool * pool, GstStructure * config)
|
|||
if (allocator /* && GST_IS_GL_MEMORY_ALLOCATOR (allocator) FIXME EGLImage */ ) {
|
||||
priv->allocator = gst_object_ref (allocator);
|
||||
} else {
|
||||
priv->allocator = gst_allocator_find (GST_GL_MEMORY_PBO_ALLOCATOR_NAME);
|
||||
priv->allocator =
|
||||
GST_ALLOCATOR (gst_gl_memory_allocator_get_default (glpool->context));
|
||||
g_assert (priv->allocator);
|
||||
}
|
||||
|
||||
|
|
|
@ -1173,3 +1173,22 @@ gst_gl_memory_setup_buffer (GstGLMemoryAllocator * allocator,
|
|||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
GstGLMemoryAllocator *
|
||||
gst_gl_memory_allocator_get_default (GstGLContext * context)
|
||||
{
|
||||
GstGLMemoryAllocator *allocator = NULL;
|
||||
|
||||
g_return_val_if_fail (GST_IS_GL_CONTEXT (context), NULL);
|
||||
|
||||
if (USING_OPENGL (context) || USING_OPENGL3 (context)
|
||||
|| USING_GLES3 (context)) {
|
||||
allocator = (GstGLMemoryAllocator *)
|
||||
gst_allocator_find (GST_GL_MEMORY_PBO_ALLOCATOR_NAME);
|
||||
} else {
|
||||
allocator = (GstGLMemoryAllocator *)
|
||||
gst_allocator_find (GST_GL_MEMORY_ALLOCATOR_NAME);
|
||||
}
|
||||
|
||||
return allocator;
|
||||
}
|
||||
|
|
|
@ -216,6 +216,9 @@ gboolean gst_gl_memory_setup_buffer (GstGLMemoryAllocato
|
|||
GstBuffer * buffer,
|
||||
GstGLVideoAllocationParams * params);
|
||||
|
||||
|
||||
GstGLMemoryAllocator * gst_gl_memory_allocator_get_default (GstGLContext *context);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* _GST_GL_MEMORY_H_ */
|
||||
|
|
|
@ -348,7 +348,8 @@ gst_gl_composition_overlay_upload (GstGLCompositionOverlay * overlay,
|
|||
GstGLBaseMemoryAllocator *mem_allocator;
|
||||
GstAllocator *allocator;
|
||||
|
||||
allocator = gst_allocator_find (GST_GL_MEMORY_PBO_ALLOCATOR_NAME);
|
||||
allocator =
|
||||
GST_ALLOCATOR (gst_gl_memory_allocator_get_default (overlay->context));
|
||||
mem_allocator = GST_GL_BASE_MEMORY_ALLOCATOR (allocator);
|
||||
|
||||
gst_gl_composition_overlay_add_transformation (overlay, buf);
|
||||
|
|
|
@ -223,7 +223,9 @@ _gl_memory_upload_propose_allocation (gpointer impl, GstQuery * decide_query,
|
|||
GstAllocationParams params;
|
||||
gst_allocation_params_init (¶ms);
|
||||
|
||||
allocator = gst_allocator_find (GST_GL_MEMORY_PBO_ALLOCATOR_NAME);
|
||||
allocator =
|
||||
GST_ALLOCATOR (gst_gl_memory_allocator_get_default (upload->
|
||||
upload->context));
|
||||
gst_query_add_allocation_param (query, allocator, ¶ms);
|
||||
gst_object_unref (allocator);
|
||||
}
|
||||
|
@ -696,9 +698,7 @@ _upload_meta_upload_perform (gpointer impl, GstBuffer * buffer,
|
|||
guint max_planes = GST_VIDEO_INFO_N_PLANES (in_info);
|
||||
GstGLMemoryAllocator *allocator;
|
||||
|
||||
allocator =
|
||||
GST_GL_MEMORY_ALLOCATOR (gst_allocator_find
|
||||
(GST_GL_MEMORY_PBO_ALLOCATOR_NAME));
|
||||
allocator = gst_gl_memory_allocator_get_default (upload->upload->context);
|
||||
|
||||
/* Support stereo views for separated multiview mode */
|
||||
if (GST_VIDEO_INFO_MULTIVIEW_MODE (in_info) ==
|
||||
|
@ -916,8 +916,8 @@ _raw_data_upload_perform (gpointer impl, GstBuffer * buffer,
|
|||
guint n_mem = GST_VIDEO_INFO_N_PLANES (in_info);
|
||||
|
||||
allocator =
|
||||
GST_GL_BASE_MEMORY_ALLOCATOR (gst_allocator_find
|
||||
(GST_GL_MEMORY_PBO_ALLOCATOR_NAME));
|
||||
GST_GL_BASE_MEMORY_ALLOCATOR (gst_gl_memory_allocator_get_default
|
||||
(raw->upload->context));
|
||||
|
||||
/* FIXME Use a buffer pool to cache the generated textures */
|
||||
/* FIXME: multiview support with separated left/right frames? */
|
||||
|
|
|
@ -1897,7 +1897,9 @@ _gen_buffer (GstGLViewConvert * viewconvert, GstBuffer ** target)
|
|||
|
||||
*target = gst_buffer_new ();
|
||||
|
||||
allocator = gst_allocator_find (GST_GL_MEMORY_PBO_ALLOCATOR_NAME);
|
||||
allocator =
|
||||
GST_ALLOCATOR (gst_gl_memory_allocator_get_default
|
||||
(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);
|
||||
|
@ -2037,7 +2039,8 @@ _do_view_convert (GstGLContext * context, GstGLViewConvert * viewconvert)
|
|||
gst_video_info_set_format (&temp_info, GST_VIDEO_FORMAT_RGBA, out_width,
|
||||
out_height);
|
||||
|
||||
allocator = gst_allocator_find (GST_GL_MEMORY_PBO_ALLOCATOR_NAME);
|
||||
allocator =
|
||||
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);
|
||||
|
|
|
@ -155,7 +155,7 @@ gl_mem_from_buffer (GstVideoTextureCache * cache,
|
|||
GstGLBaseMemoryAllocator *base_mem_alloc;
|
||||
GstGLVideoAllocationParams *params;
|
||||
|
||||
base_mem_alloc = GST_GL_BASE_MEMORY_ALLOCATOR (gst_allocator_find (GST_GL_MEMORY_PBO_ALLOCATOR_NAME));
|
||||
base_mem_alloc = GST_GL_BASE_MEMORY_ALLOCATOR (gst_gl_memory_allocator_get_default (cache->ctx));
|
||||
|
||||
*mem1 = NULL;
|
||||
*mem2 = NULL;
|
||||
|
|
Loading…
Reference in a new issue