From a8f230959565cf1172792117a54abfd3ae2166c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Tue, 10 Oct 2017 11:35:24 +0300 Subject: [PATCH] vaapidecodebin: Register element if no VPP support is available too VPP support is only needed for advanced deinterlacing, which is not enabled by default either. Error out if it is selected but VPP is not supported, and otherwise just work without VPP support. https://bugzilla.gnome.org/show_bug.cgi?id=788758 --- gst/vaapi/gstvaapi.c | 11 +++++++---- gst/vaapi/gstvaapi.h | 30 ++++++++++++++++++++++++++++++ gst/vaapi/gstvaapidecodebin.c | 13 +++++++++++++ 3 files changed, 50 insertions(+), 4 deletions(-) create mode 100644 gst/vaapi/gstvaapi.h diff --git a/gst/vaapi/gstvaapi.c b/gst/vaapi/gstvaapi.c index d7a3519c1e..7939f9aaf5 100644 --- a/gst/vaapi/gstvaapi.c +++ b/gst/vaapi/gstvaapi.c @@ -54,6 +54,8 @@ #endif +gboolean _gst_vaapi_has_video_processing = FALSE; + #define PLUGIN_NAME "vaapi" #define PLUGIN_DESC "VA-API based elements" #define PLUGIN_LICENSE "LGPL" @@ -217,6 +219,9 @@ plugin_init (GstPlugin * plugin) if (!gst_vaapi_driver_is_whitelisted (display)) goto unsupported_driver; + _gst_vaapi_has_video_processing = + gst_vaapi_display_has_video_processing (display); + decoders = display_get_decoder_codecs (display); if (decoders) { gst_vaapidecode_register (plugin, decoders); @@ -226,10 +231,8 @@ plugin_init (GstPlugin * plugin) gst_element_register (plugin, "vaapipostproc", GST_RANK_PRIMARY, GST_TYPE_VAAPIPOSTPROC); - if (gst_vaapi_display_has_video_processing (display)) { - gst_element_register (plugin, "vaapidecodebin", - GST_RANK_PRIMARY + 2, GST_TYPE_VAAPI_DECODE_BIN); - } + gst_element_register (plugin, "vaapidecodebin", + GST_RANK_PRIMARY + 2, GST_TYPE_VAAPI_DECODE_BIN); gst_element_register (plugin, "vaapisink", GST_RANK_PRIMARY, GST_TYPE_VAAPISINK); diff --git a/gst/vaapi/gstvaapi.h b/gst/vaapi/gstvaapi.h new file mode 100644 index 0000000000..f5859508f1 --- /dev/null +++ b/gst/vaapi/gstvaapi.h @@ -0,0 +1,30 @@ +/* + * gstvaapi.h - VA-API element registration + * + * Copyright (C) 2011-2013 Intel Corporation + * Author: Gwenole Beauchesne + * Copyright (C) 2011 Collabora Ltd. + * Author: Nicolas Dufresne + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 + * of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + */ + +#ifndef __GST_VAAPI_H__ +#define __GST_VAAPI_H__ + +G_GNUC_INTERNAL extern gboolean _gst_vaapi_has_video_processing; + +#endif /* __GST_VAAPI_H__ */ diff --git a/gst/vaapi/gstvaapidecodebin.c b/gst/vaapi/gstvaapidecodebin.c index 2522b0af1c..34a6338d3f 100644 --- a/gst/vaapi/gstvaapidecodebin.c +++ b/gst/vaapi/gstvaapidecodebin.c @@ -50,6 +50,7 @@ #include "gstvaapidecodebin.h" #include "gstvaapivideocontext.h" #include "gstvaapipluginbase.h" +#include "gstvaapi.h" #define GST_PLUGIN_NAME "vaapidecodebin" #define GST_PLUGIN_DESC "A VA-API based bin with a decoder and a postprocessor" @@ -296,6 +297,7 @@ gst_vaapi_decode_bin_configure (GstVaapiDecodeBin * vaapidecbin) GstCaps *caps; GstPad *queue_srcpad, *bin_srcpad, *capsfilter_sinkpad, *vpp_srcpad; gboolean res; + gboolean has_vpp; g_object_set (G_OBJECT (vaapidecbin->queue), "max-size-bytes", vaapidecbin->max_size_bytes, @@ -305,6 +307,17 @@ gst_vaapi_decode_bin_configure (GstVaapiDecodeBin * vaapidecbin) if (vaapidecbin->disable_vpp || vaapidecbin->configured) return TRUE; + has_vpp = _gst_vaapi_has_video_processing; + + if (!has_vpp && (vaapidecbin->deinterlace_method == + GST_VAAPI_DEINTERLACE_METHOD_MOTION_ADAPTIVE + || vaapidecbin->deinterlace_method == + GST_VAAPI_DEINTERLACE_METHOD_MOTION_COMPENSATED)) { + GST_ERROR_OBJECT (vaapidecbin, + "Don't have VPP support but advanced deinterlacing selected"); + return FALSE; + } + GST_INFO_OBJECT (vaapidecbin, "enabling VPP"); /* capsfilter to avoid negotiation with vaapidecode */