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
This commit is contained in:
Nicolas Dufresne 2014-05-25 09:03:32 -04:00 committed by Tim-Philipp Müller
parent ee04a6e6eb
commit d85c344204

View file

@ -687,6 +687,41 @@ gst_gl_filter_set_caps_features (const GstCaps * caps,
return tmp; 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 * static GstCaps *
gst_gl_filter_transform_caps (GstBaseTransform * bt, gst_gl_filter_transform_caps (GstBaseTransform * bt,
GstPadDirection direction, GstCaps * caps, GstCaps * filter) GstPadDirection direction, GstCaps * caps, GstCaps * filter)
@ -694,6 +729,8 @@ gst_gl_filter_transform_caps (GstBaseTransform * bt,
GstCaps *tmp = NULL; GstCaps *tmp = NULL;
GstCaps *result = NULL; GstCaps *result = NULL;
tmp = gst_caps_new_empty ();
if (direction == GST_PAD_SINK) { if (direction == GST_PAD_SINK) {
GstCaps *glcaps = gst_gl_filter_set_caps_features (caps, GstCaps *glcaps = gst_gl_filter_set_caps_features (caps,
GST_CAPS_FEATURE_MEMORY_GL_MEMORY); 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, GstCaps *uploadcaps = gst_gl_filter_set_caps_features (caps,
GST_CAPS_FEATURE_META_GST_VIDEO_GL_TEXTURE_UPLOAD_META); GST_CAPS_FEATURE_META_GST_VIDEO_GL_TEXTURE_UPLOAD_META);
tmp = gst_caps_new_empty ();
tmp = gst_caps_merge (tmp, glcaps); tmp = gst_caps_merge (tmp, glcaps);
#if GST_GL_HAVE_PLATFORM_EGL #if GST_GL_HAVE_PLATFORM_EGL
tmp = gst_caps_merge (tmp, eglcaps); tmp = gst_caps_merge (tmp, eglcaps);
#endif #endif
tmp = gst_caps_merge (tmp, uploadcaps); 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) { if (filter) {
result = gst_caps_intersect_full (filter, tmp, GST_CAPS_INTERSECT_FIRST); result = gst_caps_intersect_full (filter, tmp, GST_CAPS_INTERSECT_FIRST);
gst_caps_unref (tmp); gst_caps_unref (tmp);