mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-26 11:41:09 +00:00
glupload: make gl memory upload manner only consider memory:GLMemory feature
The current _gl_memory_upload_transform_caps() only simply apply "memory:GLMemory" to all input caps to transform the output caps. This is not precise and may cause problem. For example, if the input caps include: video/x-raw(memory:DMABuf), width=(int)1920, height=(int)1080, \ interlace-mode=(string)progressive, multiview-mode=(string)mono, \ framerate=(fraction)30/1, drm-format=(string)NV12:0x0100000000000002 it will be changed as video/x-raw(memory:GLMemory), width=(int)1920, height=(int)1080, \ interlace-mode=(string)progressive, multiview-mode=(string)mono, \ framerate=(fraction)30/1, drm-format=(string)NV12:0x0100000000000002 For GLMemory kind caps, no drm-format should appear. So we should let it only transforms which it can recognize. And in _gl_memory_upload_propose_allocation(), we should only allocate the allocator and buffer pool for the caps with "memory:GLMemory" feature. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3524>
This commit is contained in:
parent
414f91d0fa
commit
b9c97ba76d
1 changed files with 49 additions and 25 deletions
|
@ -305,16 +305,24 @@ _gl_memory_upload_transform_caps (gpointer impl, GstGLContext * context,
|
||||||
(GST_CAPS_FEATURE_META_GST_VIDEO_OVERLAY_COMPOSITION);
|
(GST_CAPS_FEATURE_META_GST_VIDEO_OVERLAY_COMPOSITION);
|
||||||
GstCaps *ret;
|
GstCaps *ret;
|
||||||
|
|
||||||
ret =
|
|
||||||
_set_caps_features_with_passthrough (caps,
|
|
||||||
GST_CAPS_FEATURE_MEMORY_GL_MEMORY, passthrough);
|
|
||||||
|
|
||||||
gst_caps_features_free (passthrough);
|
|
||||||
|
|
||||||
if (direction == GST_PAD_SINK) {
|
if (direction == GST_PAD_SINK) {
|
||||||
GstCaps *tmp;
|
GstCaps *tmp;
|
||||||
|
GstCapsFeatures *filter_features;
|
||||||
GstGLTextureTarget target_mask;
|
GstGLTextureTarget target_mask;
|
||||||
|
|
||||||
|
filter_features = gst_caps_features_new (GST_CAPS_FEATURE_MEMORY_GL_MEMORY,
|
||||||
|
GST_CAPS_FEATURE_MEMORY_SYSTEM_MEMORY, NULL);
|
||||||
|
if (!_filter_caps_with_features (caps, filter_features, &tmp)) {
|
||||||
|
gst_caps_features_free (filter_features);
|
||||||
|
gst_caps_features_free (passthrough);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
gst_caps_features_free (filter_features);
|
||||||
|
|
||||||
|
ret = _set_caps_features_with_passthrough (tmp,
|
||||||
|
GST_CAPS_FEATURE_MEMORY_GL_MEMORY, passthrough);
|
||||||
|
gst_caps_unref (tmp);
|
||||||
|
|
||||||
if (upload->input_target != GST_GL_TEXTURE_TARGET_NONE) {
|
if (upload->input_target != GST_GL_TEXTURE_TARGET_NONE) {
|
||||||
target_mask = 1 << upload->input_target;
|
target_mask = 1 << upload->input_target;
|
||||||
} else {
|
} else {
|
||||||
|
@ -329,6 +337,9 @@ _gl_memory_upload_transform_caps (gpointer impl, GstGLContext * context,
|
||||||
} else {
|
} else {
|
||||||
gint i, n;
|
gint i, n;
|
||||||
|
|
||||||
|
ret = _set_caps_features_with_passthrough (caps,
|
||||||
|
GST_CAPS_FEATURE_MEMORY_GL_MEMORY, passthrough);
|
||||||
|
|
||||||
n = gst_caps_get_size (ret);
|
n = gst_caps_get_size (ret);
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
GstStructure *s = gst_caps_get_structure (ret, i);
|
GstStructure *s = gst_caps_get_structure (ret, i);
|
||||||
|
@ -337,6 +348,12 @@ _gl_memory_upload_transform_caps (gpointer impl, GstGLContext * context,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gst_caps_features_free (passthrough);
|
||||||
|
|
||||||
|
GST_DEBUG_OBJECT (upload->upload, "direction %s, transformed %"
|
||||||
|
GST_PTR_FORMAT " into %" GST_PTR_FORMAT,
|
||||||
|
direction == GST_PAD_SRC ? "src" : "sink", caps, ret);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -390,16 +407,24 @@ _gl_memory_upload_propose_allocation (gpointer impl, GstQuery * decide_query,
|
||||||
guint n_pools, i;
|
guint n_pools, i;
|
||||||
GstCaps *caps;
|
GstCaps *caps;
|
||||||
GstCapsFeatures *features;
|
GstCapsFeatures *features;
|
||||||
|
GstAllocator *allocator;
|
||||||
|
GstAllocationParams params;
|
||||||
|
|
||||||
gst_query_parse_allocation (query, &caps, NULL);
|
gst_query_parse_allocation (query, &caps, NULL);
|
||||||
if (caps == NULL)
|
if (caps == NULL)
|
||||||
goto invalid_caps;
|
goto invalid_caps;
|
||||||
features = gst_caps_get_features (caps, 0);
|
|
||||||
|
|
||||||
|
g_assert (gst_caps_is_fixed (caps));
|
||||||
|
|
||||||
|
features = gst_caps_features_new (GST_CAPS_FEATURE_MEMORY_GL_MEMORY,
|
||||||
|
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 (gst_caps_features_contains (features, GST_CAPS_FEATURE_MEMORY_GL_MEMORY)) {
|
if (!_filter_caps_with_features (caps, features, NULL)) {
|
||||||
GstAllocator *allocator;
|
gst_caps_features_free (features);
|
||||||
GstAllocationParams params;
|
return;
|
||||||
|
}
|
||||||
|
gst_caps_features_free (features);
|
||||||
|
|
||||||
gst_allocation_params_init (¶ms);
|
gst_allocation_params_init (¶ms);
|
||||||
|
|
||||||
allocator =
|
allocator =
|
||||||
|
@ -418,7 +443,6 @@ _gl_memory_upload_propose_allocation (gpointer impl, GstQuery * decide_query,
|
||||||
gst_object_unref (allocator);
|
gst_object_unref (allocator);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
|
||||||
|
|
||||||
n_pools = gst_query_get_n_allocation_pools (query);
|
n_pools = gst_query_get_n_allocation_pools (query);
|
||||||
for (i = 0; i < n_pools; i++) {
|
for (i = 0; i < n_pools; i++) {
|
||||||
|
|
Loading…
Reference in a new issue