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
parent b53972a5cb
commit 65f03061ad

View file

@ -105,16 +105,37 @@ struct _GstGLUploadPrivate
};
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 n = gst_caps_get_size (tmp);
guint i = 0;
guint i, j, m, n;
GstCaps *tmp;
tmp = gst_caps_copy (caps);
n = gst_caps_get_size (caps);
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);
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);
}
@ -164,7 +185,18 @@ static GstCaps *
_gl_memory_upload_transform_caps (GstGLContext * context,
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
@ -228,8 +260,8 @@ _gl_memory_upload_propose_allocation (gpointer impl, GstQuery * decide_query,
gst_allocation_params_init (&params);
allocator =
GST_ALLOCATOR (gst_gl_memory_allocator_get_default (upload->
upload->context));
GST_ALLOCATOR (gst_gl_memory_allocator_get_default (upload->upload->
context));
gst_query_add_allocation_param (query, allocator, &params);
gst_object_unref (allocator);
}
@ -369,14 +401,21 @@ static GstCaps *
_egl_image_upload_transform_caps (GstGLContext * context,
GstPadDirection direction, GstCaps * caps)
{
GstCapsFeatures *passthrough =
gst_caps_features_from_string
(GST_CAPS_FEATURE_META_GST_VIDEO_OVERLAY_COMPOSITION);
GstCaps *ret;
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 {
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);
n = gst_caps_get_size (ret);
@ -387,6 +426,8 @@ _egl_image_upload_transform_caps (GstGLContext * context,
}
}
gst_caps_features_free (passthrough);
return ret;
}
@ -575,14 +616,21 @@ static GstCaps *
_dma_buf_upload_transform_caps (GstGLContext * context,
GstPadDirection direction, GstCaps * caps)
{
GstCapsFeatures *passthrough =
gst_caps_features_from_string
(GST_CAPS_FEATURE_META_GST_VIDEO_OVERLAY_COMPOSITION);
GstCaps *ret;
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 {
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);
for (i = 0; i < n; i++) {
@ -592,6 +640,8 @@ _dma_buf_upload_transform_caps (GstGLContext * context,
}
}
gst_caps_features_free (passthrough);
return ret;
}
@ -832,16 +882,21 @@ static GstCaps *
_upload_meta_upload_transform_caps (GstGLContext * context,
GstPadDirection direction, GstCaps * caps)
{
GstCapsFeatures *passthrough =
gst_caps_features_from_string
(GST_CAPS_FEATURE_META_GST_VIDEO_OVERLAY_COMPOSITION);
GstCaps *ret;
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 {
gint i, n;
ret =
_set_caps_features (caps,
GST_CAPS_FEATURE_META_GST_VIDEO_GL_TEXTURE_UPLOAD_META);
_set_caps_features_with_passthrough (caps,
GST_CAPS_FEATURE_META_GST_VIDEO_GL_TEXTURE_UPLOAD_META, passthrough);
gst_caps_set_simple (ret, "format", G_TYPE_STRING, "RGBA", NULL);
n = gst_caps_get_size (ret);
@ -852,6 +907,8 @@ _upload_meta_upload_transform_caps (GstGLContext * context,
}
}
gst_caps_features_free (passthrough);
return ret;
}
@ -1113,14 +1170,21 @@ static GstCaps *
_raw_data_upload_transform_caps (GstGLContext * context,
GstPadDirection direction, GstCaps * caps)
{
GstCapsFeatures *passthrough =
gst_caps_features_from_string
(GST_CAPS_FEATURE_META_GST_VIDEO_OVERLAY_COMPOSITION);
GstCaps *ret;
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 {
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);
for (i = 0; i < n; i++) {
@ -1130,6 +1194,8 @@ _raw_data_upload_transform_caps (GstGLContext * context,
}
}
gst_caps_features_free (passthrough);
return ret;
}
@ -1365,9 +1431,6 @@ gst_gl_upload_transform_caps (GstGLContext * context, GstPadDirection direction,
tmp = gst_caps_merge (tmp, tmp2);
}
tmp = gst_gl_overlay_compositor_add_caps (tmp);
if (filter) {
result = gst_caps_intersect_full (filter, tmp, GST_CAPS_INTERSECT_FIRST);
gst_caps_unref (tmp);