videoconvertscale: Don't claim we can support any kind of memory

Since d0133a2d11 "videoconvert: Allow
passthrough for ANY caps features" videoconvert will always claim that
it supports any kind of memory which is true in very specific case (when
it is running in passthrough mode). To get elements that autoplug
converters depending on the caps running in the pipeline (like
autovideoconvert), we need to have converters no lie about what they can
do when queried `accept_caps` or `query_caps`.

This still accepts any caps feature as before but it introduces
a restriction in the way we handle memory capsfeatures.

We keep previous behaviour in videoconvert and videoscale.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/898>
This commit is contained in:
Thibault Saunier 2021-05-21 18:55:25 -04:00
parent d11f13f476
commit f3fd4d7e90
4 changed files with 28 additions and 1 deletions

View file

@ -49,7 +49,7 @@ GST_ELEMENT_REGISTER_DEFINE (videoconvert, "videoconvert",
static void
gst_video_convert_class_init (GstVideoConvertClass * klass)
{
((GstVideoConvertScaleClass *) klass)->any_memory = TRUE;
}
static void

View file

@ -617,6 +617,7 @@ static GstCaps *
gst_video_convert_scale_transform_caps (GstBaseTransform * trans,
GstPadDirection direction, GstCaps * caps, GstCaps * filter)
{
gint i;
GstCaps *ret;
GST_DEBUG_OBJECT (trans,
@ -633,6 +634,28 @@ gst_video_convert_scale_transform_caps (GstBaseTransform * trans,
ret = intersection;
}
if (GST_VIDEO_CONVERT_SCALE_GET_CLASS (trans)->any_memory)
return ret;
for (i = 0; i < gst_caps_get_size (ret); i++) {
gint j;
GstCapsFeatures *f = gst_caps_get_features (ret, i);
if (!f || gst_caps_features_is_any (f) ||
gst_caps_features_is_equal (f, GST_CAPS_FEATURES_MEMORY_SYSTEM_MEMORY))
continue;
for (j = 0; j < gst_caps_features_get_size (f); j++) {
const gchar *feature = gst_caps_features_get_nth (f, j);
if (g_str_has_prefix (feature, "memory:")) {
GST_DEBUG_OBJECT (trans, "Can not work with memory `%s`", feature);
gst_caps_remove_structure (ret, i);
break;
}
}
}
GST_DEBUG_OBJECT (trans, "returning caps: %" GST_PTR_FORMAT, ret);
return ret;

View file

@ -36,6 +36,8 @@ G_DECLARE_DERIVABLE_TYPE (GstVideoConvertScale, gst_video_convert_scale, GST, VI
struct _GstVideoConvertScaleClass
{
GstVideoFilterClass parent;
gboolean any_memory;
};
/**

View file

@ -112,6 +112,8 @@ gst_video_scale_class_init (GstVideoScaleClass * klass)
gobject_class->set_property = gst_video_scale_set_property;
gobject_class->get_property = gst_video_scale_get_property;
((GstVideoConvertScaleClass *) klass)->any_memory = TRUE;
g_object_class_install_property (gobject_class, PROP_GAMMA_DECODE,
g_param_spec_boolean ("gamma-decode", "Gamma Decode",
"Decode gamma before scaling", DEFAULT_PROP_GAMMA_DECODE,