glupload: passthrough composition caps features

Don't unconditionally add it to any and all caps transformations.

https://bugzilla.gnome.org/show_bug.cgi?id=759860
This commit is contained in:
Matthew Waters 2015-12-29 18:16:04 +11:00 committed by Tim-Philipp Müller
parent d7f508acbb
commit ec5eb678d0

View file

@ -105,16 +105,37 @@ struct _GstGLUploadPrivate
}; };
static GstCaps * static GstCaps *
_set_caps_features (const GstCaps * caps, const gchar * feature_name) _set_caps_features_with_passthrough (const GstCaps * caps,
const gchar * feature_name, GstCapsFeatures * passthrough)
{ {
GstCaps *tmp = gst_caps_copy (caps); guint i, j, m, n;
guint n = gst_caps_get_size (tmp); GstCaps *tmp;
guint i = 0;
tmp = gst_caps_copy (caps);
n = gst_caps_get_size (caps);
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
GstCapsFeatures *features; GstCapsFeatures *features, *orig_features;
orig_features = gst_caps_get_features (caps, i);
features = gst_caps_features_new (feature_name, NULL); features = gst_caps_features_new (feature_name, NULL);
m = gst_caps_features_get_size (orig_features);
for (j = 0; j < m; j++) {
const gchar *feature = gst_caps_features_get_nth (orig_features, j);
/* if we already have the features */
if (gst_caps_features_contains (features, feature))
continue;
if (g_strcmp0 (feature, GST_CAPS_FEATURE_MEMORY_SYSTEM_MEMORY) == 0)
continue;
if (gst_caps_features_contains (passthrough, feature)) {
gst_caps_features_add (features, feature);
}
}
gst_caps_set_features (tmp, i, features); gst_caps_set_features (tmp, i, features);
} }
@ -164,7 +185,18 @@ static GstCaps *
_gl_memory_upload_transform_caps (GstGLContext * context, _gl_memory_upload_transform_caps (GstGLContext * context,
GstPadDirection direction, GstCaps * caps) GstPadDirection direction, GstCaps * caps)
{ {
return _set_caps_features (caps, GST_CAPS_FEATURE_MEMORY_GL_MEMORY); GstCapsFeatures *passthrough =
gst_caps_features_from_string
(GST_CAPS_FEATURE_META_GST_VIDEO_OVERLAY_COMPOSITION);
GstCaps *ret;
ret =
_set_caps_features_with_passthrough (caps,
GST_CAPS_FEATURE_MEMORY_GL_MEMORY, passthrough);
gst_caps_features_free (passthrough);
return ret;
} }
static gboolean static gboolean
@ -228,8 +260,8 @@ _gl_memory_upload_propose_allocation (gpointer impl, GstQuery * decide_query,
gst_allocation_params_init (&params); gst_allocation_params_init (&params);
allocator = allocator =
GST_ALLOCATOR (gst_gl_memory_allocator_get_default (upload-> GST_ALLOCATOR (gst_gl_memory_allocator_get_default (upload->upload->
upload->context)); context));
gst_query_add_allocation_param (query, allocator, &params); gst_query_add_allocation_param (query, allocator, &params);
gst_object_unref (allocator); gst_object_unref (allocator);
} }
@ -369,14 +401,21 @@ static GstCaps *
_egl_image_upload_transform_caps (GstGLContext * context, _egl_image_upload_transform_caps (GstGLContext * context,
GstPadDirection direction, GstCaps * caps) GstPadDirection direction, GstCaps * caps)
{ {
GstCapsFeatures *passthrough =
gst_caps_features_from_string
(GST_CAPS_FEATURE_META_GST_VIDEO_OVERLAY_COMPOSITION);
GstCaps *ret; GstCaps *ret;
if (direction == GST_PAD_SINK) { if (direction == GST_PAD_SINK) {
ret = _set_caps_features (caps, GST_CAPS_FEATURE_MEMORY_GL_MEMORY); ret =
_set_caps_features_with_passthrough (caps,
GST_CAPS_FEATURE_MEMORY_GL_MEMORY, passthrough);
} else { } else {
gint i, n; gint i, n;
ret = _set_caps_features (caps, GST_CAPS_FEATURE_MEMORY_EGL_IMAGE); ret =
_set_caps_features_with_passthrough (caps,
GST_CAPS_FEATURE_MEMORY_EGL_IMAGE, passthrough);
gst_caps_set_simple (ret, "format", G_TYPE_STRING, "RGBA", NULL); gst_caps_set_simple (ret, "format", G_TYPE_STRING, "RGBA", NULL);
n = gst_caps_get_size (ret); n = gst_caps_get_size (ret);
@ -387,6 +426,8 @@ _egl_image_upload_transform_caps (GstGLContext * context,
} }
} }
gst_caps_features_free (passthrough);
return ret; return ret;
} }
@ -575,14 +616,21 @@ static GstCaps *
_dma_buf_upload_transform_caps (GstGLContext * context, _dma_buf_upload_transform_caps (GstGLContext * context,
GstPadDirection direction, GstCaps * caps) GstPadDirection direction, GstCaps * caps)
{ {
GstCapsFeatures *passthrough =
gst_caps_features_from_string
(GST_CAPS_FEATURE_META_GST_VIDEO_OVERLAY_COMPOSITION);
GstCaps *ret; GstCaps *ret;
if (direction == GST_PAD_SINK) { if (direction == GST_PAD_SINK) {
ret = _set_caps_features (caps, GST_CAPS_FEATURE_MEMORY_GL_MEMORY); ret =
_set_caps_features_with_passthrough (caps,
GST_CAPS_FEATURE_MEMORY_GL_MEMORY, passthrough);
} else { } else {
gint i, n; gint i, n;
ret = _set_caps_features (caps, GST_CAPS_FEATURE_MEMORY_SYSTEM_MEMORY); ret =
_set_caps_features_with_passthrough (caps,
GST_CAPS_FEATURE_MEMORY_SYSTEM_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++) {
@ -592,6 +640,8 @@ _dma_buf_upload_transform_caps (GstGLContext * context,
} }
} }
gst_caps_features_free (passthrough);
return ret; return ret;
} }
@ -832,16 +882,21 @@ static GstCaps *
_upload_meta_upload_transform_caps (GstGLContext * context, _upload_meta_upload_transform_caps (GstGLContext * context,
GstPadDirection direction, GstCaps * caps) GstPadDirection direction, GstCaps * caps)
{ {
GstCapsFeatures *passthrough =
gst_caps_features_from_string
(GST_CAPS_FEATURE_META_GST_VIDEO_OVERLAY_COMPOSITION);
GstCaps *ret; GstCaps *ret;
if (direction == GST_PAD_SINK) { if (direction == GST_PAD_SINK) {
ret = _set_caps_features (caps, GST_CAPS_FEATURE_MEMORY_GL_MEMORY); ret =
_set_caps_features_with_passthrough (caps,
GST_CAPS_FEATURE_MEMORY_GL_MEMORY, passthrough);
} else { } else {
gint i, n; gint i, n;
ret = ret =
_set_caps_features (caps, _set_caps_features_with_passthrough (caps,
GST_CAPS_FEATURE_META_GST_VIDEO_GL_TEXTURE_UPLOAD_META); GST_CAPS_FEATURE_META_GST_VIDEO_GL_TEXTURE_UPLOAD_META, passthrough);
gst_caps_set_simple (ret, "format", G_TYPE_STRING, "RGBA", NULL); gst_caps_set_simple (ret, "format", G_TYPE_STRING, "RGBA", NULL);
n = gst_caps_get_size (ret); n = gst_caps_get_size (ret);
@ -852,6 +907,8 @@ _upload_meta_upload_transform_caps (GstGLContext * context,
} }
} }
gst_caps_features_free (passthrough);
return ret; return ret;
} }
@ -1113,14 +1170,21 @@ static GstCaps *
_raw_data_upload_transform_caps (GstGLContext * context, _raw_data_upload_transform_caps (GstGLContext * context,
GstPadDirection direction, GstCaps * caps) GstPadDirection direction, GstCaps * caps)
{ {
GstCapsFeatures *passthrough =
gst_caps_features_from_string
(GST_CAPS_FEATURE_META_GST_VIDEO_OVERLAY_COMPOSITION);
GstCaps *ret; GstCaps *ret;
if (direction == GST_PAD_SINK) { if (direction == GST_PAD_SINK) {
ret = _set_caps_features (caps, GST_CAPS_FEATURE_MEMORY_GL_MEMORY); ret =
_set_caps_features_with_passthrough (caps,
GST_CAPS_FEATURE_MEMORY_GL_MEMORY, passthrough);
} else { } else {
gint i, n; gint i, n;
ret = _set_caps_features (caps, GST_CAPS_FEATURE_MEMORY_SYSTEM_MEMORY); ret =
_set_caps_features_with_passthrough (caps,
GST_CAPS_FEATURE_MEMORY_SYSTEM_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++) {
@ -1130,6 +1194,8 @@ _raw_data_upload_transform_caps (GstGLContext * context,
} }
} }
gst_caps_features_free (passthrough);
return ret; return ret;
} }
@ -1365,9 +1431,6 @@ gst_gl_upload_transform_caps (GstGLContext * context, GstPadDirection direction,
tmp = gst_caps_merge (tmp, tmp2); tmp = gst_caps_merge (tmp, tmp2);
} }
tmp = gst_gl_overlay_compositor_add_caps (tmp);
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);