Home | History | Annotate | Download | only in va
      1 /*
      2  * Copyright (c) 2007-2009 Intel Corporation. All Rights Reserved.
      3  *
      4  * Permission is hereby granted, free of charge, to any person obtaining a
      5  * copy of this software and associated documentation files (the
      6  * "Software"), to deal in the Software without restriction, including
      7  * without limitation the rights to use, copy, modify, merge, publish,
      8  * distribute, sub license, and/or sell copies of the Software, and to
      9  * permit persons to whom the Software is furnished to do so, subject to
     10  * the following conditions:
     11  *
     12  * The above copyright notice and this permission notice (including the
     13  * next paragraph) shall be included in all copies or substantial portions
     14  * of the Software.
     15  *
     16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
     17  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
     18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
     19  * IN NO EVENT SHALL INTEL AND/OR ITS SUPPLIERS BE LIABLE FOR
     20  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
     21  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
     22  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
     23  */
     24 /*
     25  * Video Acceleration (VA) API Specification
     26  *
     27  * Rev. 0.30
     28  * <jonathan.bian (at) intel.com>
     29  *
     30  * Revision History:
     31  * rev 0.10 (12/10/2006 Jonathan Bian) - Initial draft
     32  * rev 0.11 (12/15/2006 Jonathan Bian) - Fixed some errors
     33  * rev 0.12 (02/05/2007 Jonathan Bian) - Added VC-1 data structures for slice level decode
     34  * rev 0.13 (02/28/2007 Jonathan Bian) - Added GetDisplay()
     35  * rev 0.14 (04/13/2007 Jonathan Bian) - Fixed MPEG-2 PictureParameter structure, cleaned up a few funcs.
     36  * rev 0.15 (04/20/2007 Jonathan Bian) - Overhauled buffer management
     37  * rev 0.16 (05/02/2007 Jonathan Bian) - Added error codes and fixed some issues with configuration
     38  * rev 0.17 (05/07/2007 Jonathan Bian) - Added H.264/AVC data structures for slice level decode.
     39  * rev 0.18 (05/14/2007 Jonathan Bian) - Added data structures for MPEG-4 slice level decode
     40  *                                       and MPEG-2 motion compensation.
     41  * rev 0.19 (08/06/2007 Jonathan Bian) - Removed extra type for bitplane data.
     42  * rev 0.20 (08/08/2007 Jonathan Bian) - Added missing fields to VC-1 PictureParameter structure.
     43  * rev 0.21 (08/20/2007 Jonathan Bian) - Added image and subpicture support.
     44  * rev 0.22 (08/27/2007 Jonathan Bian) - Added support for chroma-keying and global alpha.
     45  * rev 0.23 (09/11/2007 Jonathan Bian) - Fixed some issues with images and subpictures.
     46  * rev 0.24 (09/18/2007 Jonathan Bian) - Added display attributes.
     47  * rev 0.25 (10/18/2007 Jonathan Bian) - Changed to use IDs only for some types.
     48  * rev 0.26 (11/07/2007 Waldo Bastian) - Change vaCreateBuffer semantics
     49  * rev 0.27 (11/19/2007 Matt Sottek)   - Added DeriveImage
     50  * rev 0.28 (12/06/2007 Jonathan Bian) - Added new versions of PutImage and AssociateSubpicture
     51  *                                       to enable scaling
     52  * rev 0.29 (02/07/2008 Jonathan Bian) - VC1 parameter fixes,
     53  *                                       added VA_STATUS_ERROR_RESOLUTION_NOT_SUPPORTED
     54  * rev 0.30 (03/01/2009 Jonathan Bian) - Added encoding support for H.264 BP and MPEG-4 SP and fixes
     55  *                                       for ISO C conformance.
     56  * rev 0.31 (09/02/2009 Gwenole Beauchesne) - VC-1/H264 fields change for VDPAU and XvBA backend
     57  *                                       Application needs to relink with the new library.
     58  *
     59  * rev 0.31.1 (03/29/2009)              - Data structure for JPEG encode
     60  * rev 0.31.2 (01/13/2011 Anthony Pabon)- Added a flag to indicate Subpicture coordinates are screen
     61  *                                        screen relative rather than source video relative.
     62  * rev 0.32.0 (01/13/2011 Xiang Haihao) - Add profile into VAPictureParameterBufferVC1
     63  *                                        update VAAPI to 0.32.0
     64  *
     65  * Acknowledgements:
     66  *  Some concepts borrowed from XvMC and XvImage.
     67  *  Waldo Bastian (Intel), Matt Sottek (Intel),  Austin Yuan (Intel), and Gwenole Beauchesne (SDS)
     68  *  contributed to various aspects of the API.
     69  */
     70 
     71 /**
     72  * \file va.h
     73  * \brief The Core API
     74  *
     75  * This file contains the \ref api_core "Core API".
     76  */
     77 
     78 #ifndef _VA_H_
     79 #define _VA_H_
     80 
     81 #include <stdint.h>
     82 #include <va/va_version.h>
     83 
     84 #ifdef __cplusplus
     85 extern "C" {
     86 #endif
     87 
     88 #ifdef __GNUC__
     89 # define __maybe_unused __attribute__((__unused__))
     90 #else
     91 # define __maybe_unused
     92 #endif
     93 
     94 /**
     95  * \mainpage Video Acceleration (VA) API
     96  *
     97  * \section intro Introduction
     98  *
     99  * The main motivation for VA-API (Video Acceleration API) is to
    100  * enable hardware accelerated video decode and encode at various
    101  * entry-points (VLD, IDCT, Motion Compensation etc.) for the
    102  * prevailing coding standards today (MPEG-2, MPEG-4 ASP/H.263, MPEG-4
    103  * AVC/H.264, VC-1/VMW3, and JPEG).
    104  *
    105  * VA-API is split into several modules:
    106  * - \ref api_core
    107  * - \ref api_enc_core
    108  * - \ref api_enc_h264
    109  * - \ref api_vpp
    110  */
    111 
    112 /**
    113  * \defgroup api_core Core API
    114  *
    115  * @{
    116  */
    117 
    118 /*
    119 Overview
    120 
    121 The VA API is intended to provide an interface between a video decode/encode/display
    122 application (client) and a hardware accelerator (server), to off-load
    123 video decode/encode/display operations from the host to the hardware accelerator at various
    124 entry-points.
    125 
    126 The basic operation steps are:
    127 
    128 - Negotiate a mutually acceptable configuration with the server to lock
    129   down profile, entrypoints, and other attributes that will not change on
    130   a frame-by-frame basis.
    131 - Create a decode context which represents a "virtualized" hardware decode
    132   device
    133 - Get and fill decode buffers with picture level, slice level and macroblock
    134   level data (depending on entrypoints)
    135 - Pass the decode buffers to the server to decode the current frame
    136 
    137 Initialization & Configuration Management
    138 
    139 - Find out supported profiles
    140 - Find out entrypoints for a given profile
    141 - Find out configuration attributes for a given profile/entrypoint pair
    142 - Create a configuration for use by the decoder
    143 
    144 */
    145 
    146 typedef void* VADisplay;	/* window system dependent */
    147 
    148 typedef int VAStatus;	/* Return status type from functions */
    149 /* Values for the return status */
    150 #define VA_STATUS_SUCCESS			0x00000000
    151 #define VA_STATUS_ERROR_OPERATION_FAILED	0x00000001
    152 #define VA_STATUS_ERROR_ALLOCATION_FAILED	0x00000002
    153 #define VA_STATUS_ERROR_INVALID_DISPLAY		0x00000003
    154 #define VA_STATUS_ERROR_INVALID_CONFIG		0x00000004
    155 #define VA_STATUS_ERROR_INVALID_CONTEXT		0x00000005
    156 #define VA_STATUS_ERROR_INVALID_SURFACE		0x00000006
    157 #define VA_STATUS_ERROR_INVALID_BUFFER		0x00000007
    158 #define VA_STATUS_ERROR_INVALID_IMAGE		0x00000008
    159 #define VA_STATUS_ERROR_INVALID_SUBPICTURE	0x00000009
    160 #define VA_STATUS_ERROR_ATTR_NOT_SUPPORTED	0x0000000a
    161 #define VA_STATUS_ERROR_MAX_NUM_EXCEEDED	0x0000000b
    162 #define VA_STATUS_ERROR_UNSUPPORTED_PROFILE	0x0000000c
    163 #define VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT	0x0000000d
    164 #define VA_STATUS_ERROR_UNSUPPORTED_RT_FORMAT	0x0000000e
    165 #define VA_STATUS_ERROR_UNSUPPORTED_BUFFERTYPE	0x0000000f
    166 #define VA_STATUS_ERROR_SURFACE_BUSY		0x00000010
    167 #define VA_STATUS_ERROR_FLAG_NOT_SUPPORTED      0x00000011
    168 #define VA_STATUS_ERROR_INVALID_PARAMETER	0x00000012
    169 #define VA_STATUS_ERROR_RESOLUTION_NOT_SUPPORTED 0x00000013
    170 #define VA_STATUS_ERROR_UNIMPLEMENTED           0x00000014
    171 #define VA_STATUS_ERROR_SURFACE_IN_DISPLAYING   0x00000015
    172 #define VA_STATUS_ERROR_INVALID_IMAGE_FORMAT    0x00000016
    173 #define VA_STATUS_ERROR_DECODING_ERROR          0x00000017
    174 #define VA_STATUS_ERROR_ENCODING_ERROR          0x00000018
    175 /**
    176  * \brief An invalid/unsupported value was supplied.
    177  *
    178  * This is a catch-all error code for invalid or unsupported values.
    179  * e.g. value exceeding the valid range, invalid type in the context
    180  * of generic attribute values.
    181  */
    182 #define VA_STATUS_ERROR_INVALID_VALUE           0x00000019
    183 /** \brief An unsupported filter was supplied. */
    184 #define VA_STATUS_ERROR_UNSUPPORTED_FILTER      0x00000020
    185 /** \brief An invalid filter chain was supplied. */
    186 #define VA_STATUS_ERROR_INVALID_FILTER_CHAIN    0x00000021
    187 /** \brief Indicate HW busy (e.g. run multiple encoding simultaneously). */
    188 #define VA_STATUS_ERROR_HW_BUSY	                0x00000022
    189 /** \brief An invalid blend state was supplied. */
    190 #define VA_STATUS_ERROR_INVALID_BLEND_STATE     0x00000023
    191 #define VA_STATUS_ERROR_UNKNOWN			0xFFFFFFFF
    192 
    193 /* De-interlacing flags for vaPutSurface() */
    194 #define VA_FRAME_PICTURE        0x00000000
    195 #define VA_TOP_FIELD            0x00000001
    196 #define VA_BOTTOM_FIELD         0x00000002
    197 
    198 /*
    199  * Enabled the positioning/cropping/blending feature:
    200  * 1, specify the video playback position in the isurface
    201  * 2, specify the cropping info for video playback
    202  * 3, encoded video will blend with background color
    203  */
    204 #define VA_ENABLE_BLEND         0x00000004 /* video area blend with the constant color */
    205 
    206 /*
    207  * Clears the drawable with background color.
    208  * for hardware overlay based implementation this flag
    209  * can be used to turn off the overlay
    210  */
    211 #define VA_CLEAR_DRAWABLE       0x00000008
    212 
    213 /* Color space conversion flags for vaPutSurface() */
    214 #define VA_SRC_COLOR_MASK       0x000000f0
    215 #define VA_SRC_BT601            0x00000010
    216 #define VA_SRC_BT709            0x00000020
    217 #define VA_SRC_SMPTE_240        0x00000040
    218 #define VA_SRC_BT2020           0x00000080
    219 
    220 /* Scaling flags for vaPutSurface() */
    221 #define VA_FILTER_SCALING_DEFAULT       0x00000000
    222 #define VA_FILTER_SCALING_FAST          0x00000100
    223 #define VA_FILTER_SCALING_HQ            0x00000200
    224 #define VA_FILTER_SCALING_NL_ANAMORPHIC 0x00000300
    225 #define VA_FILTER_SCALING_MASK          0x00000f00
    226 
    227 /*
    228  * The upper 16 bits are reserved for VPP filter fast path usage.
    229  * Flag to enable auto noise reduction.
    230  */
    231 #define VA_FILTER_NOISEREDUCTION_AUTO   0x00010000
    232 
    233 /*
    234  * This is to indicate that the color-space conversion uses full range or reduced range.
    235  * VA_SOURCE_RANGE_FULL(Full range): Y/Cb/Cr is in [0, 255]. It is mainly used
    236  *      for JPEG/JFIF formats. The combination with the BT601 flag means that
    237  *      JPEG/JFIF color-space conversion matrix is used.
    238  * VA_SOURCE_RANGE_REDUCED(Reduced range): Y is in [16, 235] and Cb/Cr is in [16, 240].
    239  *      It is mainly used for the YUV->RGB color-space conversion in SDTV/HDTV/UHDTV.
    240  */
    241 #define VA_SOURCE_RANGE_MASK            0x00020000
    242 #define VA_SOURCE_RANGE_FULL            0x00020000
    243 #define VA_SOURCE_RANGE_REDUCED         0x00000000
    244 /*
    245  * Returns a short english description of error_status
    246  */
    247 const char *vaErrorStr(VAStatus error_status);
    248 
    249 typedef struct _VARectangle
    250 {
    251     short x;
    252     short y;
    253     unsigned short width;
    254     unsigned short height;
    255 } VARectangle;
    256 
    257 /** \brief Generic motion vector data structure. */
    258 typedef struct _VAMotionVector {
    259     /** \mv0[0]: horizontal motion vector for past reference */
    260     /** \mv0[1]: vertical motion vector for past reference */
    261     /** \mv1[0]: horizontal motion vector for future reference */
    262     /** \mv1[1]: vertical motion vector for future reference */
    263     unsigned short  mv0[2];  /* past reference */
    264     unsigned short  mv1[2];  /* future reference */
    265 } VAMotionVector;
    266 
    267 /*
    268  * Initialization:
    269  * A display must be obtained by calling vaGetDisplay() before calling
    270  * vaInitialize() and other functions. This connects the API to the
    271  * native window system.
    272  * For X Windows, native_dpy would be from XOpenDisplay()
    273  */
    274 typedef void* VANativeDisplay;	/* window system dependent */
    275 
    276 int vaDisplayIsValid(VADisplay dpy);
    277 
    278 /*
    279  * Initialize the library
    280  */
    281 VAStatus vaInitialize (
    282     VADisplay dpy,
    283     int *major_version,	 /* out */
    284     int *minor_version 	 /* out */
    285 );
    286 
    287 /*
    288  * After this call, all library internal resources will be cleaned up
    289  */
    290 VAStatus vaTerminate (
    291     VADisplay dpy
    292 );
    293 
    294 /*
    295  * vaQueryVendorString returns a pointer to a zero-terminated string
    296  * describing some aspects of the VA implemenation on a specific
    297  * hardware accelerator. The format of the returned string is vendor
    298  * specific and at the discretion of the implementer.
    299  * e.g. for the Intel GMA500 implementation, an example would be:
    300  * "Intel GMA500 - 2.0.0.32L.0005"
    301  */
    302 const char *vaQueryVendorString (
    303     VADisplay dpy
    304 );
    305 
    306 typedef int (*VAPrivFunc)();
    307 
    308 /*
    309  * Return a function pointer given a function name in the library.
    310  * This allows private interfaces into the library
    311  */
    312 VAPrivFunc vaGetLibFunc (
    313     VADisplay dpy,
    314     const char *func
    315 );
    316 
    317 /* Currently defined profiles */
    318 typedef enum
    319 {
    320     /** \brief Profile ID used for video processing. */
    321     VAProfileNone                       = -1,
    322     VAProfileMPEG2Simple		= 0,
    323     VAProfileMPEG2Main			= 1,
    324     VAProfileMPEG4Simple		= 2,
    325     VAProfileMPEG4AdvancedSimple	= 3,
    326     VAProfileMPEG4Main			= 4,
    327     VAProfileH264Baseline		= 5,
    328     VAProfileH264Main			= 6,
    329     VAProfileH264High			= 7,
    330     VAProfileVC1Simple			= 8,
    331     VAProfileVC1Main			= 9,
    332     VAProfileVC1Advanced		= 10,
    333     VAProfileH263Baseline		= 11,
    334     VAProfileJPEGBaseline               = 12,
    335     VAProfileH264ConstrainedBaseline    = 13,
    336     VAProfileVP8Version0_3              = 14,
    337     VAProfileH264MultiviewHigh          = 15,
    338     VAProfileH264StereoHigh             = 16,
    339     VAProfileHEVCMain                   = 17,
    340     VAProfileHEVCMain10                 = 18,
    341     VAProfileVP9Version0                = 19,
    342     VAProfileAVS                        = 20,
    343     VAProfileMax
    344 } VAProfile;
    345 
    346 /*
    347  *  Currently defined entrypoints
    348  */
    349 typedef enum
    350 {
    351     VAEntrypointVLD		= 1,
    352     VAEntrypointIZZ		= 2,
    353     VAEntrypointIDCT		= 3,
    354     VAEntrypointMoComp		= 4,
    355     VAEntrypointDeblocking	= 5,
    356     VAEntrypointEncSlice	= 6,	/* slice level encode */
    357     VAEntrypointEncPicture 	= 7,	/* pictuer encode, JPEG, etc */
    358     /*
    359      * For an implementation that supports a low power/high performance variant
    360      * for slice level encode, it can choose to expose the
    361      * VAEntrypointEncSliceLP entrypoint. Certain encoding tools may not be
    362      * available with this entrypoint (e.g. interlace, MBAFF) and the
    363      * application can query the encoding configuration attributes to find
    364      * out more details if this entrypoint is supported.
    365      */
    366     VAEntrypointEncSliceLP 	= 8,
    367     VAEntrypointVideoProc       = 10,   /**< Video pre/post-processing. */
    368 
    369     /**
    370      * \brief Intel specific entrypoints start at 1001
    371      */
    372     /**
    373      * \brief VAEntrypointEncFEIIntel
    374      *
    375      * The purpose of FEI (Flexible Encoding Infrastructure) is to allow applications to
    376      * have more controls and trade off quality for speed with their own IPs. A pre-processing
    377      * function for getting some statistics and motion vectors is added
    378      * and some extra controls for Encode pipeline are provided.
    379      * The application can optionally call the statistics function
    380      * to get motion vectors and statistics before calling encode function.
    381      * The application can also optionally provide input to VME for extra
    382      * encode control and get the output from VME. Application can chose to
    383      * modify the VME output/PAK input during encoding, but the performance
    384      * impact is significant.
    385      *
    386      * On top of the existing buffers for normal encode, there will be
    387      * one extra input buffer (VAEncMiscParameterIntelFEIFrameControl) and
    388      * three extra output buffers (VAIntelEncFEIMVBufferType, VAIntelEncFEIModeBufferType
    389      * and VAIntelEncFEIDistortionBufferType) for VAEntrypointIntelEncFEI entry function.
    390      * If separate PAK is set, two extra input buffers
    391      * (VAIntelEncFEIMVBufferType, VAIntelEncFEIModeBufferType) are needed for PAK input.
    392      *
    393      **/
    394     VAEntrypointEncFEIIntel     = 1001,
    395     /**
    396      * \brief VAEntrypointStatisticsIntel
    397      *
    398      * Statistics, like variances, distortions, motion vectors can be obtained
    399      * via this entry point. Checking whether Statistics is supported can be
    400      * performed with vaQueryConfigEntrypoints() and the profile argument
    401      * set to #VAProfileNone. If Statistics entry point is supported,
    402      * then the list of returned entry-points will include #VAEntrypointIntelStatistics.
    403      * Supported pixel format, maximum resolution and statistics specific attributes
    404      * can be obtained via normal attribute query.
    405      * One input buffer (VAIntelStatsStatisticsParameterBufferType) and one or two
    406      * output buffers (VAIntelStatsStatisticsBufferType and VAIntelStatsMotionVectorBufferType)
    407      * are needed for this entry point.
    408      *
    409      **/
    410     VAEntrypointStatisticsIntel,
    411     VAEntrypointMax
    412 } VAEntrypoint;
    413 
    414 /* Currently defined configuration attribute types */
    415 typedef enum
    416 {
    417     VAConfigAttribRTFormat		= 0,
    418     VAConfigAttribSpatialResidual	= 1,
    419     VAConfigAttribSpatialClipping	= 2,
    420     VAConfigAttribIntraResidual		= 3,
    421     VAConfigAttribEncryption		= 4,
    422     VAConfigAttribRateControl		= 5,
    423 
    424     /** @name Attributes for decoding */
    425     /**@{*/
    426     /**
    427      * \brief Slice Decoding mode. Read/write.
    428      *
    429      * This attribute determines what mode the driver supports for slice
    430      * decoding, through vaGetConfigAttributes(); and what mode the user
    431      * will be providing to the driver, through vaCreateConfig(), if the
    432      * driver supports those. If this attribute is not set by the user then
    433      * it is assumed that VA_DEC_SLICE_MODE_NORMAL mode is used.
    434      *
    435      * See \c VA_DEC_SLICE_MODE_xxx for the list of slice decoding modes.
    436      */
    437     VAConfigAttribDecSliceMode		= 6,
    438    /**
    439      * \brief JPEG decoding attribute. Read-only.
    440      *
    441      * This attribute exposes a number of capabilities of the underlying
    442      * JPEG implementation. The attribute value is partitioned into fields as defined in the
    443      * VAConfigAttribValDecJPEG union.
    444      */
    445     VAConfigAttribDecJPEG             = 7,
    446 
    447     /** @name Attributes for encoding */
    448     /**@{*/
    449     /**
    450      * \brief Packed headers mode. Read/write.
    451      *
    452      * This attribute determines what packed headers the driver supports,
    453      * through vaGetConfigAttributes(); and what packed headers the user
    454      * will be providing to the driver, through vaCreateConfig(), if the
    455      * driver supports those.
    456      *
    457      * See \c VA_ENC_PACKED_HEADER_xxx for the list of packed headers.
    458      */
    459     VAConfigAttribEncPackedHeaders      = 10,
    460     /**
    461      * \brief Interlaced mode. Read/write.
    462      *
    463      * This attribute determines what kind of interlaced encoding mode
    464      * the driver supports.
    465      *
    466      * See \c VA_ENC_INTERLACED_xxx for the list of interlaced modes.
    467      */
    468     VAConfigAttribEncInterlaced         = 11,
    469     /**
    470      * \brief Maximum number of reference frames. Read-only.
    471      *
    472      * This attribute determines the maximum number of reference
    473      * frames supported for encoding.
    474      *
    475      * Note: for H.264 encoding, the value represents the maximum number
    476      * of reference frames for both the reference picture list 0 (bottom
    477      * 16 bits) and the reference picture list 1 (top 16 bits).
    478      */
    479     VAConfigAttribEncMaxRefFrames       = 13,
    480     /**
    481      * \brief Maximum number of slices per frame. Read-only.
    482      *
    483      * This attribute determines the maximum number of slices the
    484      * driver can support to encode a single frame.
    485      */
    486     VAConfigAttribEncMaxSlices          = 14,
    487     /**
    488      * \brief Slice structure. Read-only.
    489      *
    490      * This attribute determines slice structures supported by the
    491      * driver for encoding. This attribute is a hint to the user so
    492      * that he can choose a suitable surface size and how to arrange
    493      * the encoding process of multiple slices per frame.
    494      *
    495      * More specifically, for H.264 encoding, this attribute
    496      * determines the range of accepted values to
    497      * VAEncSliceParameterBufferH264::macroblock_address and
    498      * VAEncSliceParameterBufferH264::num_macroblocks.
    499      *
    500      * See \c VA_ENC_SLICE_STRUCTURE_xxx for the supported slice
    501      * structure types.
    502      */
    503     VAConfigAttribEncSliceStructure     = 15,
    504     /**
    505      * \brief Macroblock information. Read-only.
    506      *
    507      * This attribute determines whether the driver supports extra
    508      * encoding information per-macroblock. e.g. QP.
    509      *
    510      * More specifically, for H.264 encoding, if the driver returns a non-zero
    511      * value for this attribute, this means the application can create
    512      * additional #VAEncMacroblockParameterBufferH264 buffers referenced
    513      * through VAEncSliceParameterBufferH264::macroblock_info.
    514      */
    515     VAConfigAttribEncMacroblockInfo     = 16,
    516     /**
    517      * \brief Auto reference frame management. Read-only
    518      *
    519      * This attribute determines whether the driver supports auto reference management
    520      *
    521      * If driver supports, application only needs to set scratch reference surfaces
    522      * via VAPictureParameterBufferH264:ReferenceFrames. The scratch surfaces number is
    523      * determined by the maximum number of RefPicList0 and RefPicList0 which can be queried from
    524      * VAConfigAttribEncMaxRefFrames. Application doesn't need to set VAPictureParameterBufferH264:CurrPic
    525      * and VAEncSliceParameterBufferH264:RefPicList. Driver will manage the reference frames internally
    526      * and choose the best reference frames. Which scratch surface is used for reconstructed frame and which
    527      * surfaces are used for reference frames will be fedback via VACodedBufferSegment
    528      */
    529     VAConfigAttribEncAutoReference     = 17,
    530     /**
    531      * \brief Maximum picture width. Read-only.
    532      *
    533      * This attribute determines the maximum picture width the driver supports
    534      * for a given configuration.
    535      */
    536     VAConfigAttribMaxPictureWidth     = 18,
    537     /**
    538      * \brief Maximum picture height. Read-only.
    539      *
    540      * This attribute determines the maximum picture height the driver supports
    541      * for a given configuration.
    542      */
    543     VAConfigAttribMaxPictureHeight    = 19,
    544     /**
    545      * \brief JPEG encoding attribute. Read-only.
    546      *
    547      * This attribute exposes a number of capabilities of the underlying
    548      * JPEG implementation. The attribute value is partitioned into fields as defined in the
    549      * VAConfigAttribValEncJPEG union.
    550      */
    551     VAConfigAttribEncJPEG             = 20,
    552     /**
    553      * \brief Encoding quality range attribute. Read-only.
    554      *
    555      * This attribute conveys whether the driver supports different quality level settings
    556      * for encoding. A value less than or equal to 1 means that the encoder only has a single
    557      * quality setting, and a value greater than 1 represents the number of quality levels
    558      * that can be configured. e.g. a value of 2 means there are two distinct quality levels.
    559      */
    560     VAConfigAttribEncQualityRange     = 21,
    561     /**
    562      * \brief Encoding quantization attribute. Read-only.
    563      *
    564      * This attribute conveys whether the driver supports certain types of quantization methods
    565      * for encoding (e.g. trellis).
    566      */
    567     VAConfigAttribEncQuantization     = 22,
    568     /**
    569      * \brief Encoding intra refresh attribute. Read-only.
    570      *
    571      * This attribute conveys whether the driver supports certain types of intra refresh methods
    572      * for encoding (e.g. adaptive intra refresh or rolling intra refresh).
    573      */
    574     VAConfigAttribEncIntraRefresh     = 23,
    575     /**
    576      * \brief Encoding skip frame attribute. Read-only.
    577      *
    578      * This attribute conveys whether the driver supports sending skip frame parameters
    579      * (VAEncMiscParameterTypeSkipFrame) to the encoder's rate control, when the user has
    580      * externally skipped frames.  It is a boolean value 0 - unsupported, 1 - supported.
    581      */
    582     VAConfigAttribEncSkipFrame        = 24,
    583     /**
    584      * \brief Encoding region-of-interest (ROI) attribute. Read-only.
    585      *
    586      * This attribute conveys whether the driver supports region-of-interest (ROI) encoding,
    587      * based on user provided ROI rectangles.  The attribute value returned indicates the number
    588      * of regions that are supported.  e.g. A value of 0 means ROI encoding is not supported.
    589      * If ROI encoding is supported, the ROI information is passed to the driver using
    590      * VAEncMiscParameterTypeRoi.
    591      */
    592     VAConfigAttribEncRoi              = 25,
    593     /**
    594      * \brief Encoding extended rate control attribute. Read-only.
    595      *
    596      * This attribute conveys whether the driver supports any extended rate control features
    597      * The attribute value is partitioned into fields as defined in the
    598      * VAConfigAttribValEncRateControlExt union.
    599      */
    600     VAConfigAttribEncRateControlExt   = 26,
    601     /**
    602      * \brief Intel specific attributes start at 1001
    603      */
    604     /**
    605      * \brief Encode function type.
    606      *
    607      * This attribute conveys whether the driver supports different function types for encode.
    608      * It can be ENC, PAK, or ENC + PAK. Currently it is for FEI entry point only.
    609      * Default is ENC + PAK.
    610      */
    611     VAConfigAttribEncFunctionTypeIntel = 1001,
    612     /**
    613      * \brief Maximum number of MV predictors. Read-only.
    614      *
    615      * This attribute determines the maximum number of MV predictors the driver
    616      * can support to encode a single frame. 0 means no MV predictor is supported.
    617      */
    618     VAConfigAttribEncMVPredictorsIntel,
    619     /**
    620      * \brief Statistics attribute. Read-only.
    621      *
    622      * This attribute exposes a number of capabilities of the VAEntrypointStatistics entry
    623      * point. The attribute value is partitioned into fields as defined in the
    624      * VAConfigAttribValStatistics union.
    625      */
    626     VAConfigAttribStatisticsIntel,
    627     /**@}*/
    628     VAConfigAttribTypeMax
    629 } VAConfigAttribType;
    630 
    631 /*
    632  * Configuration attributes
    633  * If there is more than one value for an attribute, a default
    634  * value will be assigned to the attribute if the client does not
    635  * specify the attribute when creating a configuration
    636  */
    637 typedef struct _VAConfigAttrib {
    638     VAConfigAttribType type;
    639     unsigned int value; /* OR'd flags (bits) for this attribute */
    640 } VAConfigAttrib;
    641 
    642 /* attribute value for VAConfigAttribRTFormat */
    643 #define VA_RT_FORMAT_YUV420	0x00000001
    644 #define VA_RT_FORMAT_YUV422	0x00000002
    645 #define VA_RT_FORMAT_YUV444	0x00000004
    646 #define VA_RT_FORMAT_YUV411	0x00000008
    647 #define VA_RT_FORMAT_YUV400	0x00000010
    648 #define VA_RT_FORMAT_RGB16	0x00010000
    649 #define VA_RT_FORMAT_RGB32	0x00020000
    650 /* RGBP covers RGBP and BGRP fourcc */
    651 #define VA_RT_FORMAT_RGBP	0x00100000
    652 #define VA_RT_FORMAT_PROTECTED	0x80000000
    653 
    654 /** @name Attribute values for VAConfigAttribRateControl */
    655 /**@{*/
    656 /** \brief Driver does not support any form of rate control. */
    657 #define VA_RC_NONE                      0x00000001
    658 /** \brief Constant bitrate. */
    659 #define VA_RC_CBR                       0x00000002
    660 /** \brief Variable bitrate. */
    661 #define VA_RC_VBR                       0x00000004
    662 /** \brief Video conference mode. */
    663 #define VA_RC_VCM                       0x00000008
    664 /** \brief Constant QP. */
    665 #define VA_RC_CQP                       0x00000010
    666 /** \brief Variable bitrate with peak rate higher than average bitrate. */
    667 #define VA_RC_VBR_CONSTRAINED           0x00000020
    668 /** \brief Intelligent Constant Quality. Provided an initial ICQ_quality_factor,
    669  *  adjusts QP at a frame and MB level based on motion to improve subjective quality. */
    670 #define VA_RC_ICQ			0x00000040
    671 /** \brief Macroblock based rate control.  Per MB control is decided
    672  *  internally in the encoder. It may be combined with other RC modes, except CQP. */
    673 #define VA_RC_MB                        0x00000080
    674 
    675 /**@}*/
    676 
    677 /** @name Attribute values for VAConfigAttribDecSliceMode */
    678 /**@{*/
    679 /** \brief Driver supports normal mode for slice decoding */
    680 #define VA_DEC_SLICE_MODE_NORMAL       0x00000001
    681 /** \brief Driver supports base mode for slice decoding */
    682 #define VA_DEC_SLICE_MODE_BASE         0x00000002
    683 
    684 /** @name Attribute values for VAConfigAttribDecJPEG */
    685 /**@{*/
    686 typedef union _VAConfigAttribValDecJPEG {
    687     /** \brief Set to (1 << VA_ROTATION_xxx) for supported rotation angles. */
    688     unsigned int rotation;
    689     /** \brief Reserved for future use. */
    690     unsigned int reserved[3];
    691 } VAConfigAttribValDecJPEG;
    692 /** \brief Driver supports subsample mode for slice decoding */
    693 #define VA_DEC_SLICE_MODE_SUBSAMPLE    0x00000004
    694 
    695 /**@}*/
    696 
    697 /** @name Attribute values for VAConfigAttribEncPackedHeaders */
    698 /**@{*/
    699 /** \brief Driver does not support any packed headers mode. */
    700 #define VA_ENC_PACKED_HEADER_NONE       0x00000000
    701 /** \brief Driver supports packed sequence headers. e.g. SPS for H.264. */
    702 #define VA_ENC_PACKED_HEADER_SEQUENCE   0x00000001
    703 /** \brief Driver supports packed picture headers. e.g. PPS for H.264. */
    704 #define VA_ENC_PACKED_HEADER_PICTURE    0x00000002
    705 /** \brief Driver supports packed slice headers. e.g. \c slice_header() for H.264. */
    706 #define VA_ENC_PACKED_HEADER_SLICE      0x00000004
    707 /** \brief Driver supports misc packed headers. e.g. SEI for H.264. */
    708 #define VA_ENC_PACKED_HEADER_MISC       0x00000008
    709 /** \brief Driver supports raw packed header, see VAEncPackedHeaderRawData */
    710 #define VA_ENC_PACKED_HEADER_RAW_DATA   0x0000000C
    711 /**@}*/
    712 
    713 /** @name Attribute values for VAConfigAttribEncInterlaced */
    714 /**@{*/
    715 /** \brief Driver does not support interlaced coding. */
    716 #define VA_ENC_INTERLACED_NONE          0x00000000
    717 /** \brief Driver supports interlaced frame coding. */
    718 #define VA_ENC_INTERLACED_FRAME         0x00000001
    719 /** \brief Driver supports interlaced field coding. */
    720 #define VA_ENC_INTERLACED_FIELD         0x00000002
    721 /** \brief Driver supports macroblock adaptive frame field coding. */
    722 #define VA_ENC_INTERLACED_MBAFF         0x00000004
    723 /** \brief Driver supports picture adaptive frame field coding. */
    724 #define VA_ENC_INTERLACED_PAFF          0x00000008
    725 /**@}*/
    726 
    727 /** @name Attribute values for VAConfigAttribEncSliceStructure */
    728 /**@{*/
    729 /** \brief Driver supports an arbitrary number of rows per slice. */
    730 #define VA_ENC_SLICE_STRUCTURE_ARBITRARY_ROWS           0x00000000
    731 /** \brief Driver supports a power-of-two number of rows per slice. */
    732 #define VA_ENC_SLICE_STRUCTURE_POWER_OF_TWO_ROWS        0x00000001
    733 /** \brief Driver supports an arbitrary number of rows per slice. */
    734 #define VA_ENC_SLICE_STRUCTURE_ARBITRARY_MACROBLOCKS    0x00000002
    735 /** \brief Driver supports any number of rows per slice but they must be the same
    736 	for all slices except for the last one, which must be equal or smaller
    737 	to the previous slices. */
    738 #define VA_ENC_SLICE_STRUCTURE_EQUAL_ROWS    		0x00000004
    739 /** \brief Driver supports a maximum slice size requested by the app.
    740 	The size is sent in VAEncMiscParameterMaxSliceSize. */
    741 #define VA_ENC_SLICE_STRUCTURE_MAX_SLICE_SIZE           0x00000008
    742 /**@}*/
    743 
    744 /** \brief Attribute value for VAConfigAttribEncJPEG */
    745 typedef union _VAConfigAttribValEncJPEG {
    746     struct {
    747         /** \brief set to 1 for arithmatic coding. */
    748         unsigned int arithmatic_coding_mode : 1;
    749         /** \brief set to 1 for progressive dct. */
    750         unsigned int progressive_dct_mode : 1;
    751         /** \brief set to 1 for non-interleaved. */
    752         unsigned int non_interleaved_mode : 1;
    753         /** \brief set to 1 for differential. */
    754         unsigned int differential_mode : 1;
    755         unsigned int max_num_components : 3;
    756         unsigned int max_num_scans : 4;
    757         unsigned int max_num_huffman_tables : 3;
    758         unsigned int max_num_quantization_tables : 3;
    759     } bits;
    760     unsigned int value;
    761 } VAConfigAttribValEncJPEG;
    762 
    763 /** @name Attribute values for VAConfigAttribEncQuantization */
    764 /**@{*/
    765 /** \brief Driver does not support special types of quantization */
    766 #define VA_ENC_QUANTIZATION_NONE                        0x00000000
    767 /** \brief Driver supports trellis quantization */
    768 #define VA_ENC_QUANTIZATION_TRELLIS_SUPPORTED           0x00000001
    769 /**@}*/
    770 
    771 /** @name Attribute values for VAConfigAttribEncIntraRefresh */
    772 /**@{*/
    773 /** \brief Driver does not support intra refresh */
    774 #define VA_ENC_INTRA_REFRESH_NONE                       0x00000000
    775 /** \brief Driver supports column based rolling intra refresh */
    776 #define VA_ENC_INTRA_REFRESH_ROLLING_COLUMN             0x00000001
    777 /** \brief Driver supports row based rolling intra refresh */
    778 #define VA_ENC_INTRA_REFRESH_ROLLING_ROW                0x00000002
    779 /** \brief Driver supports adaptive intra refresh */
    780 #define VA_ENC_INTRA_REFRESH_ADAPTIVE                   0x00000010
    781 /** \brief Driver supports cyclic intra refresh */
    782 #define VA_ENC_INTRA_REFRESH_CYCLIC                     0x00000020
    783 
    784 /**@}*/
    785 
    786 /** \brief Attribute value for VAConfigAttribEncRateControlExt */
    787 typedef union _VAConfigAttribValEncRateControlExt {
    788     struct {
    789         /** \brief The number of temporal layers with layer specific bit-rate targets
    790          * that are supported. The application will send multiple
    791          * VAEncMiscParameterRateControl and VAEncMiscParameterFrameRate structures
    792          * for each layer, using the temporal_id field as the layer identifier.
    793          * If per temporal layer rate control is not supported,
    794          * num_temporal_layers_minus1 will be 0 and the temporal_id field in
    795          * VAEncMiscParameterRateControl and VAEncMiscParameterFrameRate will be ignored.
    796          */
    797      unsigned int num_temporal_layers_minus1 : 8;
    798      unsigned int reserved                   : 24;
    799      } bits;
    800      unsigned int value;
    801 } VAConfigAttribValEncRateControlExt;
    802 
    803 /**
    804  * \brief Intel specific attribute definitions
    805  */
    806 /** @name Attribute values for VAConfigAttribEncFunctionTypeIntel
    807  *
    808  * The desired type should be passed to driver when creating the configuration.
    809  * If VA_ENC_FUNCTION_ENC_PAK is set, VA_ENC_FUNCTION_ENC and VA_ENC_FUNCTION_PAK
    810  * will be ignored if set also.  VA_ENC_FUNCTION_ENC and VA_ENC_FUNCTION_PAK operations
    811  * shall be called separately if ENC and PAK (VA_ENC_FUNCTION_ENC | VA_ENC_FUNCTION_PAK)
    812  * is set for configuration. VA_ENC_FUNCTION_ENC_PAK is recommended for best performance.
    813  * If only VA_ENC_FUNCTION_ENC is set, there will be no bitstream output.
    814  * If VA_ENC_FUNCTION_ENC_PAK is not set and VA_ENC_FUNCTION_PAK is set, then two extra
    815  * input buffers for PAK are needed: VAEncFEIMVBufferType and VAEncFEIModeBufferType.
    816  **/
    817 /**@{*/
    818 /** \brief Only default is supported */
    819 #define VA_ENC_FUNCTION_DEFAULT_INTEL                         0x00000000
    820 /** \brief ENC only is supported */
    821 #define VA_ENC_FUNCTION_ENC_INTEL                             0x00000001
    822 /** \brief PAK only is supported */
    823 #define VA_ENC_FUNCTION_PAK_INTEL                             0x00000002
    824 /** \brief ENC_PAK is supported */
    825 #define VA_ENC_FUNCTION_ENC_PAK_INTEL                         0x00000004
    826 
    827 /**@}*/
    828 
    829 /** \brief Attribute value for VAConfigAttribStatisticsIntel */
    830 typedef union _VAConfigAttribValStatisticsIntel {
    831     struct {
    832         /** \brief Max number of past reference frames that are supported. */
    833         unsigned int	max_num_past_references   : 4;
    834         /** \brief Max number of future reference frames that are supported. */
    835         unsigned int	max_num_future_references : 4;
    836         /** \brief Number of output surfaces that are supported */
    837         unsigned int	num_outputs               : 3;
    838         /** \brief Interlaced content is supported */
    839         unsigned int    interlaced                : 1;
    840         unsigned int	reserved                  : 20;
    841     } bits;
    842     unsigned int value;
    843 } VAConfigAttribValStatisticsIntel;
    844 
    845 /*
    846  * if an attribute is not applicable for a given
    847  * profile/entrypoint pair, then set the value to the following
    848  */
    849 #define VA_ATTRIB_NOT_SUPPORTED 0x80000000
    850 
    851 /* Get maximum number of profiles supported by the implementation */
    852 int vaMaxNumProfiles (
    853     VADisplay dpy
    854 );
    855 
    856 /* Get maximum number of entrypoints supported by the implementation */
    857 int vaMaxNumEntrypoints (
    858     VADisplay dpy
    859 );
    860 
    861 /* Get maximum number of attributs supported by the implementation */
    862 int vaMaxNumConfigAttributes (
    863     VADisplay dpy
    864 );
    865 
    866 /*
    867  * Query supported profiles
    868  * The caller must provide a "profile_list" array that can hold at
    869  * least vaMaxNumProfile() entries. The actual number of profiles
    870  * returned in "profile_list" is returned in "num_profile".
    871  */
    872 VAStatus vaQueryConfigProfiles (
    873     VADisplay dpy,
    874     VAProfile *profile_list,	/* out */
    875     int *num_profiles		/* out */
    876 );
    877 
    878 /*
    879  * Query supported entrypoints for a given profile
    880  * The caller must provide an "entrypoint_list" array that can hold at
    881  * least vaMaxNumEntrypoints() entries. The actual number of entrypoints
    882  * returned in "entrypoint_list" is returned in "num_entrypoints".
    883  */
    884 VAStatus vaQueryConfigEntrypoints (
    885     VADisplay dpy,
    886     VAProfile profile,
    887     VAEntrypoint *entrypoint_list,	/* out */
    888     int *num_entrypoints		/* out */
    889 );
    890 
    891 /*
    892  * Get attributes for a given profile/entrypoint pair
    893  * The caller must provide an "attrib_list" with all attributes to be
    894  * retrieved.  Upon return, the attributes in "attrib_list" have been
    895  * updated with their value.  Unknown attributes or attributes that are
    896  * not supported for the given profile/entrypoint pair will have their
    897  * value set to VA_ATTRIB_NOT_SUPPORTED
    898  */
    899 VAStatus vaGetConfigAttributes (
    900     VADisplay dpy,
    901     VAProfile profile,
    902     VAEntrypoint entrypoint,
    903     VAConfigAttrib *attrib_list, /* in/out */
    904     int num_attribs
    905 );
    906 
    907 /* Generic ID type, can be re-typed for specific implementation */
    908 typedef unsigned int VAGenericID;
    909 
    910 typedef VAGenericID VAConfigID;
    911 
    912 /*
    913  * Create a configuration for the decode pipeline
    914  * it passes in the attribute list that specifies the attributes it cares
    915  * about, with the rest taking default values.
    916  */
    917 VAStatus vaCreateConfig (
    918     VADisplay dpy,
    919     VAProfile profile,
    920     VAEntrypoint entrypoint,
    921     VAConfigAttrib *attrib_list,
    922     int num_attribs,
    923     VAConfigID *config_id /* out */
    924 );
    925 
    926 /*
    927  * Free resources associdated with a given config
    928  */
    929 VAStatus vaDestroyConfig (
    930     VADisplay dpy,
    931     VAConfigID config_id
    932 );
    933 
    934 /*
    935  * Query all attributes for a given configuration
    936  * The profile of the configuration is returned in "profile"
    937  * The entrypoint of the configuration is returned in "entrypoint"
    938  * The caller must provide an "attrib_list" array that can hold at least
    939  * vaMaxNumConfigAttributes() entries. The actual number of attributes
    940  * returned in "attrib_list" is returned in "num_attribs"
    941  */
    942 VAStatus vaQueryConfigAttributes (
    943     VADisplay dpy,
    944     VAConfigID config_id,
    945     VAProfile *profile, 	/* out */
    946     VAEntrypoint *entrypoint, 	/* out */
    947     VAConfigAttrib *attrib_list,/* out */
    948     int *num_attribs 		/* out */
    949 );
    950 
    951 
    952 /*
    953  * Contexts and Surfaces
    954  *
    955  * Context represents a "virtual" video decode pipeline. Surfaces are render
    956  * targets for a given context. The data in the surfaces are not accessible
    957  * to the client and the internal data format of the surface is implementatin
    958  * specific.
    959  *
    960  * Surfaces will be bound to a context when the context is created. Once
    961  * a surface is bound to a given context, it can not be used to create
    962  * another context. The association is removed when the context is destroyed
    963  *
    964  * Both contexts and surfaces are identified by unique IDs and its
    965  * implementation specific internals are kept opaque to the clients
    966  */
    967 
    968 typedef VAGenericID VAContextID;
    969 
    970 typedef VAGenericID VASurfaceID;
    971 
    972 #define VA_INVALID_ID		0xffffffff
    973 #define VA_INVALID_SURFACE	VA_INVALID_ID
    974 
    975 /** \brief Generic value types. */
    976 typedef enum  {
    977     VAGenericValueTypeInteger = 1,      /**< 32-bit signed integer. */
    978     VAGenericValueTypeFloat,            /**< 32-bit floating-point value. */
    979     VAGenericValueTypePointer,          /**< Generic pointer type */
    980     VAGenericValueTypeFunc              /**< Pointer to function */
    981 } VAGenericValueType;
    982 
    983 /** \brief Generic function type. */
    984 typedef void (*VAGenericFunc)(void);
    985 
    986 /** \brief Generic value. */
    987 typedef struct _VAGenericValue {
    988     /** \brief Value type. See #VAGenericValueType. */
    989     VAGenericValueType  type;
    990     /** \brief Value holder. */
    991     union {
    992         /** \brief 32-bit signed integer. */
    993         int             i;
    994         /** \brief 32-bit float. */
    995         float           f;
    996         /** \brief Generic pointer. */
    997         void           *p;
    998         /** \brief Pointer to function. */
    999         VAGenericFunc   fn;
   1000     }                   value;
   1001 } VAGenericValue;
   1002 
   1003 /** @name Surface attribute flags */
   1004 /**@{*/
   1005 /** \brief Surface attribute is not supported. */
   1006 #define VA_SURFACE_ATTRIB_NOT_SUPPORTED 0x00000000
   1007 /** \brief Surface attribute can be got through vaQuerySurfaceAttributes(). */
   1008 #define VA_SURFACE_ATTRIB_GETTABLE      0x00000001
   1009 /** \brief Surface attribute can be set through vaCreateSurfaces(). */
   1010 #define VA_SURFACE_ATTRIB_SETTABLE      0x00000002
   1011 /**@}*/
   1012 
   1013 /** \brief Surface attribute types. */
   1014 typedef enum {
   1015     VASurfaceAttribNone = 0,
   1016     /**
   1017      * \brief Pixel format (fourcc).
   1018      *
   1019      * The value is meaningful as input to vaQuerySurfaceAttributes().
   1020      * If zero, the driver returns the optimal pixel format for the
   1021      * specified config. Otherwise, if non-zero, the value represents
   1022      * a pixel format (FOURCC) that is kept as is on output, if the
   1023      * driver supports it. Otherwise, the driver sets the value to
   1024      * zero and drops the \c VA_SURFACE_ATTRIB_SETTABLE flag.
   1025      */
   1026     VASurfaceAttribPixelFormat,
   1027     /** \brief Minimal width in pixels (int, read-only). */
   1028     VASurfaceAttribMinWidth,
   1029     /** \brief Maximal width in pixels (int, read-only). */
   1030     VASurfaceAttribMaxWidth,
   1031     /** \brief Minimal height in pixels (int, read-only). */
   1032     VASurfaceAttribMinHeight,
   1033     /** \brief Maximal height in pixels (int, read-only). */
   1034     VASurfaceAttribMaxHeight,
   1035     /** \brief Surface memory type expressed in bit fields (int, read/write). */
   1036     VASurfaceAttribMemoryType,
   1037     /** \brief External buffer descriptor (pointer, write). */
   1038     VASurfaceAttribExternalBufferDescriptor,
   1039     /** \brief Surface usage hint, gives the driver a hint of intended usage
   1040      *  to optimize allocation (e.g. tiling) (int, read/write). */
   1041     VASurfaceAttribUsageHint,
   1042     /** \brief Number of surface attributes. */
   1043     VASurfaceAttribCount
   1044 } VASurfaceAttribType;
   1045 
   1046 /** \brief Surface attribute. */
   1047 typedef struct _VASurfaceAttrib {
   1048     /** \brief Type. */
   1049     VASurfaceAttribType type;
   1050     /** \brief Flags. See "Surface attribute flags". */
   1051     unsigned int        flags;
   1052     /** \brief Value. See "Surface attribute types" for the expected types. */
   1053     VAGenericValue      value;
   1054 } VASurfaceAttrib;
   1055 
   1056 /**
   1057  * @name VASurfaceAttribMemoryType values in bit fields.
   1058  * Bit 0:7 are reserved for generic types, Bit 31:28 are reserved for
   1059  * Linux DRM, Bit 23:20 are reserved for Android. DRM and Android specific
   1060  * types are defined in DRM and Android header files.
   1061  */
   1062 /**@{*/
   1063 /** \brief VA memory type (default) is supported. */
   1064 #define VA_SURFACE_ATTRIB_MEM_TYPE_VA			0x00000001
   1065 /** \brief V4L2 buffer memory type is supported. */
   1066 #define VA_SURFACE_ATTRIB_MEM_TYPE_V4L2			0x00000002
   1067 /** \brief User pointer memory type is supported. */
   1068 #define VA_SURFACE_ATTRIB_MEM_TYPE_USER_PTR		0x00000004
   1069 /**@}*/
   1070 
   1071 /**
   1072  * \brief VASurfaceAttribExternalBuffers structure for
   1073  * the VASurfaceAttribExternalBufferDescriptor attribute.
   1074  */
   1075 typedef struct _VASurfaceAttribExternalBuffers {
   1076     /** \brief pixel format in fourcc. */
   1077     unsigned int pixel_format;
   1078     /** \brief width in pixels. */
   1079     unsigned int width;
   1080     /** \brief height in pixels. */
   1081     unsigned int height;
   1082     /** \brief total size of the buffer in bytes. */
   1083     unsigned int data_size;
   1084     /** \brief number of planes for planar layout */
   1085     unsigned int num_planes;
   1086     /** \brief pitch for each plane in bytes */
   1087     unsigned int pitches[4];
   1088     /** \brief offset for each plane in bytes */
   1089     unsigned int offsets[4];
   1090     /** \brief buffer handles or user pointers */
   1091     unsigned long *buffers;
   1092     /** \brief number of elements in the "buffers" array */
   1093     unsigned int num_buffers;
   1094     /** \brief flags. See "Surface external buffer descriptor flags". */
   1095     unsigned int flags;
   1096     /** \brief reserved for passing private data */
   1097     void *private_data;
   1098 } VASurfaceAttribExternalBuffers;
   1099 
   1100 /** @name VASurfaceAttribExternalBuffers flags */
   1101 /**@{*/
   1102 /** \brief Enable memory tiling */
   1103 #define VA_SURFACE_EXTBUF_DESC_ENABLE_TILING	0x00000001
   1104 /** \brief Memory is cacheable */
   1105 #define VA_SURFACE_EXTBUF_DESC_CACHED		0x00000002
   1106 /** \brief Memory is non-cacheable */
   1107 #define VA_SURFACE_EXTBUF_DESC_UNCACHED		0x00000004
   1108 /** \brief Memory is write-combined */
   1109 #define VA_SURFACE_EXTBUF_DESC_WC		0x00000008
   1110 /** \brief Memory is protected */
   1111 #define VA_SURFACE_EXTBUF_DESC_PROTECTED        0x80000000
   1112 
   1113 /** @name VASurfaceAttribUsageHint attribute usage hint flags */
   1114 /**@{*/
   1115 /** \brief Surface usage not indicated. */
   1116 #define VA_SURFACE_ATTRIB_USAGE_HINT_GENERIC 	0x00000000
   1117 /** \brief Surface used by video decoder. */
   1118 #define VA_SURFACE_ATTRIB_USAGE_HINT_DECODER 	0x00000001
   1119 /** \brief Surface used by video encoder. */
   1120 #define VA_SURFACE_ATTRIB_USAGE_HINT_ENCODER 	0x00000002
   1121 /** \brief Surface read by video post-processing. */
   1122 #define VA_SURFACE_ATTRIB_USAGE_HINT_VPP_READ 	0x00000004
   1123 /** \brief Surface written by video post-processing. */
   1124 #define VA_SURFACE_ATTRIB_USAGE_HINT_VPP_WRITE 	0x00000008
   1125 /** \brief Surface used for display. */
   1126 #define VA_SURFACE_ATTRIB_USAGE_HINT_DISPLAY 	0x00000010
   1127 
   1128 /**@}*/
   1129 
   1130 /**
   1131  * \brief Queries surface attributes for the supplied config.
   1132  *
   1133  * Unlike vaGetSurfaceAttributes(), this function queries for all
   1134  * supported attributes for the supplied VA @config. In particular, if
   1135  * the underlying hardware supports the creation of VA surfaces in
   1136  * various formats, then this function will enumerate all pixel
   1137  * formats that are supported.
   1138  *
   1139  * The \c attrib_list array is allocated by the user and \c
   1140  * num_attribs shall be initialized to the number of allocated
   1141  * elements in that array. Upon successful return, the actual number
   1142  * of attributes will be overwritten into \c num_attribs. Otherwise,
   1143  * \c VA_STATUS_ERROR_MAX_NUM_EXCEEDED is returned and \c num_attribs
   1144  * is adjusted to the number of elements that would be returned if
   1145  * enough space was available.
   1146  *
   1147  * Note: it is perfectly valid to pass NULL to the \c attrib_list
   1148  * argument when vaQuerySurfaceAttributes() is used to determine the
   1149  * actual number of elements that need to be allocated.
   1150  *
   1151  * @param[in] dpy               the VA display
   1152  * @param[in] config            the config identifying a codec or a video
   1153  *     processing pipeline
   1154  * @param[out] attrib_list      the output array of #VASurfaceAttrib elements
   1155  * @param[in,out] num_attribs   the number of elements allocated on
   1156  *      input, the number of elements actually filled in output
   1157  */
   1158 VAStatus
   1159 vaQuerySurfaceAttributes(
   1160     VADisplay           dpy,
   1161     VAConfigID          config,
   1162     VASurfaceAttrib    *attrib_list,
   1163     unsigned int       *num_attribs
   1164 );
   1165 
   1166 /**
   1167  * \brief Creates an array of surfaces
   1168  *
   1169  * Creates an array of surfaces. The optional list of attributes shall
   1170  * be constructed and validated through vaGetSurfaceAttributes() or
   1171  * constructed based based on what the underlying hardware could
   1172  * expose through vaQuerySurfaceAttributes().
   1173  *
   1174  * @param[in] dpy               the VA display
   1175  * @param[in] format            the desired surface format. See \c VA_RT_FORMAT_*
   1176  * @param[in] width             the surface width
   1177  * @param[in] height            the surface height
   1178  * @param[out] surfaces         the array of newly created surfaces
   1179  * @param[in] num_surfaces      the number of surfaces to create
   1180  * @param[in] attrib_list       the list of (optional) attributes, or \c NULL
   1181  * @param[in] num_attribs       the number of attributes supplied in
   1182  *     \c attrib_list, or zero
   1183  */
   1184 VAStatus
   1185 vaCreateSurfaces(
   1186     VADisplay           dpy,
   1187     unsigned int        format,
   1188     unsigned int        width,
   1189     unsigned int        height,
   1190     VASurfaceID        *surfaces,
   1191     unsigned int        num_surfaces,
   1192     VASurfaceAttrib    *attrib_list,
   1193     unsigned int        num_attribs
   1194 );
   1195 
   1196 /*
   1197  * vaDestroySurfaces - Destroy resources associated with surfaces.
   1198  *  Surfaces can only be destroyed after the context associated has been
   1199  *  destroyed.
   1200  *  dpy: display
   1201  *  surfaces: array of surfaces to destroy
   1202  *  num_surfaces: number of surfaces in the array to be destroyed.
   1203  */
   1204 VAStatus vaDestroySurfaces (
   1205     VADisplay dpy,
   1206     VASurfaceID *surfaces,
   1207     int num_surfaces
   1208 );
   1209 
   1210 #define VA_PROGRESSIVE 0x1
   1211 /*
   1212  * vaCreateContext - Create a context
   1213  *  dpy: display
   1214  *  config_id: configuration for the context
   1215  *  picture_width: coded picture width
   1216  *  picture_height: coded picture height
   1217  *  flag: any combination of the following:
   1218  *    VA_PROGRESSIVE (only progressive frame pictures in the sequence when set)
   1219  *  render_targets: render targets (surfaces) tied to the context
   1220  *  num_render_targets: number of render targets in the above array
   1221  *  context: created context id upon return
   1222  */
   1223 VAStatus vaCreateContext (
   1224     VADisplay dpy,
   1225     VAConfigID config_id,
   1226     int picture_width,
   1227     int picture_height,
   1228     int flag,
   1229     VASurfaceID *render_targets,
   1230     int num_render_targets,
   1231     VAContextID *context		/* out */
   1232 );
   1233 
   1234 /*
   1235  * vaDestroyContext - Destroy a context
   1236  *  dpy: display
   1237  *  context: context to be destroyed
   1238  */
   1239 VAStatus vaDestroyContext (
   1240     VADisplay dpy,
   1241     VAContextID context
   1242 );
   1243 
   1244 /*
   1245  * Buffers
   1246  * Buffers are used to pass various types of data from the
   1247  * client to the server. The server maintains a data store
   1248  * for each buffer created, and the client idenfies a buffer
   1249  * through a unique buffer id assigned by the server.
   1250  */
   1251 
   1252 typedef VAGenericID VABufferID;
   1253 
   1254 typedef enum
   1255 {
   1256     VAPictureParameterBufferType	= 0,
   1257     VAIQMatrixBufferType		= 1,
   1258     VABitPlaneBufferType		= 2,
   1259     VASliceGroupMapBufferType		= 3,
   1260     VASliceParameterBufferType		= 4,
   1261     VASliceDataBufferType		= 5,
   1262     VAMacroblockParameterBufferType	= 6,
   1263     VAResidualDataBufferType		= 7,
   1264     VADeblockingParameterBufferType	= 8,
   1265     VAImageBufferType			= 9,
   1266     VAProtectedSliceDataBufferType	= 10,
   1267     VAQMatrixBufferType                 = 11,
   1268     VAHuffmanTableBufferType            = 12,
   1269     VAProbabilityBufferType             = 13,
   1270 /* Following are encode buffer types */
   1271     VAEncCodedBufferType		= 21,
   1272     VAEncSequenceParameterBufferType	= 22,
   1273     VAEncPictureParameterBufferType	= 23,
   1274     VAEncSliceParameterBufferType	= 24,
   1275     VAEncPackedHeaderParameterBufferType = 25,
   1276     VAEncPackedHeaderDataBufferType     = 26,
   1277     VAEncMiscParameterBufferType	= 27,
   1278     VAEncMacroblockParameterBufferType	= 28,
   1279     VAEncMacroblockMapBufferType        = 29,
   1280     VAEncQpBufferType                   = 30,
   1281 /* Following are video processing buffer types */
   1282     /**
   1283      * \brief Video processing pipeline parameter buffer.
   1284      *
   1285      * This buffer describes the video processing pipeline. See
   1286      * #VAProcPipelineParameterBuffer for details.
   1287      */
   1288     VAProcPipelineParameterBufferType   = 41,
   1289     /**
   1290      * \brief Video filter parameter buffer.
   1291      *
   1292      * This buffer describes the video filter parameters. All buffers
   1293      * inherit from #VAProcFilterParameterBufferBase, thus including
   1294      * a unique filter buffer type.
   1295      *
   1296      * The default buffer used by most filters is #VAProcFilterParameterBuffer.
   1297      * Filters requiring advanced parameters include, but are not limited to,
   1298      * deinterlacing (#VAProcFilterParameterBufferDeinterlacing),
   1299      * color balance (#VAProcFilterParameterBufferColorBalance), etc.
   1300      */
   1301     VAProcFilterParameterBufferType     = 42,
   1302     VAParsePictureParameterBufferType   = 43,
   1303     VAParseSliceHeaderGroupBufferType   = 44,
   1304 
   1305     /**
   1306      * \brief Intel specific buffer types start at 1001
   1307      */
   1308     VAEncFEIMVBufferTypeIntel                 = 1001,
   1309     VAEncFEIModeBufferTypeIntel,
   1310     VAEncFEIDistortionBufferTypeIntel,
   1311     VAStatsStatisticsParameterBufferTypeIntel,
   1312     VAStatsStatisticsBufferTypeIntel,
   1313     VAStatsMotionVectorBufferTypeIntel,
   1314 
   1315     VABufferTypeMax
   1316 } VABufferType;
   1317 
   1318 typedef enum
   1319 {
   1320     VAEncMiscParameterTypeFrameRate 	= 0,
   1321     VAEncMiscParameterTypeRateControl  	= 1,
   1322     VAEncMiscParameterTypeMaxSliceSize	= 2,
   1323     /** \brief Buffer type used for Adaptive intra refresh */
   1324     VAEncMiscParameterTypeAIR    	= 3,
   1325     /** \brief Buffer type used to express a maximum frame size (in bits). */
   1326     VAEncMiscParameterTypeMaxFrameSize  = 4,
   1327     /** \brief Buffer type used for HRD parameters. */
   1328     VAEncMiscParameterTypeHRD           = 5,
   1329     VAEncMiscParameterTypeQualityLevel  = 6,
   1330     /** \brief Buffer type used for Rolling intra refresh */
   1331     VAEncMiscParameterTypeRIR           = 7,
   1332     VAEncMiscParameterTypeQuantization  = 8,
   1333     /** \brief Buffer type used for sending skip frame parameters to the encoder's
   1334       * rate control, when the user has externally skipped frames. */
   1335     VAEncMiscParameterTypeSkipFrame     = 9,
   1336     /** \brief Buffer type used for region-of-interest (ROI) parameters. */
   1337     VAEncMiscParameterTypeROI           = 10,
   1338     /** \brief Buffer type used for Cyclic intra refresh */
   1339     VAEncMiscParameterTypeCIR           = 11,
   1340     /** \brief Buffer type used for temporal layer structure */
   1341     VAEncMiscParameterTypeTemporalLayerStructure   = 12,
   1342 
   1343     /* Intel specific types start at 1001 */
   1344     /* VAEntrypointEncFEIIntel */
   1345     VAEncMiscParameterTypeFEIFrameControlIntel = 1001
   1346 } VAEncMiscParameterType;
   1347 
   1348 /** \brief Packed header type. */
   1349 typedef enum {
   1350     /** \brief Packed sequence header. */
   1351     VAEncPackedHeaderSequence   = 1,
   1352     /** \brief Packed picture header. */
   1353     VAEncPackedHeaderPicture    = 2,
   1354     /** \brief Packed slice header. */
   1355     VAEncPackedHeaderSlice      = 3,
   1356     /**
   1357      * \brief Packed raw header.
   1358      *
   1359      * Packed raw data header can be used by the client to insert a header
   1360      * into the bitstream data buffer at the point it is passed, the driver
   1361      * will handle the raw packed header based on "has_emulation_bytes" field
   1362      * in the packed header parameter structure.
   1363      */
   1364     VAEncPackedHeaderRawData    = 4,
   1365     /** \brief Misc packed header. See codec-specific definitions. */
   1366     VAEncPackedHeaderMiscMask   = 0x80000000,
   1367 } VAEncPackedHeaderType;
   1368 
   1369 /** \brief Packed header parameter. */
   1370 typedef struct _VAEncPackedHeaderParameterBuffer {
   1371     /** Type of the packed header buffer. See #VAEncPackedHeaderType. */
   1372     unsigned int                type;
   1373     /** \brief Size of the #VAEncPackedHeaderDataBuffer in bits. */
   1374     unsigned int                bit_length;
   1375     /** \brief Flag: buffer contains start code emulation prevention bytes? */
   1376     unsigned char               has_emulation_bytes;
   1377 } VAEncPackedHeaderParameterBuffer;
   1378 
   1379 /*
   1380  *  For application, e.g. set a new bitrate
   1381  *    VABufferID buf_id;
   1382  *    VAEncMiscParameterBuffer *misc_param;
   1383  *    VAEncMiscParameterRateControl *misc_rate_ctrl;
   1384  *
   1385  *    vaCreateBuffer(dpy, context, VAEncMiscParameterBufferType,
   1386  *              sizeof(VAEncMiscParameterBuffer) + sizeof(VAEncMiscParameterRateControl),
   1387  *              1, NULL, &buf_id);
   1388  *
   1389  *    vaMapBuffer(dpy,buf_id,(void **)&misc_param);
   1390  *    misc_param->type = VAEncMiscParameterTypeRateControl;
   1391  *    misc_rate_ctrl= (VAEncMiscParameterRateControl *)misc_param->data;
   1392  *    misc_rate_ctrl->bits_per_second = 6400000;
   1393  *    vaUnmapBuffer(dpy, buf_id);
   1394  *    vaRenderPicture(dpy, context, &buf_id, 1);
   1395  */
   1396 typedef struct _VAEncMiscParameterBuffer
   1397 {
   1398     VAEncMiscParameterType type;
   1399     unsigned int data[0];
   1400 } VAEncMiscParameterBuffer;
   1401 
   1402 /** \brief Temporal Structure*/
   1403 typedef struct _VAEncMiscParameterTemporalLayerStructure
   1404 {
   1405     /* The number of temporal layers */
   1406     uint32_t number_of_layers;
   1407     /* this is Length of the sequence defining frame layer membership. Should be 1-32 */
   1408     uint32_t periodicity;
   1409     /*This is Array indicating the layer id for each frame in a sequence of length ts_periodicity.*/
   1410     uint32_t layer_id[32];
   1411 } VAEncMiscParameterTemporalLayerStructure;
   1412 
   1413 
   1414 /** \brief Rate control parameters */
   1415 typedef struct _VAEncMiscParameterRateControl
   1416 {
   1417     /* this is the maximum bit-rate to be constrained by the rate control implementation */
   1418     unsigned int bits_per_second;
   1419     /* this is the bit-rate the rate control is targeting, as a percentage of the maximum
   1420      * bit-rate for example if target_percentage is 95 then the rate control will target
   1421      * a bit-rate that is 95% of the maximum bit-rate
   1422      */
   1423     unsigned int target_percentage;
   1424     /* windows size in milliseconds. For example if this is set to 500,
   1425      * then the rate control will guarantee the target bit-rate over a 500 ms window
   1426      */
   1427     unsigned int window_size;
   1428     /* initial_qp: initial QP for the first I frames
   1429      * min_qp/max_qp: minimal and maximum QP frames
   1430      * If set them to 0, encoder chooses the best QP according to rate control
   1431      */
   1432     unsigned int initial_qp;
   1433     unsigned int min_qp;
   1434     unsigned int max_qp;
   1435     unsigned int basic_unit_size;
   1436     union
   1437     {
   1438         struct
   1439         {
   1440             unsigned int reset : 1;
   1441             unsigned int disable_frame_skip : 1; /* Disable frame skip in rate control mode */
   1442             unsigned int disable_bit_stuffing : 1; /* Disable bit stuffing in rate control mode */
   1443             unsigned int mb_rate_control : 4; /* Control VA_RC_MB 0: default, 1: enable, 2: disable, other: reserved*/
   1444             /*
   1445              * The temporal layer that the rate control parameters are specified for.
   1446              */
   1447             unsigned int temporal_id : 8;
   1448             unsigned int reserved : 17;
   1449         } bits;
   1450         unsigned int value;
   1451     } rc_flags;
   1452     unsigned int ICQ_quality_factor; /* Initial ICQ quality factor: 1-51. */
   1453 } VAEncMiscParameterRateControl;
   1454 
   1455 typedef struct _VAEncMiscParameterFrameRate
   1456 {
   1457     unsigned int framerate;
   1458     union
   1459     {
   1460         struct
   1461         {
   1462             /*
   1463              * The temporal id the framerate parameters are specified for.
   1464              */
   1465             unsigned int temporal_id : 8;
   1466             unsigned int reserved : 24;
   1467          } bits;
   1468          unsigned int value;
   1469      } framerate_flags;
   1470 } VAEncMiscParameterFrameRate;
   1471 
   1472 /*
   1473  * Allow a maximum slice size to be specified (in bits).
   1474  * The encoder will attempt to make sure that individual slices do not exceed this size
   1475  * Or to signal applicate if the slice size exceed this size, see "status" of VACodedBufferSegment
   1476  */
   1477 typedef struct _VAEncMiscParameterMaxSliceSize
   1478 {
   1479     unsigned int max_slice_size;
   1480 } VAEncMiscParameterMaxSliceSize;
   1481 
   1482 /*
   1483  * \brief Cyclic intra refresh data structure for encoding.
   1484  */
   1485 typedef struct _VAEncMiscParameterCIR
   1486 {
   1487     /** \brief  the number of consecutive macroblocks to be coded as intra */
   1488     unsigned int cir_num_mbs;
   1489 } VAEncMiscParameterCIR;
   1490 
   1491 /*
   1492  * \brief Adaptive intra refresh data structure for encoding.
   1493  */
   1494 typedef struct _VAEncMiscParameterAIR
   1495 {
   1496     /** \brief the minimum number of macroblocks to refresh in a frame */
   1497     unsigned int air_num_mbs;
   1498     /**
   1499      * \brief threshhold of blockmatching criterion (typically SAD)
   1500      *
   1501      * Macroblocks above that threshold are marked as candidates and
   1502      * on subsequent frames a number of these candidates are coded as Intra
   1503      * Generally the threshhold need to be set and tuned to an appropriate level
   1504      * according to the feedback of coded frame.
   1505      */
   1506     unsigned int air_threshold;
   1507     /** \brief if set to 1 then hardware auto-tune the AIR threshold */
   1508     unsigned int air_auto;
   1509 } VAEncMiscParameterAIR;
   1510 
   1511 /*
   1512  * \brief Rolling intra refresh data structure for encoding.
   1513  */
   1514 typedef struct _VAEncMiscParameterRIR
   1515 {
   1516     union
   1517     {
   1518         struct
   1519 	/**
   1520 	 * \brief Indicate if intra refresh is enabled in column/row.
   1521 	 *
   1522 	 * App should query VAConfigAttribEncIntraRefresh to confirm RIR support
   1523 	 * by the driver before sending this structure. The following RIR restrictions
   1524 	 * apply:
   1525 	 *  - No field encoding.
   1526 	 *  - No B frames.
   1527 	 *  - No multiple references.
   1528 	 */
   1529         {
   1530 	    /* \brief enable RIR in column */
   1531             unsigned int enable_rir_column : 1;
   1532 	    /* \brief enable RIR in row */
   1533             unsigned int enable_rir_row : 1;
   1534 	    unsigned int reserved : 30;
   1535         } bits;
   1536         unsigned int value;
   1537     } rir_flags;
   1538     /**
   1539      * \brief Indicates the column or row location in MB. It is ignored if
   1540      * rir_flags is 0.
   1541      */
   1542     unsigned short intra_insertion_location;
   1543     /**
   1544      * \brief Indicates the number of columns or rows in MB. It is ignored if
   1545      * rir_flags is 0.
   1546      */
   1547     unsigned short intra_insert_size;
   1548     /**
   1549      * \brief indicates the Qp difference for inserted intra columns or rows.
   1550      * App can use this to adjust intra Qp based on bitrate & max frame size.
   1551      */
   1552     char qp_delta_for_inserted_intra;
   1553 
   1554 } VAEncMiscParameterRIR;
   1555 
   1556 typedef struct _VAEncMiscParameterHRD
   1557 {
   1558    /**
   1559     * \brief This value indicates the amount of data that will
   1560     * be buffered by the decoding application prior to beginning playback
   1561     */
   1562     unsigned int initial_buffer_fullness;       /* in bits */
   1563    /**
   1564     * \brief This value indicates the amount of data that the
   1565     * encoder should try to maintain in the decoder's buffer
   1566     */
   1567     unsigned int optimal_buffer_fullness;       /* in bits */
   1568     /**
   1569      * \brief This value indicates the amount of data that
   1570      * may be buffered by the decoding application
   1571      */
   1572     unsigned int buffer_size;                   /* in bits */
   1573 } VAEncMiscParameterHRD;
   1574 
   1575 /**
   1576  * \brief Defines a maximum frame size (in bits).
   1577  *
   1578  * This misc parameter buffer defines the maximum size of a frame (in
   1579  * bits). The encoder will try to make sure that each frame does not
   1580  * exceed this size. Otherwise, if the frame size exceeds this size,
   1581  * the \c status flag of #VACodedBufferSegment will contain
   1582  * #VA_CODED_BUF_STATUS_FRAME_SIZE_OVERFLOW.
   1583  */
   1584 typedef struct _VAEncMiscParameterBufferMaxFrameSize {
   1585     /** \brief Type. Shall be set to #VAEncMiscParameterTypeMaxFrameSize. */
   1586     VAEncMiscParameterType      type;
   1587     /** \brief Maximum size of a frame (in bits). */
   1588     unsigned int                max_frame_size;
   1589 } VAEncMiscParameterBufferMaxFrameSize;
   1590 
   1591 /**
   1592  * \brief Encoding quality level.
   1593  *
   1594  * The encoding quality could be set through this structure, if the implementation
   1595  * supports multiple quality levels. The quality level set through this structure is
   1596  * persistent over the entire coded sequence, or until a new structure is being sent.
   1597  * The quality level range can be queried through the VAConfigAttribEncQualityRange
   1598  * attribute. A lower value means higher quality, and a value of 1 represents the highest
   1599  * quality. The quality level setting is used as a trade-off between quality and speed/power
   1600  * consumption, with higher quality corresponds to lower speed and higher power consumption.
   1601  */
   1602 typedef struct _VAEncMiscParameterBufferQualityLevel {
   1603     /** \brief Encoding quality level setting. */
   1604     unsigned int                quality_level;
   1605 } VAEncMiscParameterBufferQualityLevel;
   1606 
   1607 /**
   1608  * \brief Quantization settings for encoding.
   1609  *
   1610  * Some encoders support special types of quantization such as trellis, and this structure
   1611  * can be used by the app to control these special types of quantization by the encoder.
   1612  */
   1613 typedef struct _VAEncMiscParameterQuantization
   1614 {
   1615     union
   1616     {
   1617     /* if no flags is set then quantization is determined by the driver */
   1618         struct
   1619         {
   1620 	    /* \brief disable trellis for all frames/fields */
   1621             unsigned int disable_trellis : 1;
   1622 	    /* \brief enable trellis for I frames/fields */
   1623             unsigned int enable_trellis_I : 1;
   1624 	    /* \brief enable trellis for P frames/fields */
   1625             unsigned int enable_trellis_P : 1;
   1626 	    /* \brief enable trellis for B frames/fields */
   1627             unsigned int enable_trellis_B : 1;
   1628             unsigned int reserved : 28;
   1629         } bits;
   1630         unsigned int value;
   1631     } quantization_flags;
   1632 } VAEncMiscParameterQuantization;
   1633 
   1634 /**
   1635  * \brief Encoding skip frame.
   1636  *
   1637  * The application may choose to skip frames externally to the encoder (e.g. drop completely or
   1638  * code as all skip's). For rate control purposes the encoder will need to know the size and number
   1639  * of skipped frames.  Skip frame(s) indicated through this structure is applicable only to the
   1640  * current frame.  It is allowed for the application to still send in packed headers for the driver to
   1641  * pack, although no frame will be encoded (e.g. for HW to encrypt the frame).
   1642  */
   1643 typedef struct _VAEncMiscParameterSkipFrame {
   1644     /** \brief Indicates skip frames as below.
   1645       * 0: Encode as normal, no skip.
   1646       * 1: One or more frames were skipped prior to the current frame, encode the current frame as normal.
   1647       * 2: The current frame is to be skipped, do not encode it but pack/encrypt the packed header contents
   1648       *    (all except VAEncPackedHeaderSlice) which could contain actual frame contents (e.g. pack the frame
   1649       *    in VAEncPackedHeaderPicture).  */
   1650     unsigned char               skip_frame_flag;
   1651     /** \brief The number of frames skipped prior to the current frame.  Valid when skip_frame_flag = 1. */
   1652     unsigned char               num_skip_frames;
   1653     /** \brief When skip_frame_flag = 1, the size of the skipped frames in bits.   When skip_frame_flag = 2,
   1654       * the size of the current skipped frame that is to be packed/encrypted in bits. */
   1655     unsigned int                size_skip_frames;
   1656 } VAEncMiscParameterSkipFrame;
   1657 
   1658 /**
   1659  * \brief Encoding region-of-interest (ROI).
   1660  *
   1661  * The encoding ROI can be set through this structure, if the implementation
   1662  * supports ROI input. The ROI set through this structure is applicable only to the
   1663  * current frame.  The number of supported ROIs can be queried through the
   1664  * VAConfigAttribEncRoi.  The encoder will use the ROI information to adjust the QP
   1665  * values of the MB's that fall within the ROIs.
   1666  */
   1667 typedef struct _VAEncMiscParameterBufferRoi {
   1668     /** \brief Number of ROIs being sent.*/
   1669     unsigned int                num_roi;
   1670     /** \brief Valid when VAConfigAttribRateControl != VA_RC_CQP, then the encoder's
   1671      *  rate control will determine actual delta QPs.  Specifies the max/min allowed delta QPs.*/
   1672     char                        max_delta_qp;
   1673     char                        min_delta_qp;
   1674 
   1675     /** \brief Pointer to a VAEncROI array with num_ROI elements.*/
   1676     struct VAEncROI
   1677     {
   1678         /** \brief Defines the ROI boundary in pixels, the driver will map it to appropriate
   1679          *  codec coding units.  It is relative to the frame coordinates for both frame and field cases. */
   1680         VARectangle             roi_rectangle;
   1681         /** \brief When VAConfigAttribRateControl == VA_RC_CQP then roi_value specifes the delta QP that
   1682          *  will be added on top of the frame level QP.  For other rate control modes, roi_value specifies the
   1683          *  priority of the ROI region relative to the non-ROI region.  It can positive (more important) or
   1684          *  negative (less important) values and is compared with non-ROI region (taken as value 0).
   1685          *  E.g. ROI region with roi_value -3 is less important than the non-ROI region (roi_value implied to be 0)
   1686          *  which is less important than ROI region with roi_value +2.  For overlapping regions, the roi_value
   1687          *  that is first in the ROI array will have priority.   */
   1688         char                    roi_value;
   1689     } *ROI;
   1690 } VAEncMiscParameterBufferROI;
   1691 
   1692 /*
   1693  * There will be cases where the bitstream buffer will not have enough room to hold
   1694  * the data for the entire slice, and the following flags will be used in the slice
   1695  * parameter to signal to the server for the possible cases.
   1696  * If a slice parameter buffer and slice data buffer pair is sent to the server with
   1697  * the slice data partially in the slice data buffer (BEGIN and MIDDLE cases below),
   1698  * then a slice parameter and data buffer needs to be sent again to complete this slice.
   1699  */
   1700 #define VA_SLICE_DATA_FLAG_ALL		0x00	/* whole slice is in the buffer */
   1701 #define VA_SLICE_DATA_FLAG_BEGIN	0x01	/* The beginning of the slice is in the buffer but the end if not */
   1702 #define VA_SLICE_DATA_FLAG_MIDDLE	0x02	/* Neither beginning nor end of the slice is in the buffer */
   1703 #define VA_SLICE_DATA_FLAG_END		0x04	/* end of the slice is in the buffer */
   1704 
   1705 /* Codec-independent Slice Parameter Buffer base */
   1706 typedef struct _VASliceParameterBufferBase
   1707 {
   1708     unsigned int slice_data_size;	/* number of bytes in the slice data buffer for this slice */
   1709     unsigned int slice_data_offset;	/* the offset to the first byte of slice data */
   1710     unsigned int slice_data_flag;	/* see VA_SLICE_DATA_FLAG_XXX definitions */
   1711 } VASliceParameterBufferBase;
   1712 
   1713 #include <va/va_dec_jpeg.h>
   1714 
   1715 /****************************
   1716  * MPEG-2 data structures
   1717  ****************************/
   1718 
   1719 /* MPEG-2 Picture Parameter Buffer */
   1720 /*
   1721  * For each frame or field, and before any slice data, a single
   1722  * picture parameter buffer must be send.
   1723  */
   1724 typedef struct _VAPictureParameterBufferMPEG2
   1725 {
   1726     unsigned short horizontal_size;
   1727     unsigned short vertical_size;
   1728     VASurfaceID forward_reference_picture;
   1729     VASurfaceID backward_reference_picture;
   1730     /* meanings of the following fields are the same as in the standard */
   1731     int picture_coding_type;
   1732     int f_code; /* pack all four fcode into this */
   1733     union {
   1734         struct {
   1735             unsigned int intra_dc_precision		: 2;
   1736             unsigned int picture_structure		: 2;
   1737             unsigned int top_field_first		: 1;
   1738             unsigned int frame_pred_frame_dct		: 1;
   1739             unsigned int concealment_motion_vectors	: 1;
   1740             unsigned int q_scale_type			: 1;
   1741             unsigned int intra_vlc_format		: 1;
   1742             unsigned int alternate_scan			: 1;
   1743             unsigned int repeat_first_field		: 1;
   1744             unsigned int progressive_frame		: 1;
   1745             unsigned int is_first_field			: 1; /* indicate whether the current field
   1746                                                               * is the first field for field picture
   1747                                                               */
   1748         } bits;
   1749         unsigned int value;
   1750     } picture_coding_extension;
   1751 } VAPictureParameterBufferMPEG2;
   1752 
   1753 /* MPEG-2 Inverse Quantization Matrix Buffer */
   1754 typedef struct _VAIQMatrixBufferMPEG2
   1755 {
   1756     int load_intra_quantiser_matrix;
   1757     int load_non_intra_quantiser_matrix;
   1758     int load_chroma_intra_quantiser_matrix;
   1759     int load_chroma_non_intra_quantiser_matrix;
   1760     unsigned char intra_quantiser_matrix[64];
   1761     unsigned char non_intra_quantiser_matrix[64];
   1762     unsigned char chroma_intra_quantiser_matrix[64];
   1763     unsigned char chroma_non_intra_quantiser_matrix[64];
   1764 } VAIQMatrixBufferMPEG2;
   1765 
   1766 /* MPEG-2 Slice Parameter Buffer */
   1767 typedef struct _VASliceParameterBufferMPEG2
   1768 {
   1769     unsigned int slice_data_size;/* number of bytes in the slice data buffer for this slice */
   1770     unsigned int slice_data_offset;/* the offset to the first byte of slice data */
   1771     unsigned int slice_data_flag; /* see VA_SLICE_DATA_FLAG_XXX defintions */
   1772     unsigned int macroblock_offset;/* the offset to the first bit of MB from the first byte of slice data */
   1773     unsigned int slice_horizontal_position;
   1774     unsigned int slice_vertical_position;
   1775     int quantiser_scale_code;
   1776     int intra_slice_flag;
   1777 } VASliceParameterBufferMPEG2;
   1778 
   1779 /* MPEG-2 Macroblock Parameter Buffer */
   1780 typedef struct _VAMacroblockParameterBufferMPEG2
   1781 {
   1782     unsigned short macroblock_address;
   1783     /*
   1784      * macroblock_address (in raster scan order)
   1785      * top-left: 0
   1786      * bottom-right: picture-height-in-mb*picture-width-in-mb - 1
   1787      */
   1788     unsigned char macroblock_type;  /* see definition below */
   1789     union {
   1790         struct {
   1791             unsigned int frame_motion_type		: 2;
   1792             unsigned int field_motion_type		: 2;
   1793             unsigned int dct_type			: 1;
   1794         } bits;
   1795         unsigned int value;
   1796     } macroblock_modes;
   1797     unsigned char motion_vertical_field_select;
   1798     /*
   1799      * motion_vertical_field_select:
   1800      * see section 6.3.17.2 in the spec
   1801      * only the lower 4 bits are used
   1802      * bit 0: first vector forward
   1803      * bit 1: first vector backward
   1804      * bit 2: second vector forward
   1805      * bit 3: second vector backward
   1806      */
   1807     short PMV[2][2][2]; /* see Table 7-7 in the spec */
   1808     unsigned short coded_block_pattern;
   1809     /*
   1810      * The bitplanes for coded_block_pattern are described
   1811      * in Figure 6.10-12 in the spec
   1812      */
   1813 
   1814     /* Number of skipped macroblocks after this macroblock */
   1815     unsigned short num_skipped_macroblocks;
   1816 } VAMacroblockParameterBufferMPEG2;
   1817 
   1818 /*
   1819  * OR'd flags for macroblock_type (section 6.3.17.1 in the spec)
   1820  */
   1821 #define VA_MB_TYPE_MOTION_FORWARD	0x02
   1822 #define VA_MB_TYPE_MOTION_BACKWARD	0x04
   1823 #define VA_MB_TYPE_MOTION_PATTERN	0x08
   1824 #define VA_MB_TYPE_MOTION_INTRA		0x10
   1825 
   1826 /*
   1827  * MPEG-2 Residual Data Buffer
   1828  * For each macroblock, there wil be 64 shorts (16-bit) in the
   1829  * residual data buffer
   1830  */
   1831 
   1832 /****************************
   1833  * MPEG-4 Part 2 data structures
   1834  ****************************/
   1835 
   1836 /* MPEG-4 Picture Parameter Buffer */
   1837 /*
   1838  * For each frame or field, and before any slice data, a single
   1839  * picture parameter buffer must be send.
   1840  */
   1841 typedef struct _VAPictureParameterBufferMPEG4
   1842 {
   1843     unsigned short vop_width;
   1844     unsigned short vop_height;
   1845     VASurfaceID forward_reference_picture;
   1846     VASurfaceID backward_reference_picture;
   1847     union {
   1848         struct {
   1849             unsigned int short_video_header		: 1;
   1850             unsigned int chroma_format			: 2;
   1851             unsigned int interlaced			: 1;
   1852             unsigned int obmc_disable			: 1;
   1853             unsigned int sprite_enable			: 2;
   1854             unsigned int sprite_warping_accuracy	: 2;
   1855             unsigned int quant_type			: 1;
   1856             unsigned int quarter_sample			: 1;
   1857             unsigned int data_partitioned		: 1;
   1858             unsigned int reversible_vlc			: 1;
   1859             unsigned int resync_marker_disable		: 1;
   1860         } bits;
   1861         unsigned int value;
   1862     } vol_fields;
   1863     unsigned char no_of_sprite_warping_points;
   1864     short sprite_trajectory_du[3];
   1865     short sprite_trajectory_dv[3];
   1866     unsigned char quant_precision;
   1867     union {
   1868         struct {
   1869             unsigned int vop_coding_type		: 2;
   1870             unsigned int backward_reference_vop_coding_type	: 2;
   1871             unsigned int vop_rounding_type		: 1;
   1872             unsigned int intra_dc_vlc_thr		: 3;
   1873             unsigned int top_field_first		: 1;
   1874             unsigned int alternate_vertical_scan_flag	: 1;
   1875         } bits;
   1876         unsigned int value;
   1877     } vop_fields;
   1878     unsigned char vop_fcode_forward;
   1879     unsigned char vop_fcode_backward;
   1880     unsigned short vop_time_increment_resolution;
   1881     /* short header related */
   1882     unsigned char num_gobs_in_vop;
   1883     unsigned char num_macroblocks_in_gob;
   1884     /* for direct mode prediction */
   1885     short TRB;
   1886     short TRD;
   1887     unsigned int Tframe;
   1888     unsigned char vop_quant;
   1889 } VAPictureParameterBufferMPEG4;
   1890 
   1891 /* MPEG-4 Inverse Quantization Matrix Buffer */
   1892 typedef struct _VAIQMatrixBufferMPEG4
   1893 {
   1894     int load_intra_quant_mat;
   1895     int load_non_intra_quant_mat;
   1896     unsigned char intra_quant_mat[64];
   1897     unsigned char non_intra_quant_mat[64];
   1898 } VAIQMatrixBufferMPEG4;
   1899 
   1900 /* MPEG-4 Slice Parameter Buffer */
   1901 typedef struct _VASliceParameterBufferMPEG4
   1902 {
   1903     unsigned int slice_data_size;/* number of bytes in the slice data buffer for this slice */
   1904     unsigned int slice_data_offset;/* the offset to the first byte of slice data */
   1905     unsigned int slice_data_flag; /* see VA_SLICE_DATA_FLAG_XXX defintions */
   1906     unsigned int macroblock_offset;/* the offset to the first bit of MB from the first byte of slice data */
   1907     unsigned int macroblock_number;
   1908     int quant_scale;
   1909 } VASliceParameterBufferMPEG4;
   1910 
   1911 /*
   1912  VC-1 data structures
   1913 */
   1914 
   1915 typedef enum   /* see 7.1.1.32 */
   1916 {
   1917     VAMvMode1Mv                        = 0,
   1918     VAMvMode1MvHalfPel                 = 1,
   1919     VAMvMode1MvHalfPelBilinear         = 2,
   1920     VAMvModeMixedMv                    = 3,
   1921     VAMvModeIntensityCompensation      = 4
   1922 } VAMvModeVC1;
   1923 
   1924 /* VC-1 Picture Parameter Buffer */
   1925 /*
   1926  * For each picture, and before any slice data, a picture parameter
   1927  * buffer must be send. Multiple picture parameter buffers may be
   1928  * sent for a single picture. In that case picture parameters will
   1929  * apply to all slice data that follow it until a new picture
   1930  * parameter buffer is sent.
   1931  *
   1932  * Notes:
   1933  *   pic_quantizer_type should be set to the applicable quantizer
   1934  *   type as defined by QUANTIZER (J.1.19) and either
   1935  *   PQUANTIZER (7.1.1.8) or PQINDEX (7.1.1.6)
   1936  */
   1937 typedef struct _VAPictureParameterBufferVC1
   1938 {
   1939     VASurfaceID forward_reference_picture;
   1940     VASurfaceID backward_reference_picture;
   1941     /* if out-of-loop post-processing is done on the render
   1942        target, then we need to keep the in-loop decoded
   1943        picture as a reference picture */
   1944     VASurfaceID inloop_decoded_picture;
   1945 
   1946     /* sequence layer for AP or meta data for SP and MP */
   1947     union {
   1948         struct {
   1949             unsigned int pulldown	: 1; /* SEQUENCE_LAYER::PULLDOWN */
   1950             unsigned int interlace	: 1; /* SEQUENCE_LAYER::INTERLACE */
   1951             unsigned int tfcntrflag	: 1; /* SEQUENCE_LAYER::TFCNTRFLAG */
   1952             unsigned int finterpflag	: 1; /* SEQUENCE_LAYER::FINTERPFLAG */
   1953             unsigned int psf		: 1; /* SEQUENCE_LAYER::PSF */
   1954             unsigned int multires	: 1; /* METADATA::MULTIRES */
   1955             unsigned int overlap	: 1; /* METADATA::OVERLAP */
   1956             unsigned int syncmarker	: 1; /* METADATA::SYNCMARKER */
   1957             unsigned int rangered	: 1; /* METADATA::RANGERED */
   1958             unsigned int max_b_frames	: 3; /* METADATA::MAXBFRAMES */
   1959             unsigned int profile	: 2; /* SEQUENCE_LAYER::PROFILE or The MSB of METADATA::PROFILE */
   1960         } bits;
   1961         unsigned int value;
   1962     } sequence_fields;
   1963 
   1964     unsigned short coded_width;		/* ENTRY_POINT_LAYER::CODED_WIDTH */
   1965     unsigned short coded_height;	/* ENTRY_POINT_LAYER::CODED_HEIGHT */
   1966     union {
   1967 	struct {
   1968             unsigned int broken_link	: 1; /* ENTRY_POINT_LAYER::BROKEN_LINK */
   1969             unsigned int closed_entry	: 1; /* ENTRY_POINT_LAYER::CLOSED_ENTRY */
   1970             unsigned int panscan_flag	: 1; /* ENTRY_POINT_LAYER::PANSCAN_FLAG */
   1971             unsigned int loopfilter	: 1; /* ENTRY_POINT_LAYER::LOOPFILTER */
   1972 	} bits;
   1973 	unsigned int value;
   1974     } entrypoint_fields;
   1975     unsigned char conditional_overlap_flag; /* ENTRY_POINT_LAYER::CONDOVER */
   1976     unsigned char fast_uvmc_flag;	/* ENTRY_POINT_LAYER::FASTUVMC */
   1977     union {
   1978         struct {
   1979             unsigned int luma_flag	: 1; /* ENTRY_POINT_LAYER::RANGE_MAPY_FLAG */
   1980             unsigned int luma		: 3; /* ENTRY_POINT_LAYER::RANGE_MAPY */
   1981             unsigned int chroma_flag	: 1; /* ENTRY_POINT_LAYER::RANGE_MAPUV_FLAG */
   1982             unsigned int chroma		: 3; /* ENTRY_POINT_LAYER::RANGE_MAPUV */
   1983         } bits;
   1984         unsigned int value;
   1985     } range_mapping_fields;
   1986 
   1987     unsigned char b_picture_fraction;	/* PICTURE_LAYER::BFRACTION */
   1988     unsigned char cbp_table;		/* PICTURE_LAYER::CBPTAB/ICBPTAB */
   1989     unsigned char mb_mode_table;	/* PICTURE_LAYER::MBMODETAB */
   1990     unsigned char range_reduction_frame;/* PICTURE_LAYER::RANGEREDFRM */
   1991     unsigned char rounding_control;	/* PICTURE_LAYER::RNDCTRL */
   1992     unsigned char post_processing;	/* PICTURE_LAYER::POSTPROC */
   1993     unsigned char picture_resolution_index;	/* PICTURE_LAYER::RESPIC */
   1994     unsigned char luma_scale;		/* PICTURE_LAYER::LUMSCALE */
   1995     unsigned char luma_shift;		/* PICTURE_LAYER::LUMSHIFT */
   1996     union {
   1997         struct {
   1998             unsigned int picture_type		: 3; /* PICTURE_LAYER::PTYPE */
   1999             unsigned int frame_coding_mode	: 3; /* PICTURE_LAYER::FCM */
   2000             unsigned int top_field_first	: 1; /* PICTURE_LAYER::TFF */
   2001             unsigned int is_first_field		: 1; /* set to 1 if it is the first field */
   2002             unsigned int intensity_compensation	: 1; /* PICTURE_LAYER::INTCOMP */
   2003         } bits;
   2004         unsigned int value;
   2005     } picture_fields;
   2006     union {
   2007         struct {
   2008             unsigned int mv_type_mb	: 1; 	/* PICTURE::MVTYPEMB */
   2009             unsigned int direct_mb	: 1; 	/* PICTURE::DIRECTMB */
   2010             unsigned int skip_mb	: 1; 	/* PICTURE::SKIPMB */
   2011             unsigned int field_tx	: 1; 	/* PICTURE::FIELDTX */
   2012             unsigned int forward_mb	: 1;	/* PICTURE::FORWARDMB */
   2013             unsigned int ac_pred	: 1;	/* PICTURE::ACPRED */
   2014             unsigned int overflags	: 1;	/* PICTURE::OVERFLAGS */
   2015         } flags;
   2016         unsigned int value;
   2017     } raw_coding;
   2018     union {
   2019         struct {
   2020             unsigned int bp_mv_type_mb   : 1;    /* PICTURE::MVTYPEMB */
   2021             unsigned int bp_direct_mb    : 1;    /* PICTURE::DIRECTMB */
   2022             unsigned int bp_skip_mb      : 1;    /* PICTURE::SKIPMB */
   2023             unsigned int bp_field_tx     : 1;    /* PICTURE::FIELDTX */
   2024             unsigned int bp_forward_mb   : 1;    /* PICTURE::FORWARDMB */
   2025             unsigned int bp_ac_pred      : 1;    /* PICTURE::ACPRED */
   2026             unsigned int bp_overflags    : 1;    /* PICTURE::OVERFLAGS */
   2027         } flags;
   2028         unsigned int value;
   2029     } bitplane_present; /* signal what bitplane is being passed via the bitplane buffer */
   2030     union {
   2031         struct {
   2032             unsigned int reference_distance_flag : 1;/* PICTURE_LAYER::REFDIST_FLAG */
   2033             unsigned int reference_distance	: 5;/* PICTURE_LAYER::REFDIST */
   2034             unsigned int num_reference_pictures: 1;/* PICTURE_LAYER::NUMREF */
   2035             unsigned int reference_field_pic_indicator	: 1;/* PICTURE_LAYER::REFFIELD */
   2036         } bits;
   2037         unsigned int value;
   2038     } reference_fields;
   2039     union {
   2040         struct {
   2041             unsigned int mv_mode		: 3; /* PICTURE_LAYER::MVMODE */
   2042             unsigned int mv_mode2		: 3; /* PICTURE_LAYER::MVMODE2 */
   2043             unsigned int mv_table		: 3; /* PICTURE_LAYER::MVTAB/IMVTAB */
   2044             unsigned int two_mv_block_pattern_table: 2; /* PICTURE_LAYER::2MVBPTAB */
   2045             unsigned int four_mv_switch		: 1; /* PICTURE_LAYER::4MVSWITCH */
   2046             unsigned int four_mv_block_pattern_table : 2; /* PICTURE_LAYER::4MVBPTAB */
   2047             unsigned int extended_mv_flag	: 1; /* ENTRY_POINT_LAYER::EXTENDED_MV */
   2048             unsigned int extended_mv_range	: 2; /* PICTURE_LAYER::MVRANGE */
   2049             unsigned int extended_dmv_flag	: 1; /* ENTRY_POINT_LAYER::EXTENDED_DMV */
   2050             unsigned int extended_dmv_range	: 2; /* PICTURE_LAYER::DMVRANGE */
   2051         } bits;
   2052         unsigned int value;
   2053     } mv_fields;
   2054     union {
   2055         struct {
   2056             unsigned int dquant	: 2; 	/* ENTRY_POINT_LAYER::DQUANT */
   2057             unsigned int quantizer     : 2; 	/* ENTRY_POINT_LAYER::QUANTIZER */
   2058             unsigned int half_qp	: 1; 	/* PICTURE_LAYER::HALFQP */
   2059             unsigned int pic_quantizer_scale : 5;/* PICTURE_LAYER::PQUANT */
   2060             unsigned int pic_quantizer_type : 1;/* PICTURE_LAYER::PQUANTIZER */
   2061             unsigned int dq_frame	: 1; 	/* VOPDQUANT::DQUANTFRM */
   2062             unsigned int dq_profile	: 2; 	/* VOPDQUANT::DQPROFILE */
   2063             unsigned int dq_sb_edge	: 2; 	/* VOPDQUANT::DQSBEDGE */
   2064             unsigned int dq_db_edge 	: 2; 	/* VOPDQUANT::DQDBEDGE */
   2065             unsigned int dq_binary_level : 1; 	/* VOPDQUANT::DQBILEVEL */
   2066             unsigned int alt_pic_quantizer : 5;/* VOPDQUANT::ALTPQUANT */
   2067         } bits;
   2068         unsigned int value;
   2069     } pic_quantizer_fields;
   2070     union {
   2071         struct {
   2072             unsigned int variable_sized_transform_flag	: 1;/* ENTRY_POINT_LAYER::VSTRANSFORM */
   2073             unsigned int mb_level_transform_type_flag	: 1;/* PICTURE_LAYER::TTMBF */
   2074             unsigned int frame_level_transform_type	: 2;/* PICTURE_LAYER::TTFRM */
   2075             unsigned int transform_ac_codingset_idx1	: 2;/* PICTURE_LAYER::TRANSACFRM */
   2076             unsigned int transform_ac_codingset_idx2	: 2;/* PICTURE_LAYER::TRANSACFRM2 */
   2077             unsigned int intra_transform_dc_table	: 1;/* PICTURE_LAYER::TRANSDCTAB */
   2078         } bits;
   2079         unsigned int value;
   2080     } transform_fields;
   2081     unsigned char luma_scale2;		/* PICTURE_LAYER::LUMSCALE2 */
   2082     unsigned char luma_shift2;		/* PICTURE_LAYER::LUMSHIFT2 */
   2083 } VAPictureParameterBufferVC1;
   2084 
   2085 /* VC-1 Bitplane Buffer
   2086 There will be at most three bitplanes coded in any picture header. To send
   2087 the bitplane data more efficiently, each byte is divided in two nibbles, with
   2088 each nibble carrying three bitplanes for one macroblock.  The following table
   2089 shows the bitplane data arrangement within each nibble based on the picture
   2090 type.
   2091 
   2092 Picture Type	Bit3		Bit2		Bit1		Bit0
   2093 I or BI				OVERFLAGS	ACPRED		FIELDTX
   2094 P				MYTYPEMB	SKIPMB		DIRECTMB
   2095 B				FORWARDMB	SKIPMB		DIRECTMB
   2096 
   2097 Within each byte, the lower nibble is for the first MB and the upper nibble is
   2098 for the second MB.  E.g. the lower nibble of the first byte in the bitplane
   2099 buffer is for Macroblock #1 and the upper nibble of the first byte is for
   2100 Macroblock #2 in the first row.
   2101 */
   2102 
   2103 /* VC-1 Slice Parameter Buffer */
   2104 typedef struct _VASliceParameterBufferVC1
   2105 {
   2106     unsigned int slice_data_size;/* number of bytes in the slice data buffer for this slice */
   2107     unsigned int slice_data_offset;/* the offset to the first byte of slice data */
   2108     unsigned int slice_data_flag; /* see VA_SLICE_DATA_FLAG_XXX defintions */
   2109     unsigned int macroblock_offset;/* the offset to the first bit of MB from the first byte of slice data */
   2110     unsigned int slice_vertical_position;
   2111 } VASliceParameterBufferVC1;
   2112 
   2113 /* VC-1 Slice Data Buffer */
   2114 /*
   2115 This is simplely a buffer containing raw bit-stream bytes
   2116 */
   2117 
   2118 /****************************
   2119  * H.264/AVC data structures
   2120  ****************************/
   2121 
   2122 typedef struct _VAPictureH264
   2123 {
   2124     VASurfaceID picture_id;
   2125     /*
   2126      * frame_idx is long_term_frame_idx for long term reference picture,
   2127      * and frame_num for short term reference picture.
   2128      */
   2129     unsigned int frame_idx;
   2130     /*
   2131      * see flags below.
   2132      */
   2133     unsigned int flags;
   2134     signed int TopFieldOrderCnt;
   2135     signed int BottomFieldOrderCnt;
   2136 } VAPictureH264;
   2137 /* flags in VAPictureH264 could be OR of the following */
   2138 #define VA_PICTURE_H264_INVALID			0x00000001
   2139 #define VA_PICTURE_H264_TOP_FIELD		0x00000002
   2140 #define VA_PICTURE_H264_BOTTOM_FIELD		0x00000004
   2141 #define VA_PICTURE_H264_SHORT_TERM_REFERENCE	0x00000008
   2142 #define VA_PICTURE_H264_LONG_TERM_REFERENCE	0x00000010
   2143 #define VA_PICTURE_H264_NON_EXISTING		0x00000020
   2144 
   2145 /* H.264 Picture Parameter Buffer */
   2146 /*
   2147  * For each picture, and before any slice data, a single
   2148  * picture parameter buffer must be send.
   2149  */
   2150 typedef struct _VAPictureParameterBufferH264
   2151 {
   2152     VAPictureH264 CurrPic;
   2153     VAPictureH264 ReferenceFrames[16];	/* in DPB */
   2154     unsigned short picture_width_in_mbs_minus1;
   2155     unsigned short picture_height_in_mbs_minus1;
   2156     unsigned char bit_depth_luma_minus8;
   2157     unsigned char bit_depth_chroma_minus8;
   2158     unsigned char num_ref_frames;
   2159     union {
   2160         struct {
   2161             unsigned int chroma_format_idc			: 2;
   2162             unsigned int residual_colour_transform_flag		: 1;
   2163             unsigned int gaps_in_frame_num_value_allowed_flag	: 1;
   2164             unsigned int frame_mbs_only_flag			: 1;
   2165             unsigned int mb_adaptive_frame_field_flag		: 1;
   2166             unsigned int direct_8x8_inference_flag		: 1;
   2167             unsigned int MinLumaBiPredSize8x8			: 1; /* see A.3.3.2 */
   2168             unsigned int log2_max_frame_num_minus4		: 4;
   2169             unsigned int pic_order_cnt_type			: 2;
   2170             unsigned int log2_max_pic_order_cnt_lsb_minus4	: 4;
   2171             unsigned int delta_pic_order_always_zero_flag	: 1;
   2172         } bits;
   2173         unsigned int value;
   2174     } seq_fields;
   2175     unsigned char num_slice_groups_minus1;
   2176     unsigned char slice_group_map_type;
   2177     unsigned short slice_group_change_rate_minus1;
   2178     signed char pic_init_qp_minus26;
   2179     signed char pic_init_qs_minus26;
   2180     signed char chroma_qp_index_offset;
   2181     signed char second_chroma_qp_index_offset;
   2182     union {
   2183         struct {
   2184             unsigned int entropy_coding_mode_flag	: 1;
   2185             unsigned int weighted_pred_flag		: 1;
   2186             unsigned int weighted_bipred_idc		: 2;
   2187             unsigned int transform_8x8_mode_flag	: 1;
   2188             unsigned int field_pic_flag			: 1;
   2189             unsigned int constrained_intra_pred_flag	: 1;
   2190             unsigned int pic_order_present_flag			: 1;
   2191             unsigned int deblocking_filter_control_present_flag : 1;
   2192             unsigned int redundant_pic_cnt_present_flag		: 1;
   2193             unsigned int reference_pic_flag			: 1; /* nal_ref_idc != 0 */
   2194         } bits;
   2195         unsigned int value;
   2196     } pic_fields;
   2197     unsigned short frame_num;
   2198     unsigned char num_ref_idx_l0_default_active_minus1;
   2199     unsigned char num_ref_idx_l1_default_active_minus1;
   2200 } VAPictureParameterBufferH264;
   2201 
   2202 /* H.264 Inverse Quantization Matrix Buffer */
   2203 typedef struct _VAIQMatrixBufferH264
   2204 {
   2205     unsigned char ScalingList4x4[6][16];
   2206     unsigned char ScalingList8x8[2][64];
   2207 } VAIQMatrixBufferH264;
   2208 
   2209 /*
   2210  * H.264 Slice Group Map Buffer
   2211  * When VAPictureParameterBufferH264::num_slice_group_minus1 is not equal to 0,
   2212  * A slice group map buffer should be sent for each picture if required. The buffer
   2213  * is sent only when there is a change in the mapping values.
   2214  * The slice group map buffer map "map units" to slice groups as specified in
   2215  * section 8.2.2 of the H.264 spec. The buffer will contain one byte for each macroblock
   2216  * in raster scan order
   2217  */
   2218 
   2219 /*
   2220  * H.264 Slice Parameter Buffer for base mode decoding
   2221  */
   2222 typedef struct _VASliceParameterBufferBaseH264
   2223 {
   2224     unsigned int slice_data_size;/* number of bytes in the slice data buffer for this slice */
   2225     /** \brief Byte offset to the NAL Header Unit for this slice. */
   2226     unsigned int slice_data_offset;
   2227     unsigned int slice_data_flag; /* see VA_SLICE_DATA_FLAG_XXX defintions */
   2228 } VASliceParameterBufferH264Base;
   2229 
   2230 /*
   2231  * H.264 Slice Parameter Buffer for normal mode decoding
   2232  */
   2233 typedef struct _VASliceParameterBufferH264
   2234 {
   2235     unsigned int slice_data_size;/* number of bytes in the slice data buffer for this slice */
   2236     /** \brief Byte offset to the NAL Header Unit for this slice. */
   2237     unsigned int slice_data_offset;
   2238     unsigned int slice_data_flag; /* see VA_SLICE_DATA_FLAG_XXX defintions */
   2239     /**
   2240      * \brief Bit offset from NAL Header Unit to the begining of slice_data().
   2241      *
   2242      * This bit offset is relative to and includes the NAL unit byte
   2243      * and represents the number of bits parsed in the slice_header()
   2244      * after the removal of any emulation prevention bytes in
   2245      * there. However, the slice data buffer passed to the hardware is
   2246      * the original bitstream, thus including any emulation prevention
   2247      * bytes.
   2248      */
   2249     unsigned short slice_data_bit_offset;
   2250     unsigned short first_mb_in_slice;
   2251     unsigned char slice_type;
   2252     unsigned char direct_spatial_mv_pred_flag;
   2253     unsigned char num_ref_idx_l0_active_minus1;
   2254     unsigned char num_ref_idx_l1_active_minus1;
   2255     unsigned char cabac_init_idc;
   2256     char slice_qp_delta;
   2257     unsigned char disable_deblocking_filter_idc;
   2258     char slice_alpha_c0_offset_div2;
   2259     char slice_beta_offset_div2;
   2260     VAPictureH264 RefPicList0[32];	/* See 8.2.4.2 */
   2261     VAPictureH264 RefPicList1[32];	/* See 8.2.4.2 */
   2262     unsigned char luma_log2_weight_denom;
   2263     unsigned char chroma_log2_weight_denom;
   2264     unsigned char luma_weight_l0_flag;
   2265     short luma_weight_l0[32];
   2266     short luma_offset_l0[32];
   2267     unsigned char chroma_weight_l0_flag;
   2268     short chroma_weight_l0[32][2];
   2269     short chroma_offset_l0[32][2];
   2270     unsigned char luma_weight_l1_flag;
   2271     short luma_weight_l1[32];
   2272     short luma_offset_l1[32];
   2273     unsigned char chroma_weight_l1_flag;
   2274     short chroma_weight_l1[32][2];
   2275     short chroma_offset_l1[32][2];
   2276 } VASliceParameterBufferH264;
   2277 
   2278 /****************************
   2279  * Common encode data structures
   2280  ****************************/
   2281 typedef enum
   2282 {
   2283     VAEncPictureTypeIntra		= 0,
   2284     VAEncPictureTypePredictive		= 1,
   2285     VAEncPictureTypeBidirectional	= 2,
   2286 } VAEncPictureType;
   2287 
   2288 /* Encode Slice Parameter Buffer */
   2289 typedef struct _VAEncSliceParameterBuffer
   2290 {
   2291     unsigned int start_row_number;	/* starting MB row number for this slice */
   2292     unsigned int slice_height;	/* slice height measured in MB */
   2293     union {
   2294         struct {
   2295             unsigned int is_intra	: 1;
   2296             unsigned int disable_deblocking_filter_idc : 2;
   2297             unsigned int uses_long_term_ref		:1;
   2298             unsigned int is_long_term_ref		:1;
   2299         } bits;
   2300         unsigned int value;
   2301     } slice_flags;
   2302 } VAEncSliceParameterBuffer;
   2303 
   2304 
   2305 /****************************
   2306  * H.263 specific encode data structures
   2307  ****************************/
   2308 
   2309 typedef struct _VAEncSequenceParameterBufferH263
   2310 {
   2311     unsigned int intra_period;
   2312     unsigned int bits_per_second;
   2313     unsigned int frame_rate;
   2314     unsigned int initial_qp;
   2315     unsigned int min_qp;
   2316 } VAEncSequenceParameterBufferH263;
   2317 
   2318 typedef struct _VAEncPictureParameterBufferH263
   2319 {
   2320     VASurfaceID reference_picture;
   2321     VASurfaceID reconstructed_picture;
   2322     VABufferID coded_buf;
   2323     unsigned short picture_width;
   2324     unsigned short picture_height;
   2325     VAEncPictureType picture_type;
   2326 } VAEncPictureParameterBufferH263;
   2327 
   2328 /****************************
   2329  * MPEG-4 specific encode data structures
   2330  ****************************/
   2331 
   2332 typedef struct _VAEncSequenceParameterBufferMPEG4
   2333 {
   2334     unsigned char profile_and_level_indication;
   2335     unsigned int intra_period;
   2336     unsigned int video_object_layer_width;
   2337     unsigned int video_object_layer_height;
   2338     unsigned int vop_time_increment_resolution;
   2339     unsigned int fixed_vop_rate;
   2340     unsigned int fixed_vop_time_increment;
   2341     unsigned int bits_per_second;
   2342     unsigned int frame_rate;
   2343     unsigned int initial_qp;
   2344     unsigned int min_qp;
   2345 } VAEncSequenceParameterBufferMPEG4;
   2346 
   2347 typedef struct _VAEncPictureParameterBufferMPEG4
   2348 {
   2349     VASurfaceID reference_picture;
   2350     VASurfaceID reconstructed_picture;
   2351     VABufferID coded_buf;
   2352     unsigned short picture_width;
   2353     unsigned short picture_height;
   2354     unsigned int modulo_time_base; /* number of 1s */
   2355     unsigned int vop_time_increment;
   2356     VAEncPictureType picture_type;
   2357 } VAEncPictureParameterBufferMPEG4;
   2358 
   2359 
   2360 
   2361 /* Buffer functions */
   2362 
   2363 /*
   2364  * Creates a buffer for "num_elements" elements of "size" bytes and
   2365  * initalize with "data".
   2366  * if "data" is null, then the contents of the buffer data store
   2367  * are undefined.
   2368  * Basically there are two ways to get buffer data to the server side. One is
   2369  * to call vaCreateBuffer() with a non-null "data", which results the data being
   2370  * copied to the data store on the server side.  A different method that
   2371  * eliminates this copy is to pass null as "data" when calling vaCreateBuffer(),
   2372  * and then use vaMapBuffer() to map the data store from the server side to the
   2373  * client address space for access.
   2374  *  Note: image buffers are created by the library, not the client. Please see
   2375  *        vaCreateImage on how image buffers are managed.
   2376  */
   2377 VAStatus vaCreateBuffer (
   2378     VADisplay dpy,
   2379     VAContextID context,
   2380     VABufferType type,	/* in */
   2381     unsigned int size,	/* in */
   2382     unsigned int num_elements, /* in */
   2383     void *data,		/* in */
   2384     VABufferID *buf_id	/* out */
   2385 );
   2386 
   2387 /*
   2388  * Convey to the server how many valid elements are in the buffer.
   2389  * e.g. if multiple slice parameters are being held in a single buffer,
   2390  * this will communicate to the server the number of slice parameters
   2391  * that are valid in the buffer.
   2392  */
   2393 VAStatus vaBufferSetNumElements (
   2394     VADisplay dpy,
   2395     VABufferID buf_id,	/* in */
   2396     unsigned int num_elements /* in */
   2397 );
   2398 
   2399 
   2400 /*
   2401  * device independent data structure for codedbuffer
   2402  */
   2403 
   2404 /*
   2405  * FICTURE_AVE_QP(bit7-0): The average Qp value used during this frame
   2406  * LARGE_SLICE(bit8):At least one slice in the current frame was large
   2407  *              enough for the encoder to attempt to limit its size.
   2408  * SLICE_OVERFLOW(bit9): At least one slice in the current frame has
   2409  *              exceeded the maximum slice size specified.
   2410  * BITRATE_OVERFLOW(bit10): The peak bitrate was exceeded for this frame.
   2411  * BITRATE_HIGH(bit11): The frame size got within the safety margin of the maximum size (VCM only)
   2412  * AIR_MB_OVER_THRESHOLD: the number of MBs adapted to Intra MB
   2413  */
   2414 #define VA_CODED_BUF_STATUS_PICTURE_AVE_QP_MASK         0xff
   2415 #define VA_CODED_BUF_STATUS_LARGE_SLICE_MASK            0x100
   2416 #define VA_CODED_BUF_STATUS_SLICE_OVERFLOW_MASK         0x200
   2417 #define VA_CODED_BUF_STATUS_BITRATE_OVERFLOW		0x400
   2418 #define VA_CODED_BUF_STATUS_BITRATE_HIGH		0x800
   2419 /**
   2420  * \brief The frame has exceeded the maximum requested size.
   2421  *
   2422  * This flag indicates that the encoded frame size exceeds the value
   2423  * specified through a misc parameter buffer of type
   2424  * #VAEncMiscParameterTypeMaxFrameSize.
   2425  */
   2426 #define VA_CODED_BUF_STATUS_FRAME_SIZE_OVERFLOW         0x1000
   2427 #define VA_CODED_BUF_STATUS_AIR_MB_OVER_THRESHOLD	0xff0000
   2428 
   2429 /**
   2430  * \brief The coded buffer segment contains a single NAL unit.
   2431  *
   2432  * This flag indicates that the coded buffer segment contains a
   2433  * single NAL unit. This flag might be useful to the user for
   2434  * processing the coded buffer.
   2435  */
   2436 #define VA_CODED_BUF_STATUS_SINGLE_NALU                 0x10000000
   2437 
   2438 /**
   2439  * \brief The coded buffer segment contains a private data.
   2440  *
   2441  * This flag indicates that the coded buffer segment contains
   2442  * private data. This flag can be used to exchange private data
   2443  * between the client and the driver. Private data should follow
   2444  * regular coded data in the coded buffer segement list.
   2445  */
   2446 #define VA_CODED_BUF_STATUS_PRIVATE_DATA                 0x80000000
   2447 
   2448 /**
   2449  * \brief Coded buffer segment.
   2450  *
   2451  * #VACodedBufferSegment is an element of a linked list describing
   2452  * some information on the coded buffer. The coded buffer segment
   2453  * could contain either a single NAL unit, or more than one NAL unit.
   2454  * It is recommended (but not required) to return a single NAL unit
   2455  * in a coded buffer segment, and the implementation should set the
   2456  * VA_CODED_BUF_STATUS_SINGLE_NALU status flag if that is the case.
   2457  */
   2458 typedef  struct _VACodedBufferSegment  {
   2459     /**
   2460      * \brief Size of the data buffer in this segment (in bytes).
   2461      */
   2462     unsigned int        size;
   2463     /** \brief Bit offset into the data buffer where the video data starts. */
   2464     unsigned int        bit_offset;
   2465     /** \brief Status set by the driver. See \c VA_CODED_BUF_STATUS_*. */
   2466     unsigned int        status;
   2467     /** \brief Reserved for future use. */
   2468     unsigned int        reserved;
   2469     /** \brief Pointer to the start of the data buffer. */
   2470     void               *buf;
   2471     /**
   2472      * \brief Pointer to the next #VACodedBufferSegment element,
   2473      * or \c NULL if there is none.
   2474      */
   2475     void               *next;
   2476 } VACodedBufferSegment;
   2477 
   2478 
   2479 /*
   2480  * H.264 Parsed Slice Header Group Info
   2481  * After slice header is parsed by decode hardware,
   2482  * group slice header buffer will be returned to client.
   2483  * client will retrieve multiple parsed slice header infos from that buffer
   2484  */
   2485 
   2486 /* H.264 Parsed Slice Header Info */
   2487 typedef struct _VAParseSliceHeaderGroupBuffer
   2488 {
   2489 	unsigned int size;
   2490 
   2491 	unsigned char nal_ref_idc;
   2492 	unsigned char nal_unit_type;
   2493 	unsigned char slice_type;
   2494 	unsigned char redundant_pic_cnt;
   2495 
   2496 	unsigned short first_mb_in_slice;
   2497 	char slice_qp_delta;
   2498 	char slice_qs_delta;
   2499 
   2500 	unsigned char luma_log2_weight_denom;
   2501 	unsigned char chroma_log2_weight_denom;
   2502 	unsigned char cabac_init_idc;
   2503         unsigned char reserved8bit;
   2504 
   2505         unsigned short pic_order_cnt_lsb;
   2506         unsigned short reserved16bit;
   2507 
   2508         unsigned short idr_pic_id;
   2509         unsigned char pic_parameter_set_id;
   2510 	unsigned char colour_plane_id;
   2511 
   2512 	char slice_alpha_c0_offset_div2;
   2513 	char slice_beta_offset_div2;
   2514 	unsigned char slice_group_change_cycle;
   2515 	unsigned char disable_deblocking_filter_idc;
   2516 
   2517 	unsigned int frame_num;
   2518 	int delta_pic_order_cnt_bottom;
   2519 	int delta_pic_order_cnt[2];
   2520 
   2521 	unsigned char num_reorder_cmds[2];
   2522 	unsigned char num_ref_active_minus1[2];
   2523 
   2524 	unsigned int weights_present[2][2];
   2525 
   2526 	unsigned short num_mem_man_ops;
   2527 
   2528 	union {
   2529 		struct {
   2530 			unsigned field_pic_flag                     : 1;
   2531 			unsigned bottom_field_flag                  : 1;
   2532 			unsigned num_ref_idx_active_override_flag   : 1;
   2533 			unsigned direct_spatial_mv_pred_flag        : 1;
   2534 			unsigned no_output_of_prior_pics_flag       : 1;
   2535 			unsigned long_term_reference_flag           : 1;
   2536 			unsigned idr_flag                           : 1;
   2537 			unsigned anchor_pic_flag                    : 1;
   2538 			unsigned inter_view_flag                    : 1;
   2539 		} bits;
   2540 
   2541 		unsigned short value;
   2542 	} flags;
   2543 
   2544 //MVC
   2545 	unsigned short view_id;
   2546 	unsigned char priority_id;
   2547 	unsigned char temporal_id;
   2548 } VAParseSliceHeaderGroupBuffer;
   2549 
   2550 typedef struct _VAParsePictureParameterBuffer {
   2551     VABufferID frame_buf_id;
   2552     VABufferID slice_headers_buf_id;
   2553     unsigned int frame_size;
   2554     unsigned int slice_headers_size;
   2555     union {
   2556         struct {
   2557             unsigned frame_mbs_only_flag : 1;
   2558             unsigned pic_order_present_flag : 1;
   2559             unsigned delta_pic_order_always_zero_flag : 1;
   2560             unsigned redundant_pic_cnt_present_flag : 1;
   2561             unsigned weighted_pred_flag : 1;
   2562             unsigned entropy_coding_mode_flag : 1;
   2563             unsigned deblocking_filter_control_present_flag : 1;
   2564             unsigned weighted_bipred_idc : 1;
   2565         } bits;
   2566         unsigned int value;
   2567     } flags;
   2568 
   2569     union {
   2570         struct {
   2571             unsigned char nalu_header_unit_type : 5;
   2572             unsigned char nalu_header_ref_idc : 2;
   2573         } bits;
   2574         unsigned char value;
   2575     } nalu_header;
   2576 
   2577     unsigned short expected_pic_parameter_set_id;
   2578     unsigned char num_slice_groups_minus1;
   2579     unsigned char slice_group_map_type;
   2580     unsigned char log2_slice_group_change_cycle;
   2581     unsigned char chroma_format_idc;
   2582 
   2583     unsigned char log2_max_pic_order_cnt_lsb_minus4;
   2584     unsigned char pic_order_cnt_type;
   2585     unsigned char log2_max_frame_num_minus4;
   2586     unsigned char idr_flag;
   2587     unsigned char slice_offset;
   2588 
   2589     /* additionally */
   2590     unsigned char residual_colour_transform_flag;
   2591     unsigned char num_ref_idc_l0_active_minus1;
   2592     unsigned char num_ref_idc_l1_active_minus1;
   2593 } VAParsePictureParameterBuffer;
   2594 
   2595 /*
   2596  * Map data store of the buffer into the client's address space
   2597  * vaCreateBuffer() needs to be called with "data" set to NULL before
   2598  * calling vaMapBuffer()
   2599  *
   2600  * if buffer type is VAEncCodedBufferType, pbuf points to link-list of
   2601  * VACodedBufferSegment, and the list is terminated if "next" is NULL
   2602  */
   2603 VAStatus vaMapBuffer (
   2604     VADisplay dpy,
   2605     VABufferID buf_id,	/* in */
   2606     void **pbuf 	/* out */
   2607 );
   2608 
   2609 /*
   2610  * After client making changes to a mapped data store, it needs to
   2611  * "Unmap" it to let the server know that the data is ready to be
   2612  * consumed by the server
   2613  */
   2614 VAStatus vaUnmapBuffer (
   2615     VADisplay dpy,
   2616     VABufferID buf_id	/* in */
   2617 );
   2618 
   2619 /*
   2620  * After this call, the buffer is deleted and this buffer_id is no longer valid
   2621  * Only call this if the buffer is not going to be passed to vaRenderBuffer
   2622  */
   2623 VAStatus vaDestroyBuffer (
   2624     VADisplay dpy,
   2625     VABufferID buffer_id
   2626 );
   2627 
   2628 /*
   2629 Render (Decode) Pictures
   2630 
   2631 A picture represents either a frame or a field.
   2632 
   2633 The Begin/Render/End sequence sends the decode buffers to the server
   2634 */
   2635 
   2636 /*
   2637  * Get ready to decode a picture to a target surface
   2638  */
   2639 VAStatus vaBeginPicture (
   2640     VADisplay dpy,
   2641     VAContextID context,
   2642     VASurfaceID render_target
   2643 );
   2644 
   2645 /*
   2646  * Send decode buffers to the server.
   2647  * Buffers are automatically destroyed afterwards
   2648  */
   2649 VAStatus vaRenderPicture (
   2650     VADisplay dpy,
   2651     VAContextID context,
   2652     VABufferID *buffers,
   2653     int num_buffers
   2654 );
   2655 
   2656 /*
   2657  * Make the end of rendering for a picture.
   2658  * The server should start processing all pending operations for this
   2659  * surface. This call is non-blocking. The client can start another
   2660  * Begin/Render/End sequence on a different render target.
   2661  */
   2662 VAStatus vaEndPicture (
   2663     VADisplay dpy,
   2664     VAContextID context
   2665 );
   2666 
   2667 /*
   2668 
   2669 Synchronization
   2670 
   2671 */
   2672 
   2673 /*
   2674  * This function blocks until all pending operations on the render target
   2675  * have been completed.  Upon return it is safe to use the render target for a
   2676  * different picture.
   2677  */
   2678 VAStatus vaSyncSurface (
   2679     VADisplay dpy,
   2680     VASurfaceID render_target
   2681 );
   2682 
   2683 typedef enum
   2684 {
   2685     VASurfaceRendering	= 1, /* Rendering in progress */
   2686     VASurfaceDisplaying	= 2, /* Displaying in progress (not safe to render into it) */
   2687                              /* this status is useful if surface is used as the source */
   2688                              /* of an overlay */
   2689     VASurfaceReady	= 4, /* not being rendered or displayed */
   2690     VASurfaceSkipped	= 8  /* Indicate a skipped frame during encode */
   2691 } VASurfaceStatus;
   2692 
   2693 /*
   2694  * Find out any pending ops on the render target
   2695  */
   2696 VAStatus vaQuerySurfaceStatus (
   2697     VADisplay dpy,
   2698     VASurfaceID render_target,
   2699     VASurfaceStatus *status	/* out */
   2700 );
   2701 
   2702 typedef enum
   2703 {
   2704     VADecodeSliceMissing            = 0,
   2705     VADecodeMBError                 = 1,
   2706 } VADecodeErrorType;
   2707 
   2708 /*
   2709  * Client calls vaQuerySurfaceError with VA_STATUS_ERROR_DECODING_ERROR, server side returns
   2710  * an array of structure VASurfaceDecodeMBErrors, and the array is terminated by setting status=-1
   2711 */
   2712 typedef struct _VASurfaceDecodeMBErrors
   2713 {
   2714     int status; /* 1 if start_mb/end_mb with errors is returned, 2 if num_mb with errors is returned, -1 means this record is invalid */
   2715     unsigned int start_mb; /* start mb address with errors */
   2716     unsigned int end_mb;   /* end mb address with errors */
   2717     VADecodeErrorType decode_error_type;
   2718     unsigned int num_mb;   /* number of mbs with errors */
   2719 } VASurfaceDecodeMBErrors;
   2720 
   2721 /*
   2722  * After the application gets VA_STATUS_ERROR_DECODING_ERROR after calling vaSyncSurface(),
   2723  * it can call vaQuerySurfaceError to find out further details on the particular error.
   2724  * VA_STATUS_ERROR_DECODING_ERROR should be passed in as "error_status",
   2725  * upon the return, error_info will point to an array of _VASurfaceDecodeMBErrors structure,
   2726  * which is allocated and filled by libVA with detailed information on the missing or error macroblocks.
   2727  * The array is terminated if "status==-1" is detected.
   2728  */
   2729 VAStatus vaQuerySurfaceError(
   2730     VADisplay dpy,
   2731     VASurfaceID surface,
   2732     VAStatus error_status,
   2733     void **error_info
   2734 );
   2735 
   2736 /*
   2737  * Images and Subpictures
   2738  * VAImage is used to either get the surface data to client memory, or
   2739  * to copy image data in client memory to a surface.
   2740  * Both images, subpictures and surfaces follow the same 2D coordinate system where origin
   2741  * is at the upper left corner with positive X to the right and positive Y down
   2742  */
   2743 #define VA_FOURCC(ch0, ch1, ch2, ch3) \
   2744     ((unsigned long)(unsigned char) (ch0) | ((unsigned long)(unsigned char) (ch1) << 8) | \
   2745     ((unsigned long)(unsigned char) (ch2) << 16) | ((unsigned long)(unsigned char) (ch3) << 24 ))
   2746 
   2747 /*
   2748  * Pre-defined fourcc codes
   2749  */
   2750 #define VA_FOURCC_NV12		0x3231564E
   2751 #define VA_FOURCC_NV21		0x3132564E
   2752 #define VA_FOURCC_AI44		0x34344149
   2753 #define VA_FOURCC_RGBA		0x41424752
   2754 #define VA_FOURCC_RGBX		0x58424752
   2755 #define VA_FOURCC_BGRA		0x41524742
   2756 #define VA_FOURCC_BGRX		0x58524742
   2757 #define VA_FOURCC_ARGB		0x42475241
   2758 #define VA_FOURCC_XRGB		0x42475258
   2759 #define VA_FOURCC_ABGR          0x52474241
   2760 #define VA_FOURCC_XBGR          0x52474258
   2761 #define VA_FOURCC_UYVY          0x59565955
   2762 #define VA_FOURCC_YUY2          0x32595559
   2763 #define VA_FOURCC_AYUV          0x56555941
   2764 #define VA_FOURCC_NV11          0x3131564e
   2765 #define VA_FOURCC_YV12          0x32315659
   2766 #define VA_FOURCC_P208          0x38303250
   2767 #define VA_FOURCC_IYUV          0x56555949
   2768 #define VA_FOURCC_YV24          0x34325659
   2769 #define VA_FOURCC_YV32          0x32335659
   2770 #define VA_FOURCC_Y800          0x30303859
   2771 #define VA_FOURCC_IMC3          0x33434D49
   2772 #define VA_FOURCC_411P          0x50313134
   2773 #define VA_FOURCC_422H          0x48323234
   2774 #define VA_FOURCC_422V          0x56323234
   2775 #define VA_FOURCC_444P          0x50343434
   2776 #define VA_FOURCC_RGBP          0x50424752
   2777 #define VA_FOURCC_BGRP          0x50524742
   2778 #define VA_FOURCC_411R          0x52313134 /* rotated 411P */
   2779 
   2780 /* byte order */
   2781 #define VA_LSB_FIRST		1
   2782 #define VA_MSB_FIRST		2
   2783 
   2784 typedef struct _VAImageFormat
   2785 {
   2786     unsigned int	fourcc;
   2787     unsigned int	byte_order; /* VA_LSB_FIRST, VA_MSB_FIRST */
   2788     unsigned int	bits_per_pixel;
   2789     /* for RGB formats */
   2790     unsigned int	depth; /* significant bits per pixel */
   2791     unsigned int	red_mask;
   2792     unsigned int	green_mask;
   2793     unsigned int	blue_mask;
   2794     unsigned int	alpha_mask;
   2795 } VAImageFormat;
   2796 
   2797 typedef VAGenericID VAImageID;
   2798 
   2799 typedef struct _VAImage
   2800 {
   2801     VAImageID		image_id; /* uniquely identify this image */
   2802     VAImageFormat	format;
   2803     VABufferID		buf;	/* image data buffer */
   2804     /*
   2805      * Image data will be stored in a buffer of type VAImageBufferType to facilitate
   2806      * data store on the server side for optimal performance. The buffer will be
   2807      * created by the CreateImage function, and proper storage allocated based on the image
   2808      * size and format. This buffer is managed by the library implementation, and
   2809      * accessed by the client through the buffer Map/Unmap functions.
   2810      */
   2811     unsigned short	width;
   2812     unsigned short	height;
   2813     unsigned int	data_size;
   2814     unsigned int	num_planes;	/* can not be greater than 4 */
   2815     /*
   2816      * An array indicating the scanline pitch in bytes for each plane.
   2817      * Each plane may have a different pitch. Maximum 3 planes for planar formats
   2818      */
   2819     unsigned int	pitches[3];
   2820     /*
   2821      * An array indicating the byte offset from the beginning of the image data
   2822      * to the start of each plane.
   2823      */
   2824     unsigned int	offsets[3];
   2825 
   2826     /* The following fields are only needed for paletted formats */
   2827     int num_palette_entries;   /* set to zero for non-palette images */
   2828     /*
   2829      * Each component is one byte and entry_bytes indicates the number of components in
   2830      * each entry (eg. 3 for YUV palette entries). set to zero for non-palette images
   2831      */
   2832     int entry_bytes;
   2833     /*
   2834      * An array of ascii characters describing the order of the components within the bytes.
   2835      * Only entry_bytes characters of the string are used.
   2836      */
   2837     char component_order[4];
   2838     /*
   2839      * Pitch and byte offset for the fourth plane if the image format requires 4 planes
   2840      * Particular use case is JPEG with CMYK profile
   2841      */
   2842     unsigned int extra_pitch;
   2843     unsigned int extra_offset;
   2844 } VAImage;
   2845 
   2846 /* Get maximum number of image formats supported by the implementation */
   2847 int vaMaxNumImageFormats (
   2848     VADisplay dpy
   2849 );
   2850 
   2851 /*
   2852  * Query supported image formats
   2853  * The caller must provide a "format_list" array that can hold at
   2854  * least vaMaxNumImageFormats() entries. The actual number of formats
   2855  * returned in "format_list" is returned in "num_formats".
   2856  */
   2857 VAStatus vaQueryImageFormats (
   2858     VADisplay dpy,
   2859     VAImageFormat *format_list,	/* out */
   2860     int *num_formats		/* out */
   2861 );
   2862 
   2863 /*
   2864  * Create a VAImage structure
   2865  * The width and height fields returned in the VAImage structure may get
   2866  * enlarged for some YUV formats. Upon return from this function,
   2867  * image->buf has been created and proper storage allocated by the library.
   2868  * The client can access the image through the Map/Unmap calls.
   2869  */
   2870 VAStatus vaCreateImage (
   2871     VADisplay dpy,
   2872     VAImageFormat *format,
   2873     int width,
   2874     int height,
   2875     VAImage *image	/* out */
   2876 );
   2877 
   2878 /*
   2879  * Should call DestroyImage before destroying the surface it is bound to
   2880  */
   2881 VAStatus vaDestroyImage (
   2882     VADisplay dpy,
   2883     VAImageID image
   2884 );
   2885 
   2886 VAStatus vaSetImagePalette (
   2887     VADisplay dpy,
   2888     VAImageID image,
   2889     /*
   2890      * pointer to an array holding the palette data.  The size of the array is
   2891      * num_palette_entries * entry_bytes in size.  The order of the components
   2892      * in the palette is described by the component_order in VAImage struct
   2893      */
   2894     unsigned char *palette
   2895 );
   2896 
   2897 /*
   2898  * Retrive surface data into a VAImage
   2899  * Image must be in a format supported by the implementation
   2900  */
   2901 VAStatus vaGetImage (
   2902     VADisplay dpy,
   2903     VASurfaceID surface,
   2904     int x,	/* coordinates of the upper left source pixel */
   2905     int y,
   2906     unsigned int width, /* width and height of the region */
   2907     unsigned int height,
   2908     VAImageID image
   2909 );
   2910 
   2911 /*
   2912  * Copy data from a VAImage to a surface
   2913  * Image must be in a format supported by the implementation
   2914  * Returns a VA_STATUS_ERROR_SURFACE_BUSY if the surface
   2915  * shouldn't be rendered into when this is called
   2916  */
   2917 VAStatus vaPutImage (
   2918     VADisplay dpy,
   2919     VASurfaceID surface,
   2920     VAImageID image,
   2921     int src_x,
   2922     int src_y,
   2923     unsigned int src_width,
   2924     unsigned int src_height,
   2925     int dest_x,
   2926     int dest_y,
   2927     unsigned int dest_width,
   2928     unsigned int dest_height
   2929 );
   2930 
   2931 /*
   2932  * Derive an VAImage from an existing surface.
   2933  * This interface will derive a VAImage and corresponding image buffer from
   2934  * an existing VA Surface. The image buffer can then be mapped/unmapped for
   2935  * direct CPU access. This operation is only possible on implementations with
   2936  * direct rendering capabilities and internal surface formats that can be
   2937  * represented with a VAImage. When the operation is not possible this interface
   2938  * will return VA_STATUS_ERROR_OPERATION_FAILED. Clients should then fall back
   2939  * to using vaCreateImage + vaPutImage to accomplish the same task in an
   2940  * indirect manner.
   2941  *
   2942  * Implementations should only return success when the resulting image buffer
   2943  * would be useable with vaMap/Unmap.
   2944  *
   2945  * When directly accessing a surface special care must be taken to insure
   2946  * proper synchronization with the graphics hardware. Clients should call
   2947  * vaQuerySurfaceStatus to insure that a surface is not the target of concurrent
   2948  * rendering or currently being displayed by an overlay.
   2949  *
   2950  * Additionally nothing about the contents of a surface should be assumed
   2951  * following a vaPutSurface. Implementations are free to modify the surface for
   2952  * scaling or subpicture blending within a call to vaPutImage.
   2953  *
   2954  * Calls to vaPutImage or vaGetImage using the same surface from which the image
   2955  * has been derived will return VA_STATUS_ERROR_SURFACE_BUSY. vaPutImage or
   2956  * vaGetImage with other surfaces is supported.
   2957  *
   2958  * An image created with vaDeriveImage should be freed with vaDestroyImage. The
   2959  * image and image buffer structures will be destroyed; however, the underlying
   2960  * surface will remain unchanged until freed with vaDestroySurfaces.
   2961  */
   2962 VAStatus vaDeriveImage (
   2963     VADisplay dpy,
   2964     VASurfaceID surface,
   2965     VAImage *image	/* out */
   2966 );
   2967 
   2968 /*
   2969  * Subpictures
   2970  * Subpicture is a special type of image that can be blended
   2971  * with a surface during vaPutSurface(). Subpicture can be used to render
   2972  * DVD sub-titles or closed captioning text etc.
   2973  */
   2974 
   2975 typedef VAGenericID VASubpictureID;
   2976 
   2977 /* Get maximum number of subpicture formats supported by the implementation */
   2978 int vaMaxNumSubpictureFormats (
   2979     VADisplay dpy
   2980 );
   2981 
   2982 /* flags for subpictures */
   2983 #define VA_SUBPICTURE_CHROMA_KEYING			0x0001
   2984 #define VA_SUBPICTURE_GLOBAL_ALPHA			0x0002
   2985 #define VA_SUBPICTURE_DESTINATION_IS_SCREEN_COORD	0x0004
   2986 /*
   2987  * Query supported subpicture formats
   2988  * The caller must provide a "format_list" array that can hold at
   2989  * least vaMaxNumSubpictureFormats() entries. The flags arrary holds the flag
   2990  * for each format to indicate additional capabilities for that format. The actual
   2991  * number of formats returned in "format_list" is returned in "num_formats".
   2992  *  flags: returned value to indicate addtional capabilities
   2993  *         VA_SUBPICTURE_CHROMA_KEYING - supports chroma-keying
   2994  *         VA_SUBPICTURE_GLOBAL_ALPHA - supports global alpha
   2995  * 	   VA_SUBPICTURE_DESTINATION_IS_SCREEN_COORD - supports unscaled screen relative subpictures for On Screen Display
   2996  */
   2997 
   2998 VAStatus vaQuerySubpictureFormats (
   2999     VADisplay dpy,
   3000     VAImageFormat *format_list,	/* out */
   3001     unsigned int *flags,	/* out */
   3002     unsigned int *num_formats	/* out */
   3003 );
   3004 
   3005 /*
   3006  * Subpictures are created with an image associated.
   3007  */
   3008 VAStatus vaCreateSubpicture (
   3009     VADisplay dpy,
   3010     VAImageID image,
   3011     VASubpictureID *subpicture	/* out */
   3012 );
   3013 
   3014 /*
   3015  * Destroy the subpicture before destroying the image it is assocated to
   3016  */
   3017 VAStatus vaDestroySubpicture (
   3018     VADisplay dpy,
   3019     VASubpictureID subpicture
   3020 );
   3021 
   3022 /*
   3023  * Bind an image to the subpicture. This image will now be associated with
   3024  * the subpicture instead of the one at creation.
   3025  */
   3026 VAStatus vaSetSubpictureImage (
   3027     VADisplay dpy,
   3028     VASubpictureID subpicture,
   3029     VAImageID image
   3030 );
   3031 
   3032 /*
   3033  * If chromakey is enabled, then the area where the source value falls within
   3034  * the chromakey [min, max] range is transparent
   3035  * The chromakey component format is the following:
   3036  *  For RGB: [0:7] Red [8:15] Blue [16:23] Green
   3037  *  For YUV: [0:7] V [8:15] U [16:23] Y
   3038  * The chromakey mask can be used to mask out certain components for chromakey
   3039  * comparision
   3040  */
   3041 VAStatus vaSetSubpictureChromakey (
   3042     VADisplay dpy,
   3043     VASubpictureID subpicture,
   3044     unsigned int chromakey_min,
   3045     unsigned int chromakey_max,
   3046     unsigned int chromakey_mask
   3047 );
   3048 
   3049 /*
   3050  * Global alpha value is between 0 and 1. A value of 1 means fully opaque and
   3051  * a value of 0 means fully transparent. If per-pixel alpha is also specified then
   3052  * the overall alpha is per-pixel alpha multiplied by the global alpha
   3053  */
   3054 VAStatus vaSetSubpictureGlobalAlpha (
   3055     VADisplay dpy,
   3056     VASubpictureID subpicture,
   3057     float global_alpha
   3058 );
   3059 
   3060 /*
   3061  * vaAssociateSubpicture associates the subpicture with target_surfaces.
   3062  * It defines the region mapping between the subpicture and the target
   3063  * surfaces through source and destination rectangles (with the same width and height).
   3064  * Both will be displayed at the next call to vaPutSurface.  Additional
   3065  * associations before the call to vaPutSurface simply overrides the association.
   3066  */
   3067 VAStatus vaAssociateSubpicture (
   3068     VADisplay dpy,
   3069     VASubpictureID subpicture,
   3070     VASurfaceID *target_surfaces,
   3071     int num_surfaces,
   3072     short src_x, /* upper left offset in subpicture */
   3073     short src_y,
   3074     unsigned short src_width,
   3075     unsigned short src_height,
   3076     short dest_x, /* upper left offset in surface */
   3077     short dest_y,
   3078     unsigned short dest_width,
   3079     unsigned short dest_height,
   3080     /*
   3081      * whether to enable chroma-keying, global-alpha, or screen relative mode
   3082      * see VA_SUBPICTURE_XXX values
   3083      */
   3084     unsigned int flags
   3085 );
   3086 
   3087 /*
   3088  * vaDeassociateSubpicture removes the association of the subpicture with target_surfaces.
   3089  */
   3090 VAStatus vaDeassociateSubpicture (
   3091     VADisplay dpy,
   3092     VASubpictureID subpicture,
   3093     VASurfaceID *target_surfaces,
   3094     int num_surfaces
   3095 );
   3096 
   3097 /*
   3098  * Display attributes
   3099  * Display attributes are used to control things such as contrast, hue, saturation,
   3100  * brightness etc. in the rendering process.  The application can query what
   3101  * attributes are supported by the driver, and then set the appropriate attributes
   3102  * before calling vaPutSurface()
   3103  */
   3104 
   3105 /**
   3106  * @name Rotation angles
   3107  *
   3108  * Those values could be used for VADisplayAttribRotation attribute or
   3109  * VAProcPipelineParameterBuffer::rotation_state or in VAConfigAttribValDecJPEG.
   3110  * The rotation operation is clockwise.
   3111  */
   3112 /**@{*/
   3113 /** \brief No rotation. */
   3114 #define VA_ROTATION_NONE        0x00000000
   3115 /** \brief Rotation by 90 clockwise. */
   3116 #define VA_ROTATION_90          0x00000001
   3117 /** \brief Rotation by 180 clockwise. */
   3118 #define VA_ROTATION_180         0x00000002
   3119 /** \brief Rotation by 270 clockwise. */
   3120 #define VA_ROTATION_270         0x00000003
   3121 /**@}*/
   3122 
   3123 /**
   3124  * @name Mirroring directions
   3125  *
   3126  * Those values could be used for VADisplayAttribMirror attribute or
   3127  * VAProcPipelineParameterBuffer::mirror_state.
   3128 
   3129  */
   3130 /**@{*/
   3131 /** \brief No Mirroring. */
   3132 #define VA_MIRROR_NONE              0x00000000
   3133 /** \brief Horizontal Mirroring. */
   3134 #define VA_MIRROR_HORIZONTAL        0x00000001
   3135 /** \brief Vertical Mirroring. */
   3136 #define VA_MIRROR_VERTICAL          0x00000002
   3137 /**@}*/
   3138 
   3139 /* attribute value for VADisplayAttribOutOfLoopDeblock */
   3140 #define VA_OOL_DEBLOCKING_FALSE 0x00000000
   3141 #define VA_OOL_DEBLOCKING_TRUE  0x00000001
   3142 
   3143 /* Render mode */
   3144 #define VA_RENDER_MODE_UNDEFINED           0
   3145 #define VA_RENDER_MODE_LOCAL_OVERLAY       1
   3146 #define VA_RENDER_MODE_LOCAL_GPU           2
   3147 #define VA_RENDER_MODE_EXTERNAL_OVERLAY    4
   3148 #define VA_RENDER_MODE_EXTERNAL_GPU        8
   3149 
   3150 /* Render device */
   3151 #define VA_RENDER_DEVICE_UNDEFINED  0
   3152 #define VA_RENDER_DEVICE_LOCAL      1
   3153 #define VA_RENDER_DEVICE_EXTERNAL   2
   3154 
   3155 /* Currently defined display attribute types */
   3156 typedef enum
   3157 {
   3158     VADisplayAttribBrightness		= 0,
   3159     VADisplayAttribContrast		= 1,
   3160     VADisplayAttribHue			= 2,
   3161     VADisplayAttribSaturation		= 3,
   3162     /* client can specifiy a background color for the target window
   3163      * the new feature of video conference,
   3164      * the uncovered area of the surface is filled by this color
   3165      * also it will blend with the decoded video color
   3166      */
   3167     VADisplayAttribBackgroundColor      = 4,
   3168     VADisplayAttribRotation            = 6,
   3169     VADisplayAttribOutofLoopDeblock    = 7,
   3170 
   3171     /*
   3172      * For type VADisplayAttribCSCMatrix, "value" field is a pointer to the color
   3173      * conversion matrix. Each element in the matrix is float-point
   3174      */
   3175     VADisplayAttribCSCMatrix           = 12,
   3176     /* specify the constant color used to blend with video surface
   3177      * Cd = Cv*Cc*Ac + Cb *(1 - Ac) C means the constant RGB
   3178      *      d: the final color to overwrite into the frame buffer
   3179      *      v: decoded video after color conversion,
   3180      *      c: video color specified by VADisplayAttribBlendColor
   3181      *      b: background color of the drawable
   3182      */
   3183     VADisplayAttribBlendColor          = 13,
   3184     /*
   3185      * Indicate driver to skip painting color key or not.
   3186      * only applicable if the render is overlay
   3187      */
   3188     VADisplayAttribOverlayAutoPaintColorKey   = 14,
   3189     /*
   3190      * customized overlay color key, the format is RGB888
   3191      * [23:16] = Red, [15:08] = Green, [07:00] = Blue.
   3192      */
   3193     VADisplayAttribOverlayColorKey	= 15,
   3194     /*
   3195      * The hint for the implementation of vaPutSurface
   3196      * normally, the driver could use an overlay or GPU to render the surface on the screen
   3197      * this flag provides APP the flexibity to switch the render dynamically
   3198      */
   3199     VADisplayAttribRenderMode           = 16,
   3200     /*
   3201      * specify if vaPutSurface needs to render into specified monitors
   3202      * one example is that one external monitor (e.g. HDMI) is enabled,
   3203      * but the window manager is not aware of it, and there is no associated drawable
   3204      */
   3205     VADisplayAttribRenderDevice        = 17,
   3206     /*
   3207      * specify vaPutSurface render area if there is no drawable on the monitor
   3208      */
   3209     VADisplayAttribRenderRect          = 18,
   3210     /*
   3211      * The flag is used to indicate that the range flag of color-space conversion.
   3212      * "value" field should be assigned as VA_SOURCE_RANGE_FULL or VA_SOURCE_RANGE_REDUCED
   3213      * to indicate full range or reduced range
   3214      */
   3215     VADisplayAttribColorRange          = 19,
   3216 
   3217 } VADisplayAttribType;
   3218 
   3219 /* flags for VADisplayAttribute */
   3220 #define VA_DISPLAY_ATTRIB_NOT_SUPPORTED	0x0000
   3221 #define VA_DISPLAY_ATTRIB_GETTABLE	0x0001
   3222 #define VA_DISPLAY_ATTRIB_SETTABLE	0x0002
   3223 
   3224 typedef struct _VADisplayAttribute
   3225 {
   3226     VADisplayAttribType type;
   3227     int min_value;
   3228     int max_value;
   3229     int value;	/* used by the set/get attribute functions */
   3230 /* flags can be VA_DISPLAY_ATTRIB_GETTABLE or VA_DISPLAY_ATTRIB_SETTABLE or OR'd together */
   3231     unsigned int flags;
   3232     void *attrib_ptr; /* if flags contains VA_DISPLAY_ATTRIB_POINTER, then "attrib_ptr" points to a structure for this display attribute */
   3233 } VADisplayAttribute;
   3234 
   3235 /* Get maximum number of display attributs supported by the implementation */
   3236 int vaMaxNumDisplayAttributes (
   3237     VADisplay dpy
   3238 );
   3239 
   3240 /*
   3241  * Query display attributes
   3242  * The caller must provide a "attr_list" array that can hold at
   3243  * least vaMaxNumDisplayAttributes() entries. The actual number of attributes
   3244  * returned in "attr_list" is returned in "num_attributes".
   3245  */
   3246 VAStatus vaQueryDisplayAttributes (
   3247     VADisplay dpy,
   3248     VADisplayAttribute *attr_list,	/* out */
   3249     int *num_attributes			/* out */
   3250 );
   3251 
   3252 /*
   3253  * Get display attributes
   3254  * This function returns the current attribute values in "attr_list".
   3255  * Only attributes returned with VA_DISPLAY_ATTRIB_GETTABLE set in the "flags" field
   3256  * from vaQueryDisplayAttributes() can have their values retrieved.
   3257  */
   3258 VAStatus vaGetDisplayAttributes (
   3259     VADisplay dpy,
   3260     VADisplayAttribute *attr_list,	/* in/out */
   3261     int num_attributes
   3262 );
   3263 
   3264 /*
   3265  * Set display attributes
   3266  * Only attributes returned with VA_DISPLAY_ATTRIB_SETTABLE set in the "flags" field
   3267  * from vaQueryDisplayAttributes() can be set.  If the attribute is not settable or
   3268  * the value is out of range, the function returns VA_STATUS_ERROR_ATTR_NOT_SUPPORTED
   3269  */
   3270 VAStatus vaSetDisplayAttributes (
   3271     VADisplay dpy,
   3272     VADisplayAttribute *attr_list,
   3273     int num_attributes
   3274 );
   3275 
   3276 /**@}*/
   3277 
   3278 #ifdef __cplusplus
   3279 }
   3280 #endif
   3281 
   3282 #endif /* _VA_H_ */
   3283