diff options
author | Víctor Manuel Jáquez Leal <vjaquez@igalia.com> | 2021-12-01 12:26:11 +0100 |
---|---|---|
committer | Tim-Philipp Müller <tim@centricular.com> | 2022-01-17 19:32:25 +0000 |
commit | 19f05d77b4028291fb6ed88b749ffab9131636bf (patch) | |
tree | 3469befa2abcd445d896a79ddbdd8af6e25ff2bc | |
parent | 3d6df27dc85f113bcb1bbf796cdfb1e4091ff6ec (diff) | |
download | gstreamer-vaapi-19f05d77b4028291fb6ed88b749ffab9131636bf.tar.gz |
vaapidecode: Autogenerate caps template.
vaapidecode is used in vaapidecodebin and it exposes all the
theoretically supported caps, but that slows down autoplug. With this
autplug is negotiated faster, giving more option to decodebin to select
other decoder.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/440>
-rw-r--r-- | gst/vaapi/gstvaapidecode.c | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/gst/vaapi/gstvaapidecode.c b/gst/vaapi/gstvaapidecode.c index 329c0e65..1045564d 100644 --- a/gst/vaapi/gstvaapidecode.c +++ b/gst/vaapi/gstvaapidecode.c @@ -64,18 +64,7 @@ GST_DEBUG_CATEGORY_STATIC (gst_debug_vaapidecode); #define GST_CAPS_CODEC(CODEC) CODEC "; " /* *INDENT-OFF* */ -static const char gst_vaapidecode_sink_caps_str[] = - GST_CAPS_CODEC("video/mpeg, mpegversion=2, systemstream=(boolean)false") - GST_CAPS_CODEC("video/mpeg, mpegversion=4") - GST_CAPS_CODEC("video/x-divx") - GST_CAPS_CODEC("video/x-xvid") - GST_CAPS_CODEC("video/x-h263") - GST_CAPS_CODEC("video/x-h264") - GST_CAPS_CODEC("video/x-h265") - GST_CAPS_CODEC("video/x-wmv") - GST_CAPS_CODEC("video/x-vp8") - GST_CAPS_CODEC("video/x-vp9") - ; +char *gst_vaapidecode_sink_caps_str = NULL; static const char gst_vaapidecode_src_caps_str[] = GST_VAAPI_MAKE_SURFACE_CAPS "; " @@ -118,8 +107,7 @@ static const GstVaapiDecoderMap vaapi_decode_map[] = { {GST_VAAPI_CODEC_VP8, GST_RANK_PRIMARY, "vp8", "video/x-vp8", NULL}, {GST_VAAPI_CODEC_VP9, GST_RANK_PRIMARY, "vp9", "video/x-vp9", NULL}, {GST_VAAPI_CODEC_H265, GST_RANK_PRIMARY, "h265", "video/x-h265", NULL}, - {0 /* the rest */ , GST_RANK_PRIMARY + 1, NULL, - gst_vaapidecode_sink_caps_str, NULL}, + {0 /* the rest */ , GST_RANK_PRIMARY + 1, NULL, NULL, NULL}, }; static GstElementClass *parent_class = NULL; @@ -1554,7 +1542,12 @@ gst_vaapidecode_class_init (GstVaapiDecodeClass * klass) map->install_properties (object_class); /* sink pad */ - caps = gst_caps_from_string (map->caps_str); + if (map->caps_str) { + caps = gst_caps_from_string (map->caps_str); + } else { + caps = gst_caps_from_string (gst_vaapidecode_sink_caps_str); + g_free (gst_vaapidecode_sink_caps_str); + } pad_template = gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, caps); gst_caps_unref (caps); @@ -1580,7 +1573,7 @@ gst_vaapidecode_register (GstPlugin * plugin, GArray * decoders) { gboolean ret = FALSE; guint i, codec, rank; - gchar *type_name, *element_name; + gchar *type_name, *element_name, *sink_caps_str; const gchar *name; GType type; GTypeInfo typeinfo = { @@ -1603,6 +1596,15 @@ gst_vaapidecode_register (GstPlugin * plugin, GArray * decoders) if (codec && !gst_vaapi_codecs_has_codec (decoders, codec)) continue; + if (!gst_vaapidecode_sink_caps_str) { + gst_vaapidecode_sink_caps_str = g_strdup (vaapi_decode_map[i].caps_str); + } else { + sink_caps_str = g_strconcat (gst_vaapidecode_sink_caps_str, "; ", + vaapi_decode_map[i].caps_str, NULL); + g_clear_pointer (&gst_vaapidecode_sink_caps_str, g_free); + gst_vaapidecode_sink_caps_str = sink_caps_str; + } + if (codec) { type_name = g_strdup_printf ("GstVaapiDecode_%s", name); element_name = g_strdup_printf ("vaapi%sdec", name); |