summaryrefslogtreecommitdiff
path: root/va
diff options
context:
space:
mode:
authorGwenole Beauchesne <gwenole.beauchesne@intel.com>2011-12-18 23:50:25 +0100
committerXiang, Haihao <haihao.xiang@intel.com>2013-06-05 09:38:35 +0800
commite1d3569778a6662a2d8b97180c790e862a3926be (patch)
tree433e5a8698e5735902ac2ec5db76c1478cd78f50 /va
parent57b99c7c8e9671202b5c3d1e476b60bdc4b7d1f5 (diff)
API: add surface attributes.
Diffstat (limited to 'va')
-rw-r--r--va/va.c69
-rw-r--r--va/va.h114
-rw-r--r--va/va_backend.h20
3 files changed, 172 insertions, 31 deletions
diff --git a/va/va.c b/va/va.c
index 24cb1d1..80025a3 100644
--- a/va/va.c
+++ b/va/va.c
@@ -655,26 +655,65 @@ VAStatus vaQueryConfigAttributes (
return ctx->vtable->vaQueryConfigAttributes( ctx, config_id, profile, entrypoint, attrib_list, num_attribs);
}
-VAStatus vaCreateSurfaces (
- VADisplay dpy,
- int width,
- int height,
- int format,
- int num_surfaces,
- VASurfaceID *surfaces /* out */
+VAStatus
+vaGetSurfaceAttributes(
+ VADisplay dpy,
+ VAConfigID config,
+ VASurfaceAttrib *attrib_list,
+ unsigned int num_attribs
)
{
- VADriverContextP ctx;
- VAStatus vaStatus;
+ VADriverContextP ctx;
+ VAStatus vaStatus;
- CHECK_DISPLAY(dpy);
- ctx = CTX(dpy);
+ CHECK_DISPLAY(dpy);
+ ctx = CTX(dpy);
+ if (!ctx)
+ return VA_STATUS_ERROR_INVALID_DISPLAY;
- vaStatus = ctx->vtable->vaCreateSurfaces( ctx, width, height, format, num_surfaces, surfaces );
+ if (!ctx->vtable->vaGetSurfaceAttributes)
+ return VA_STATUS_ERROR_UNIMPLEMENTED;
- VA_TRACE_LOG(va_TraceCreateSurface, dpy, width, height, format, num_surfaces, surfaces);
-
- return vaStatus;
+ vaStatus = ctx->vtable->vaGetSurfaceAttributes(ctx, config,
+ attrib_list, num_attribs);
+ return vaStatus;
+}
+
+VAStatus
+vaCreateSurfaces(
+ VADisplay dpy,
+ unsigned int format,
+ unsigned int width,
+ unsigned int height,
+ VASurfaceID *surfaces,
+ unsigned int num_surfaces,
+ VASurfaceAttrib *attrib_list,
+ unsigned int num_attribs
+)
+{
+ VADriverContextP ctx;
+ VAStatus vaStatus;
+
+ CHECK_DISPLAY(dpy);
+ ctx = CTX(dpy);
+ if (!ctx)
+ return VA_STATUS_ERROR_INVALID_DISPLAY;
+
+ if (ctx->vtable->vaCreateSurfaces2)
+ return ctx->vtable->vaCreateSurfaces2(ctx, format, width, height,
+ surfaces, num_surfaces,
+ attrib_list, num_attribs);
+
+ if (attrib_list && num_attribs > 0)
+ return VA_STATUS_ERROR_ATTR_NOT_SUPPORTED;
+
+ vaStatus = ctx->vtable->vaCreateSurfaces(ctx, width, height, format,
+ num_surfaces, surfaces);
+
+ VA_TRACE_LOG(va_TraceCreateSurface,
+ dpy, width, height, format, num_surfaces, surfaces);
+
+ return vaStatus;
}
diff --git a/va/va.h b/va/va.h
index f7f8e0b..5dd34d1 100644
--- a/va/va.h
+++ b/va/va.h
@@ -619,24 +619,106 @@ typedef struct _VAGenericValue {
} value;
} VAGenericValue;
-/*
- * vaCreateSurfaces - Create an array of surfaces used for decode and display
- * dpy: display
- * width: surface width
- * height: surface height
- * format: VA_RT_FORMAT_YUV420, VA_RT_FORMAT_YUV422 or VA_RT_FORMAT_YUV444
- * num_surfaces: number of surfaces to be created
- * surfaces: array of surfaces created upon return
- */
-VAStatus vaCreateSurfaces (
- VADisplay dpy,
- int width,
- int height,
- int format,
- int num_surfaces,
- VASurfaceID *surfaces /* out */
+/** @name Surface attribute flags */
+/**@{*/
+/** \brief Surface attribute is not supported. */
+#define VA_SURFACE_ATTRIB_NOT_SUPPORTED 0x00000000
+/** \brief Surface attribute can be got through vaQuerySurfaceAttributes(). */
+#define VA_SURFACE_ATTRIB_GETTABLE 0x00000001
+/** \brief Surface attribute can be set through vaCreateSurfaces(). */
+#define VA_SURFACE_ATTRIB_SETTABLE 0x00000002
+/**@}*/
+
+/** \brief Surface attribute types. */
+typedef enum {
+ VASurfaceAttribNone = 0,
+ /**
+ * \brief Pixel format (fourcc).
+ *
+ * The value is meaningful as input to vaQuerySurfaceAttributes().
+ * If zero, the driver returns the optimal pixel format for the
+ * specified config. Otherwise, if non-zero, the value represents
+ * a pixel format (FOURCC) that is kept as is on output, if the
+ * driver supports it. Otherwise, the driver sets the value to
+ * zero and drops the \c VA_SURFACE_ATTRIB_SETTABLE flag.
+ */
+ VASurfaceAttribPixelFormat,
+ /** \brief Minimal width in pixels (int, read/write). */
+ VASurfaceAttribMinWidth,
+ /** \brief Maximal width in pixels (int, read-only). */
+ VASurfaceAttribMaxWidth,
+ /** \brief Minimal height in pixels (int, read-only). */
+ VASurfaceAttribMinHeight,
+ /** \brief Maximal height in pixels (int, read-only). */
+ VASurfaceAttribMaxHeight,
+ /** \brief Number of surface attributes. */
+ VASurfaceAttribCount
+} VASurfaceAttribType;
+
+/** \brief Surface attribute. */
+typedef struct _VASurfaceAttrib {
+ /** \brief Type. */
+ VASurfaceAttribType type;
+ /** \brief Flags. See "Surface attribute flags". */
+ unsigned int flags;
+ /** \brief Value. See "Surface attribute types" for the expected types. */
+ VAGenericValue value;
+} VASurfaceAttrib;
+
+/**
+ * \brief Get surface attributes for the supplied config.
+ *
+ * This function retrieves the surface attributes matching the supplied
+ * config. The caller shall provide an \c attrib_list with all attributes
+ * to be retrieved. Upon successful return, the attributes in \c attrib_list
+ * are updated with the requested value. Unknown attributes or attributes
+ * that are not supported for the given config will have their \c flags
+ * field set to \c VA_SURFACE_ATTRIB_NOT_SUPPORTED.
+ *
+ * @param[in] dpy the VA display
+ * @param[in] config the config identifying a codec or a video
+ * processing pipeline
+ * @param[in,out] attrib_list the list of attributes on input, with at
+ * least \c type fields filled in, and possibly \c value fields whenever
+ * necessary. The updated list of attributes and flags on output
+ * @param[in] num_attribs the number of attributes supplied in the
+ * \c attrib_list array
+ */
+VAStatus
+vaGetSurfaceAttributes(
+ VADisplay dpy,
+ VAConfigID config,
+ VASurfaceAttrib *attrib_list,
+ unsigned int num_attribs
);
+/**
+ * \brief Creates an array of surfaces
+ *
+ * Creates an array of surfaces. The optional list of attributes shall
+ * be constructed and verified through vaGetSurfaceAttributes().
+ *
+ * @param[in] dpy the VA display
+ * @param[in] format the desired surface format. See \c VA_RT_FORMAT_*
+ * @param[in] width the surface width
+ * @param[in] height the surface height
+ * @param[out] surfaces the array of newly created surfaces
+ * @param[in] num_surfaces the number of surfaces to create
+ * @param[in] attrib_list the list of (optional) attributes, or \c NULL
+ * @param[in] num_attribs the number of attributes supplied in
+ * \c attrib_list, or zero
+ */
+VAStatus
+vaCreateSurfaces(
+ VADisplay dpy,
+ unsigned int format,
+ unsigned int width,
+ unsigned int height,
+ VASurfaceID *surfaces,
+ unsigned int num_surfaces,
+ VASurfaceAttrib *attrib_list,
+ unsigned int num_attribs
+);
/*
* vaDestroySurfaces - Destroy resources associated with surfaces.
diff --git a/va/va_backend.h b/va/va_backend.h
index 35e96cf..f27b32f 100644
--- a/va/va_backend.h
+++ b/va/va_backend.h
@@ -391,6 +391,26 @@ struct VADriverVTable
VADriverContextP ctx,
VASurfaceID surface
);
+
+ VAStatus
+ (*vaGetSurfaceAttributes)(
+ VADriverContextP dpy,
+ VAConfigID config,
+ VASurfaceAttrib *attrib_list,
+ unsigned int num_attribs
+ );
+
+ VAStatus
+ (*vaCreateSurfaces2)(
+ VADriverContextP ctx,
+ unsigned int format,
+ unsigned int width,
+ unsigned int height,
+ VASurfaceID *surfaces,
+ unsigned int num_surfaces,
+ VASurfaceAttrib *attrib_list,
+ unsigned int num_attribs
+ );
};
struct VADriverContext