vaapi: plugin: Handle when no encoders/decoders available.

Nouveau driver currently only exposes postproc entry. But
vaapidecodebin is registered independent if there are decoders or not,
exposing a segmentation fault.

This patch removes the encoder/decoder/codec arrays if no entries are
found, and if no decoders are found vaapidecodebin is not
registered. Also for vaapipostproc if no postproc entry is found.

Also, if general decoder, used by vaapidecodebin, doesn't have a sink
pad string, don't register the glib type.

Fixes: #1349
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2865>
This commit is contained in:
Víctor Manuel Jáquez Leal 2022-08-11 21:22:12 +02:00 committed by GStreamer Marge Bot
parent 73c75479d6
commit 664c051d79
3 changed files with 15 additions and 6 deletions

View file

@ -557,6 +557,13 @@ ensure_profiles (GstVaapiDisplay * display)
}
success = TRUE;
if (priv->encoders->len == 0)
g_clear_pointer (&priv->encoders, g_ptr_array_unref);
if (priv->decoders->len == 0)
g_clear_pointer (&priv->decoders, g_ptr_array_unref);
if (priv->codecs->len == 0)
g_clear_pointer (&priv->codecs, g_array_unref);
cleanup:
g_free (profiles);
g_free (entrypoints);

View file

@ -200,17 +200,17 @@ plugin_init (GstPlugin * plugin)
decoders = display_get_decoder_codecs (display);
if (decoders) {
gst_vaapidecode_register (plugin, decoders);
gst_element_register (plugin, "vaapidecodebin",
GST_RANK_PRIMARY + 2, GST_TYPE_VAAPI_DECODE_BIN);
g_array_unref (decoders);
}
if (_gst_vaapi_has_video_processing)
if (_gst_vaapi_has_video_processing) {
gst_vaapioverlay_register (plugin, display);
gst_element_register (plugin, "vaapipostproc",
GST_RANK_NONE, GST_TYPE_VAAPIPOSTPROC);
gst_element_register (plugin, "vaapidecodebin",
GST_RANK_PRIMARY + 2, GST_TYPE_VAAPI_DECODE_BIN);
gst_element_register (plugin, "vaapipostproc",
GST_RANK_NONE, GST_TYPE_VAAPIPOSTPROC);
}
rank = GST_RANK_SECONDARY;
if (g_getenv ("WAYLAND_DISPLAY"))

View file

@ -1614,6 +1614,8 @@ gst_vaapidecode_register (GstPlugin * plugin, GArray * decoders)
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);
if (!sink_caps_str)
break;
gst_vaapidecode_sink_caps_str = sink_caps_str;
}