From 075701669e90d1d4ffb75a214a1a718c8f1326a4 Mon Sep 17 00:00:00 2001 From: Nicolas Dufresne Date: Sun, 25 May 2014 09:03:32 -0400 Subject: [PATCH] glfilter: Remove format information to allow color convert again We also need to remove the format information, as glfilter can do color convertion. This code was imported from videoconvert. https://bugzilla.gnome.org/show_bug.cgi?id=729861 --- gst-libs/gst/gl/gstglfilter.c | 44 ++++++++++++++++++++++++++++++++++++++----- 1 file changed, 39 insertions(+), 5 deletions(-) diff --git a/gst-libs/gst/gl/gstglfilter.c b/gst-libs/gst/gl/gstglfilter.c index 4007ac2..2d44686 100644 --- a/gst-libs/gst/gl/gstglfilter.c +++ b/gst-libs/gst/gl/gstglfilter.c @@ -687,6 +687,41 @@ gst_gl_filter_set_caps_features (const GstCaps * caps, return tmp; } +/* copies the given caps */ +static GstCaps * +gst_gl_filter_caps_remove_format_info (GstCaps * caps) +{ + GstStructure *st; + GstCapsFeatures *f; + gint i, n; + GstCaps *res; + + res = gst_caps_new_empty (); + + n = gst_caps_get_size (caps); + for (i = 0; i < n; i++) { + st = gst_caps_get_structure (caps, i); + f = gst_caps_get_features (caps, i); + + /* If this is already expressed by the existing caps + * skip this structure */ + if (i > 0 && gst_caps_is_subset_structure_full (res, st, f)) + continue; + + st = gst_structure_copy (st); + /* Only remove format info for the cases when we can actually convert */ + if (!gst_caps_features_is_any (f) + && gst_caps_features_is_equal (f, + GST_CAPS_FEATURES_MEMORY_SYSTEM_MEMORY)) + gst_structure_remove_fields (st, "format", "colorimetry", "chroma-site", + NULL); + + gst_caps_append_structure_full (res, st, gst_caps_features_copy (f)); + } + + return res; +} + static GstCaps * gst_gl_filter_transform_caps (GstBaseTransform * bt, GstPadDirection direction, GstCaps * caps, GstCaps * filter) @@ -694,6 +729,8 @@ gst_gl_filter_transform_caps (GstBaseTransform * bt, GstCaps *tmp = NULL; GstCaps *result = NULL; + tmp = gst_caps_new_empty (); + if (direction == GST_PAD_SINK) { GstCaps *glcaps = gst_gl_filter_set_caps_features (caps, GST_CAPS_FEATURE_MEMORY_GL_MEMORY); @@ -704,18 +741,15 @@ gst_gl_filter_transform_caps (GstBaseTransform * bt, GstCaps *uploadcaps = gst_gl_filter_set_caps_features (caps, GST_CAPS_FEATURE_META_GST_VIDEO_GL_TEXTURE_UPLOAD_META); - tmp = gst_caps_new_empty (); - tmp = gst_caps_merge (tmp, glcaps); #if GST_GL_HAVE_PLATFORM_EGL tmp = gst_caps_merge (tmp, eglcaps); #endif tmp = gst_caps_merge (tmp, uploadcaps); - tmp = gst_caps_merge (tmp, gst_caps_copy (caps)); - } else { - tmp = gst_caps_copy (caps); } + tmp = gst_caps_merge (tmp, gst_gl_filter_caps_remove_format_info (caps)); + if (filter) { result = gst_caps_intersect_full (filter, tmp, GST_CAPS_INTERSECT_FIRST); gst_caps_unref (tmp); -- 2.7.4