API: vpp: add blend state for composition.
authorGwenole Beauchesne <gwenole.beauchesne@intel.com>
Tue, 3 Apr 2012 12:28:40 +0000 (14:28 +0200)
committerGwenole Beauchesne <gwenole.beauchesne@intel.com>
Fri, 14 Dec 2012 16:45:08 +0000 (17:45 +0100)
Add a new VABlendState structure that defines the blending operations for
composition. So far, only luma keying, alpha blending and premultiplied
alpha are supported.

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
va/va.h
va/va_vpp.h

diff --git a/va/va.h b/va/va.h
index 01b1f9f..3525088 100644 (file)
--- a/va/va.h
+++ b/va/va.h
@@ -179,6 +179,8 @@ typedef int VAStatus;       /* Return status type from functions */
 #define VA_STATUS_ERROR_INVALID_FILTER_CHAIN    0x00000021
 /** \brief Indicate HW busy (e.g. run multiple encoding simultaneously). */
 #define VA_STATUS_ERROR_HW_BUSY                        0x00000022
+/** \brief An invalid blend state was supplied. */
+#define VA_STATUS_ERROR_INVALID_BLEND_STATE     0x00000023
 #define VA_STATUS_ERROR_UNKNOWN                        0xFFFFFFFF
 
 /* De-interlacing flags for vaPutSurface() */
index fcbb196..fea5aca 100644 (file)
@@ -312,6 +312,45 @@ typedef enum _VAProcColorStandardType {
     VAProcColorStandardCount
 } VAProcColorStandardType;
 
+/** @name Video blending flags */
+/**@{*/
+/** \brief Global alpha blending. */
+#define VA_BLEND_GLOBAL_ALPHA           0x0002
+/** \brief Premultiplied alpha blending (RGBA surfaces only). */
+#define VA_BLEND_PREMULTIPLIED_ALPHA    0x0008
+/** \brief Luma color key (YUV surfaces only). */
+#define VA_BLEND_LUMA_KEY               0x0010
+/**@}*/
+
+/** \brief Video blending state definition. */
+typedef struct _VABlendState {
+    /** \brief Video blending flags. */
+    unsigned int        flags;
+    /**
+     * \brief Global alpha value.
+     *
+     * Valid if \flags has VA_BLEND_GLOBAL_ALPHA.
+     * Valid range is 0.0 to 1.0 inclusive.
+     */
+    float               global_alpha;
+    /**
+     * \brief Minimum luma value.
+     *
+     * Valid if \flags has VA_BLEND_LUMA_KEY.
+     * Valid range is 0.0 to 1.0 inclusive.
+     * \ref min_luma shall be set to a sensible value lower than \ref max_luma.
+     */
+    float               min_luma;
+    /**
+     * \brief Maximum luma value.
+     *
+     * Valid if \flags has VA_BLEND_LUMA_KEY.
+     * Valid range is 0.0 to 1.0 inclusive.
+     * \ref max_luma shall be set to a sensible value larger than \ref min_luma.
+     */
+    float               max_luma;
+} VABlendState;
+
 /** @name Video pipeline flags */
 /**@{*/
 /** \brief Specifies whether to apply subpictures when processing a surface. */
@@ -373,6 +412,8 @@ typedef struct _VAProcPipelineCaps {
      * \endcode
      */
     unsigned int        rotation_flags;
+    /** \brief Blend flags. See "Video blending flags". */
+    unsigned int        blend_flags;
     /** \brief Number of forward reference frames that are needed. */
     unsigned int        num_forward_references;
     /** \brief Number of backward reference frames that are needed. */
@@ -512,6 +553,25 @@ typedef struct _VAProcPipelineParameterBuffer {
      */
     unsigned int        rotation_state;
     /**
+     * \brief blending state. See "Video blending state definition".
+     *
+     * If \ref blend_state is NULL, then default operation mode depends
+     * on the source \ref surface format:
+     * - RGB: per-pixel alpha blending ;
+     * - YUV: no blending, i.e override the underlying pixels.
+     *
+     * Otherwise, \ref blend_state is a pointer to a #VABlendState
+     * structure that shall be live until vaEndPicture().
+     *
+     * Implementation note: the driver is responsible for checking the
+     * blend state flags against the actual source \ref surface format.
+     * e.g. premultiplied alpha blending is only applicable to RGB
+     * surfaces, and luma keying is only applicable to YUV surfaces.
+     * If a mismatch occurs, then #VA_STATUS_ERROR_INVALID_BLEND_STATE
+     * is returned.
+     */
+    const VABlendState *blend_state;
+    /**
      * \brief Pipeline filters. See video pipeline flags.
      *
      * Flags to control the pipeline, like whether to apply subpictures