summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGwenole Beauchesne <gwenole.beauchesne@intel.com>2012-08-28 14:05:16 +0200
committerGwenole Beauchesne <gwenole.beauchesne@intel.com>2012-09-07 14:37:06 +0200
commit64c3d4788b9bf6d441afc01023829a72d43ac92a (patch)
tree0852bb54942f4fa5170c085391b4c4ff1680e7ef
parentf6fb598b147f5dd942016d6616b2e8764039c7b1 (diff)
downloadgstreamer-vaapi-64c3d4788b9bf6d441afc01023829a72d43ac92a.tar.gz
display: fix validation process of properties during discovery.
Some VA drivers (e.g. EMGD) can have completely random values for initial display attributes. So, try to improve the discovery process to check the initial display attribute values actually fall within valid bounds. If not, try to reset those to some sensible values like the default value reported through vaQueryDisplayAttributes().
-rw-r--r--gst-libs/gst/vaapi/gstvaapidisplay.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/gst-libs/gst/vaapi/gstvaapidisplay.c b/gst-libs/gst/vaapi/gstvaapidisplay.c
index bb980600..2f1e9041 100644
--- a/gst-libs/gst/vaapi/gstvaapidisplay.c
+++ b/gst-libs/gst/vaapi/gstvaapidisplay.c
@@ -61,6 +61,12 @@ enum {
static GstVaapiDisplayCache *g_display_cache = NULL;
+static gboolean
+get_attribute(GstVaapiDisplay *display, VADisplayAttribType type, gint *value);
+
+static gboolean
+set_attribute(GstVaapiDisplay *display, VADisplayAttribType type, gint value);
+
static inline GstVaapiDisplayCache *
get_display_cache(void)
{
@@ -533,6 +539,7 @@ gst_vaapi_display_create(GstVaapiDisplay *display)
for (i = 0; i < n; i++) {
VADisplayAttribute * const attr = &display_attrs[i];
GstVaapiProperty prop;
+ gint value;
GST_DEBUG(" %s", string_of_VADisplayAttributeType(attr->type));
@@ -551,6 +558,17 @@ gst_vaapi_display_create(GstVaapiDisplay *display)
}
if (!prop.name)
continue;
+
+ /* Assume the attribute is really supported if we can get the
+ * actual and current value */
+ if (!get_attribute(display, attr->type, &value))
+ continue;
+
+ /* Some drivers (e.g. EMGD) have completely random initial
+ * values */
+ if (value < attr->min_value || value > attr->max_value)
+ continue;
+
prop.attribute = *attr;
g_array_append_val(priv->properties, prop);
}