mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-09 00:45:56 +00:00
gl: upload: gl memory method should not provide pool for system memory caps
In _gl_memory_upload_propose_allocation(), when output target is "external-oes", then we should not provide GL allocator and pool in the allocation query. This is because the "external-oes" kind memory can never be mapped directly and the upstream element may misuse it. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5468>
This commit is contained in:
parent
ea35adc55f
commit
c5f50b1602
1 changed files with 29 additions and 16 deletions
|
@ -445,9 +445,11 @@ _gl_memory_upload_propose_allocation (gpointer impl, GstQuery * decide_query,
|
||||||
GstBufferPool *pool = NULL;
|
GstBufferPool *pool = NULL;
|
||||||
guint n_pools, i;
|
guint n_pools, i;
|
||||||
GstCaps *caps;
|
GstCaps *caps;
|
||||||
GstCapsFeatures *features;
|
GstCapsFeatures *features_gl, *features_sys;
|
||||||
GstAllocator *allocator;
|
GstAllocator *allocator;
|
||||||
GstAllocationParams params;
|
GstAllocationParams params;
|
||||||
|
gboolean use_sys_mem = FALSE;
|
||||||
|
const gchar *target_pool_option_str = NULL;
|
||||||
|
|
||||||
gst_query_parse_allocation (query, &caps, NULL);
|
gst_query_parse_allocation (query, &caps, NULL);
|
||||||
if (caps == NULL)
|
if (caps == NULL)
|
||||||
|
@ -455,14 +457,34 @@ _gl_memory_upload_propose_allocation (gpointer impl, GstQuery * decide_query,
|
||||||
|
|
||||||
g_assert (gst_caps_is_fixed (caps));
|
g_assert (gst_caps_is_fixed (caps));
|
||||||
|
|
||||||
features = gst_caps_features_new (GST_CAPS_FEATURE_MEMORY_GL_MEMORY,
|
features_gl = gst_caps_features_new (GST_CAPS_FEATURE_MEMORY_GL_MEMORY, NULL);
|
||||||
GST_CAPS_FEATURE_MEMORY_SYSTEM_MEMORY, NULL);
|
features_sys =
|
||||||
|
gst_caps_features_new (GST_CAPS_FEATURE_MEMORY_SYSTEM_MEMORY, NULL);
|
||||||
/* Only offer our custom allocator if that type of memory was negotiated. */
|
/* Only offer our custom allocator if that type of memory was negotiated. */
|
||||||
if (!_filter_caps_with_features (caps, features, NULL)) {
|
if (_filter_caps_with_features (caps, features_sys, NULL)) {
|
||||||
gst_caps_features_free (features);
|
use_sys_mem = TRUE;
|
||||||
|
} else if (!_filter_caps_with_features (caps, features_gl, NULL)) {
|
||||||
|
gst_caps_features_free (features_gl);
|
||||||
|
gst_caps_features_free (features_sys);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
gst_caps_features_free (features);
|
gst_caps_features_free (features_gl);
|
||||||
|
gst_caps_features_free (features_sys);
|
||||||
|
|
||||||
|
if (upload->upload->priv->out_caps) {
|
||||||
|
GstGLTextureTarget target;
|
||||||
|
|
||||||
|
target = _caps_get_texture_target (upload->upload->priv->out_caps,
|
||||||
|
GST_GL_TEXTURE_TARGET_2D);
|
||||||
|
|
||||||
|
/* Do not provide the allocator and pool for system memory caps
|
||||||
|
because the external oes kind GL memory can not be mapped. */
|
||||||
|
if (target == GST_GL_TEXTURE_TARGET_EXTERNAL_OES && use_sys_mem)
|
||||||
|
return;
|
||||||
|
|
||||||
|
target_pool_option_str =
|
||||||
|
gst_gl_texture_target_to_buffer_pool_option (target);
|
||||||
|
}
|
||||||
|
|
||||||
gst_allocation_params_init (¶ms);
|
gst_allocation_params_init (¶ms);
|
||||||
|
|
||||||
|
@ -510,17 +532,8 @@ _gl_memory_upload_propose_allocation (gpointer impl, GstQuery * decide_query,
|
||||||
gst_buffer_pool_config_set_gl_min_free_queue_size (config, 1);
|
gst_buffer_pool_config_set_gl_min_free_queue_size (config, 1);
|
||||||
gst_buffer_pool_config_add_option (config,
|
gst_buffer_pool_config_add_option (config,
|
||||||
GST_BUFFER_POOL_OPTION_GL_SYNC_META);
|
GST_BUFFER_POOL_OPTION_GL_SYNC_META);
|
||||||
if (upload->upload->priv->out_caps) {
|
if (target_pool_option_str)
|
||||||
GstGLTextureTarget target;
|
|
||||||
const gchar *target_pool_option_str;
|
|
||||||
|
|
||||||
target =
|
|
||||||
_caps_get_texture_target (upload->upload->priv->out_caps,
|
|
||||||
GST_GL_TEXTURE_TARGET_2D);
|
|
||||||
target_pool_option_str =
|
|
||||||
gst_gl_texture_target_to_buffer_pool_option (target);
|
|
||||||
gst_buffer_pool_config_add_option (config, target_pool_option_str);
|
gst_buffer_pool_config_add_option (config, target_pool_option_str);
|
||||||
}
|
|
||||||
|
|
||||||
if (!gst_buffer_pool_set_config (pool, config)) {
|
if (!gst_buffer_pool_set_config (pool, config)) {
|
||||||
gst_object_unref (pool);
|
gst_object_unref (pool);
|
||||||
|
|
Loading…
Reference in a new issue