summaryrefslogtreecommitdiff
path: root/gst-libs/gst
diff options
context:
space:
mode:
authorGwenole Beauchesne <gwenole.beauchesne@intel.com>2012-08-27 17:02:49 +0300
committerGwenole Beauchesne <gwenole.beauchesne@intel.com>2012-08-27 17:52:32 +0200
commita503aaf9b9bddb4b381a500a7dff31a3fa9dd593 (patch)
tree5a67e88e4ce88168fca0597f90d1e3a537438457 /gst-libs/gst
parentf2741a88cc77cfbb3a0989a930fb69d3d497cbcb (diff)
display: add initial support for display attributes.
The VA display attributes are mapped to properties so that to maintain the GStreamer terminology. Properties are to be identified by name, but internal functions are available to lookup the property by the actual VA display attribute type.
Diffstat (limited to 'gst-libs/gst')
-rw-r--r--gst-libs/gst/vaapi/gstvaapidisplay.c88
-rw-r--r--gst-libs/gst/vaapi/gstvaapidisplay.h3
-rw-r--r--gst-libs/gst/vaapi/gstvaapidisplay_priv.h1
3 files changed, 90 insertions, 2 deletions
diff --git a/gst-libs/gst/vaapi/gstvaapidisplay.c b/gst-libs/gst/vaapi/gstvaapidisplay.c
index 1f82f33e..7dc06016 100644
--- a/gst-libs/gst/vaapi/gstvaapidisplay.c
+++ b/gst-libs/gst/vaapi/gstvaapidisplay.c
@@ -45,6 +45,12 @@ struct _GstVaapiConfig {
GstVaapiEntrypoint entrypoint;
};
+typedef struct _GstVaapiProperty GstVaapiProperty;
+struct _GstVaapiProperty {
+ const gchar *name;
+ VADisplayAttribute attribute;
+};
+
enum {
PROP_0,
@@ -304,6 +310,40 @@ get_format_caps(GArray *formats)
return out_caps;
}
+/* Find display attribute */
+static const GstVaapiProperty *
+find_property(GArray *properties, const gchar *name)
+{
+ GstVaapiProperty *prop;
+ guint i;
+
+ if (!name)
+ return NULL;
+
+ for (i = 0; i < properties->len; i++) {
+ prop = &g_array_index(properties, GstVaapiProperty, i);
+ if (strcmp(prop->name, name) == 0)
+ return prop;
+ }
+ return NULL;
+}
+
+#if 0
+static const GstVaapiProperty *
+find_property_by_type(GArray *properties, VADisplayAttribType type)
+{
+ GstVaapiProperty *prop;
+ guint i;
+
+ for (i = 0; i < properties->len; i++) {
+ prop = &g_array_index(properties, GstVaapiProperty, i);
+ if (prop->attribute.type == type)
+ return prop;
+ }
+ return NULL;
+}
+#endif
+
static void
gst_vaapi_display_calculate_pixel_aspect_ratio(GstVaapiDisplay *display)
{
@@ -374,6 +414,11 @@ gst_vaapi_display_destroy(GstVaapiDisplay *display)
priv->subpicture_formats = NULL;
}
+ if (priv->properties) {
+ g_array_free(priv->properties, TRUE);
+ priv->properties = NULL;
+ }
+
if (priv->display) {
if (!priv->parent)
vaTerminate(priv->display);
@@ -523,9 +568,26 @@ gst_vaapi_display_create(GstVaapiDisplay *display)
if (!vaapi_check_status(status, "vaQueryDisplayAttributes()"))
goto end;
+ priv->properties = g_array_new(FALSE, FALSE, sizeof(GstVaapiProperty));
+ if (!priv->properties)
+ goto end;
+
GST_DEBUG("%d display attributes", n);
- for (i = 0; i < n; i++)
- GST_DEBUG(" %s", string_of_VADisplayAttributeType(display_attrs[i].type));
+ for (i = 0; i < n; i++) {
+ VADisplayAttribute * const attr = &display_attrs[i];
+ GstVaapiProperty prop;
+
+ GST_DEBUG(" %s", string_of_VADisplayAttributeType(attr->type));
+
+ switch (attr->type) {
+ default:
+ prop.attribute.flags = 0;
+ break;
+ }
+ if (!prop.attribute.flags)
+ continue;
+ g_array_append_val(priv->properties, prop);
+ }
/* VA image formats */
formats = g_new(VAImageFormat, vaMaxNumImageFormats(priv->display));
@@ -755,6 +817,7 @@ gst_vaapi_display_init(GstVaapiDisplay *display)
priv->encoders = NULL;
priv->image_formats = NULL;
priv->subpicture_formats = NULL;
+ priv->properties = NULL;
priv->create_display = TRUE;
g_static_rec_mutex_init(&priv->mutex);
@@ -1153,3 +1216,24 @@ gst_vaapi_display_has_subpicture_format(
return find_format(display->priv->subpicture_formats, format);
}
+
+/**
+ * gst_vaapi_display_has_property:
+ * @display: a #GstVaapiDisplay
+ * @name: the property name to check
+ *
+ * Returns whether VA @display supports the requested property. The
+ * check is performed against the property @name. So, the client
+ * application may perform this check only once and cache this
+ * information.
+ *
+ * Return value: %TRUE if VA @display supports property @name
+ */
+gboolean
+gst_vaapi_display_has_property(GstVaapiDisplay *display, const gchar *name)
+{
+ g_return_val_if_fail(GST_VAAPI_IS_DISPLAY(display), FALSE);
+ g_return_val_if_fail(name, FALSE);
+
+ return find_property(display->priv->properties, name) != NULL;
+}
diff --git a/gst-libs/gst/vaapi/gstvaapidisplay.h b/gst-libs/gst/vaapi/gstvaapidisplay.h
index 2b826665..1b0ade65 100644
--- a/gst-libs/gst/vaapi/gstvaapidisplay.h
+++ b/gst-libs/gst/vaapi/gstvaapidisplay.h
@@ -218,6 +218,9 @@ gst_vaapi_display_has_subpicture_format(
GstVaapiImageFormat format
);
+gboolean
+gst_vaapi_display_has_property(GstVaapiDisplay *display, const gchar *name);
+
G_END_DECLS
#endif /* GST_VAAPI_DISPLAY_H */
diff --git a/gst-libs/gst/vaapi/gstvaapidisplay_priv.h b/gst-libs/gst/vaapi/gstvaapidisplay_priv.h
index d48cc60f..ac0555e3 100644
--- a/gst-libs/gst/vaapi/gstvaapidisplay_priv.h
+++ b/gst-libs/gst/vaapi/gstvaapidisplay_priv.h
@@ -86,6 +86,7 @@ struct _GstVaapiDisplayPrivate {
GArray *encoders;
GArray *image_formats;
GArray *subpicture_formats;
+ GArray *properties;
guint create_display : 1;
};