tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

va.h (210429B)


      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@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 <stddef.h>
     82 #include <stdint.h>
     83 #include <va/va_version.h>
     84 
     85 #ifdef __cplusplus
     86 extern "C" {
     87 #endif
     88 
     89 #if defined(__GNUC__) && !defined(__COVERITY__)
     90 #define va_deprecated __attribute__((deprecated))
     91 #if __GNUC__ >= 6
     92 #define va_deprecated_enum va_deprecated
     93 #else
     94 #define va_deprecated_enum
     95 #endif
     96 #else
     97 #define va_deprecated
     98 #define va_deprecated_enum
     99 #endif
    100 
    101 /**
    102 * \mainpage Video Acceleration (VA) API
    103 *
    104 * \section intro Introduction
    105 *
    106 * The main motivation for VA-API (Video Acceleration API) is to
    107 * enable hardware accelerated video decode and encode at various
    108 * entry-points (VLD, IDCT, Motion Compensation etc.) for the
    109 * prevailing coding standards today (MPEG-2, MPEG-4 ASP/H.263, MPEG-4
    110 * AVC/H.264, VC-1/VMW3, and JPEG, HEVC/H265, VP8, VP9) and video pre/post
    111 * processing
    112 *
    113 * VA-API is split into several modules:
    114 * - \ref api_core
    115 * - Encoder (H264, HEVC, JPEG, MPEG2, VP8, VP9)
    116 *  - \ref api_enc_h264
    117 *  - \ref api_enc_hevc
    118 *  - \ref api_enc_jpeg
    119 *  - \ref api_enc_mpeg2
    120 *  - \ref api_enc_vp8
    121 *  - \ref api_enc_vp9
    122 * - Decoder (HEVC, JPEG, VP8, VP9, AV1)
    123 *      - \ref api_dec_hevc
    124 *      - \ref api_dec_jpeg
    125 *      - \ref api_dec_vp8
    126 *      - \ref api_dec_vp9
    127 *      - \ref api_dec_av1
    128 * - \ref api_vpp
    129 * - \ref api_prot
    130 * - FEI (H264, HEVC)
    131 *  - \ref api_fei
    132 *  - \ref api_fei_h264
    133 *  - \ref api_fei_hevc
    134 *
    135 * \section threading Multithreading Guide
    136 * All VAAPI functions implemented in libva are thread-safe. For any VAAPI
    137 * function that requires the implementation of a backend (e.g. hardware driver),
    138 * the backend must ensure that its implementation is also thread-safe. If the
    139 * backend implementation of a VAAPI function is not thread-safe then this should
    140 * be considered as a bug against the backend implementation.
    141 *
    142 * It is assumed that none of the VAAPI functions will be called from signal
    143 * handlers.
    144 *
    145 * Thread-safety in this context means that when VAAPI is being called by multiple
    146 * concurrent threads, it will not crash or hang the OS, and VAAPI internal
    147 * data structures will not be corrupted. When multiple threads are operating on
    148 * the same VAAPI objects, it is the application's responsibility to synchronize
    149 * these operations in order to generate the expected results. For example, using
    150 * a single VAContext from multiple threads may generate unexpected results.
    151 *
    152 * Following pseudo code illustrates a multithreaded transcoding scenario, where
    153 * one thread is handling the decoding operation and another thread is handling
    154 * the encoding operation, while synchronizing the use of a common pool of
    155 * surfaces.
    156 *
    157 * \code
    158 * // Initialization
    159 * dpy = vaGetDisplayDRM(fd);
    160 * vaInitialize(dpy, ...);
    161 *
    162 * // Create surfaces required for decoding and subsequence encoding
    163 * vaCreateSurfaces(dpy, VA_RT_FORMAT_YUV420, width, height, &surfaces[0], ...);
    164 *
    165 * // Set up a queue for the surfaces shared between decode and encode threads
    166 * surface_queue = queue_create();
    167 *
    168 * // Create decode_thread
    169 * pthread_create(&decode_thread, NULL, decode, ...);
    170 *
    171 * // Create encode_thread
    172 * pthread_create(&encode_thread, NULL, encode, ...);
    173 *
    174 * // Decode thread function
    175 * decode() {
    176 *   // Find the decode entrypoint for H.264
    177 *   vaQueryConfigEntrypoints(dpy, h264_profile, entrypoints, ...);
    178 *
    179 *   // Create a config for H.264 decode
    180 *   vaCreateConfig(dpy, h264_profile, VAEntrypointVLD, ...);
    181 *
    182 *   // Create a context for decode
    183 *   vaCreateContext(dpy, config, width, height, VA_PROGRESSIVE, surfaces,
    184 *     num_surfaces, &decode_context);
    185 *
    186 *   // Decode frames in the bitstream
    187 *   for (;;) {
    188 *     // Parse one frame and decode
    189 *     vaBeginPicture(dpy, decode_context, surfaces[surface_index]);
    190 *     vaRenderPicture(dpy, decode_context, buf, ...);
    191 *     vaEndPicture(dpy, decode_context);
    192 *     // Poll the decoding status and enqueue the surface in display order after
    193 *     // decoding is complete
    194 *     vaQuerySurfaceStatus();
    195 *     enqueue(surface_queue, surface_index);
    196 *   }
    197 * }
    198 *
    199 * // Encode thread function
    200 * encode() {
    201 *   // Find the encode entrypoint for HEVC
    202 *   vaQueryConfigEntrypoints(dpy, hevc_profile, entrypoints, ...);
    203 *
    204 *   // Create a config for HEVC encode
    205 *   vaCreateConfig(dpy, hevc_profile, VAEntrypointEncSlice, ...);
    206 *
    207 *   // Create a context for encode
    208 *   vaCreateContext(dpy, config, width, height, VA_PROGRESSIVE, surfaces,
    209 *     num_surfaces, &encode_context);
    210 *
    211 *   // Encode frames produced by the decoder
    212 *   for (;;) {
    213 *     // Dequeue the surface enqueued by the decoder
    214 *     surface_index = dequeue(surface_queue);
    215 *     // Encode using this surface as the source
    216 *     vaBeginPicture(dpy, encode_context, surfaces[surface_index]);
    217 *     vaRenderPicture(dpy, encode_context, buf, ...);
    218 *     vaEndPicture(dpy, encode_context);
    219 *   }
    220 * }
    221 * \endcode
    222 */
    223 
    224 /**
    225 * \defgroup api_core Core API
    226 *
    227 * @{
    228 */
    229 
    230 /**
    231 Overview
    232 
    233 The VA API is intended to provide an interface between a video decode/encode/processing
    234 application (client) and a hardware accelerator (server), to off-load
    235 video decode/encode/processing operations from the host to the hardware accelerator at various
    236 entry-points.
    237 
    238 The basic operation steps are:
    239 
    240 - Negotiate a mutually acceptable configuration with the server to lock
    241  down profile, entrypoints, and other attributes that will not change on
    242  a frame-by-frame basis.
    243 - Create a video decode, encode or processing context which represents a
    244  "virtualized" hardware device
    245 - Get and fill the render buffers with the corresponding data (depending on
    246  profiles and entrypoints)
    247 - Pass the render buffers to the server to handle the current frame
    248 
    249 Initialization & Configuration Management
    250 
    251 - Find out supported profiles
    252 - Find out entrypoints for a given profile
    253 - Find out configuration attributes for a given profile/entrypoint pair
    254 - Create a configuration for use by the application
    255 
    256 */
    257 
    258 typedef void* VADisplay;    /* window system dependent */
    259 
    260 typedef int VAStatus;   /** Return status type from functions */
    261 /** Values for the return status */
    262 #define VA_STATUS_SUCCESS           0x00000000
    263 #define VA_STATUS_ERROR_OPERATION_FAILED    0x00000001
    264 #define VA_STATUS_ERROR_ALLOCATION_FAILED   0x00000002
    265 #define VA_STATUS_ERROR_INVALID_DISPLAY     0x00000003
    266 #define VA_STATUS_ERROR_INVALID_CONFIG      0x00000004
    267 #define VA_STATUS_ERROR_INVALID_CONTEXT     0x00000005
    268 #define VA_STATUS_ERROR_INVALID_SURFACE     0x00000006
    269 #define VA_STATUS_ERROR_INVALID_BUFFER      0x00000007
    270 #define VA_STATUS_ERROR_INVALID_IMAGE       0x00000008
    271 #define VA_STATUS_ERROR_INVALID_SUBPICTURE  0x00000009
    272 #define VA_STATUS_ERROR_ATTR_NOT_SUPPORTED  0x0000000a
    273 #define VA_STATUS_ERROR_MAX_NUM_EXCEEDED    0x0000000b
    274 #define VA_STATUS_ERROR_UNSUPPORTED_PROFILE 0x0000000c
    275 #define VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT  0x0000000d
    276 #define VA_STATUS_ERROR_UNSUPPORTED_RT_FORMAT   0x0000000e
    277 #define VA_STATUS_ERROR_UNSUPPORTED_BUFFERTYPE  0x0000000f
    278 #define VA_STATUS_ERROR_SURFACE_BUSY        0x00000010
    279 #define VA_STATUS_ERROR_FLAG_NOT_SUPPORTED      0x00000011
    280 #define VA_STATUS_ERROR_INVALID_PARAMETER   0x00000012
    281 #define VA_STATUS_ERROR_RESOLUTION_NOT_SUPPORTED 0x00000013
    282 #define VA_STATUS_ERROR_UNIMPLEMENTED           0x00000014
    283 #define VA_STATUS_ERROR_SURFACE_IN_DISPLAYING   0x00000015
    284 #define VA_STATUS_ERROR_INVALID_IMAGE_FORMAT    0x00000016
    285 #define VA_STATUS_ERROR_DECODING_ERROR          0x00000017
    286 #define VA_STATUS_ERROR_ENCODING_ERROR          0x00000018
    287 /**
    288 * \brief An invalid/unsupported value was supplied.
    289 *
    290 * This is a catch-all error code for invalid or unsupported values.
    291 * e.g. value exceeding the valid range, invalid type in the context
    292 * of generic attribute values.
    293 */
    294 #define VA_STATUS_ERROR_INVALID_VALUE           0x00000019
    295 /** \brief An unsupported filter was supplied. */
    296 #define VA_STATUS_ERROR_UNSUPPORTED_FILTER      0x00000020
    297 /** \brief An invalid filter chain was supplied. */
    298 #define VA_STATUS_ERROR_INVALID_FILTER_CHAIN    0x00000021
    299 /** \brief Indicate HW busy (e.g. run multiple encoding simultaneously). */
    300 #define VA_STATUS_ERROR_HW_BUSY                 0x00000022
    301 /** \brief An unsupported memory type was supplied. */
    302 #define VA_STATUS_ERROR_UNSUPPORTED_MEMORY_TYPE 0x00000024
    303 /** \brief Indicate allocated buffer size is not enough for input or output. */
    304 #define VA_STATUS_ERROR_NOT_ENOUGH_BUFFER       0x00000025
    305 /** \brief Indicate an operation isn't completed because time-out interval elapsed. */
    306 #define VA_STATUS_ERROR_TIMEDOUT                0x00000026
    307 #define VA_STATUS_ERROR_UNKNOWN         0xFFFFFFFF
    308 
    309 /**
    310 * 1. De-interlacing flags for vaPutSurface()
    311 * 2. Surface sample type for input/output surface flag
    312 *    - Progressive: VA_FRAME_PICTURE
    313 *    - Interleaved: VA_TOP_FIELD_FIRST, VA_BOTTOM_FIELD_FIRST
    314 *    - Field: VA_TOP_FIELD, VA_BOTTOM_FIELD
    315 */
    316 #define VA_FRAME_PICTURE        0x00000000
    317 #define VA_TOP_FIELD            0x00000001
    318 #define VA_BOTTOM_FIELD         0x00000002
    319 #define VA_TOP_FIELD_FIRST      0x00000004
    320 #define VA_BOTTOM_FIELD_FIRST   0x00000008
    321 
    322 /**
    323 * Enabled the positioning/cropping/blending feature:
    324 * 1, specify the video playback position in the isurface
    325 * 2, specify the cropping info for video playback
    326 * 3, encoded video will blend with background color
    327 */
    328 #define VA_ENABLE_BLEND         0x00000004 /* video area blend with the constant color */
    329 
    330 /**
    331 * Clears the drawable with background color.
    332 * for hardware overlay based implementation this flag
    333 * can be used to turn off the overlay
    334 */
    335 #define VA_CLEAR_DRAWABLE       0x00000008
    336 
    337 /** Color space conversion flags for vaPutSurface() */
    338 #define VA_SRC_COLOR_MASK       0x000000f0
    339 #define VA_SRC_BT601            0x00000010
    340 #define VA_SRC_BT709            0x00000020
    341 #define VA_SRC_SMPTE_240        0x00000040
    342 
    343 /** Scaling flags for vaPutSurface() */
    344 #define VA_FILTER_SCALING_DEFAULT       0x00000000
    345 #define VA_FILTER_SCALING_FAST          0x00000100
    346 #define VA_FILTER_SCALING_HQ            0x00000200
    347 #define VA_FILTER_SCALING_NL_ANAMORPHIC 0x00000300
    348 #define VA_FILTER_SCALING_MASK          0x00000f00
    349 
    350 /** Interpolation method for scaling */
    351 #define VA_FILTER_INTERPOLATION_DEFAULT                    0x00000000
    352 #define VA_FILTER_INTERPOLATION_NEAREST_NEIGHBOR           0x00001000
    353 #define VA_FILTER_INTERPOLATION_BILINEAR                   0x00002000
    354 #define VA_FILTER_INTERPOLATION_ADVANCED                   0x00003000
    355 #define VA_FILTER_INTERPOLATION_MASK                       0x0000f000
    356 
    357 /** Padding size in 4-bytes */
    358 #define VA_PADDING_LOW          4
    359 #define VA_PADDING_MEDIUM       8
    360 #define VA_PADDING_HIGH         16
    361 #define VA_PADDING_LARGE        32
    362 
    363 /** operation options */
    364 /** synchronization, block call, output should be ready after execution function return*/
    365 #define VA_EXEC_SYNC              0x0
    366 /** asynchronization,application should call additonal sync operation to access output */
    367 #define VA_EXEC_ASYNC             0x1
    368 
    369 /** operation mode */
    370 #define VA_EXEC_MODE_DEFAULT      0x0
    371 #define VA_EXEC_MODE_POWER_SAVING 0x1
    372 #define VA_EXEC_MODE_PERFORMANCE  0x2
    373 
    374 /* Values used to describe device features. */
    375 /** The feature is not supported by the device.
    376 *
    377 * Any corresponding feature flag must not be set.
    378 */
    379 #define VA_FEATURE_NOT_SUPPORTED  0
    380 /** The feature is supported by the device.
    381 *
    382 * The user may decide whether or not to use this feature.
    383 *
    384 * Note that support for a feature only indicates that the hardware
    385 * is able to use it; whether it is actually a positive change to
    386 * enable it in a given situation will depend on other factors
    387 * including the input provided by the user.
    388 */
    389 #define VA_FEATURE_SUPPORTED      1
    390 /** The feature is required by the device.
    391 *
    392 * The device does not support not enabling this feature, so any
    393 * corresponding feature flag must be set and any additional
    394 * configuration needed by the feature must be supplied.
    395 */
    396 #define VA_FEATURE_REQUIRED       2
    397 
    398 /**
    399 * Returns a short english description of error_status
    400 */
    401 const char *vaErrorStr(VAStatus error_status);
    402 
    403 typedef struct _VARectangle {
    404    int16_t x;
    405    int16_t y;
    406    uint16_t width;
    407    uint16_t height;
    408 } VARectangle;
    409 
    410 /** \brief Generic motion vector data structure. */
    411 typedef struct _VAMotionVector {
    412    /** \mv0[0]: horizontal motion vector for past reference */
    413    /** \mv0[1]: vertical motion vector for past reference */
    414    /** \mv1[0]: horizontal motion vector for future reference */
    415    /** \mv1[1]: vertical motion vector for future reference */
    416    int16_t  mv0[2];  /* past reference */
    417    int16_t  mv1[2];  /* future reference */
    418 } VAMotionVector;
    419 
    420 /** Type of a message callback, used for both error and info log. */
    421 typedef void (*VAMessageCallback)(void *user_context, const char *message);
    422 
    423 /**
    424 * Set the callback for error messages, or NULL for no logging.
    425 * Returns the previous one, or NULL if it was disabled.
    426 */
    427 VAMessageCallback vaSetErrorCallback(VADisplay dpy, VAMessageCallback callback, void *user_context);
    428 
    429 /**
    430 * Set the callback for info messages, or NULL for no logging.
    431 * Returns the previous one, or NULL if it was disabled.
    432 */
    433 VAMessageCallback vaSetInfoCallback(VADisplay dpy, VAMessageCallback callback, void *user_context);
    434 
    435 /**
    436 * Initialization:
    437 * A display must be obtained by calling vaGetDisplay() before calling
    438 * vaInitialize() and other functions. This connects the API to the
    439 * native window system.
    440 * For X Windows, native_dpy would be from XOpenDisplay()
    441 */
    442 typedef void* VANativeDisplay;  /* window system dependent */
    443 
    444 int vaDisplayIsValid(VADisplay dpy);
    445 
    446 /**
    447 *  Set the override driver name instead of queried driver driver.
    448 */
    449 VAStatus vaSetDriverName(VADisplay dpy,
    450                         char *driver_name
    451                        );
    452 
    453 /**
    454 * Initialize the library
    455 */
    456 VAStatus vaInitialize(
    457    VADisplay dpy,
    458    int *major_version,  /* out */
    459    int *minor_version   /* out */
    460 );
    461 
    462 /**
    463 * After this call, all library internal resources will be cleaned up
    464 */
    465 VAStatus vaTerminate(
    466    VADisplay dpy
    467 );
    468 
    469 /**
    470 * vaQueryVendorString returns a pointer to a zero-terminated string
    471 * describing some aspects of the VA implemenation on a specific
    472 * hardware accelerator. The format of the returned string is vendor
    473 * specific and at the discretion of the implementer.
    474 * e.g. for the Intel GMA500 implementation, an example would be:
    475 * "Intel GMA500 - 2.0.0.32L.0005"
    476 */
    477 const char *vaQueryVendorString(
    478    VADisplay dpy
    479 );
    480 
    481 typedef int (*VAPrivFunc)(void);
    482 
    483 /**
    484 * Return a function pointer given a function name in the library.
    485 * This allows private interfaces into the library
    486 */
    487 VAPrivFunc vaGetLibFunc(
    488    VADisplay dpy,
    489    const char *func
    490 );
    491 
    492 /** Currently defined profiles */
    493 typedef enum {
    494    /** \brief Profile ID used for video processing. */
    495    VAProfileNone                       = -1,
    496    VAProfileMPEG2Simple        = 0,
    497    VAProfileMPEG2Main          = 1,
    498    VAProfileMPEG4Simple        = 2,
    499    VAProfileMPEG4AdvancedSimple    = 3,
    500    VAProfileMPEG4Main          = 4,
    501    VAProfileH264Baseline va_deprecated_enum = 5,
    502    VAProfileH264Main           = 6,
    503    VAProfileH264High           = 7,
    504    VAProfileVC1Simple          = 8,
    505    VAProfileVC1Main            = 9,
    506    VAProfileVC1Advanced        = 10,
    507    VAProfileH263Baseline       = 11,
    508    VAProfileJPEGBaseline               = 12,
    509    VAProfileH264ConstrainedBaseline    = 13,
    510    VAProfileVP8Version0_3              = 14,
    511    VAProfileH264MultiviewHigh          = 15,
    512    VAProfileH264StereoHigh             = 16,
    513    VAProfileHEVCMain                   = 17,
    514    VAProfileHEVCMain10                 = 18,
    515    VAProfileVP9Profile0                = 19,
    516    VAProfileVP9Profile1                = 20,
    517    VAProfileVP9Profile2                = 21,
    518    VAProfileVP9Profile3                = 22,
    519    VAProfileHEVCMain12                 = 23,
    520    VAProfileHEVCMain422_10             = 24,
    521    VAProfileHEVCMain422_12             = 25,
    522    VAProfileHEVCMain444                = 26,
    523    VAProfileHEVCMain444_10             = 27,
    524    VAProfileHEVCMain444_12             = 28,
    525    VAProfileHEVCSccMain                = 29,
    526    VAProfileHEVCSccMain10              = 30,
    527    VAProfileHEVCSccMain444             = 31,
    528    VAProfileAV1Profile0                = 32,
    529    VAProfileAV1Profile1                = 33,
    530    VAProfileHEVCSccMain444_10          = 34,
    531    /** \brief Profile ID used for protected video playback. */
    532    VAProfileProtected                  = 35
    533 } VAProfile;
    534 
    535 /**
    536 *  Currently defined entrypoints
    537 */
    538 typedef enum {
    539    VAEntrypointVLD     = 1,
    540    VAEntrypointIZZ     = 2,
    541    VAEntrypointIDCT        = 3,
    542    VAEntrypointMoComp      = 4,
    543    VAEntrypointDeblocking  = 5,
    544    VAEntrypointEncSlice    = 6,    /* slice level encode */
    545    VAEntrypointEncPicture  = 7,    /* pictuer encode, JPEG, etc */
    546    /*
    547     * For an implementation that supports a low power/high performance variant
    548     * for slice level encode, it can choose to expose the
    549     * VAEntrypointEncSliceLP entrypoint. Certain encoding tools may not be
    550     * available with this entrypoint (e.g. interlace, MBAFF) and the
    551     * application can query the encoding configuration attributes to find
    552     * out more details if this entrypoint is supported.
    553     */
    554    VAEntrypointEncSliceLP  = 8,
    555    VAEntrypointVideoProc       = 10,   /**< Video pre/post-processing. */
    556    /**
    557     * \brief VAEntrypointFEI
    558     *
    559     * The purpose of FEI (Flexible Encoding Infrastructure) is to allow applications to
    560     * have more controls and trade off quality for speed with their own IPs.
    561     * The application can optionally provide input to ENC for extra encode control
    562     * and get the output from ENC. Application can chose to modify the ENC
    563     * output/PAK input during encoding, but the performance impact is significant.
    564     *
    565     * On top of the existing buffers for normal encode, there will be
    566     * one extra input buffer (VAEncMiscParameterFEIFrameControl) and
    567     * three extra output buffers (VAEncFEIMVBufferType, VAEncFEIMBModeBufferType
    568     * and VAEncFEIDistortionBufferType) for VAEntrypointFEI entry function.
    569     * If separate PAK is set, two extra input buffers
    570     * (VAEncFEIMVBufferType, VAEncFEIMBModeBufferType) are needed for PAK input.
    571     **/
    572    VAEntrypointFEI         = 11,
    573    /**
    574     * \brief VAEntrypointStats
    575     *
    576     * A pre-processing function for getting some statistics and motion vectors is added,
    577     * and some extra controls for Encode pipeline are provided. The application can
    578     * optionally call the statistics function to get motion vectors and statistics like
    579     * variances, distortions before calling Encode function via this entry point.
    580     *
    581     * Checking whether Statistics is supported can be performed with vaQueryConfigEntrypoints().
    582     * If Statistics entry point is supported, then the list of returned entry-points will
    583     * include #VAEntrypointStats. Supported pixel format, maximum resolution and statistics
    584     * specific attributes can be obtained via normal attribute query. One input buffer
    585     * (VAStatsStatisticsParameterBufferType) and one or two output buffers
    586     * (VAStatsStatisticsBufferType, VAStatsStatisticsBottomFieldBufferType (for interlace only)
    587     * and VAStatsMVBufferType) are needed for this entry point.
    588     **/
    589    VAEntrypointStats       = 12,
    590    /**
    591     * \brief VAEntrypointProtectedTEEComm
    592     *
    593     * A function for communicating with TEE (Trusted Execution Environment).
    594     **/
    595    VAEntrypointProtectedTEEComm       = 13,
    596    /**
    597     * \brief VAEntrypointProtectedContent
    598     *
    599     * A function for protected content to decrypt encrypted content.
    600     **/
    601    VAEntrypointProtectedContent       = 14,
    602 } VAEntrypoint;
    603 
    604 /** Currently defined configuration attribute types */
    605 typedef enum {
    606    VAConfigAttribRTFormat      = 0,
    607    VAConfigAttribSpatialResidual   = 1,
    608    VAConfigAttribSpatialClipping   = 2,
    609    VAConfigAttribIntraResidual     = 3,
    610    VAConfigAttribEncryption        = 4,
    611    VAConfigAttribRateControl       = 5,
    612 
    613    /** @name Attributes for decoding */
    614    /**@{*/
    615    /**
    616     * \brief Slice Decoding mode. Read/write.
    617     *
    618     * This attribute determines what mode the driver supports for slice
    619     * decoding, through vaGetConfigAttributes(); and what mode the user
    620     * will be providing to the driver, through vaCreateConfig(), if the
    621     * driver supports those. If this attribute is not set by the user then
    622     * it is assumed that VA_DEC_SLICE_MODE_NORMAL mode is used.
    623     *
    624     * See \c VA_DEC_SLICE_MODE_xxx for the list of slice decoding modes.
    625     */
    626    VAConfigAttribDecSliceMode      = 6,
    627    /**
    628      * \brief JPEG decoding attribute. Read-only.
    629      *
    630      * This attribute exposes a number of capabilities of the underlying
    631      * JPEG implementation. The attribute value is partitioned into fields as defined in the
    632      * VAConfigAttribValDecJPEG union.
    633      */
    634    VAConfigAttribDecJPEG             = 7,
    635    /**
    636     * \brief Decode processing support. Read/write.
    637     *
    638     * This attribute determines if the driver supports video processing
    639     * with decoding using the decoding context in a single call, through
    640     * vaGetConfigAttributes(); and if the user may use this feature,
    641     * through vaCreateConfig(), if the driver supports the user scenario.
    642     * The user will essentially create a regular decode VAContext.  Therefore,
    643     * the parameters of vaCreateContext() such as picture_width, picture_height
    644     * and render_targets are in relation to the decode output parameters
    645     * (not processing output parameters) as normal.
    646     * If this attribute is not set by the user then it is assumed that no
    647     * extra processing is done after decoding for this decode context.
    648     *
    649     * Since essentially the application is creating a decoder config and context,
    650     * all function calls that take in the config (e.g. vaQuerySurfaceAttributes())
    651     * or context are in relation to the decoder, except those video processing
    652     * function specified in the next paragraph.
    653     *
    654     * Once the decode config and context are created, the user must further
    655     * query the supported processing filters using vaQueryVideoProcFilters(),
    656     * vaQueryVideoProcFilterCaps(), vaQueryVideoProcPipelineCaps() by specifying
    657     * the created decode context.  The user must provide processing information
    658     * and extra processing output surfaces as "additional_outputs" to the driver
    659     * through VAProcPipelineParameterBufferType.  The render_target specified
    660     * at vaBeginPicture() time refers to the decode output surface.  The
    661     * target surface for the output of processing needs to be a different
    662     * surface since the decode process requires the original reconstructed buffer.
    663     * The “surface” member of VAProcPipelineParameterBuffer should be set to the
    664     * same as “render_target” set in vaBeginPicture(), but the driver may choose
    665     * to ignore this parameter.
    666     */
    667    VAConfigAttribDecProcessing     = 8,
    668    /** @name Attributes for encoding */
    669    /**@{*/
    670    /**
    671     * \brief Packed headers mode. Read/write.
    672     *
    673     * This attribute determines what packed headers the driver supports,
    674     * through vaGetConfigAttributes(); and what packed headers the user
    675     * will be providing to the driver, through vaCreateConfig(), if the
    676     * driver supports those.
    677     *
    678     * See \c VA_ENC_PACKED_HEADER_xxx for the list of packed headers.
    679     */
    680    VAConfigAttribEncPackedHeaders      = 10,
    681    /**
    682     * \brief Interlaced mode. Read/write.
    683     *
    684     * This attribute determines what kind of interlaced encoding mode
    685     * the driver supports.
    686     *
    687     * See \c VA_ENC_INTERLACED_xxx for the list of interlaced modes.
    688     */
    689    VAConfigAttribEncInterlaced         = 11,
    690    /**
    691     * \brief Maximum number of reference frames. Read-only.
    692     *
    693     * This attribute determines the maximum number of reference
    694     * frames supported for encoding.
    695     *
    696     * Note: for H.264 encoding, the value represents the maximum number
    697     * of reference frames for both the reference picture list 0 (bottom
    698     * 16 bits) and the reference picture list 1 (top 16 bits).
    699     */
    700    VAConfigAttribEncMaxRefFrames       = 13,
    701    /**
    702     * \brief Maximum number of slices per frame. Read-only.
    703     *
    704     * This attribute determines the maximum number of slices the
    705     * driver can support to encode a single frame.
    706     */
    707    VAConfigAttribEncMaxSlices          = 14,
    708    /**
    709     * \brief Slice structure. Read-only.
    710     *
    711     * This attribute determines slice structures supported by the
    712     * driver for encoding. This attribute is a hint to the user so
    713     * that he can choose a suitable surface size and how to arrange
    714     * the encoding process of multiple slices per frame.
    715     *
    716     * More specifically, for H.264 encoding, this attribute
    717     * determines the range of accepted values to
    718     * VAEncSliceParameterBufferH264::macroblock_address and
    719     * VAEncSliceParameterBufferH264::num_macroblocks.
    720     *
    721     * See \c VA_ENC_SLICE_STRUCTURE_xxx for the supported slice
    722     * structure types.
    723     */
    724    VAConfigAttribEncSliceStructure     = 15,
    725    /**
    726     * \brief Macroblock information. Read-only.
    727     *
    728     * This attribute determines whether the driver supports extra
    729     * encoding information per-macroblock. e.g. QP.
    730     *
    731     * More specifically, for H.264 encoding, if the driver returns a non-zero
    732     * value for this attribute, this means the application can create
    733     * additional #VAEncMacroblockParameterBufferH264 buffers referenced
    734     * through VAEncSliceParameterBufferH264::macroblock_info.
    735     */
    736    VAConfigAttribEncMacroblockInfo     = 16,
    737    /**
    738     * \brief Maximum picture width. Read-only.
    739     *
    740     * This attribute determines the maximum picture width the driver supports
    741     * for a given configuration.
    742     */
    743    VAConfigAttribMaxPictureWidth     = 18,
    744    /**
    745     * \brief Maximum picture height. Read-only.
    746     *
    747     * This attribute determines the maximum picture height the driver supports
    748     * for a given configuration.
    749     */
    750    VAConfigAttribMaxPictureHeight    = 19,
    751    /**
    752     * \brief JPEG encoding attribute. Read-only.
    753     *
    754     * This attribute exposes a number of capabilities of the underlying
    755     * JPEG implementation. The attribute value is partitioned into fields as defined in the
    756     * VAConfigAttribValEncJPEG union.
    757     */
    758    VAConfigAttribEncJPEG             = 20,
    759    /**
    760     * \brief Encoding quality range attribute. Read-only.
    761     *
    762     * This attribute conveys whether the driver supports different quality level settings
    763     * for encoding. A value less than or equal to 1 means that the encoder only has a single
    764     * quality setting, and a value greater than 1 represents the number of quality levels
    765     * that can be configured. e.g. a value of 2 means there are two distinct quality levels.
    766     */
    767    VAConfigAttribEncQualityRange     = 21,
    768    /**
    769     * \brief Encoding quantization attribute. Read-only.
    770     *
    771     * This attribute conveys whether the driver supports certain types of quantization methods
    772     * for encoding (e.g. trellis). See \c VA_ENC_QUANTIZATION_xxx for the list of quantization methods
    773     */
    774    VAConfigAttribEncQuantization     = 22,
    775    /**
    776     * \brief Encoding intra refresh attribute. Read-only.
    777     *
    778     * This attribute conveys whether the driver supports certain types of intra refresh methods
    779     * for encoding (e.g. adaptive intra refresh or rolling intra refresh).
    780     * See \c VA_ENC_INTRA_REFRESH_xxx for intra refresh methods
    781     */
    782    VAConfigAttribEncIntraRefresh     = 23,
    783    /**
    784     * \brief Encoding skip frame attribute. Read-only.
    785     *
    786     * This attribute conveys whether the driver supports sending skip frame parameters
    787     * (VAEncMiscParameterTypeSkipFrame) to the encoder's rate control, when the user has
    788     * externally skipped frames.
    789     */
    790    VAConfigAttribEncSkipFrame        = 24,
    791    /**
    792     * \brief Encoding region-of-interest (ROI) attribute. Read-only.
    793     *
    794     * This attribute conveys whether the driver supports region-of-interest (ROI) encoding,
    795     * based on user provided ROI rectangles.  The attribute value is partitioned into fields
    796     * as defined in the VAConfigAttribValEncROI union.
    797     *
    798     * If ROI encoding is supported, the ROI information is passed to the driver using
    799     * VAEncMiscParameterTypeROI.
    800     */
    801    VAConfigAttribEncROI              = 25,
    802    /**
    803     * \brief Encoding extended rate control attribute. Read-only.
    804     *
    805     * This attribute conveys whether the driver supports any extended rate control features
    806     * The attribute value is partitioned into fields as defined in the
    807     * VAConfigAttribValEncRateControlExt union.
    808     */
    809    VAConfigAttribEncRateControlExt   = 26,
    810    /**
    811     * \brief Processing rate reporting attribute. Read-only.
    812     *
    813     * This attribute conveys whether the driver supports reporting of
    814     * encode/decode processing rate based on certain set of parameters
    815     * (i.e. levels, I frame internvals) for a given configuration.
    816     * If this is supported, vaQueryProcessingRate() can be used to get
    817     * encode or decode processing rate.
    818     * See \c VA_PROCESSING_RATE_xxx for encode/decode processing rate
    819     */
    820    VAConfigAttribProcessingRate    = 27,
    821    /**
    822     * \brief Encoding dirty rectangle. Read-only.
    823     *
    824     * This attribute conveys whether the driver supports dirty rectangle.
    825     * encoding, based on user provided ROI rectangles which indicate the rectangular areas
    826     * where the content has changed as compared to the previous picture.  The regions of the
    827     * picture that are not covered by dirty rect rectangles are assumed to have not changed
    828     * compared to the previous picture.  The encoder may do some optimizations based on
    829     * this information.  The attribute value returned indicates the number of regions that
    830     * are supported.  e.g. A value of 0 means dirty rect encoding is not supported.  If dirty
    831     * rect encoding is supported, the ROI information is passed to the driver using
    832     * VAEncMiscParameterTypeDirtyRect.
    833     */
    834    VAConfigAttribEncDirtyRect       = 28,
    835    /**
    836     * \brief Parallel Rate Control (hierachical B) attribute. Read-only.
    837     *
    838     * This attribute conveys whether the encoder supports parallel rate control.
    839     * It is a integer value 0 - unsupported, > 0 - maximum layer supported.
    840     * This is the way when hireachical B frames are encoded, multiple independent B frames
    841     * on the same layer may be processed at same time. If supported, app may enable it by
    842     * setting enable_parallel_brc in VAEncMiscParameterRateControl,and the number of B frames
    843     * per layer per GOP will be passed to driver through VAEncMiscParameterParallelRateControl
    844     * structure.Currently three layers are defined.
    845     */
    846    VAConfigAttribEncParallelRateControl   = 29,
    847    /**
    848    * \brief Dynamic Scaling Attribute. Read-only.
    849    *
    850    * This attribute conveys whether encoder is capable to determine dynamic frame
    851    * resolutions adaptive to bandwidth utilization and processing power, etc.
    852    * It is a boolean value 0 - unsupported, 1 - supported.
    853    * If it is supported,for VP9, suggested frame resolution can be retrieved from VACodedBufferVP9Status.
    854    */
    855    VAConfigAttribEncDynamicScaling        = 30,
    856    /**
    857    * \brief frame size tolerance support
    858    * it indicates the tolerance of frame size
    859    */
    860    VAConfigAttribFrameSizeToleranceSupport = 31,
    861    /**
    862    * \brief Encode function type for FEI.
    863    *
    864    * This attribute conveys whether the driver supports different function types for encode.
    865    * It can be VA_FEI_FUNCTION_ENC, VA_FEI_FUNCTION_PAK, or VA_FEI_FUNCTION_ENC_PAK. Currently
    866    * it is for FEI entry point only.
    867    * Default is VA_FEI_FUNCTION_ENC_PAK.
    868    */
    869    VAConfigAttribFEIFunctionType     = 32,
    870    /**
    871     * \brief Maximum number of FEI MV predictors. Read-only.
    872     *
    873     * This attribute determines the maximum number of MV predictors the driver
    874     * can support to encode a single frame. 0 means no MV predictor is supported.
    875     * Currently it is for FEI entry point only.
    876     */
    877    VAConfigAttribFEIMVPredictors     = 33,
    878    /**
    879     * \brief Statistics attribute. Read-only.
    880     *
    881     * This attribute exposes a number of capabilities of the VAEntrypointStats entry
    882     * point. The attribute value is partitioned into fields as defined in the
    883     * VAConfigAttribValStats union. Currently it is for VAEntrypointStats only.
    884     */
    885    VAConfigAttribStats               = 34,
    886    /**
    887    * \brief Tile Support Attribute. Read-only.
    888    *
    889    * This attribute conveys whether encoder is capable to support tiles.
    890    * If not supported, the tile related parameters sent to encoder, such as
    891    * tiling structure, should be ignored. 0 - unsupported, 1 - supported.
    892    */
    893    VAConfigAttribEncTileSupport        = 35,
    894    /**
    895     * \brief whether accept rouding setting from application. Read-only.
    896     * This attribute is for encode quality, if it is report,
    897     * application can change the rounding setting by VAEncMiscParameterTypeCustomRoundingControl
    898     */
    899    VAConfigAttribCustomRoundingControl = 36,
    900    /**
    901     * \brief Encoding QP info block size attribute. Read-only.
    902     * This attribute conveys the block sizes that underlying driver
    903     * support for QP info for buffer #VAEncQpBuffer.
    904     */
    905    VAConfigAttribQPBlockSize            = 37,
    906    /**
    907     * \brief encode max frame size attribute. Read-only
    908     * attribute value \c VAConfigAttribValMaxFrameSize represent max frame size support
    909     */
    910    VAConfigAttribMaxFrameSize           = 38,
    911    /** \brief inter frame prediction directrion attribute. Read-only.
    912     * this attribute conveys the prediction direction (backward or forword) for specific config
    913     * the value could be  VA_PREDICTION_DIRECTION_XXXX. it can be combined with VAConfigAttribEncMaxRefFrames
    914     * to describe reference list , and the prediction direction. if this attrib is not present,both direction
    915     * should be supported, no restriction.
    916     * for example: normal HEVC encoding , maximum reference frame number in reflist 0 and reflist 1 is deduced
    917     * by  VAConfigAttribEncMaxRefFrames. so there are typical P frame, B frame,
    918     * if VAConfigAttribPredictionDirection is also present. it will stipulate prediction direction in both
    919     * reference list. if only one prediction direction present(such as PREVIOUS),all reference frame should be
    920     *  previous frame (PoC < current).
    921     */
    922    VAConfigAttribPredictionDirection   = 39,
    923    /** \brief combined submission of multiple frames from different streams, it is optimization for different HW
    924     * implementation, multiple frames encode/decode can improve HW concurrency
    925     */
    926    VAConfigAttribMultipleFrame         = 40,
    927    /** \brief priority setting for the context. Read-Write
    928     *  attribute value is \c VAConfigAttribValContextPriority
    929     *  this setting also could be update by \c VAContextParameterUpdateBuffer
    930     */
    931    VAConfigAttribContextPriority       = 41,
    932    /** \brief AV1 decoding features.  Read-only.
    933     *
    934     * This attribute describes the supported features of an
    935     * AV1 decoder configuration.  The value returned uses the
    936     * VAConfigAttribValDecAV1Features type.
    937     */
    938    VAConfigAttribDecAV1Features    = 42,
    939    /** \brief TEE could be any HW secure device. Read-only */
    940    VAConfigAttribTEEType               = 43,
    941    /** \brief TEE type client is a specific module supporting specific functions in TEE. Read-only*/
    942    VAConfigAttribTEETypeClient         = 44,
    943    /**
    944     * \brief Cipher algorithm of the protected content session.
    945     *
    946     * This attribute specifies the cipher algorithm of the protected content session. It
    947     * could be \c VA_PC_CIPHER_AES, etc....
    948     */
    949    VAConfigAttribProtectedContentCipherAlgorithm = 45,
    950    /**
    951     * \brief Cipher block size of the protected content session.
    952     *
    953     * This attribute specifies the block size of the protected content session. It could be
    954     * \c VA_PC_BLOCK_SIZE_128, \c VA_PC_BLOCK_SIZE_192, or \c VA_PC_BLOCK_SIZE_256, etc....
    955     */
    956    VAConfigAttribProtectedContentCipherBlockSize = 46,
    957    /**
    958     * \brief Cipher mode of the protected content session.
    959     *
    960     * This attribute specifies the cipher mode of the protected content session. It could
    961     * be \c VA_PC_CIPHER_MODE_ECB, \c VA_PC_CIPHER_MODE_CBC, \c VA_PC_CIPHER_MODE_CTR, etc...
    962     */
    963    VAConfigAttribProtectedContentCipherMode = 47,
    964    /**
    965     * \brief Decryption sample type of the protected content session.
    966     *
    967     * This attribute specifies the decryption sample type of the protected content session.
    968     * It could be \c VA_PC_SAMPLE_TYPE_FULLSAMPLE or \c VA_PC_SAMPLE_TYPE_SUBSAMPLE.
    969     */
    970    VAConfigAttribProtectedContentCipherSampleType = 48,
    971    /**
    972     * \brief Special usage attribute of the protected session.
    973     *
    974     * The attribute specifies the flow for the protected session could be used. For
    975     * example, it could be \c VA_PC_USAGE_DEFAULT, \c VA_PC_USAGE_WIDEVINE, etc....
    976     */
    977    VAConfigAttribProtectedContentUsage = 49,
    978 
    979    /** \brief HEVC/H.265 encoding features.  Read-only.
    980     *
    981     * This attribute describes the supported features of an
    982     * HEVC/H.265 encoder configuration.  The value returned uses the
    983     * VAConfigAttribValEncHEVCFeatures type.
    984     *
    985     * If this attribute is supported by a driver then it must also
    986     * support the VAConfigAttribEncHEVCBlockSizes attribute.
    987     */
    988    VAConfigAttribEncHEVCFeatures       = 50,
    989    /** \brief HEVC/H.265 encoding block sizes.  Read-only.
    990     *
    991     * This attribute describes the supported coding tree and transform
    992     * block sizes of an HEVC/H.265 encoder configuration.  The value
    993     * returned uses the VAConfigAttribValEncHEVCBlockSizes type.
    994     *
    995     * If this attribute is supported by a driver then it must also
    996     * support the VAConfigAttribEncHEVCFeatures attribute.
    997     */
    998    VAConfigAttribEncHEVCBlockSizes     = 51,
    999    /**@}*/
   1000    VAConfigAttribTypeMax
   1001 } VAConfigAttribType;
   1002 
   1003 /**
   1004 * Configuration attributes
   1005 * If there is more than one value for an attribute, a default
   1006 * value will be assigned to the attribute if the client does not
   1007 * specify the attribute when creating a configuration
   1008 */
   1009 typedef struct _VAConfigAttrib {
   1010    VAConfigAttribType type;
   1011    uint32_t value; /* OR'd flags (bits) for this attribute */
   1012 } VAConfigAttrib;
   1013 
   1014 /* Attribute values for VAConfigAttribRTFormat. */
   1015 
   1016 #define VA_RT_FORMAT_YUV420 0x00000001  ///< YUV 4:2:0 8-bit.
   1017 #define VA_RT_FORMAT_YUV422 0x00000002  ///< YUV 4:2:2 8-bit.
   1018 #define VA_RT_FORMAT_YUV444 0x00000004  ///< YUV 4:4:4 8-bit.
   1019 #define VA_RT_FORMAT_YUV411 0x00000008  ///< YUV 4:1:1 8-bit.
   1020 #define VA_RT_FORMAT_YUV400 0x00000010  ///< Greyscale 8-bit.
   1021 #define VA_RT_FORMAT_YUV420_10  0x00000100  ///< YUV 4:2:0 10-bit.
   1022 #define VA_RT_FORMAT_YUV422_10  0x00000200  ///< YUV 4:2:2 10-bit.
   1023 #define VA_RT_FORMAT_YUV444_10  0x00000400  ///< YUV 4:4:4 10-bit.
   1024 #define VA_RT_FORMAT_YUV420_12  0x00001000  ///< YUV 4:2:0 12-bit.
   1025 #define VA_RT_FORMAT_YUV422_12  0x00002000  ///< YUV 4:2:2 12-bit.
   1026 #define VA_RT_FORMAT_YUV444_12  0x00004000  ///< YUV 4:4:4 12-bit.
   1027 
   1028 #define VA_RT_FORMAT_RGB16  0x00010000  ///< Packed RGB, 16 bits per pixel.
   1029 #define VA_RT_FORMAT_RGB32  0x00020000  ///< Packed RGB, 32 bits per pixel, 8 bits per colour sample.
   1030 #define VA_RT_FORMAT_RGBP   0x00100000  ///< Planar RGB, 8 bits per sample.
   1031 #define VA_RT_FORMAT_RGB32_10   0x00200000  ///< Packed RGB, 32 bits per pixel, 10 bits per colour sample.
   1032 
   1033 #define VA_RT_FORMAT_PROTECTED  0x80000000
   1034 
   1035 #define VA_RT_FORMAT_RGB32_10BPP    VA_RT_FORMAT_RGB32_10   ///< @deprecated use VA_RT_FORMAT_RGB32_10 instead.
   1036 #define VA_RT_FORMAT_YUV420_10BPP   VA_RT_FORMAT_YUV420_10  ///< @deprecated use VA_RT_FORMAT_YUV420_10 instead.
   1037 
   1038 /** @name Attribute values for VAConfigAttribRateControl */
   1039 /**@{*/
   1040 /** \brief Driver does not support any form of rate control. */
   1041 #define VA_RC_NONE                      0x00000001
   1042 /** \brief Constant bitrate. */
   1043 #define VA_RC_CBR                       0x00000002
   1044 /** \brief Variable bitrate. */
   1045 #define VA_RC_VBR                       0x00000004
   1046 /** \brief Video conference mode. */
   1047 #define VA_RC_VCM                       0x00000008
   1048 /** \brief Constant QP. */
   1049 #define VA_RC_CQP                       0x00000010
   1050 /** \brief Variable bitrate with peak rate higher than average bitrate. */
   1051 #define VA_RC_VBR_CONSTRAINED           0x00000020
   1052 /** \brief Intelligent Constant Quality. Provided an initial ICQ_quality_factor,
   1053 *  adjusts QP at a frame and MB level based on motion to improve subjective quality. */
   1054 #define VA_RC_ICQ           0x00000040
   1055 /** \brief Macroblock based rate control.  Per MB control is decided
   1056 *  internally in the encoder. It may be combined with other RC modes, except CQP. */
   1057 #define VA_RC_MB                        0x00000080
   1058 /** \brief Constant Frame Size, it is used for small tolerent  */
   1059 #define VA_RC_CFS                       0x00000100
   1060 /** \brief Parallel BRC, for hierachical B.
   1061 *
   1062 *  For hierachical B, B frames can be refered by other B frames.
   1063 *  Currently three layers of hierachy are defined:
   1064 *  B0 - regular B, no reference to other B frames.
   1065 *  B1 - reference to only I, P and regular B0 frames.
   1066 *  B2 - reference to any other frames, including B1.
   1067 *  In Hierachical B structure, B frames on the same layer can be processed
   1068 *  simultaneously. And BRC would adjust accordingly. This is so called
   1069 *  Parallel BRC. */
   1070 #define VA_RC_PARALLEL                  0x00000200
   1071 /** \brief Quality defined VBR
   1072 * Use Quality factor to determine the good enough QP for each MB such that
   1073 * good enough quality can be obtained without waste of bits
   1074 * for this BRC mode, you must set all legacy VBR parameters
   1075 * and reuse quality_factor in \c VAEncMiscParameterRateControl
   1076 * */
   1077 #define VA_RC_QVBR                      0x00000400
   1078 /** \brief Average VBR
   1079 *  Average variable bitrate control algorithm focuses on overall encoding
   1080 *  quality while meeting the specified target bitrate, within the accuracy
   1081 *  range, after a convergence period.
   1082 *  bits_per_second in VAEncMiscParameterRateControl is target bitrate for AVBR.
   1083 *  Convergence is specified in the unit of frame.
   1084 *  window_size in VAEncMiscParameterRateControl is equal to convergence for AVBR.
   1085 *  Accuracy is in the range of [1,100], 1 means one percent, and so on.
   1086 *  target_percentage in VAEncMiscParameterRateControl is equal to accuracy for AVBR.
   1087 * */
   1088 #define VA_RC_AVBR                      0x00000800
   1089 /** \brief Transport Controlled BRC
   1090 *  Specific bitrate control for real time streaming.
   1091 *  TCBRC can instantly react to channel change to remove or significantly reduce the delay.
   1092 *  Application (transport) provides channel feedback to driver through TargetFrameSize.
   1093 *  When channel condition is very good (almost no constraint on instant frame size),
   1094 *  the app should set target frame size as zero. Otherwise, channel capacity divided by fps
   1095 *  should be used.
   1096 * */
   1097 #define VA_RC_TCBRC                     0x00001000
   1098 
   1099 /**@}*/
   1100 
   1101 /** @name Attribute values for VAConfigAttribDecSliceMode */
   1102 /**@{*/
   1103 /** \brief Driver supports normal mode for slice decoding */
   1104 #define VA_DEC_SLICE_MODE_NORMAL       0x00000001
   1105 /** \brief Driver supports base mode for slice decoding */
   1106 #define VA_DEC_SLICE_MODE_BASE         0x00000002
   1107 
   1108 /** @name Attribute values for VAConfigAttribDecJPEG */
   1109 /**@{*/
   1110 typedef union _VAConfigAttribValDecJPEG {
   1111    struct {
   1112        /** \brief Set to (1 << VA_ROTATION_xxx) for supported rotation angles. */
   1113        uint32_t rotation : 4;
   1114        /** \brief Reserved for future use. */
   1115        uint32_t reserved : 28;
   1116    } bits;
   1117    uint32_t value;
   1118 } VAConfigAttribValDecJPEG;
   1119 /** @name Attribute values for VAConfigAttribDecProcessing */
   1120 /**@{*/
   1121 /** \brief No decoding + processing in a single decoding call. */
   1122 #define VA_DEC_PROCESSING_NONE     0x00000000
   1123 /** \brief Decode + processing in a single decoding call. */
   1124 #define VA_DEC_PROCESSING          0x00000001
   1125 /**@}*/
   1126 
   1127 /** @name Attribute values for VAConfigAttribEncPackedHeaders */
   1128 /**@{*/
   1129 /** \brief Driver does not support any packed headers mode. */
   1130 #define VA_ENC_PACKED_HEADER_NONE       0x00000000
   1131 /**
   1132 * \brief Driver supports packed sequence headers. e.g. SPS for H.264.
   1133 *
   1134 * Application must provide it to driver once this flag is returned through
   1135 * vaGetConfigAttributes()
   1136 */
   1137 #define VA_ENC_PACKED_HEADER_SEQUENCE   0x00000001
   1138 /**
   1139 * \brief Driver supports packed picture headers. e.g. PPS for H.264.
   1140 *
   1141 * Application must provide it to driver once this falg is returned through
   1142 * vaGetConfigAttributes()
   1143 */
   1144 #define VA_ENC_PACKED_HEADER_PICTURE    0x00000002
   1145 /**
   1146 * \brief Driver supports packed slice headers. e.g. slice_header() for H.264.
   1147 *
   1148 * Application must provide it to driver once this flag is returned through
   1149 * vaGetConfigAttributes()
   1150 */
   1151 #define VA_ENC_PACKED_HEADER_SLICE      0x00000004
   1152 /**
   1153 * \brief Driver supports misc packed headers. e.g. SEI for H.264.
   1154 *
   1155 * @deprecated
   1156 * This is a deprecated packed header flag, All applications can use
   1157 * \c VA_ENC_PACKED_HEADER_RAW_DATA to pass the corresponding packed
   1158 * header data buffer to the driver
   1159 */
   1160 #define VA_ENC_PACKED_HEADER_MISC       0x00000008
   1161 /** \brief Driver supports raw packed header, see VAEncPackedHeaderRawData */
   1162 #define VA_ENC_PACKED_HEADER_RAW_DATA   0x00000010
   1163 /**@}*/
   1164 
   1165 /** @name Attribute values for VAConfigAttribEncInterlaced */
   1166 /**@{*/
   1167 /** \brief Driver does not support interlaced coding. */
   1168 #define VA_ENC_INTERLACED_NONE          0x00000000
   1169 /** \brief Driver supports interlaced frame coding. */
   1170 #define VA_ENC_INTERLACED_FRAME         0x00000001
   1171 /** \brief Driver supports interlaced field coding. */
   1172 #define VA_ENC_INTERLACED_FIELD         0x00000002
   1173 /** \brief Driver supports macroblock adaptive frame field coding. */
   1174 #define VA_ENC_INTERLACED_MBAFF         0x00000004
   1175 /** \brief Driver supports picture adaptive frame field coding. */
   1176 #define VA_ENC_INTERLACED_PAFF          0x00000008
   1177 /**@}*/
   1178 
   1179 /** @name Attribute values for VAConfigAttribEncSliceStructure */
   1180 /**@{*/
   1181 /** \brief Driver supports a power-of-two number of rows per slice. */
   1182 #define VA_ENC_SLICE_STRUCTURE_POWER_OF_TWO_ROWS        0x00000001
   1183 /** \brief Driver supports an arbitrary number of macroblocks per slice. */
   1184 #define VA_ENC_SLICE_STRUCTURE_ARBITRARY_MACROBLOCKS    0x00000002
   1185 /** \brief Driver support 1 row per slice */
   1186 #define VA_ENC_SLICE_STRUCTURE_EQUAL_ROWS               0x00000004
   1187 /** \brief Driver support max encoded slice size per slice */
   1188 #define VA_ENC_SLICE_STRUCTURE_MAX_SLICE_SIZE           0x00000008
   1189 /** \brief Driver supports an arbitrary number of rows per slice. */
   1190 #define VA_ENC_SLICE_STRUCTURE_ARBITRARY_ROWS           0x00000010
   1191 /** \brief Driver supports any number of rows per slice but they must be the same
   1192 *       for all slices except for the last one, which must be equal or smaller
   1193 *       to the previous slices. */
   1194 #define VA_ENC_SLICE_STRUCTURE_EQUAL_MULTI_ROWS         0x00000020
   1195 /**@}*/
   1196 
   1197 /** \brief Attribute value for VAConfigAttribMaxFrameSize */
   1198 typedef union _VAConfigAttribValMaxFrameSize {
   1199    struct {
   1200        /** \brief support max frame size
   1201          * if max_frame_size == 1, VAEncMiscParameterTypeMaxFrameSize/VAEncMiscParameterBufferMaxFrameSize
   1202          * could be used to set the frame size, if multiple_pass also equal 1, VAEncMiscParameterTypeMultiPassFrameSize
   1203          * VAEncMiscParameterBufferMultiPassFrameSize could be used to set frame size and pass information
   1204          */
   1205        uint32_t max_frame_size : 1;
   1206        /** \brief multiple_pass support */
   1207        uint32_t multiple_pass  : 1;
   1208        /** \brief reserved bits for future, must be zero*/
   1209        uint32_t reserved       : 30;
   1210    } bits;
   1211    uint32_t value;
   1212 } VAConfigAttribValMaxFrameSize;
   1213 
   1214 /** \brief Attribute value for VAConfigAttribEncJPEG */
   1215 typedef union _VAConfigAttribValEncJPEG {
   1216    struct {
   1217        /** \brief set to 1 for arithmatic coding. */
   1218        uint32_t arithmatic_coding_mode : 1;
   1219        /** \brief set to 1 for progressive dct. */
   1220        uint32_t progressive_dct_mode : 1;
   1221        /** \brief set to 1 for non-interleaved. */
   1222        uint32_t non_interleaved_mode : 1;
   1223        /** \brief set to 1 for differential. */
   1224        uint32_t differential_mode : 1;
   1225        uint32_t max_num_components : 3;
   1226        uint32_t max_num_scans : 4;
   1227        uint32_t max_num_huffman_tables : 3;
   1228        uint32_t max_num_quantization_tables : 3;
   1229    } bits;
   1230    uint32_t value;
   1231 } VAConfigAttribValEncJPEG;
   1232 
   1233 /** @name Attribute values for VAConfigAttribEncQuantization */
   1234 /**@{*/
   1235 /** \brief Driver does not support special types of quantization */
   1236 #define VA_ENC_QUANTIZATION_NONE                        0x00000000
   1237 /** \brief Driver supports trellis quantization */
   1238 #define VA_ENC_QUANTIZATION_TRELLIS_SUPPORTED           0x00000001
   1239 /**@}*/
   1240 
   1241 /** @name Attribute values for VAConfigAttribPredictionDirection */
   1242 /**@{*/
   1243 /** \brief Driver support forward reference frame (inter frame for vpx, P frame for H26x MPEG)
   1244 * can work with the VAConfigAttribEncMaxRefFrames. for example: low delay B frame of HEVC.
   1245 * these value can be OR'd together. typical value should be VA_PREDICTION_DIRECTION_PREVIOUS
   1246 * or VA_PREDICTION_DIRECTION_PREVIOUS | VA_PREDICTION_DIRECTION_FUTURE, theoretically, there
   1247 * are no stream only include future reference frame.
   1248 */
   1249 #define VA_PREDICTION_DIRECTION_PREVIOUS                0x00000001
   1250 /** \brief Driver support backward prediction frame/slice */
   1251 #define VA_PREDICTION_DIRECTION_FUTURE                  0x00000002
   1252 /** \brief Dirver require both reference list must be not empty for inter frame */
   1253 #define VA_PREDICTION_DIRECTION_BI_NOT_EMPTY            0x00000004
   1254 /**@}*/
   1255 
   1256 /** @name Attribute values for VAConfigAttribEncIntraRefresh */
   1257 /**@{*/
   1258 /** \brief Driver does not support intra refresh */
   1259 #define VA_ENC_INTRA_REFRESH_NONE                       0x00000000
   1260 /** \brief Driver supports column based rolling intra refresh */
   1261 #define VA_ENC_INTRA_REFRESH_ROLLING_COLUMN             0x00000001
   1262 /** \brief Driver supports row based rolling intra refresh */
   1263 #define VA_ENC_INTRA_REFRESH_ROLLING_ROW                0x00000002
   1264 /** \brief Driver supports adaptive intra refresh */
   1265 #define VA_ENC_INTRA_REFRESH_ADAPTIVE                   0x00000010
   1266 /** \brief Driver supports cyclic intra refresh */
   1267 #define VA_ENC_INTRA_REFRESH_CYCLIC                     0x00000020
   1268 /** \brief Driver supports intra refresh of P frame*/
   1269 #define VA_ENC_INTRA_REFRESH_P_FRAME                    0x00010000
   1270 /** \brief Driver supports intra refresh of B frame */
   1271 #define VA_ENC_INTRA_REFRESH_B_FRAME                    0x00020000
   1272 /** \brief Driver supports intra refresh of multiple reference encoder */
   1273 #define VA_ENC_INTRA_REFRESH_MULTI_REF                  0x00040000
   1274 
   1275 /**@}*/
   1276 
   1277 /** \brief Attribute value for VAConfigAttribEncROI */
   1278 typedef union _VAConfigAttribValEncROI {
   1279    struct {
   1280        /** \brief The number of ROI regions supported, 0 if ROI is not supported. */
   1281        uint32_t num_roi_regions        : 8;
   1282        /**
   1283         * \brief A flag indicates whether ROI priority is supported
   1284         *
   1285         * \ref roi_rc_priority_support equal to 1 specifies the underlying driver supports
   1286         * ROI priority when VAConfigAttribRateControl != VA_RC_CQP, user can use \c roi_value
   1287         * in #VAEncROI to set ROI priority. \ref roi_rc_priority_support equal to 0 specifies
   1288         * the underlying driver doesn't support ROI priority.
   1289         *
   1290         * User should ignore \ref roi_rc_priority_support when VAConfigAttribRateControl == VA_RC_CQP
   1291         * because ROI delta QP is always required when VAConfigAttribRateControl == VA_RC_CQP.
   1292         */
   1293        uint32_t roi_rc_priority_support    : 1;
   1294        /**
   1295         * \brief A flag indicates whether ROI delta QP is supported
   1296         *
   1297         * \ref roi_rc_qp_delta_support equal to 1 specifies the underlying driver supports
   1298         * ROI delta QP when VAConfigAttribRateControl != VA_RC_CQP, user can use \c roi_value
   1299         * in #VAEncROI to set ROI delta QP. \ref roi_rc_qp_delta_support equal to 0 specifies
   1300         * the underlying driver doesn't support ROI delta QP.
   1301         *
   1302         * User should ignore \ref roi_rc_qp_delta_support when VAConfigAttribRateControl == VA_RC_CQP
   1303         * because ROI delta QP is always required when VAConfigAttribRateControl == VA_RC_CQP.
   1304         */
   1305        uint32_t roi_rc_qp_delta_support    : 1;
   1306        uint32_t reserved                   : 22;
   1307    } bits;
   1308    uint32_t value;
   1309 } VAConfigAttribValEncROI;
   1310 
   1311 /** \brief Attribute value for VAConfigAttribEncRateControlExt */
   1312 typedef union _VAConfigAttribValEncRateControlExt {
   1313    struct {
   1314        /**
   1315         * \brief The maximum number of temporal layers minus 1
   1316         *
   1317         * \ref max_num_temporal_layers_minus1 plus 1 specifies the maximum number of temporal
   1318         * layers that supported by the underlying driver. \ref max_num_temporal_layers_minus1
   1319         * equal to 0 implies the underlying driver doesn't support encoding with temporal layer.
   1320         */
   1321        uint32_t max_num_temporal_layers_minus1      : 8;
   1322 
   1323        /**
   1324         * /brief support temporal layer bit-rate control flag
   1325         *
   1326         * \ref temporal_layer_bitrate_control_flag equal to 1 specifies the underlying driver
   1327         * can support bit-rate control per temporal layer when (#VAConfigAttribRateControl == #VA_RC_CBR ||
   1328         * #VAConfigAttribRateControl == #VA_RC_VBR).
   1329         *
   1330         * The underlying driver must set \ref temporal_layer_bitrate_control_flag to 0 when
   1331         * \c max_num_temporal_layers_minus1 is equal to 0
   1332         *
   1333         * To use bit-rate control per temporal layer, an application must send the right layer
   1334         * structure via #VAEncMiscParameterTemporalLayerStructure at the beginning of a coded sequence
   1335         * and then followed by #VAEncMiscParameterRateControl and #VAEncMiscParameterFrameRate structures
   1336         * for each layer, using the \c temporal_id field as the layer identifier. Otherwise
   1337         * the driver doesn't use bitrate control per temporal layer if an application doesn't send the
   1338         * layer structure via #VAEncMiscParameterTemporalLayerStructure to the driver. The driver returns
   1339         * VA_STATUS_ERROR_INVALID_PARAMETER if an application sends a wrong layer structure or doesn't send
   1340         * #VAEncMiscParameterRateControl and #VAEncMiscParameterFrameRate for each layer.
   1341         *
   1342         * The driver will ignore #VAEncMiscParameterTemporalLayerStructure and the \c temporal_id field
   1343         * in #VAEncMiscParameterRateControl and #VAEncMiscParameterFrameRate if
   1344         * \ref temporal_layer_bitrate_control_flag is equal to 0 or #VAConfigAttribRateControl == #VA_RC_CQP
   1345         */
   1346        uint32_t temporal_layer_bitrate_control_flag : 1;
   1347        uint32_t reserved                            : 23;
   1348    } bits;
   1349    uint32_t value;
   1350 } VAConfigAttribValEncRateControlExt;
   1351 
   1352 /** \brief Attribute value for VAConfigAttribMultipleFrame*/
   1353 typedef union _VAConfigAttribValMultipleFrame {
   1354    struct {
   1355        /** \brief max num of concurrent frames from different stream */
   1356        uint32_t max_num_concurrent_frames      : 8;
   1357        /** \brief indicate whether all stream must support same quality level
   1358         *  if mixed_quality_level == 0, same quality level setting for multple streams is required
   1359         *  if mixed_quality_level == 1, different stream can have different quality level*/
   1360        uint32_t mixed_quality_level            : 1;
   1361        /** \brief reserved bit for future, must be zero */
   1362        uint32_t reserved                       : 23;
   1363    } bits;
   1364    uint32_t value;
   1365 } VAConfigAttribValMultipleFrame;
   1366 
   1367 /** brief Attribute value VAConfigAttribValContextPriority */
   1368 typedef union _VAConfigAttribValContextPriority {
   1369    struct {
   1370        /** \brief the priority , for the Query operation (read) it represents highest priority
   1371         * for the set operation (write), value should be [0~highest priority] , 0 is lowest priority*/
   1372        uint32_t priority     : 16;
   1373        /** \brief reserved bits for future, must be zero*/
   1374        uint32_t reserved     : 16;
   1375    } bits;
   1376    uint32_t value;
   1377 } VAConfigAttribValContextPriority;
   1378 
   1379 /** @name Attribute values for VAConfigAttribProtectedContentCipherAlgorithm */
   1380 /** \brief AES cipher */
   1381 #define VA_PC_CIPHER_AES                    0x00000001
   1382 
   1383 /** @name Attribute values for VAConfigAttribProtectedContentCipherBlockSize */
   1384 /** \brief 128 bits block size */
   1385 #define VA_PC_BLOCK_SIZE_128                0x00000001
   1386 /** \brief 192 bits block size */
   1387 #define VA_PC_BLOCK_SIZE_192                0x00000002
   1388 /** \brief 256 bits block size */
   1389 #define VA_PC_BLOCK_SIZE_256                0x00000004
   1390 
   1391 /** @name Attribute values for VAConfigAttribProtectedContentCipherMode */
   1392 /** \brief AES ECB */
   1393 #define VA_PC_CIPHER_MODE_ECB               0x00000001
   1394 /** \brief AES CBC */
   1395 #define VA_PC_CIPHER_MODE_CBC               0x00000002
   1396 /** \brief AES CTR */
   1397 #define VA_PC_CIPHER_MODE_CTR               0x00000004
   1398 
   1399 /** @name Attribute values for VAConfigAttribProtectedContentCipherSampleType */
   1400 /** \brief Full sample */
   1401 #define VA_PC_SAMPLE_TYPE_FULLSAMPLE        0x00000001
   1402 /** \brief Sub sample */
   1403 #define VA_PC_SAMPLE_TYPE_SUBSAMPLE         0x00000002
   1404 
   1405 /** @name Attribute values for VAConfigAttribProtectedContentUsage */
   1406 /** \brief Default usage */
   1407 #define VA_PC_USAGE_DEFAULT                 0x00000000
   1408 /** \brief Widevine */
   1409 #define VA_PC_USAGE_WIDEVINE                0x00000001
   1410 
   1411 /** @name Attribute values for VAConfigAttribProcessingRate. */
   1412 /**@{*/
   1413 /** \brief Driver does not support processing rate report */
   1414 #define VA_PROCESSING_RATE_NONE                       0x00000000
   1415 /** \brief Driver supports encode processing rate report  */
   1416 #define VA_PROCESSING_RATE_ENCODE                     0x00000001
   1417 /** \brief Driver supports decode processing rate report  */
   1418 #define VA_PROCESSING_RATE_DECODE                     0x00000002
   1419 /**@}*/
   1420 /**
   1421 * if an attribute is not applicable for a given
   1422 * profile/entrypoint pair, then set the value to the following
   1423 */
   1424 #define VA_ATTRIB_NOT_SUPPORTED 0x80000000
   1425 
   1426 /** Get maximum number of profiles supported by the implementation */
   1427 int vaMaxNumProfiles(
   1428    VADisplay dpy
   1429 );
   1430 
   1431 /** Get maximum number of entrypoints supported by the implementation */
   1432 int vaMaxNumEntrypoints(
   1433    VADisplay dpy
   1434 );
   1435 
   1436 /** Get maximum number of attributs supported by the implementation */
   1437 int vaMaxNumConfigAttributes(
   1438    VADisplay dpy
   1439 );
   1440 
   1441 /**
   1442 * Query supported profiles
   1443 * The caller must provide a "profile_list" array that can hold at
   1444 * least vaMaxNumProfile() entries. The actual number of profiles
   1445 * returned in "profile_list" is returned in "num_profile".
   1446 */
   1447 VAStatus vaQueryConfigProfiles(
   1448    VADisplay dpy,
   1449    VAProfile *profile_list,    /* out */
   1450    int *num_profiles       /* out */
   1451 );
   1452 
   1453 /**
   1454 * Query supported entrypoints for a given profile
   1455 * The caller must provide an "entrypoint_list" array that can hold at
   1456 * least vaMaxNumEntrypoints() entries. The actual number of entrypoints
   1457 * returned in "entrypoint_list" is returned in "num_entrypoints".
   1458 */
   1459 VAStatus vaQueryConfigEntrypoints(
   1460    VADisplay dpy,
   1461    VAProfile profile,
   1462    VAEntrypoint *entrypoint_list,  /* out */
   1463    int *num_entrypoints        /* out */
   1464 );
   1465 
   1466 /**
   1467 * Get attributes for a given profile/entrypoint pair
   1468 * The caller must provide an "attrib_list" with all attributes to be
   1469 * retrieved.  Upon return, the attributes in "attrib_list" have been
   1470 * updated with their value.  Unknown attributes or attributes that are
   1471 * not supported for the given profile/entrypoint pair will have their
   1472 * value set to VA_ATTRIB_NOT_SUPPORTED
   1473 */
   1474 VAStatus vaGetConfigAttributes(
   1475    VADisplay dpy,
   1476    VAProfile profile,
   1477    VAEntrypoint entrypoint,
   1478    VAConfigAttrib *attrib_list, /* in/out */
   1479    int num_attribs
   1480 );
   1481 
   1482 /** Generic ID type, can be re-typed for specific implementation */
   1483 typedef unsigned int VAGenericID;
   1484 
   1485 typedef VAGenericID VAConfigID;
   1486 
   1487 /**
   1488 * Create a configuration for the video decode/encode/processing pipeline
   1489 * it passes in the attribute list that specifies the attributes it cares
   1490 * about, with the rest taking default values.
   1491 */
   1492 VAStatus vaCreateConfig(
   1493    VADisplay dpy,
   1494    VAProfile profile,
   1495    VAEntrypoint entrypoint,
   1496    VAConfigAttrib *attrib_list,
   1497    int num_attribs,
   1498    VAConfigID *config_id /* out */
   1499 );
   1500 
   1501 /**
   1502 * Free resources associdated with a given config
   1503 */
   1504 VAStatus vaDestroyConfig(
   1505    VADisplay dpy,
   1506    VAConfigID config_id
   1507 );
   1508 
   1509 /**
   1510 * Query all attributes for a given configuration
   1511 * The profile of the configuration is returned in "profile"
   1512 * The entrypoint of the configuration is returned in "entrypoint"
   1513 * The caller must provide an "attrib_list" array that can hold at least
   1514 * vaMaxNumConfigAttributes() entries. The actual number of attributes
   1515 * returned in "attrib_list" is returned in "num_attribs"
   1516 */
   1517 VAStatus vaQueryConfigAttributes(
   1518    VADisplay dpy,
   1519    VAConfigID config_id,
   1520    VAProfile *profile,     /* out */
   1521    VAEntrypoint *entrypoint,   /* out */
   1522    VAConfigAttrib *attrib_list,/* out */
   1523    int *num_attribs        /* out */
   1524 );
   1525 
   1526 
   1527 /**
   1528 * Contexts and Surfaces
   1529 *
   1530 * Context represents a "virtual" video decode, encode or video processing
   1531 * pipeline. Surfaces are render targets for a given context. The data in the
   1532 * surfaces are not accessible to the client except if derived image is supported
   1533 * and the internal data format of the surface is implementation specific.
   1534 *
   1535 * Surfaces are provided as a hint of what surfaces will be used when the context
   1536 * is created through vaCreateContext(). A surface may be used by different contexts
   1537 * at the same time as soon as application can make sure the operations are synchronized
   1538 * between different contexts, e.g. a surface is used as the output of a decode context
   1539 * and the input of a video process context. Surfaces can only be destroyed after all
   1540 * contexts using these surfaces have been destroyed.
   1541 *
   1542 * Both contexts and surfaces are identified by unique IDs and its
   1543 * implementation specific internals are kept opaque to the clients
   1544 */
   1545 
   1546 typedef VAGenericID VAContextID;
   1547 
   1548 typedef VAGenericID VASurfaceID;
   1549 
   1550 #define VA_INVALID_ID       0xffffffff
   1551 #define VA_INVALID_SURFACE  VA_INVALID_ID
   1552 
   1553 /** \brief Generic value types. */
   1554 typedef enum  {
   1555    VAGenericValueTypeInteger = 1,      /**< 32-bit signed integer. */
   1556    VAGenericValueTypeFloat,            /**< 32-bit floating-point value. */
   1557    VAGenericValueTypePointer,          /**< Generic pointer type */
   1558    VAGenericValueTypeFunc              /**< Pointer to function */
   1559 } VAGenericValueType;
   1560 
   1561 /** \brief Generic function type. */
   1562 typedef void (*VAGenericFunc)(void);
   1563 
   1564 /** \brief Generic value. */
   1565 typedef struct _VAGenericValue {
   1566    /** \brief Value type. See #VAGenericValueType. */
   1567    VAGenericValueType  type;
   1568    /** \brief Value holder. */
   1569    union {
   1570        /** \brief 32-bit signed integer. */
   1571        int32_t             i;
   1572        /** \brief 32-bit float. */
   1573        float           f;
   1574        /** \brief Generic pointer. */
   1575        void           *p;
   1576        /** \brief Pointer to function. */
   1577        VAGenericFunc   fn;
   1578    }                   value;
   1579 } VAGenericValue;
   1580 
   1581 /** @name Surface attribute flags */
   1582 /**@{*/
   1583 /** \brief Surface attribute is not supported. */
   1584 #define VA_SURFACE_ATTRIB_NOT_SUPPORTED 0x00000000
   1585 /** \brief Surface attribute can be got through vaQuerySurfaceAttributes(). */
   1586 #define VA_SURFACE_ATTRIB_GETTABLE      0x00000001
   1587 /** \brief Surface attribute can be set through vaCreateSurfaces(). */
   1588 #define VA_SURFACE_ATTRIB_SETTABLE      0x00000002
   1589 /**@}*/
   1590 
   1591 /** \brief Surface attribute types. */
   1592 typedef enum {
   1593    VASurfaceAttribNone = 0,
   1594    /**
   1595     * \brief Pixel format as a FOURCC (int, read/write).
   1596     *
   1597     * When vaQuerySurfaceAttributes() is called, the driver will return one
   1598     * PixelFormat attribute per supported pixel format.
   1599     *
   1600     * When provided as an input to vaCreateSurfaces(), the driver will
   1601     * allocate a surface with the provided pixel format.
   1602     */
   1603    VASurfaceAttribPixelFormat,
   1604    /** \brief Minimal width in pixels (int, read-only). */
   1605    VASurfaceAttribMinWidth,
   1606    /** \brief Maximal width in pixels (int, read-only). */
   1607    VASurfaceAttribMaxWidth,
   1608    /** \brief Minimal height in pixels (int, read-only). */
   1609    VASurfaceAttribMinHeight,
   1610    /** \brief Maximal height in pixels (int, read-only). */
   1611    VASurfaceAttribMaxHeight,
   1612    /** \brief Surface memory type expressed in bit fields (int, read/write). */
   1613    VASurfaceAttribMemoryType,
   1614    /** \brief External buffer descriptor (pointer, write).
   1615     *
   1616     * Refer to the documentation for the memory type being created to
   1617     * determine what descriptor structure to pass here.  If not otherwise
   1618     * stated, the common VASurfaceAttribExternalBuffers should be used.
   1619     */
   1620    VASurfaceAttribExternalBufferDescriptor,
   1621    /** \brief Surface usage hint, gives the driver a hint of intended usage
   1622     *  to optimize allocation (e.g. tiling) (int, read/write). */
   1623    VASurfaceAttribUsageHint,
   1624    /** \brief List of possible DRM format modifiers (pointer, write).
   1625     *
   1626     * The value must be a pointer to a VADRMFormatModifierList. This can only
   1627     * be used when allocating a new buffer, it's invalid to use this attribute
   1628     * when importing an existing buffer.
   1629     */
   1630    VASurfaceAttribDRMFormatModifiers,
   1631    /** \brief Number of surface attributes. */
   1632    VASurfaceAttribCount
   1633 } VASurfaceAttribType;
   1634 
   1635 /** \brief Surface attribute. */
   1636 typedef struct _VASurfaceAttrib {
   1637    /** \brief Type. */
   1638    VASurfaceAttribType type;
   1639    /** \brief Flags. See "Surface attribute flags". */
   1640    uint32_t        flags;
   1641    /** \brief Value. See "Surface attribute types" for the expected types. */
   1642    VAGenericValue      value;
   1643 } VASurfaceAttrib;
   1644 
   1645 /**
   1646 * @name VASurfaceAttribMemoryType values in bit fields.
   1647 * Bit 0:7 are reserved for generic types, Bit 31:28 are reserved for
   1648 * Linux DRM, Bit 23:20 are reserved for Android. DRM and Android specific
   1649 * types are defined in DRM and Android header files.
   1650 */
   1651 /**@{*/
   1652 /** \brief VA memory type (default) is supported. */
   1653 #define VA_SURFACE_ATTRIB_MEM_TYPE_VA           0x00000001
   1654 /** \brief V4L2 buffer memory type is supported. */
   1655 #define VA_SURFACE_ATTRIB_MEM_TYPE_V4L2         0x00000002
   1656 /** \brief User pointer memory type is supported. */
   1657 #define VA_SURFACE_ATTRIB_MEM_TYPE_USER_PTR     0x00000004
   1658 /**@}*/
   1659 
   1660 /**
   1661 * \brief VASurfaceAttribExternalBuffers structure for
   1662 * the VASurfaceAttribExternalBufferDescriptor attribute.
   1663 */
   1664 typedef struct _VASurfaceAttribExternalBuffers {
   1665    /** \brief pixel format in fourcc. */
   1666    uint32_t pixel_format;
   1667    /** \brief width in pixels. */
   1668    uint32_t width;
   1669    /** \brief height in pixels. */
   1670    uint32_t height;
   1671    /** \brief total size of the buffer in bytes. */
   1672    uint32_t data_size;
   1673    /** \brief number of planes for planar layout */
   1674    uint32_t num_planes;
   1675    /** \brief pitch for each plane in bytes */
   1676    uint32_t pitches[4];
   1677    /** \brief offset for each plane in bytes */
   1678    uint32_t offsets[4];
   1679    /** \brief buffer handles or user pointers */
   1680    uintptr_t *buffers;
   1681    /** \brief number of elements in the "buffers" array */
   1682    uint32_t num_buffers;
   1683    /** \brief flags. See "Surface external buffer descriptor flags". */
   1684    uint32_t flags;
   1685    /** \brief reserved for passing private data */
   1686    void *private_data;
   1687 } VASurfaceAttribExternalBuffers;
   1688 
   1689 /** @name VASurfaceAttribExternalBuffers flags */
   1690 /**@{*/
   1691 /** \brief Enable memory tiling */
   1692 #define VA_SURFACE_EXTBUF_DESC_ENABLE_TILING    0x00000001
   1693 /** \brief Memory is cacheable */
   1694 #define VA_SURFACE_EXTBUF_DESC_CACHED       0x00000002
   1695 /** \brief Memory is non-cacheable */
   1696 #define VA_SURFACE_EXTBUF_DESC_UNCACHED     0x00000004
   1697 /** \brief Memory is write-combined */
   1698 #define VA_SURFACE_EXTBUF_DESC_WC       0x00000008
   1699 /** \brief Memory is protected */
   1700 #define VA_SURFACE_EXTBUF_DESC_PROTECTED        0x80000000
   1701 
   1702 /** @name VASurfaceAttribUsageHint attribute usage hint flags */
   1703 /**@{*/
   1704 /** \brief Surface usage not indicated. */
   1705 #define VA_SURFACE_ATTRIB_USAGE_HINT_GENERIC    0x00000000
   1706 /** \brief Surface used by video decoder. */
   1707 #define VA_SURFACE_ATTRIB_USAGE_HINT_DECODER    0x00000001
   1708 /** \brief Surface used by video encoder. */
   1709 #define VA_SURFACE_ATTRIB_USAGE_HINT_ENCODER    0x00000002
   1710 /** \brief Surface read by video post-processing. */
   1711 #define VA_SURFACE_ATTRIB_USAGE_HINT_VPP_READ   0x00000004
   1712 /** \brief Surface written by video post-processing. */
   1713 #define VA_SURFACE_ATTRIB_USAGE_HINT_VPP_WRITE  0x00000008
   1714 /** \brief Surface used for display. */
   1715 #define VA_SURFACE_ATTRIB_USAGE_HINT_DISPLAY    0x00000010
   1716 /** \brief Surface used for export to third-party APIs, e.g. via
   1717 *  vaExportSurfaceHandle(). */
   1718 #define VA_SURFACE_ATTRIB_USAGE_HINT_EXPORT     0x00000020
   1719 
   1720 /**@}*/
   1721 
   1722 /**
   1723 * \brief Queries surface attributes for the supplied config.
   1724 *
   1725 * This function queries for all supported attributes for the
   1726 * supplied VA @config. In particular, if the underlying hardware
   1727 * supports the creation of VA surfaces in various formats, then
   1728 * this function will enumerate all pixel formats that are supported.
   1729 *
   1730 * The \c attrib_list array is allocated by the user and \c
   1731 * num_attribs shall be initialized to the number of allocated
   1732 * elements in that array. Upon successful return, the actual number
   1733 * of attributes will be overwritten into \c num_attribs. Otherwise,
   1734 * \c VA_STATUS_ERROR_MAX_NUM_EXCEEDED is returned and \c num_attribs
   1735 * is adjusted to the number of elements that would be returned if
   1736 * enough space was available.
   1737 *
   1738 * Note: it is perfectly valid to pass NULL to the \c attrib_list
   1739 * argument when vaQuerySurfaceAttributes() is used to determine the
   1740 * actual number of elements that need to be allocated.
   1741 *
   1742 * @param[in] dpy               the VA display
   1743 * @param[in] config            the config identifying a codec or a video
   1744 *     processing pipeline
   1745 * @param[out] attrib_list      the output array of #VASurfaceAttrib elements
   1746 * @param[in,out] num_attribs   the number of elements allocated on
   1747 *      input, the number of elements actually filled in output
   1748 */
   1749 VAStatus
   1750 vaQuerySurfaceAttributes(
   1751    VADisplay           dpy,
   1752    VAConfigID          config,
   1753    VASurfaceAttrib    *attrib_list,
   1754    unsigned int       *num_attribs
   1755 );
   1756 
   1757 /**
   1758 * \brief Creates an array of surfaces
   1759 *
   1760 * Creates an array of surfaces. The optional list of attributes shall
   1761 * be constructed based on what the underlying hardware could expose
   1762 * through vaQuerySurfaceAttributes().
   1763 *
   1764 * @param[in] dpy               the VA display
   1765 * @param[in] format            the desired surface format. See \c VA_RT_FORMAT_*
   1766 * @param[in] width             the surface width
   1767 * @param[in] height            the surface height
   1768 * @param[out] surfaces         the array of newly created surfaces
   1769 * @param[in] num_surfaces      the number of surfaces to create
   1770 * @param[in] attrib_list       the list of (optional) attributes, or \c NULL
   1771 * @param[in] num_attribs       the number of attributes supplied in
   1772 *     \c attrib_list, or zero
   1773 */
   1774 VAStatus
   1775 vaCreateSurfaces(
   1776    VADisplay           dpy,
   1777    unsigned int        format,
   1778    unsigned int        width,
   1779    unsigned int        height,
   1780    VASurfaceID        *surfaces,
   1781    unsigned int        num_surfaces,
   1782    VASurfaceAttrib    *attrib_list,
   1783    unsigned int        num_attribs
   1784 );
   1785 
   1786 /**
   1787 * vaDestroySurfaces - Destroy resources associated with surfaces.
   1788 *  Surfaces can only be destroyed after all contexts using these surfaces have been
   1789 *  destroyed.
   1790 *  dpy: display
   1791 *  surfaces: array of surfaces to destroy
   1792 *  num_surfaces: number of surfaces in the array to be destroyed.
   1793 */
   1794 VAStatus vaDestroySurfaces(
   1795    VADisplay dpy,
   1796    VASurfaceID *surfaces,
   1797    int num_surfaces
   1798 );
   1799 
   1800 #define VA_PROGRESSIVE 0x1
   1801 /**
   1802 * vaCreateContext - Create a context
   1803 *  dpy: display
   1804 *  config_id: configuration for the context
   1805 *  picture_width: coded picture width
   1806 *  picture_height: coded picture height
   1807 *  flag: any combination of the following:
   1808 *    VA_PROGRESSIVE (only progressive frame pictures in the sequence when set)
   1809 *  render_targets: a hint for render targets (surfaces) tied to the context
   1810 *  num_render_targets: number of render targets in the above array
   1811 *  context: created context id upon return
   1812 */
   1813 VAStatus vaCreateContext(
   1814    VADisplay dpy,
   1815    VAConfigID config_id,
   1816    int picture_width,
   1817    int picture_height,
   1818    int flag,
   1819    VASurfaceID *render_targets,
   1820    int num_render_targets,
   1821    VAContextID *context        /* out */
   1822 );
   1823 
   1824 /**
   1825 * vaDestroyContext - Destroy a context
   1826 *  dpy: display
   1827 *  context: context to be destroyed
   1828 */
   1829 VAStatus vaDestroyContext(
   1830    VADisplay dpy,
   1831    VAContextID context
   1832 );
   1833 
   1834 //Multi-frame context
   1835 typedef VAGenericID VAMFContextID;
   1836 /**
   1837 * vaCreateMFContext - Create a multi-frame context
   1838 *  interface encapsulating common for all streams memory objects and structures
   1839 *  required for single GPU task submission from several VAContextID's.
   1840 *  Allocation: This call only creates an instance, doesn't allocate any additional memory.
   1841 *  Support identification: Application can identify multi-frame feature support by ability
   1842 *  to create multi-frame context. If driver supports multi-frame - call successful,
   1843 *  mf_context != NULL and VAStatus = VA_STATUS_SUCCESS, otherwise if multi-frame processing
   1844 *  not supported driver returns VA_STATUS_ERROR_UNIMPLEMENTED and mf_context = NULL.
   1845 *  return values:
   1846 *  VA_STATUS_SUCCESS - operation successful.
   1847 *  VA_STATUS_ERROR_UNIMPLEMENTED - no support for multi-frame.
   1848 *  dpy: display adapter.
   1849 *  mf_context: Multi-Frame context encapsulating all associated context
   1850 *  for multi-frame submission.
   1851 */
   1852 VAStatus vaCreateMFContext(
   1853    VADisplay dpy,
   1854    VAMFContextID *mf_context    /* out */
   1855 );
   1856 
   1857 /**
   1858 * vaMFAddContext - Provide ability to associate each context used for
   1859 *  Multi-Frame submission and common Multi-Frame context.
   1860 *  Try to add context to understand if it is supported.
   1861 *  Allocation: this call allocates and/or reallocates all memory objects
   1862 *  common for all contexts associated with particular Multi-Frame context.
   1863 *  All memory required for each context(pixel buffers, internal driver
   1864 *  buffers required for processing) allocated during standard vaCreateContext call for each context.
   1865 *  Runtime dependency - if current implementation doesn't allow to run different entry points/profile,
   1866 *  first context added will set entry point/profile for whole Multi-Frame context,
   1867 *  all other entry points and profiles can be rejected to be added.
   1868 *  Return values:
   1869 *  VA_STATUS_SUCCESS - operation successful, context was added.
   1870 *  VA_STATUS_ERROR_OPERATION_FAILED - something unexpected happened - application have to close
   1871 *  current mf_context and associated contexts and start working with new ones.
   1872 *  VA_STATUS_ERROR_INVALID_CONTEXT - ContextID is invalid, means:
   1873 *  1 - mf_context is not valid context or
   1874 *  2 - driver can't suport different VAEntrypoint or VAProfile simultaneosly
   1875 *  and current context contradicts with previously added, application can continue with current mf_context
   1876 *  and other contexts passed this call, rejected context can continue work in stand-alone
   1877 *  mode or other mf_context.
   1878 *  VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT - particular context being added was created with with
   1879 *  unsupported VAEntrypoint. Application can continue with current mf_context
   1880 *  and other contexts passed this call, rejected context can continue work in stand-alone
   1881 *  mode.
   1882 *  VA_STATUS_ERROR_UNSUPPORTED_PROFILE - Current context with Particular VAEntrypoint is supported
   1883 *  but VAProfile is not supported. Application can continue with current mf_context
   1884 *  and other contexts passed this call, rejected context can continue work in stand-alone
   1885 *  mode.
   1886 *  dpy: display adapter.
   1887 *  context: context being associated with Multi-Frame context.
   1888 *  mf_context: - multi-frame context used to associate contexts for multi-frame submission.
   1889 */
   1890 VAStatus vaMFAddContext(
   1891    VADisplay dpy,
   1892    VAMFContextID mf_context,
   1893    VAContextID context
   1894 );
   1895 
   1896 /**
   1897 * vaMFReleaseContext - Removes context from multi-frame and
   1898 *  association with multi-frame context.
   1899 *  After association removed vaEndPicture will submit tasks, but not vaMFSubmit.
   1900 *  Return values:
   1901 *  VA_STATUS_SUCCESS - operation successful, context was removed.
   1902 *  VA_STATUS_ERROR_OPERATION_FAILED - something unexpected happened.
   1903 *  application need to destroy this VAMFContextID and all assotiated VAContextID
   1904 *  dpy: display
   1905 *  mf_context: VAMFContextID where context is added
   1906 *  context: VAContextID to be added
   1907 */
   1908 VAStatus vaMFReleaseContext(
   1909    VADisplay dpy,
   1910    VAMFContextID mf_context,
   1911    VAContextID context
   1912 );
   1913 
   1914 /**
   1915 * Buffers
   1916 * Buffers are used to pass various types of data from the
   1917 * client to the server. The server maintains a data store
   1918 * for each buffer created, and the client idenfies a buffer
   1919 * through a unique buffer id assigned by the server.
   1920 */
   1921 
   1922 typedef VAGenericID VABufferID;
   1923 
   1924 typedef enum {
   1925    VAPictureParameterBufferType    = 0,
   1926    VAIQMatrixBufferType        = 1,
   1927    VABitPlaneBufferType        = 2,
   1928    VASliceGroupMapBufferType       = 3,
   1929    VASliceParameterBufferType      = 4,
   1930    VASliceDataBufferType       = 5,
   1931    VAMacroblockParameterBufferType = 6,
   1932    VAResidualDataBufferType        = 7,
   1933    VADeblockingParameterBufferType = 8,
   1934    VAImageBufferType           = 9,
   1935    VAProtectedSliceDataBufferType  = 10,
   1936    VAQMatrixBufferType                 = 11,
   1937    VAHuffmanTableBufferType            = 12,
   1938    VAProbabilityBufferType             = 13,
   1939 
   1940    /* Following are encode buffer types */
   1941    VAEncCodedBufferType        = 21,
   1942    VAEncSequenceParameterBufferType    = 22,
   1943    VAEncPictureParameterBufferType = 23,
   1944    VAEncSliceParameterBufferType   = 24,
   1945    VAEncPackedHeaderParameterBufferType = 25,
   1946    VAEncPackedHeaderDataBufferType     = 26,
   1947    VAEncMiscParameterBufferType    = 27,
   1948    VAEncMacroblockParameterBufferType  = 28,
   1949    VAEncMacroblockMapBufferType        = 29,
   1950 
   1951    /**
   1952     * \brief Encoding QP buffer
   1953     *
   1954     * This buffer contains QP per MB for encoding. Currently
   1955     * VAEncQPBufferH264 is defined for H.264 encoding, see
   1956     * #VAEncQPBufferH264 for details
   1957     */
   1958    VAEncQPBufferType                   = 30,
   1959    /* Following are video processing buffer types */
   1960    /**
   1961     * \brief Video processing pipeline parameter buffer.
   1962     *
   1963     * This buffer describes the video processing pipeline. See
   1964     * #VAProcPipelineParameterBuffer for details.
   1965     */
   1966    VAProcPipelineParameterBufferType   = 41,
   1967    /**
   1968     * \brief Video filter parameter buffer.
   1969     *
   1970     * This buffer describes the video filter parameters. All buffers
   1971     * inherit from #VAProcFilterParameterBufferBase, thus including
   1972     * a unique filter buffer type.
   1973     *
   1974     * The default buffer used by most filters is #VAProcFilterParameterBuffer.
   1975     * Filters requiring advanced parameters include, but are not limited to,
   1976     * deinterlacing (#VAProcFilterParameterBufferDeinterlacing),
   1977     * color balance (#VAProcFilterParameterBufferColorBalance), etc.
   1978     */
   1979    VAProcFilterParameterBufferType     = 42,
   1980    /**
   1981     * \brief FEI specific buffer types
   1982     */
   1983    VAEncFEIMVBufferType                = 43,
   1984    VAEncFEIMBCodeBufferType            = 44,
   1985    VAEncFEIDistortionBufferType        = 45,
   1986    VAEncFEIMBControlBufferType         = 46,
   1987    VAEncFEIMVPredictorBufferType       = 47,
   1988    VAStatsStatisticsParameterBufferType = 48,
   1989    /** \brief Statistics output for VAEntrypointStats progressive and top field of interlaced case*/
   1990    VAStatsStatisticsBufferType         = 49,
   1991    /** \brief Statistics output for VAEntrypointStats bottom field of interlaced case*/
   1992    VAStatsStatisticsBottomFieldBufferType = 50,
   1993    VAStatsMVBufferType                 = 51,
   1994    VAStatsMVPredictorBufferType        = 52,
   1995    /** Force MB's to be non skip for encode.it's per-mb control buffer, The width of the MB map
   1996     * Surface is (width of the Picture in MB unit) * 1 byte, multiple of 64 bytes.
   1997     * The height is (height of the picture in MB unit). The picture is either
   1998     * frame or non-interleaved top or bottom field.  If the application provides this
   1999     *surface, it will override the "skipCheckDisable" setting in VAEncMiscParameterEncQuality.
   2000     */
   2001    VAEncMacroblockDisableSkipMapBufferType = 53,
   2002    /**
   2003     * \brief HEVC FEI CTB level cmd buffer
   2004     * it is CTB level information for future usage.
   2005     */
   2006    VAEncFEICTBCmdBufferType            = 54,
   2007    /**
   2008     * \brief HEVC FEI CU level data buffer
   2009     * it's CTB level information for future usage
   2010     */
   2011    VAEncFEICURecordBufferType          = 55,
   2012    /** decode stream out buffer, intermedia data of decode, it may include MV, MB mode etc.
   2013      * it can be used to detect motion and analyze the frame contain  */
   2014    VADecodeStreamoutBufferType             = 56,
   2015 
   2016    /** \brief HEVC Decoding Subset Parameter buffer type
   2017     *
   2018     * The subsets parameter buffer is concatenation with one or multiple
   2019     * subset entry point offsets. All the offset values are layed out one
   2020     * by one according to slice order with first slice segment first, second
   2021     * slice segment second, etc... The entry number is indicated by parameter
   2022     * \ref num_entry_point_offsets. And the first entry position of the entry
   2023     * point offsets for any slice segment is indicated by parameter
   2024     * entry_offset_to_subset_array in VAPictureParameterBufferHEVC data structure.
   2025     */
   2026    VASubsetsParameterBufferType        = 57,
   2027    /** \brief adjust context parameters dynamically
   2028     *
   2029     * this parameter is used to update context parameters, detail parameter is in
   2030     *  \c VAContextParameterUpdateBuffer
   2031     */
   2032    VAContextParameterUpdateBufferType  = 58,
   2033    /**
   2034     * \brief Protected session execution buffer type
   2035     *
   2036     * It's for TEE execution usage (vaProtectedSessionExecute()). The buffer structure is in
   2037     * \c VAProtectedSessionExecuteBuffer
   2038     */
   2039    VAProtectedSessionExecuteBufferType = 59,
   2040 
   2041    /** \brief Encryption parameters buffer for protected content session.
   2042     *
   2043     * Refer to \c VAEncryptionParameters
   2044    */
   2045    VAEncryptionParameterBufferType = 60,
   2046 
   2047    VABufferTypeMax
   2048 } VABufferType;
   2049 
   2050 /** \brief update the context parameter
   2051 * this structure is used to update context parameters, such as priority of the context
   2052 * backend driver should keep the parameter unchanged if there no new
   2053 * parameter updated.
   2054 */
   2055 typedef struct _VAContextParameterUpdateBuffer {
   2056    union {
   2057        struct {
   2058            /** \brief indicate whether context priority changed */
   2059            uint32_t context_priority_update : 1;
   2060            /** \brief Reserved bits for future use, must be zero */
   2061            uint32_t reserved                : 31;
   2062        } bits;
   2063        uint32_t value;
   2064    } flags;
   2065    /** \brief task/context priority */
   2066    VAConfigAttribValContextPriority context_priority;
   2067    /** \brief Reserved bytes for future use, must be zero */
   2068    uint32_t reserved[VA_PADDING_MEDIUM];
   2069 } VAContextParameterUpdateBuffer;
   2070 
   2071 /**
   2072 * These ENCRYPTION_TYPEs are used for the attribute values for
   2073 * \c VAConfigAttribEncryption and for encryption_type in
   2074 * VAEncryptionParameters.
   2075 *
   2076 * When used for \c VAConfigAttribEncryption, it be used via
   2077 * vaQueryConfigEntrypoints to check which type are supported for specific
   2078 * profile or not.
   2079 *
   2080 * When used for encryption_type in VAEncryptionParameters, it tells driver
   2081 * the parameters in VAEncryptionParameters are used for which encryption type.
   2082 */
   2083 #define VA_ENCRYPTION_TYPE_FULLSAMPLE_CTR       0x00000001  /* AES CTR fullsample */
   2084 #define VA_ENCRYPTION_TYPE_FULLSAMPLE_CBC       0x00000002  /* AES CBC fullsample */
   2085 #define VA_ENCRYPTION_TYPE_SUBSAMPLE_CTR        0x00000004  /* AES CTR fullsample */
   2086 #define VA_ENCRYPTION_TYPE_SUBSAMPLE_CBC        0x00000008  /* AES CBC fullsample */
   2087 
   2088 /** \brief structure for encrypted segment info. */
   2089 typedef struct _VAEncryptionSegmentInfo {
   2090    /** \brief  The offset relative to the start of the bitstream input in
   2091     *  bytes of the start of the segment */
   2092    uint32_t segment_start_offset;
   2093    /** \brief  The length of the segments in bytes */
   2094    uint32_t segment_length;
   2095    /** \brief  The length in bytes of the remainder of an incomplete block
   2096     *  from a previous segment*/
   2097    uint32_t partial_aes_block_size;
   2098    /** \brief  The length in bytes of the initial clear data */
   2099    uint32_t init_byte_length;
   2100    /** \brief  This will be AES counter for secure decode and secure encode
   2101     *  when numSegments equals 1, valid size is specified by
   2102     * \c key_blob_size */
   2103    uint8_t aes_cbc_iv_or_ctr[64];
   2104    /** \brief Reserved bytes for future use, must be zero */
   2105    uint32_t va_reserved[VA_PADDING_MEDIUM];
   2106 } VAEncryptionSegmentInfo;
   2107 
   2108 /** \brief Encryption parameters buffer for VAEncryptionParameterBufferType */
   2109 typedef struct _VAEncryptionParameters {
   2110    /** \brief Encryption type, refer to \c VA_ENCRYPTION_TYPE_FULLSAMPLE_CTR,
   2111     * \c VA_ENCRYPTION_TYPE_FULLSAMPLE_CBC, \c VA_ENCRYPTION_TYPE_SUBSAMPLE_CTR,
   2112     * or \c VA_ENCRYPTION_TYPE_SUBSAMPLE_CBC */
   2113    uint32_t encryption_type;
   2114    /** \brief The number of sengments */
   2115    uint32_t num_segments;
   2116    /** \brief Pointer of segments */
   2117    VAEncryptionSegmentInfo *segment_info;
   2118    /** \brief The status report index reserved for CENC fullsample workload.
   2119     * The related structures and definitions are vendor specific.
   2120    */
   2121    uint32_t status_report_index;
   2122    /** \brief CENC counter length */
   2123    uint32_t size_of_length;
   2124    /** \brief Wrapped decrypt blob (Snd)kb, valid size is specified by
   2125     * \c key_blob_size */
   2126    uint8_t wrapped_decrypt_blob[64];
   2127    /** \brief Wrapped Key blob info (Sne)kb, valid size is specified by
   2128     * \c key_blob_size */
   2129    uint8_t wrapped_encrypt_blob[64];
   2130    /** \brief key blob size
   2131     * It could be \c VA_PC_BLOCK_SIZE_128, \c VA_PC_BLOCK_SIZE_192, or
   2132     * \c VA_PC_BLOCK_SIZE_256
   2133     */
   2134    uint32_t key_blob_size;
   2135    /** \brief Indicates the number of 16-byte BLOCKS that are encrypted in any
   2136     *  given encrypted region of segments.
   2137     *  If this value is zero:
   2138     *    1. All bytes in encrypted region of segments are encrypted, i.e. the
   2139     *       CENC or CBC1 scheme is being used
   2140     *    2. blocks_stripe_clear must also be zero.
   2141     *  If this value is non-zero, blocks_stripe_clear must also be non-zero.
   2142     */
   2143    uint32_t blocks_stripe_encrypted;
   2144    /** \brief Indicates the number of 16-byte BLOCKS that are clear in any given
   2145     *  encrypted region of segments, as defined by the CENS and CBCS schemes in
   2146     *  the common encryption spec.
   2147     *  If this value is zero, all bytes in encrypted region of segments are
   2148     *  encrypted, i.e. the CENC or CBC1 scheme is being used.
   2149     */
   2150    uint32_t blocks_stripe_clear;
   2151    /** \brief Reserved bytes for future use, must be zero */
   2152    uint32_t va_reserved[VA_PADDING_MEDIUM];
   2153 } VAEncryptionParameters;
   2154 
   2155 /**
   2156 * Processing rate parameter for encode.
   2157 */
   2158 typedef struct _VAProcessingRateParameterEnc {
   2159    /** \brief Profile level */
   2160    uint8_t         level_idc;
   2161    uint8_t         reserved[3];
   2162    /** \brief quality level. When set to 0, default quality
   2163     * level is used.
   2164     */
   2165    uint32_t        quality_level;
   2166    /** \brief Period between I frames. */
   2167    uint32_t        intra_period;
   2168    /** \brief Period between I/P frames. */
   2169    uint32_t        ip_period;
   2170 } VAProcessingRateParameterEnc;
   2171 
   2172 /**
   2173 * Processing rate parameter for decode.
   2174 */
   2175 typedef struct _VAProcessingRateParameterDec {
   2176    /** \brief Profile level */
   2177    uint8_t         level_idc;
   2178    uint8_t         reserved0[3];
   2179    uint32_t        reserved;
   2180 } VAProcessingRateParameterDec;
   2181 
   2182 typedef struct _VAProcessingRateParameter {
   2183    union {
   2184        VAProcessingRateParameterEnc proc_buf_enc;
   2185        VAProcessingRateParameterDec proc_buf_dec;
   2186    };
   2187 } VAProcessingRateParameter;
   2188 
   2189 /**
   2190 * \brief Queries processing rate for the supplied config.
   2191 *
   2192 * This function queries the processing rate based on parameters in
   2193 * \c proc_buf for the given \c config. Upon successful return, the processing
   2194 * rate value will be stored in \c processing_rate. Processing rate is
   2195 * specified as the number of macroblocks/CTU per second.
   2196 *
   2197 * If NULL is passed to the \c proc_buf, the default processing rate for the
   2198 * given configuration will be returned.
   2199 *
   2200 * @param[in] dpy               the VA display
   2201 * @param[in] config            the config identifying a codec or a video
   2202 *     processing pipeline
   2203 * @param[in] proc_buf       the buffer that contains the parameters for
   2204        either the encode or decode processing rate
   2205 * @param[out] processing_rate  processing rate in number of macroblocks per
   2206        second constrained by parameters specified in proc_buf
   2207 *
   2208 */
   2209 VAStatus
   2210 vaQueryProcessingRate(
   2211    VADisplay           dpy,
   2212    VAConfigID          config,
   2213    VAProcessingRateParameter *proc_buf,
   2214    unsigned int       *processing_rate
   2215 );
   2216 
   2217 typedef enum {
   2218    VAEncMiscParameterTypeFrameRate     = 0,
   2219    VAEncMiscParameterTypeRateControl   = 1,
   2220    VAEncMiscParameterTypeMaxSliceSize  = 2,
   2221    VAEncMiscParameterTypeAIR       = 3,
   2222    /** \brief Buffer type used to express a maximum frame size (in bits). */
   2223    VAEncMiscParameterTypeMaxFrameSize  = 4,
   2224    /** \brief Buffer type used for HRD parameters. */
   2225    VAEncMiscParameterTypeHRD           = 5,
   2226    VAEncMiscParameterTypeQualityLevel  = 6,
   2227    /** \brief Buffer type used for Rolling intra refresh */
   2228    VAEncMiscParameterTypeRIR           = 7,
   2229    /** \brief Buffer type used for quantization parameters, it's per-sequence parameter*/
   2230    VAEncMiscParameterTypeQuantization  = 8,
   2231    /** \brief Buffer type used for sending skip frame parameters to the encoder's
   2232      * rate control, when the user has externally skipped frames. */
   2233    VAEncMiscParameterTypeSkipFrame     = 9,
   2234    /** \brief Buffer type used for region-of-interest (ROI) parameters. */
   2235    VAEncMiscParameterTypeROI           = 10,
   2236    /** \brief Buffer type used to express a maximum frame size (in bytes) settings for multiple pass. */
   2237    VAEncMiscParameterTypeMultiPassFrameSize       = 11,
   2238    /** \brief Buffer type used for temporal layer structure */
   2239    VAEncMiscParameterTypeTemporalLayerStructure   = 12,
   2240    /** \brief Buffer type used for dirty region-of-interest (ROI) parameters. */
   2241    VAEncMiscParameterTypeDirtyRect      = 13,
   2242    /** \brief Buffer type used for parallel BRC parameters. */
   2243    VAEncMiscParameterTypeParallelBRC   = 14,
   2244    /** \brief Set MB partion mode mask and Half-pel/Quant-pel motion search */
   2245    VAEncMiscParameterTypeSubMbPartPel = 15,
   2246    /** \brief set encode quality tuning */
   2247    VAEncMiscParameterTypeEncQuality = 16,
   2248    /** \brief Buffer type used for encoder rounding offset parameters. */
   2249    VAEncMiscParameterTypeCustomRoundingControl = 17,
   2250    /** \brief Buffer type used for FEI input frame level parameters */
   2251    VAEncMiscParameterTypeFEIFrameControl = 18,
   2252    /** \brief encode extension buffer, ect. MPEG2 Sequence extenstion data */
   2253    VAEncMiscParameterTypeExtensionData = 19
   2254 } VAEncMiscParameterType;
   2255 
   2256 /** \brief Packed header type. */
   2257 typedef enum {
   2258    /** \brief Packed sequence header. */
   2259    VAEncPackedHeaderSequence   = 1,
   2260    /** \brief Packed picture header. */
   2261    VAEncPackedHeaderPicture    = 2,
   2262    /** \brief Packed slice header. */
   2263    VAEncPackedHeaderSlice      = 3,
   2264    /**
   2265     * \brief Packed raw header.
   2266     *
   2267     * Packed raw data header can be used by the client to insert a header
   2268     * into the bitstream data buffer at the point it is passed, the driver
   2269     * will handle the raw packed header based on "has_emulation_bytes" field
   2270     * in the packed header parameter structure.
   2271     */
   2272    VAEncPackedHeaderRawData    = 4,
   2273    /**
   2274     * \brief Misc packed header. See codec-specific definitions.
   2275     *
   2276     * @deprecated
   2277     * This is a deprecated packed header type. All applications can use
   2278     * \c VAEncPackedHeaderRawData to insert a codec-specific packed header
   2279     */
   2280    VAEncPackedHeaderMiscMask va_deprecated_enum  = 0x80000000,
   2281 } VAEncPackedHeaderType;
   2282 
   2283 /** \brief Packed header parameter. */
   2284 typedef struct _VAEncPackedHeaderParameterBuffer {
   2285    /** Type of the packed header buffer. See #VAEncPackedHeaderType. */
   2286    uint32_t                type;
   2287    /** \brief Size of the #VAEncPackedHeaderDataBuffer in bits. */
   2288    uint32_t                bit_length;
   2289    /** \brief Flag: buffer contains start code emulation prevention bytes? */
   2290    uint8_t               has_emulation_bytes;
   2291 
   2292    /** \brief Reserved bytes for future use, must be zero */
   2293    uint32_t                va_reserved[VA_PADDING_LOW];
   2294 } VAEncPackedHeaderParameterBuffer;
   2295 
   2296 /**
   2297 *  For application, e.g. set a new bitrate
   2298 *    VABufferID buf_id;
   2299 *    VAEncMiscParameterBuffer *misc_param;
   2300 *    VAEncMiscParameterRateControl *misc_rate_ctrl;
   2301 *
   2302 *    vaCreateBuffer(dpy, context, VAEncMiscParameterBufferType,
   2303 *              sizeof(VAEncMiscParameterBuffer) + sizeof(VAEncMiscParameterRateControl),
   2304 *              1, NULL, &buf_id);
   2305 *
   2306 *    vaMapBuffer(dpy,buf_id,(void **)&misc_param);
   2307 *    misc_param->type = VAEncMiscParameterTypeRateControl;
   2308 *    misc_rate_ctrl= (VAEncMiscParameterRateControl *)misc_param->data;
   2309 *    misc_rate_ctrl->bits_per_second = 6400000;
   2310 *    vaUnmapBuffer(dpy, buf_id);
   2311 *    vaRenderPicture(dpy, context, &buf_id, 1);
   2312 */
   2313 typedef struct _VAEncMiscParameterBuffer {
   2314    VAEncMiscParameterType type;
   2315    uint32_t data[];
   2316 } VAEncMiscParameterBuffer;
   2317 
   2318 /** \brief Temporal layer Structure*/
   2319 typedef struct _VAEncMiscParameterTemporalLayerStructure {
   2320    /** \brief The number of temporal layers */
   2321    uint32_t number_of_layers;
   2322    /** \brief The length of the array defining frame layer membership. Should be 1-32 */
   2323    uint32_t periodicity;
   2324    /**
   2325     * \brief The array indicating the layer id for each frame
   2326     *
   2327     * The layer id for the first frame in a coded sequence is always 0, so layer_id[] specifies the layer
   2328     * ids for frames starting from the 2nd frame.
   2329     */
   2330    uint32_t layer_id[32];
   2331 
   2332    /** \brief Reserved bytes for future use, must be zero */
   2333    uint32_t                va_reserved[VA_PADDING_LOW];
   2334 } VAEncMiscParameterTemporalLayerStructure;
   2335 
   2336 
   2337 /** \brief Rate control parameters */
   2338 typedef struct _VAEncMiscParameterRateControl {
   2339    /** The maximum bit-rate which the the rate controller should generate. */
   2340    uint32_t bits_per_second;
   2341    /** The target bit-rate which the rate controller should generate, as a percentage of the
   2342     * maximum bit-rate.
   2343     *
   2344     * In CBR mode this value is ignored (treated as 100%).
   2345     */
   2346    uint32_t target_percentage;
   2347    /** Rate control window size in milliseconds.
   2348     *
   2349     * The rate controller will attempt to guarantee that the target and maximum bit-rates are
   2350     * correct over this window.
   2351     */
   2352    uint32_t window_size;
   2353    /** Initial quantiser value used at the start of the stream.
   2354     *
   2355     * Ignored if set to zero.
   2356     */
   2357    uint32_t initial_qp;
   2358    /** Minimum quantiser value to use.
   2359     *
   2360     * The quantiser will not go below the value - if this limit is hit, the output bitrate may
   2361     * be lower than the target.  Ignored if set to zero.
   2362     */
   2363    uint32_t min_qp;
   2364    /** Basic unit size.
   2365     *
   2366     * Only used by some drivers - see driver documentation for details.  Set to zero if unused.
   2367     */
   2368    uint32_t basic_unit_size;
   2369    union {
   2370        struct {
   2371            /** Force rate controller reset.
   2372             *
   2373             * The next frame will be treated as the start of a new stream, with all rate
   2374             * controller state reset to its initial values.
   2375             */
   2376            uint32_t reset : 1;
   2377            /** Disable frame skip in rate control mode. */
   2378            uint32_t disable_frame_skip : 1;
   2379            /** Disable bit stuffing in rate control mode. */
   2380            uint32_t disable_bit_stuffing : 1;
   2381            /** Macroblock-level rate control.
   2382             *
   2383             * 0: use default, 1: always enable, 2: always disable, other: reserved.
   2384             *
   2385             * This feature is only available if VAConfigAttribRateControl has the
   2386             * \ref VA_RC_MB bit set.
   2387             */
   2388            uint32_t mb_rate_control : 4;
   2389            /** The temporal layer that these rate control parameters apply to. */
   2390            uint32_t temporal_id : 8;
   2391            /** Ensure that intra frames also conform to the constant frame size. */
   2392            uint32_t cfs_I_frames : 1;
   2393            /** Enable parallel rate control for hierarchical B frames.
   2394             *
   2395             * See \ref VA_RC_PARALLEL.
   2396             */
   2397            uint32_t enable_parallel_brc    : 1;
   2398            uint32_t enable_dynamic_scaling : 1;
   2399            /** Frame tolerance mode.
   2400             *
   2401             *  Indicates the tolerance the application has to variations in the frame size.
   2402             *  For example, wireless display scenarios may require very steady bit rate to
   2403             *  reduce buffering time. It affects the rate control algorithm used,
   2404             *  but may or may not have an effect based on the combination of other BRC
   2405             *  parameters.  Only valid when the driver reports support for
   2406             *  #VAConfigAttribFrameSizeToleranceSupport.
   2407             *
   2408             *  equals 0    -- normal mode;
   2409             *  equals 1    -- maps to sliding window;
   2410             *  equals 2    -- maps to low delay mode;
   2411             *  other       -- invalid.
   2412             */
   2413            uint32_t frame_tolerance_mode   : 2;
   2414            /** Reserved for future use, must be zero. */
   2415            uint32_t reserved               : 12;
   2416        } bits;
   2417        uint32_t value;
   2418    } rc_flags;
   2419    /** Initial quality factor used in ICQ mode.
   2420     *
   2421     * This value must be between 1 and 51.
   2422     * this value will be deprecated in future, to use quality_factor instead of it.
   2423     */
   2424    uint32_t ICQ_quality_factor;
   2425    /** Maximum quantiser value to use.
   2426     *
   2427     * The quantiser will not go above this value - if this limit is hit, the output bitrate
   2428     * may exceed the target.  Ignored if set to zero.
   2429     */
   2430    uint32_t max_qp;
   2431    /** Quality factor
   2432     *
   2433     *  the range will be different for different codec
   2434     */
   2435    uint32_t quality_factor;
   2436    /** Target frame size
   2437     *
   2438     *  Desired frame size in bytes.
   2439     *  This parameter can be used in some RC modes (like Transport Controlled BRC)
   2440     *  where feedback from the app is required.
   2441     *  Zero value means no limits.
   2442     *
   2443     */
   2444    uint32_t target_frame_size;
   2445    /** Reserved bytes for future use, must be zero. */
   2446    uint32_t va_reserved[VA_PADDING_LOW];
   2447 } VAEncMiscParameterRateControl;
   2448 
   2449 /** Encode framerate parameters.
   2450 *
   2451 * Sets the encode framerate used by the rate controller.  This should be
   2452 * provided in all modes using a bitrate target (variable framerate is not
   2453 * supported).
   2454 */
   2455 typedef struct _VAEncMiscParameterFrameRate {
   2456    /** Encode framerate.
   2457     *
   2458     * The framerate is specified as a number of frames per second, as a
   2459     * fraction.  The denominator of the fraction is given in the top half
   2460     * (the high two bytes) of the framerate field, and the numerator is
   2461     * given in the bottom half (the low two bytes).
   2462     *
   2463     * That is:
   2464     * denominator = framerate >> 16 & 0xffff;
   2465     * numerator   = framerate & 0xffff;
   2466     * fps         = numerator / denominator;
   2467     *
   2468     * For example, if framerate is set to (100 << 16 | 750), this is
   2469     * 750 / 100, hence 7.5fps.
   2470     *
   2471     * If the denominator is zero (the high two bytes are both zero) then
   2472     * it takes the value one instead, so the framerate is just the integer
   2473     * in the low 2 bytes.
   2474     */
   2475    uint32_t framerate;
   2476    union {
   2477        struct {
   2478            /** The temporal layer that these framerate parameters apply to. */
   2479            uint32_t temporal_id : 8;
   2480            /** Reserved for future use, must be zero. */
   2481            uint32_t reserved : 24;
   2482        } bits;
   2483        uint32_t value;
   2484    } framerate_flags;
   2485 
   2486    /** \brief Reserved bytes for future use, must be zero */
   2487    uint32_t                va_reserved[VA_PADDING_LOW];
   2488 } VAEncMiscParameterFrameRate;
   2489 
   2490 /**
   2491 * Allow a maximum slice size to be specified (in bits).
   2492 * The encoder will attempt to make sure that individual slices do not exceed this size
   2493 * Or to signal applicate if the slice size exceed this size, see "status" of VACodedBufferSegment
   2494 */
   2495 typedef struct _VAEncMiscParameterMaxSliceSize {
   2496    uint32_t max_slice_size;
   2497 
   2498    /** \brief Reserved bytes for future use, must be zero */
   2499    uint32_t                va_reserved[VA_PADDING_LOW];
   2500 } VAEncMiscParameterMaxSliceSize;
   2501 
   2502 typedef struct _VAEncMiscParameterAIR {
   2503    uint32_t air_num_mbs;
   2504    uint32_t air_threshold;
   2505    uint32_t air_auto; /* if set to 1 then hardware auto-tune the AIR threshold */
   2506 
   2507    /** \brief Reserved bytes for future use, must be zero */
   2508    uint32_t                va_reserved[VA_PADDING_LOW];
   2509 } VAEncMiscParameterAIR;
   2510 
   2511 /*
   2512 * \brief Rolling intra refresh data structure for encoding.
   2513 */
   2514 typedef struct _VAEncMiscParameterRIR {
   2515    union {
   2516        struct
   2517        /**
   2518         * \brief Indicate if intra refresh is enabled in column/row.
   2519         *
   2520         * App should query VAConfigAttribEncIntraRefresh to confirm RIR support
   2521         * by the driver before sending this structure.
   2522             */
   2523        {
   2524            /* \brief enable RIR in column */
   2525            uint32_t enable_rir_column : 1;
   2526            /* \brief enable RIR in row */
   2527            uint32_t enable_rir_row : 1;
   2528            uint32_t reserved : 30;
   2529        } bits;
   2530        uint32_t value;
   2531    } rir_flags;
   2532    /**
   2533     * \brief Indicates the column or row location in MB. It is ignored if
   2534     * rir_flags is 0.
   2535     */
   2536    uint16_t intra_insertion_location;
   2537    /**
   2538     * \brief Indicates the number of columns or rows in MB. It is ignored if
   2539     * rir_flags is 0.
   2540     */
   2541    uint16_t intra_insert_size;
   2542    /**
   2543     * \brief indicates the Qp difference for inserted intra columns or rows.
   2544     * App can use this to adjust intra Qp based on bitrate & max frame size.
   2545     */
   2546    uint8_t  qp_delta_for_inserted_intra;
   2547    /** \brief Reserved bytes for future use, must be zero */
   2548    uint32_t                va_reserved[VA_PADDING_LOW];
   2549 } VAEncMiscParameterRIR;
   2550 
   2551 /** HRD / VBV buffering parameters for encoding.
   2552 *
   2553 * This sets the HRD / VBV parameters which will be used by the rate
   2554 * controller for encoding.  It should be specified in modes using a bitrate
   2555 * target when the buffering of the output stream needs to be constrained.
   2556 *
   2557 * If not provided, the encoder may use arbitrary amounts of buffering.
   2558 */
   2559 typedef struct _VAEncMiscParameterHRD {
   2560    /** The initial fullness of the HRD coded picture buffer, in bits.
   2561     *
   2562     * This sets how full the CPB is when encoding begins - that is, how much
   2563     * buffering will happen on the decoder side before the first frame.
   2564     * The CPB fullness will be reset to this value after any rate control
   2565     * reset (a change in parameters or an explicit reset).
   2566     *
   2567     * For H.264, it should match the value of initial_cpb_removal_delay in
   2568     * buffering_period SEI messages.
   2569     */
   2570    uint32_t initial_buffer_fullness;
   2571    /** The HRD coded picture buffer size, in bits.
   2572     *
   2573     * For H.264, it should match the value of cpb_size_value_minus1 in the VUI
   2574     * parameters.
   2575     */
   2576    uint32_t buffer_size;
   2577 
   2578    /** \brief Reserved bytes for future use, must be zero */
   2579    uint32_t                va_reserved[VA_PADDING_LOW];
   2580 } VAEncMiscParameterHRD;
   2581 
   2582 /**
   2583 * \brief Defines a maximum frame size (in bits).
   2584 *
   2585 * This misc parameter buffer defines the maximum size of a frame (in
   2586 * bits). The encoder will try to make sure that each frame does not
   2587 * exceed this size. Otherwise, if the frame size exceeds this size,
   2588 * the \c status flag of #VACodedBufferSegment will contain
   2589 * #VA_CODED_BUF_STATUS_FRAME_SIZE_OVERFLOW.
   2590 */
   2591 typedef struct _VAEncMiscParameterBufferMaxFrameSize {
   2592    /** \brief Type. Shall be set to #VAEncMiscParameterTypeMaxFrameSize. */
   2593    /** duplicated with VAEncMiscParameterBuffer, should be deprecated*/
   2594    va_deprecated VAEncMiscParameterType      type;
   2595    /** \brief Maximum size of a frame (in bits). */
   2596    uint32_t                max_frame_size;
   2597 
   2598    /** \brief Reserved bytes for future use, must be zero */
   2599    uint32_t                va_reserved[VA_PADDING_LOW];
   2600 } VAEncMiscParameterBufferMaxFrameSize;
   2601 
   2602 /**
   2603 * \brief Maximum frame size (in bytes) settings for multiple pass.
   2604 *
   2605 * This misc parameter buffer defines the maximum size of a frame (in
   2606 * bytes) settings for multiple pass. currently only AVC encoder can
   2607 * support this settings in multiple pass case. If the frame size exceeds
   2608 * this size, the encoder will do more pak passes to adjust the QP value
   2609 * to control the frame size.
   2610 */
   2611 typedef struct _VAEncMiscParameterBufferMultiPassFrameSize {
   2612    /** \brief Type. Shall be set to #VAEncMiscParameterTypeMultiPassMaxFrameSize. */
   2613    /** duplicated with VAEncMiscParameterBuffer, should be deprecated*/
   2614    va_deprecated VAEncMiscParameterType      type;
   2615    /** \brief Maximum size of a frame (in byte) */
   2616    uint32_t                max_frame_size;
   2617    /** \brief Reserved bytes for future use, must be zero */
   2618    uint32_t                reserved;
   2619    /** \brief number of passes, every pass has different QP, currently AVC encoder can support up to 4 passes */
   2620    uint8_t                 num_passes;
   2621    /** \brief delta QP list for every pass */
   2622    uint8_t                *delta_qp;
   2623 
   2624    /** \brief Reserved bytes for future use, must be zero */
   2625    unsigned long           va_reserved[VA_PADDING_LOW];
   2626 } VAEncMiscParameterBufferMultiPassFrameSize;
   2627 
   2628 /**
   2629 * \brief Encoding quality level.
   2630 *
   2631 * The encoding quality could be set through this structure, if the implementation
   2632 * supports multiple quality levels. The quality level set through this structure is
   2633 * persistent over the entire coded sequence, or until a new structure is being sent.
   2634 * The quality level range can be queried through the VAConfigAttribEncQualityRange
   2635 * attribute. A lower value means higher quality, and a value of 1 represents the highest
   2636 * quality. The quality level setting is used as a trade-off between quality and speed/power
   2637 * consumption, with higher quality corresponds to lower speed and higher power consumption.
   2638 */
   2639 typedef struct _VAEncMiscParameterBufferQualityLevel {
   2640    /** \brief Encoding quality level setting. When set to 0, default quality
   2641     * level is used.
   2642     */
   2643    uint32_t                quality_level;
   2644 
   2645    /** \brief Reserved bytes for future use, must be zero */
   2646    uint32_t                va_reserved[VA_PADDING_LOW];
   2647 } VAEncMiscParameterBufferQualityLevel;
   2648 
   2649 /**
   2650 * \brief Quantization settings for encoding.
   2651 *
   2652 * Some encoders support special types of quantization such as trellis, and this structure
   2653 * can be used by the app to control these special types of quantization by the encoder.
   2654 */
   2655 typedef struct _VAEncMiscParameterQuantization {
   2656    union {
   2657        /* if no flags is set then quantization is determined by the driver */
   2658        struct {
   2659            /* \brief disable trellis for all frames/fields */
   2660            uint32_t disable_trellis : 1;
   2661            /* \brief enable trellis for I frames/fields */
   2662            uint32_t enable_trellis_I : 1;
   2663            /* \brief enable trellis for P frames/fields */
   2664            uint32_t enable_trellis_P : 1;
   2665            /* \brief enable trellis for B frames/fields */
   2666            uint32_t enable_trellis_B : 1;
   2667            uint32_t reserved : 28;
   2668        } bits;
   2669        uint32_t value;
   2670    } quantization_flags;
   2671    uint32_t va_reserved;
   2672 } VAEncMiscParameterQuantization;
   2673 
   2674 /**
   2675 * \brief Encoding skip frame.
   2676 *
   2677 * The application may choose to skip frames externally to the encoder (e.g. drop completely or
   2678 * code as all skip's). For rate control purposes the encoder will need to know the size and number
   2679 * of skipped frames.  Skip frame(s) indicated through this structure is applicable only to the
   2680 * current frame.  It is allowed for the application to still send in packed headers for the driver to
   2681 * pack, although no frame will be encoded (e.g. for HW to encrypt the frame).
   2682 */
   2683 typedef struct _VAEncMiscParameterSkipFrame {
   2684    /** \brief Indicates skip frames as below.
   2685      * 0: Encode as normal, no skip.
   2686      * 1: One or more frames were skipped prior to the current frame, encode the current frame as normal.
   2687      * 2: The current frame is to be skipped, do not encode it but pack/encrypt the packed header contents
   2688      *    (all except VAEncPackedHeaderSlice) which could contain actual frame contents (e.g. pack the frame
   2689      *    in VAEncPackedHeaderPicture).  */
   2690    uint8_t               skip_frame_flag;
   2691    /** \brief The number of frames skipped prior to the current frame.  Valid when skip_frame_flag = 1. */
   2692    uint8_t               num_skip_frames;
   2693    /** \brief When skip_frame_flag = 1, the size of the skipped frames in bits.   When skip_frame_flag = 2,
   2694      * the size of the current skipped frame that is to be packed/encrypted in bits. */
   2695    uint32_t                size_skip_frames;
   2696 
   2697    /** \brief Reserved bytes for future use, must be zero */
   2698    uint32_t                va_reserved[VA_PADDING_LOW];
   2699 } VAEncMiscParameterSkipFrame;
   2700 
   2701 /**
   2702 * \brief Encoding region-of-interest (ROI).
   2703 *
   2704 * The encoding ROI can be set through VAEncMiscParameterBufferROI, if the implementation
   2705 * supports ROI input. The ROI set through this structure is applicable only to the
   2706 * current frame or field, so must be sent every frame or field to be applied.  The number of
   2707 * supported ROIs can be queried through the VAConfigAttribEncROI.  The encoder will use the
   2708 * ROI information to adjust the QP values of the MB's that fall within the ROIs.
   2709 */
   2710 typedef struct _VAEncROI {
   2711    /** \brief Defines the ROI boundary in pixels, the driver will map it to appropriate
   2712     *  codec coding units.  It is relative to frame coordinates for the frame case and
   2713     *  to field coordinates for the field case. */
   2714    VARectangle     roi_rectangle;
   2715    /**
   2716     * \brief ROI value
   2717     *
   2718     * \ref roi_value specifies ROI delta QP or ROI priority.
   2719     * --  ROI delta QP is the value that will be added on top of the frame level QP.
   2720     * --  ROI priority specifies the priority of a region, it can be positive (more important)
   2721     * or negative (less important) values and is compared with non-ROI region (taken as value 0),
   2722     * E.g. ROI region with \ref roi_value -3 is less important than the non-ROI region (\ref roi_value
   2723     * implied to be 0) which is less important than ROI region with roi_value +2. For overlapping
   2724     * regions, the roi_value that is first in the ROI array will have priority.
   2725     *
   2726     * \ref roi_value always specifes ROI delta QP when VAConfigAttribRateControl == VA_RC_CQP, no matter
   2727     * the value of \c roi_value_is_qp_delta in #VAEncMiscParameterBufferROI.
   2728     *
   2729     * \ref roi_value depends on \c roi_value_is_qp_delta in #VAEncMiscParameterBufferROI when
   2730     * VAConfigAttribRateControl != VA_RC_CQP. \ref roi_value specifies ROI_delta QP if \c roi_value_is_qp_delta
   2731     * in VAEncMiscParameterBufferROI is 1, otherwise \ref roi_value specifies ROI priority.
   2732     */
   2733    int8_t            roi_value;
   2734 } VAEncROI;
   2735 
   2736 typedef struct _VAEncMiscParameterBufferROI {
   2737    /** \brief Number of ROIs being sent.*/
   2738    uint32_t        num_roi;
   2739 
   2740    /** \brief Valid when VAConfigAttribRateControl != VA_RC_CQP, then the encoder's
   2741     *  rate control will determine actual delta QPs.  Specifies the max/min allowed delta
   2742     *  QPs. */
   2743    int8_t                max_delta_qp;
   2744    int8_t                min_delta_qp;
   2745 
   2746    /** \brief Pointer to a VAEncROI array with num_roi elements.  It is relative to frame
   2747      *  coordinates for the frame case and to field coordinates for the field case.*/
   2748    VAEncROI            *roi;
   2749    union {
   2750        struct {
   2751            /**
   2752             * \brief An indication for roi value.
   2753             *
   2754             * \ref roi_value_is_qp_delta equal to 1 indicates \c roi_value in #VAEncROI should
   2755             * be used as ROI delta QP. \ref roi_value_is_qp_delta equal to 0 indicates \c roi_value
   2756             * in #VAEncROI should be used as ROI priority.
   2757             *
   2758             * \ref roi_value_is_qp_delta is only available when VAConfigAttribRateControl != VA_RC_CQP,
   2759             * the setting must comply with \c roi_rc_priority_support and \c roi_rc_qp_delta_support in
   2760             * #VAConfigAttribValEncROI. The underlying driver should ignore this field
   2761             * when VAConfigAttribRateControl == VA_RC_CQP.
   2762             */
   2763            uint32_t  roi_value_is_qp_delta    : 1;
   2764            uint32_t  reserved                 : 31;
   2765        } bits;
   2766        uint32_t value;
   2767    } roi_flags;
   2768 
   2769    /** \brief Reserved bytes for future use, must be zero */
   2770    uint32_t                va_reserved[VA_PADDING_LOW];
   2771 } VAEncMiscParameterBufferROI;
   2772 /*
   2773 * \brief Dirty rectangle data structure for encoding.
   2774 *
   2775 * The encoding dirty rect can be set through VAEncMiscParameterBufferDirtyRect, if the
   2776 * implementation supports dirty rect input. The rect set through this structure is applicable
   2777 * only to the current frame or field, so must be sent every frame or field to be applied.
   2778 * The number of supported rects can be queried through the VAConfigAttribEncDirtyRect.  The
   2779 * encoder will use the rect information to know those rectangle areas have changed while the
   2780 * areas not covered by dirty rect rectangles are assumed to have not changed compared to the
   2781 * previous picture.  The encoder may do some internal optimizations.
   2782 */
   2783 typedef struct _VAEncMiscParameterBufferDirtyRect {
   2784    /** \brief Number of Rectangle being sent.*/
   2785    uint32_t    num_roi_rectangle;
   2786 
   2787    /** \brief Pointer to a VARectangle array with num_roi_rectangle elements.*/
   2788    VARectangle    *roi_rectangle;
   2789 } VAEncMiscParameterBufferDirtyRect;
   2790 
   2791 /** \brief Attribute value for VAConfigAttribEncParallelRateControl */
   2792 typedef struct _VAEncMiscParameterParallelRateControl {
   2793    /** brief Number of layers*/
   2794    uint32_t num_layers;
   2795    /** brief Number of B frames per layer per GOP.
   2796     *
   2797     * it should be allocated by application, and the is num_layers.
   2798     *  num_b_in_gop[0] is the number of regular B which refers to only I or P frames. */
   2799    uint32_t *num_b_in_gop;
   2800 } VAEncMiscParameterParallelRateControl;
   2801 
   2802 /** per frame encoder quality controls, once set they will persist for all future frames
   2803  *till it is updated again. */
   2804 typedef struct _VAEncMiscParameterEncQuality {
   2805    union {
   2806        struct {
   2807            /** Use raw frames for reference instead of reconstructed frames.
   2808              * it only impact motion estimation (ME)  stage, and will not impact MC stage
   2809              * so the reconstruct picture will can match with decode side */
   2810            uint32_t useRawPicForRef                    : 1;
   2811            /**  Disables skip check for ME stage, it will increase the bistream size
   2812              * but will improve the qulity */
   2813            uint32_t skipCheckDisable                   : 1;
   2814            /**  Indicates app will override default driver FTQ settings using FTQEnable.
   2815              *  FTQ is forward transform quantization */
   2816            uint32_t FTQOverride                        : 1;
   2817            /** Enables/disables FTQ. */
   2818            uint32_t FTQEnable                          : 1;
   2819            /** Indicates the app will provide the Skip Threshold LUT to use when FTQ is
   2820              * enabled (FTQSkipThresholdLUT), else default driver thresholds will be used. */
   2821            uint32_t FTQSkipThresholdLUTInput           : 1;
   2822            /** Indicates the app will provide the Skip Threshold LUT to use when FTQ is
   2823              * disabled (NonFTQSkipThresholdLUT), else default driver thresholds will be used. */
   2824            uint32_t NonFTQSkipThresholdLUTInput        : 1;
   2825            uint32_t ReservedBit                        : 1;
   2826            /** Control to enable the ME mode decision algorithm to bias to fewer B Direct/Skip types.
   2827              * Applies only to B frames, all other frames will ignore this setting.  */
   2828            uint32_t directBiasAdjustmentEnable         : 1;
   2829            /** Enables global motion bias. global motion also is called HME (Heirarchical Motion Estimation )
   2830              * HME is used to handle large motions and avoiding local minima in the video encoding process
   2831              * down scaled the input and reference picture, then do ME. the result will be a predictor to next level HME or ME
   2832              * current interface divide the HME to 3 level. UltraHME , SuperHME, and HME, result of UltraHME will be input of SurperHME,
   2833              * result of superHME will be a input for HME. HME result will be input of ME. it is a switch for HMEMVCostScalingFactor
   2834              * can change the HME bias inside RDO stage*/
   2835            uint32_t globalMotionBiasAdjustmentEnable   : 1;
   2836            /** MV cost scaling ratio for HME ( predictors.  It is used when
   2837              * globalMotionBiasAdjustmentEnable == 1, else it is ignored.  Values are:
   2838              *     0: set MV cost to be 0 for HME predictor.
   2839              *     1: scale MV cost to be 1/2 of the default value for HME predictor.
   2840              *     2: scale MV cost to be 1/4 of the default value for HME predictor.
   2841              *     3: scale MV cost to be 1/8 of the default value for HME predictor. */
   2842            uint32_t HMEMVCostScalingFactor             : 2;
   2843            /**disable HME, if it is disabled. Super*ultraHME should also be disabled  */
   2844            uint32_t HMEDisable                         : 1;
   2845            /**disable Super HME, if it is disabled, ultraHME should be disabled */
   2846            uint32_t SuperHMEDisable                    : 1;
   2847            /** disable Ultra HME */
   2848            uint32_t UltraHMEDisable                    : 1;
   2849            /** disable panic mode. Panic mode happened when there are extreme BRC (bit rate control) requirement
   2850              * frame size cant achieve the target of BRC.  when Panic mode is triggered, Coefficients will
   2851              *  be set to zero. disable panic mode will improve quality but will impact BRC */
   2852            uint32_t PanicModeDisable                   : 1;
   2853            /** Force RepartitionCheck
   2854             *  0: DEFAULT - follow driver default settings.
   2855             *  1: FORCE_ENABLE - enable this feature totally for all cases.
   2856             *  2: FORCE_DISABLE - disable this feature totally for all cases. */
   2857            uint32_t ForceRepartitionCheck              : 2;
   2858 
   2859        };
   2860        uint32_t encControls;
   2861    };
   2862 
   2863    /** Maps QP to skip thresholds when FTQ is enabled.  Valid range is 0-255. */
   2864    uint8_t FTQSkipThresholdLUT[52];
   2865    /** Maps QP to skip thresholds when FTQ is disabled.  Valid range is 0-65535. */
   2866    uint16_t NonFTQSkipThresholdLUT[52];
   2867 
   2868    uint32_t reserved[VA_PADDING_HIGH];  // Reserved for future use.
   2869 
   2870 } VAEncMiscParameterEncQuality;
   2871 
   2872 /**
   2873 *  \brief Custom Encoder Rounding Offset Control.
   2874 *  Application may use this structure to set customized rounding
   2875 *  offset parameters for quantization.
   2876 *  Valid when \c VAConfigAttribCustomRoundingControl equals 1.
   2877 */
   2878 typedef struct _VAEncMiscParameterCustomRoundingControl {
   2879    union {
   2880        struct {
   2881            /** \brief Enable customized rounding offset for intra blocks.
   2882             *  If 0, default value would be taken by driver for intra
   2883             *  rounding offset.
   2884             */
   2885            uint32_t    enable_custom_rouding_intra     : 1 ;
   2886 
   2887            /** \brief Intra rounding offset
   2888             *  Ignored if \c enable_custom_rouding_intra equals 0.
   2889             */
   2890            uint32_t    rounding_offset_intra           : 7;
   2891 
   2892            /** \brief Enable customized rounding offset for inter blocks.
   2893             *  If 0, default value would be taken by driver for inter
   2894             *  rounding offset.
   2895             */
   2896            uint32_t    enable_custom_rounding_inter    : 1 ;
   2897 
   2898            /** \brief Inter rounding offset
   2899             *  Ignored if \c enable_custom_rouding_inter equals 0.
   2900             */
   2901            uint32_t    rounding_offset_inter           : 7;
   2902 
   2903            /* Reserved */
   2904            uint32_t    reserved                        : 16;
   2905        }  bits;
   2906        uint32_t    value;
   2907    }   rounding_offset_setting;
   2908 } VAEncMiscParameterCustomRoundingControl;
   2909 
   2910 /**
   2911 * There will be cases where the bitstream buffer will not have enough room to hold
   2912 * the data for the entire slice, and the following flags will be used in the slice
   2913 * parameter to signal to the server for the possible cases.
   2914 * If a slice parameter buffer and slice data buffer pair is sent to the server with
   2915 * the slice data partially in the slice data buffer (BEGIN and MIDDLE cases below),
   2916 * then a slice parameter and data buffer needs to be sent again to complete this slice.
   2917 */
   2918 #define VA_SLICE_DATA_FLAG_ALL      0x00    /* whole slice is in the buffer */
   2919 #define VA_SLICE_DATA_FLAG_BEGIN    0x01    /* The beginning of the slice is in the buffer but the end if not */
   2920 #define VA_SLICE_DATA_FLAG_MIDDLE   0x02    /* Neither beginning nor end of the slice is in the buffer */
   2921 #define VA_SLICE_DATA_FLAG_END      0x04    /* end of the slice is in the buffer */
   2922 
   2923 /* Codec-independent Slice Parameter Buffer base */
   2924 typedef struct _VASliceParameterBufferBase {
   2925    uint32_t slice_data_size;   /* number of bytes in the slice data buffer for this slice */
   2926    uint32_t slice_data_offset; /* the offset to the first byte of slice data */
   2927    uint32_t slice_data_flag;   /* see VA_SLICE_DATA_FLAG_XXX definitions */
   2928 } VASliceParameterBufferBase;
   2929 
   2930 /**********************************
   2931 * JPEG common  data structures
   2932 **********************************/
   2933 /**
   2934 * \brief Huffman table for JPEG decoding.
   2935 *
   2936 * This structure holds the complete Huffman tables. This is an
   2937 * aggregation of all Huffman table (DHT) segments maintained by the
   2938 * application. i.e. up to 2 Huffman tables are stored in there for
   2939 * baseline profile.
   2940 *
   2941 * The #load_huffman_table array can be used as a hint to notify the
   2942 * VA driver implementation about which table(s) actually changed
   2943 * since the last submission of this buffer.
   2944 */
   2945 typedef struct _VAHuffmanTableBufferJPEGBaseline {
   2946    /** \brief Specifies which #huffman_table is valid. */
   2947    uint8_t       load_huffman_table[2];
   2948    /** \brief Huffman tables indexed by table identifier (Th). */
   2949    struct {
   2950        /** @name DC table (up to 12 categories) */
   2951        /**@{*/
   2952        /** \brief Number of Huffman codes of length i + 1 (Li). */
   2953        uint8_t   num_dc_codes[16];
   2954        /** \brief Value associated with each Huffman code (Vij). */
   2955        uint8_t   dc_values[12];
   2956        /**@}*/
   2957        /** @name AC table (2 special codes + up to 16 * 10 codes) */
   2958        /**@{*/
   2959        /** \brief Number of Huffman codes of length i + 1 (Li). */
   2960        uint8_t   num_ac_codes[16];
   2961        /** \brief Value associated with each Huffman code (Vij). */
   2962        uint8_t   ac_values[162];
   2963        /** \brief Padding to 4-byte boundaries. Must be set to zero. */
   2964        uint8_t   pad[2];
   2965        /**@}*/
   2966    }                   huffman_table[2];
   2967 
   2968    /** \brief Reserved bytes for future use, must be zero */
   2969    uint32_t                va_reserved[VA_PADDING_LOW];
   2970 } VAHuffmanTableBufferJPEGBaseline;
   2971 
   2972 /****************************
   2973 * MPEG-2 data structures
   2974 ****************************/
   2975 
   2976 /* MPEG-2 Picture Parameter Buffer */
   2977 /*
   2978 * For each frame or field, and before any slice data, a single
   2979 * picture parameter buffer must be send.
   2980 */
   2981 typedef struct _VAPictureParameterBufferMPEG2 {
   2982    uint16_t horizontal_size;
   2983    uint16_t vertical_size;
   2984    VASurfaceID forward_reference_picture;
   2985    VASurfaceID backward_reference_picture;
   2986    /* meanings of the following fields are the same as in the standard */
   2987    int32_t picture_coding_type;
   2988    int32_t f_code; /* pack all four fcode into this */
   2989    union {
   2990        struct {
   2991            uint32_t intra_dc_precision     : 2;
   2992            uint32_t picture_structure      : 2;
   2993            uint32_t top_field_first        : 1;
   2994            uint32_t frame_pred_frame_dct       : 1;
   2995            uint32_t concealment_motion_vectors : 1;
   2996            uint32_t q_scale_type           : 1;
   2997            uint32_t intra_vlc_format       : 1;
   2998            uint32_t alternate_scan         : 1;
   2999            uint32_t repeat_first_field     : 1;
   3000            uint32_t progressive_frame      : 1;
   3001            uint32_t is_first_field         : 1; /* indicate whether the current field
   3002                                                              * is the first field for field picture
   3003                                                              */
   3004        } bits;
   3005        uint32_t value;
   3006    } picture_coding_extension;
   3007 
   3008    /** \brief Reserved bytes for future use, must be zero */
   3009    uint32_t                va_reserved[VA_PADDING_LOW];
   3010 } VAPictureParameterBufferMPEG2;
   3011 
   3012 /** MPEG-2 Inverse Quantization Matrix Buffer */
   3013 typedef struct _VAIQMatrixBufferMPEG2 {
   3014    /** \brief Same as the MPEG-2 bitstream syntax element. */
   3015    int32_t load_intra_quantiser_matrix;
   3016    /** \brief Same as the MPEG-2 bitstream syntax element. */
   3017    int32_t load_non_intra_quantiser_matrix;
   3018    /** \brief Same as the MPEG-2 bitstream syntax element. */
   3019    int32_t load_chroma_intra_quantiser_matrix;
   3020    /** \brief Same as the MPEG-2 bitstream syntax element. */
   3021    int32_t load_chroma_non_intra_quantiser_matrix;
   3022    /** \brief Luminance intra matrix, in zig-zag scan order. */
   3023    uint8_t intra_quantiser_matrix[64];
   3024    /** \brief Luminance non-intra matrix, in zig-zag scan order. */
   3025    uint8_t non_intra_quantiser_matrix[64];
   3026    /** \brief Chroma intra matrix, in zig-zag scan order. */
   3027    uint8_t chroma_intra_quantiser_matrix[64];
   3028    /** \brief Chroma non-intra matrix, in zig-zag scan order. */
   3029    uint8_t chroma_non_intra_quantiser_matrix[64];
   3030 
   3031    /** \brief Reserved bytes for future use, must be zero */
   3032    uint32_t                va_reserved[VA_PADDING_LOW];
   3033 } VAIQMatrixBufferMPEG2;
   3034 
   3035 /** MPEG-2 Slice Parameter Buffer */
   3036 typedef struct _VASliceParameterBufferMPEG2 {
   3037    uint32_t slice_data_size;/* number of bytes in the slice data buffer for this slice */
   3038    uint32_t slice_data_offset;/* the offset to the first byte of slice data */
   3039    uint32_t slice_data_flag; /* see VA_SLICE_DATA_FLAG_XXX defintions */
   3040    uint32_t macroblock_offset;/* the offset to the first bit of MB from the first byte of slice data */
   3041    uint32_t slice_horizontal_position;
   3042    uint32_t slice_vertical_position;
   3043    int32_t quantiser_scale_code;
   3044    int32_t intra_slice_flag;
   3045 
   3046    /** \brief Reserved bytes for future use, must be zero */
   3047    uint32_t                va_reserved[VA_PADDING_LOW];
   3048 } VASliceParameterBufferMPEG2;
   3049 
   3050 /** MPEG-2 Macroblock Parameter Buffer */
   3051 typedef struct _VAMacroblockParameterBufferMPEG2 {
   3052    uint16_t macroblock_address;
   3053    /*
   3054     * macroblock_address (in raster scan order)
   3055     * top-left: 0
   3056     * bottom-right: picture-height-in-mb*picture-width-in-mb - 1
   3057     */
   3058    uint8_t macroblock_type;  /* see definition below */
   3059    union {
   3060        struct {
   3061            uint32_t frame_motion_type      : 2;
   3062            uint32_t field_motion_type      : 2;
   3063            uint32_t dct_type           : 1;
   3064        } bits;
   3065        uint32_t value;
   3066    } macroblock_modes;
   3067    uint8_t motion_vertical_field_select;
   3068    /*
   3069     * motion_vertical_field_select:
   3070     * see section 6.3.17.2 in the spec
   3071     * only the lower 4 bits are used
   3072     * bit 0: first vector forward
   3073     * bit 1: first vector backward
   3074     * bit 2: second vector forward
   3075     * bit 3: second vector backward
   3076     */
   3077    int16_t PMV[2][2][2]; /* see Table 7-7 in the spec */
   3078    uint16_t coded_block_pattern;
   3079    /*
   3080     * The bitplanes for coded_block_pattern are described
   3081     * in Figure 6.10-12 in the spec
   3082     */
   3083 
   3084    /* Number of skipped macroblocks after this macroblock */
   3085    uint16_t num_skipped_macroblocks;
   3086 
   3087    /** \brief Reserved bytes for future use, must be zero */
   3088    uint32_t                va_reserved[VA_PADDING_LOW];
   3089 } VAMacroblockParameterBufferMPEG2;
   3090 
   3091 /*
   3092 * OR'd flags for macroblock_type (section 6.3.17.1 in the spec)
   3093 */
   3094 #define VA_MB_TYPE_MOTION_FORWARD   0x02
   3095 #define VA_MB_TYPE_MOTION_BACKWARD  0x04
   3096 #define VA_MB_TYPE_MOTION_PATTERN   0x08
   3097 #define VA_MB_TYPE_MOTION_INTRA     0x10
   3098 
   3099 /**
   3100 * MPEG-2 Residual Data Buffer
   3101 * For each macroblock, there wil be 64 shorts (16-bit) in the
   3102 * residual data buffer
   3103 */
   3104 
   3105 /****************************
   3106 * MPEG-4 Part 2 data structures
   3107 ****************************/
   3108 
   3109 /* MPEG-4 Picture Parameter Buffer */
   3110 /*
   3111 * For each frame or field, and before any slice data, a single
   3112 * picture parameter buffer must be send.
   3113 */
   3114 typedef struct _VAPictureParameterBufferMPEG4 {
   3115    uint16_t vop_width;
   3116    uint16_t vop_height;
   3117    VASurfaceID forward_reference_picture;
   3118    VASurfaceID backward_reference_picture;
   3119    union {
   3120        struct {
   3121            uint32_t short_video_header     : 1;
   3122            uint32_t chroma_format          : 2;
   3123            uint32_t interlaced         : 1;
   3124            uint32_t obmc_disable           : 1;
   3125            uint32_t sprite_enable          : 2;
   3126            uint32_t sprite_warping_accuracy    : 2;
   3127            uint32_t quant_type         : 1;
   3128            uint32_t quarter_sample         : 1;
   3129            uint32_t data_partitioned       : 1;
   3130            uint32_t reversible_vlc         : 1;
   3131            uint32_t resync_marker_disable      : 1;
   3132        } bits;
   3133        uint32_t value;
   3134    } vol_fields;
   3135    uint8_t no_of_sprite_warping_points;
   3136    int16_t sprite_trajectory_du[3];
   3137    int16_t sprite_trajectory_dv[3];
   3138    uint8_t quant_precision;
   3139    union {
   3140        struct {
   3141            uint32_t vop_coding_type        : 2;
   3142            uint32_t backward_reference_vop_coding_type : 2;
   3143            uint32_t vop_rounding_type      : 1;
   3144            uint32_t intra_dc_vlc_thr       : 3;
   3145            uint32_t top_field_first        : 1;
   3146            uint32_t alternate_vertical_scan_flag   : 1;
   3147        } bits;
   3148        uint32_t value;
   3149    } vop_fields;
   3150    uint8_t vop_fcode_forward;
   3151    uint8_t vop_fcode_backward;
   3152    uint16_t vop_time_increment_resolution;
   3153    /* short header related */
   3154    uint8_t num_gobs_in_vop;
   3155    uint8_t num_macroblocks_in_gob;
   3156    /* for direct mode prediction */
   3157    int16_t TRB;
   3158    int16_t TRD;
   3159 
   3160    /** \brief Reserved bytes for future use, must be zero */
   3161    uint32_t                va_reserved[VA_PADDING_LOW];
   3162 } VAPictureParameterBufferMPEG4;
   3163 
   3164 /** MPEG-4 Inverse Quantization Matrix Buffer */
   3165 typedef struct _VAIQMatrixBufferMPEG4 {
   3166    /** Same as the MPEG-4:2 bitstream syntax element. */
   3167    int32_t load_intra_quant_mat;
   3168    /** Same as the MPEG-4:2 bitstream syntax element. */
   3169    int32_t load_non_intra_quant_mat;
   3170    /** The matrix for intra blocks, in zig-zag scan order. */
   3171    uint8_t intra_quant_mat[64];
   3172    /** The matrix for non-intra blocks, in zig-zag scan order. */
   3173    uint8_t non_intra_quant_mat[64];
   3174 
   3175    /** \brief Reserved bytes for future use, must be zero */
   3176    uint32_t                va_reserved[VA_PADDING_LOW];
   3177 } VAIQMatrixBufferMPEG4;
   3178 
   3179 /** MPEG-4 Slice Parameter Buffer */
   3180 typedef struct _VASliceParameterBufferMPEG4 {
   3181    uint32_t slice_data_size;/* number of bytes in the slice data buffer for this slice */
   3182    uint32_t slice_data_offset;/* the offset to the first byte of slice data */
   3183    uint32_t slice_data_flag; /* see VA_SLICE_DATA_FLAG_XXX defintions */
   3184    uint32_t macroblock_offset;/* the offset to the first bit of MB from the first byte of slice data */
   3185    uint32_t macroblock_number;
   3186    int32_t quant_scale;
   3187 
   3188    /** \brief Reserved bytes for future use, must be zero */
   3189    uint32_t                va_reserved[VA_PADDING_LOW];
   3190 } VASliceParameterBufferMPEG4;
   3191 
   3192 /**
   3193 VC-1 data structures
   3194 */
   3195 
   3196 typedef enum   /* see 7.1.1.32 */
   3197 {
   3198    VAMvMode1Mv                        = 0,
   3199    VAMvMode1MvHalfPel                 = 1,
   3200    VAMvMode1MvHalfPelBilinear         = 2,
   3201    VAMvModeMixedMv                    = 3,
   3202    VAMvModeIntensityCompensation      = 4
   3203 } VAMvModeVC1;
   3204 
   3205 /** VC-1 Picture Parameter Buffer */
   3206 /*
   3207 * For each picture, and before any slice data, a picture parameter
   3208 * buffer must be send. Multiple picture parameter buffers may be
   3209 * sent for a single picture. In that case picture parameters will
   3210 * apply to all slice data that follow it until a new picture
   3211 * parameter buffer is sent.
   3212 *
   3213 * Notes:
   3214 *   pic_quantizer_type should be set to the applicable quantizer
   3215 *   type as defined by QUANTIZER (J.1.19) and either
   3216 *   PQUANTIZER (7.1.1.8) or PQINDEX (7.1.1.6)
   3217 */
   3218 typedef struct _VAPictureParameterBufferVC1 {
   3219    VASurfaceID forward_reference_picture;
   3220    VASurfaceID backward_reference_picture;
   3221    /* if out-of-loop post-processing is done on the render
   3222       target, then we need to keep the in-loop decoded
   3223       picture as a reference picture */
   3224    VASurfaceID inloop_decoded_picture;
   3225 
   3226    /* sequence layer for AP or meta data for SP and MP */
   3227    union {
   3228        struct {
   3229            uint32_t pulldown   : 1; /* SEQUENCE_LAYER::PULLDOWN */
   3230            uint32_t interlace  : 1; /* SEQUENCE_LAYER::INTERLACE */
   3231            uint32_t tfcntrflag : 1; /* SEQUENCE_LAYER::TFCNTRFLAG */
   3232            uint32_t finterpflag    : 1; /* SEQUENCE_LAYER::FINTERPFLAG */
   3233            uint32_t psf        : 1; /* SEQUENCE_LAYER::PSF */
   3234            uint32_t multires   : 1; /* METADATA::MULTIRES */
   3235            uint32_t overlap    : 1; /* METADATA::OVERLAP */
   3236            uint32_t syncmarker : 1; /* METADATA::SYNCMARKER */
   3237            uint32_t rangered   : 1; /* METADATA::RANGERED */
   3238            uint32_t max_b_frames   : 3; /* METADATA::MAXBFRAMES */
   3239            uint32_t profile    : 2; /* SEQUENCE_LAYER::PROFILE or The MSB of METADATA::PROFILE */
   3240        } bits;
   3241        uint32_t value;
   3242    } sequence_fields;
   3243 
   3244    uint16_t coded_width;       /* ENTRY_POINT_LAYER::CODED_WIDTH */
   3245    uint16_t coded_height;  /* ENTRY_POINT_LAYER::CODED_HEIGHT */
   3246    union {
   3247        struct {
   3248            uint32_t broken_link    : 1; /* ENTRY_POINT_LAYER::BROKEN_LINK */
   3249            uint32_t closed_entry   : 1; /* ENTRY_POINT_LAYER::CLOSED_ENTRY */
   3250            uint32_t panscan_flag   : 1; /* ENTRY_POINT_LAYER::PANSCAN_FLAG */
   3251            uint32_t loopfilter : 1; /* ENTRY_POINT_LAYER::LOOPFILTER */
   3252        } bits;
   3253        uint32_t value;
   3254    } entrypoint_fields;
   3255    uint8_t conditional_overlap_flag; /* ENTRY_POINT_LAYER::CONDOVER */
   3256    uint8_t fast_uvmc_flag; /* ENTRY_POINT_LAYER::FASTUVMC */
   3257    union {
   3258        struct {
   3259            uint32_t luma_flag  : 1; /* ENTRY_POINT_LAYER::RANGE_MAPY_FLAG */
   3260            uint32_t luma       : 3; /* ENTRY_POINT_LAYER::RANGE_MAPY */
   3261            uint32_t chroma_flag    : 1; /* ENTRY_POINT_LAYER::RANGE_MAPUV_FLAG */
   3262            uint32_t chroma     : 3; /* ENTRY_POINT_LAYER::RANGE_MAPUV */
   3263        } bits;
   3264        uint32_t value;
   3265    } range_mapping_fields;
   3266 
   3267    uint8_t b_picture_fraction; /* Index for PICTURE_LAYER::BFRACTION value in Table 40 (7.1.1.14) */
   3268    uint8_t cbp_table;      /* PICTURE_LAYER::CBPTAB/ICBPTAB */
   3269    uint8_t mb_mode_table;  /* PICTURE_LAYER::MBMODETAB */
   3270    uint8_t range_reduction_frame;/* PICTURE_LAYER::RANGEREDFRM */
   3271    uint8_t rounding_control;   /* PICTURE_LAYER::RNDCTRL */
   3272    uint8_t post_processing;    /* PICTURE_LAYER::POSTPROC */
   3273    uint8_t picture_resolution_index;   /* PICTURE_LAYER::RESPIC */
   3274    uint8_t luma_scale;     /* PICTURE_LAYER::LUMSCALE */
   3275    uint8_t luma_shift;     /* PICTURE_LAYER::LUMSHIFT */
   3276 
   3277    union {
   3278        struct {
   3279            uint32_t picture_type       : 3; /* PICTURE_LAYER::PTYPE */
   3280            uint32_t frame_coding_mode  : 3; /* PICTURE_LAYER::FCM */
   3281            uint32_t top_field_first    : 1; /* PICTURE_LAYER::TFF */
   3282            uint32_t is_first_field     : 1; /* set to 1 if it is the first field */
   3283            uint32_t intensity_compensation : 1; /* PICTURE_LAYER::INTCOMP */
   3284        } bits;
   3285        uint32_t value;
   3286    } picture_fields;
   3287    union {
   3288        struct {
   3289            uint32_t mv_type_mb : 1;    /* PICTURE::MVTYPEMB */
   3290            uint32_t direct_mb  : 1;    /* PICTURE::DIRECTMB */
   3291            uint32_t skip_mb    : 1;    /* PICTURE::SKIPMB */
   3292            uint32_t field_tx   : 1;    /* PICTURE::FIELDTX */
   3293            uint32_t forward_mb : 1;    /* PICTURE::FORWARDMB */
   3294            uint32_t ac_pred    : 1;    /* PICTURE::ACPRED */
   3295            uint32_t overflags  : 1;    /* PICTURE::OVERFLAGS */
   3296        } flags;
   3297        uint32_t value;
   3298    } raw_coding;
   3299    union {
   3300        struct {
   3301            uint32_t bp_mv_type_mb   : 1;    /* PICTURE::MVTYPEMB */
   3302            uint32_t bp_direct_mb    : 1;    /* PICTURE::DIRECTMB */
   3303            uint32_t bp_skip_mb      : 1;    /* PICTURE::SKIPMB */
   3304            uint32_t bp_field_tx     : 1;    /* PICTURE::FIELDTX */
   3305            uint32_t bp_forward_mb   : 1;    /* PICTURE::FORWARDMB */
   3306            uint32_t bp_ac_pred      : 1;    /* PICTURE::ACPRED */
   3307            uint32_t bp_overflags    : 1;    /* PICTURE::OVERFLAGS */
   3308        } flags;
   3309        uint32_t value;
   3310    } bitplane_present; /* signal what bitplane is being passed via the bitplane buffer */
   3311    union {
   3312        struct {
   3313            uint32_t reference_distance_flag : 1;/* PICTURE_LAYER::REFDIST_FLAG */
   3314            uint32_t reference_distance : 5;/* PICTURE_LAYER::REFDIST */
   3315            uint32_t num_reference_pictures: 1;/* PICTURE_LAYER::NUMREF */
   3316            uint32_t reference_field_pic_indicator  : 1;/* PICTURE_LAYER::REFFIELD */
   3317        } bits;
   3318        uint32_t value;
   3319    } reference_fields;
   3320    union {
   3321        struct {
   3322            uint32_t mv_mode        : 3; /* PICTURE_LAYER::MVMODE */
   3323            uint32_t mv_mode2       : 3; /* PICTURE_LAYER::MVMODE2 */
   3324            uint32_t mv_table       : 3; /* PICTURE_LAYER::MVTAB/IMVTAB */
   3325            uint32_t two_mv_block_pattern_table: 2; /* PICTURE_LAYER::2MVBPTAB */
   3326            uint32_t four_mv_switch     : 1; /* PICTURE_LAYER::4MVSWITCH */
   3327            uint32_t four_mv_block_pattern_table : 2; /* PICTURE_LAYER::4MVBPTAB */
   3328            uint32_t extended_mv_flag   : 1; /* ENTRY_POINT_LAYER::EXTENDED_MV */
   3329            uint32_t extended_mv_range  : 2; /* PICTURE_LAYER::MVRANGE */
   3330            uint32_t extended_dmv_flag  : 1; /* ENTRY_POINT_LAYER::EXTENDED_DMV */
   3331            uint32_t extended_dmv_range : 2; /* PICTURE_LAYER::DMVRANGE */
   3332        } bits;
   3333        uint32_t value;
   3334    } mv_fields;
   3335    union {
   3336        struct {
   3337            uint32_t dquant : 2;    /* ENTRY_POINT_LAYER::DQUANT */
   3338            uint32_t quantizer     : 2;     /* ENTRY_POINT_LAYER::QUANTIZER */
   3339            uint32_t half_qp    : 1;    /* PICTURE_LAYER::HALFQP */
   3340            uint32_t pic_quantizer_scale : 5;/* PICTURE_LAYER::PQUANT */
   3341            uint32_t pic_quantizer_type : 1;/* PICTURE_LAYER::PQUANTIZER */
   3342            uint32_t dq_frame   : 1;    /* VOPDQUANT::DQUANTFRM */
   3343            uint32_t dq_profile : 2;    /* VOPDQUANT::DQPROFILE */
   3344            uint32_t dq_sb_edge : 2;    /* VOPDQUANT::DQSBEDGE */
   3345            uint32_t dq_db_edge     : 2;    /* VOPDQUANT::DQDBEDGE */
   3346            uint32_t dq_binary_level : 1;   /* VOPDQUANT::DQBILEVEL */
   3347            uint32_t alt_pic_quantizer : 5;/* VOPDQUANT::ALTPQUANT */
   3348        } bits;
   3349        uint32_t value;
   3350    } pic_quantizer_fields;
   3351    union {
   3352        struct {
   3353            uint32_t variable_sized_transform_flag  : 1;/* ENTRY_POINT_LAYER::VSTRANSFORM */
   3354            uint32_t mb_level_transform_type_flag   : 1;/* PICTURE_LAYER::TTMBF */
   3355            uint32_t frame_level_transform_type : 2;/* PICTURE_LAYER::TTFRM */
   3356            uint32_t transform_ac_codingset_idx1    : 2;/* PICTURE_LAYER::TRANSACFRM */
   3357            uint32_t transform_ac_codingset_idx2    : 2;/* PICTURE_LAYER::TRANSACFRM2 */
   3358            uint32_t intra_transform_dc_table   : 1;/* PICTURE_LAYER::TRANSDCTAB */
   3359        } bits;
   3360        uint32_t value;
   3361    } transform_fields;
   3362 
   3363    uint8_t luma_scale2;                  /* PICTURE_LAYER::LUMSCALE2 */
   3364    uint8_t luma_shift2;                  /* PICTURE_LAYER::LUMSHIFT2 */
   3365    uint8_t intensity_compensation_field; /* Index for PICTURE_LAYER::INTCOMPFIELD value in Table 109 (9.1.1.48) */
   3366 
   3367    /** \brief Reserved bytes for future use, must be zero */
   3368    uint32_t                va_reserved[VA_PADDING_MEDIUM - 1];
   3369 } VAPictureParameterBufferVC1;
   3370 
   3371 /** VC-1 Bitplane Buffer
   3372 There will be at most three bitplanes coded in any picture header. To send
   3373 the bitplane data more efficiently, each byte is divided in two nibbles, with
   3374 each nibble carrying three bitplanes for one macroblock.  The following table
   3375 shows the bitplane data arrangement within each nibble based on the picture
   3376 type.
   3377 
   3378 Picture Type    Bit3        Bit2        Bit1        Bit0
   3379 I or BI             OVERFLAGS   ACPRED      FIELDTX
   3380 P               MYTYPEMB    SKIPMB      DIRECTMB
   3381 B               FORWARDMB   SKIPMB      DIRECTMB
   3382 
   3383 Within each byte, the lower nibble is for the first MB and the upper nibble is
   3384 for the second MB.  E.g. the lower nibble of the first byte in the bitplane
   3385 buffer is for Macroblock #1 and the upper nibble of the first byte is for
   3386 Macroblock #2 in the first row.
   3387 */
   3388 
   3389 /* VC-1 Slice Parameter Buffer */
   3390 typedef struct _VASliceParameterBufferVC1 {
   3391    uint32_t slice_data_size;/* number of bytes in the slice data buffer for this slice */
   3392    uint32_t slice_data_offset;/* the offset to the first byte of slice data */
   3393    uint32_t slice_data_flag; /* see VA_SLICE_DATA_FLAG_XXX defintions */
   3394    uint32_t macroblock_offset;/* the offset to the first bit of MB from the first byte of slice data */
   3395    uint32_t slice_vertical_position;
   3396 
   3397    /** \brief Reserved bytes for future use, must be zero */
   3398    uint32_t                va_reserved[VA_PADDING_LOW];
   3399 } VASliceParameterBufferVC1;
   3400 
   3401 /* VC-1 Slice Data Buffer */
   3402 /*
   3403 This is simplely a buffer containing raw bit-stream bytes
   3404 */
   3405 
   3406 /****************************
   3407 * H.264/AVC data structures
   3408 ****************************/
   3409 
   3410 typedef struct _VAPictureH264 {
   3411    VASurfaceID picture_id;
   3412    uint32_t frame_idx;
   3413    uint32_t flags;
   3414    int32_t TopFieldOrderCnt;
   3415    int32_t BottomFieldOrderCnt;
   3416 
   3417    /** \brief Reserved bytes for future use, must be zero */
   3418    uint32_t                va_reserved[VA_PADDING_LOW];
   3419 } VAPictureH264;
   3420 /* flags in VAPictureH264 could be OR of the following */
   3421 #define VA_PICTURE_H264_INVALID         0x00000001
   3422 #define VA_PICTURE_H264_TOP_FIELD       0x00000002
   3423 #define VA_PICTURE_H264_BOTTOM_FIELD        0x00000004
   3424 #define VA_PICTURE_H264_SHORT_TERM_REFERENCE    0x00000008
   3425 #define VA_PICTURE_H264_LONG_TERM_REFERENCE 0x00000010
   3426 
   3427 /** H.264 Picture Parameter Buffer */
   3428 /*
   3429 * For each picture, and before any slice data, a single
   3430 * picture parameter buffer must be send.
   3431 */
   3432 typedef struct _VAPictureParameterBufferH264 {
   3433    VAPictureH264 CurrPic;
   3434    VAPictureH264 ReferenceFrames[16];  /* in DPB */
   3435    uint16_t picture_width_in_mbs_minus1;
   3436    uint16_t picture_height_in_mbs_minus1;
   3437    uint8_t bit_depth_luma_minus8;
   3438    uint8_t bit_depth_chroma_minus8;
   3439    uint8_t num_ref_frames;
   3440    union {
   3441        struct {
   3442            uint32_t chroma_format_idc          : 2;
   3443            uint32_t residual_colour_transform_flag     : 1; /* Renamed to separate_colour_plane_flag in newer standard versions. */
   3444            uint32_t gaps_in_frame_num_value_allowed_flag   : 1;
   3445            uint32_t frame_mbs_only_flag            : 1;
   3446            uint32_t mb_adaptive_frame_field_flag       : 1;
   3447            uint32_t direct_8x8_inference_flag      : 1;
   3448            uint32_t MinLumaBiPredSize8x8           : 1; /* see A.3.3.2 */
   3449            uint32_t log2_max_frame_num_minus4      : 4;
   3450            uint32_t pic_order_cnt_type         : 2;
   3451            uint32_t log2_max_pic_order_cnt_lsb_minus4  : 4;
   3452            uint32_t delta_pic_order_always_zero_flag   : 1;
   3453        } bits;
   3454        uint32_t value;
   3455    } seq_fields;
   3456    // FMO is not supported.
   3457    va_deprecated uint8_t num_slice_groups_minus1;
   3458    va_deprecated uint8_t slice_group_map_type;
   3459    va_deprecated uint16_t slice_group_change_rate_minus1;
   3460    int8_t pic_init_qp_minus26;
   3461    int8_t pic_init_qs_minus26;
   3462    int8_t chroma_qp_index_offset;
   3463    int8_t second_chroma_qp_index_offset;
   3464    union {
   3465        struct {
   3466            uint32_t entropy_coding_mode_flag   : 1;
   3467            uint32_t weighted_pred_flag     : 1;
   3468            uint32_t weighted_bipred_idc        : 2;
   3469            uint32_t transform_8x8_mode_flag    : 1;
   3470            uint32_t field_pic_flag         : 1;
   3471            uint32_t constrained_intra_pred_flag    : 1;
   3472            uint32_t pic_order_present_flag         : 1; /* Renamed to bottom_field_pic_order_in_frame_present_flag in newer standard versions. */
   3473            uint32_t deblocking_filter_control_present_flag : 1;
   3474            uint32_t redundant_pic_cnt_present_flag     : 1;
   3475            uint32_t reference_pic_flag         : 1; /* nal_ref_idc != 0 */
   3476        } bits;
   3477        uint32_t value;
   3478    } pic_fields;
   3479    uint16_t frame_num;
   3480 
   3481    /** \brief Reserved bytes for future use, must be zero */
   3482    uint32_t                va_reserved[VA_PADDING_MEDIUM];
   3483 } VAPictureParameterBufferH264;
   3484 
   3485 /** H.264 Inverse Quantization Matrix Buffer */
   3486 typedef struct _VAIQMatrixBufferH264 {
   3487    /** \brief 4x4 scaling list, in raster scan order. */
   3488    uint8_t ScalingList4x4[6][16];
   3489    /** \brief 8x8 scaling list, in raster scan order. */
   3490    uint8_t ScalingList8x8[2][64];
   3491 
   3492    /** \brief Reserved bytes for future use, must be zero */
   3493    uint32_t                va_reserved[VA_PADDING_LOW];
   3494 } VAIQMatrixBufferH264;
   3495 
   3496 /** H.264 Slice Parameter Buffer */
   3497 typedef struct _VASliceParameterBufferH264 {
   3498    uint32_t slice_data_size;/* number of bytes in the slice data buffer for this slice */
   3499    /** \brief Byte offset to the NAL Header Unit for this slice. */
   3500    uint32_t slice_data_offset;
   3501    uint32_t slice_data_flag; /* see VA_SLICE_DATA_FLAG_XXX defintions */
   3502    /**
   3503     * \brief Bit offset from NAL Header Unit to the begining of slice_data().
   3504     *
   3505     * This bit offset is relative to and includes the NAL unit byte
   3506     * and represents the number of bits parsed in the slice_header()
   3507     * after the removal of any emulation prevention bytes in
   3508     * there. However, the slice data buffer passed to the hardware is
   3509     * the original bitstream, thus including any emulation prevention
   3510     * bytes.
   3511     */
   3512    uint16_t slice_data_bit_offset;
   3513    uint16_t first_mb_in_slice;
   3514    uint8_t slice_type;
   3515    uint8_t direct_spatial_mv_pred_flag;
   3516    /**
   3517     * H264/AVC syntax element
   3518     *
   3519     * if num_ref_idx_active_override_flag equals 0, host decoder should
   3520     * set its value to num_ref_idx_l0_default_active_minus1.
   3521     */
   3522    uint8_t num_ref_idx_l0_active_minus1;
   3523    /**
   3524     * H264/AVC syntax element
   3525     *
   3526     * if num_ref_idx_active_override_flag equals 0, host decoder should
   3527     * set its value to num_ref_idx_l1_default_active_minus1.
   3528     */
   3529    uint8_t num_ref_idx_l1_active_minus1;
   3530    uint8_t cabac_init_idc;
   3531    int8_t slice_qp_delta;
   3532    uint8_t disable_deblocking_filter_idc;
   3533    int8_t slice_alpha_c0_offset_div2;
   3534    int8_t slice_beta_offset_div2;
   3535    VAPictureH264 RefPicList0[32];  /* See 8.2.4.2 */
   3536    VAPictureH264 RefPicList1[32];  /* See 8.2.4.2 */
   3537    uint8_t luma_log2_weight_denom;
   3538    uint8_t chroma_log2_weight_denom;
   3539    uint8_t luma_weight_l0_flag;
   3540    int16_t luma_weight_l0[32];
   3541    int16_t luma_offset_l0[32];
   3542    uint8_t chroma_weight_l0_flag;
   3543    int16_t chroma_weight_l0[32][2];
   3544    int16_t chroma_offset_l0[32][2];
   3545    uint8_t luma_weight_l1_flag;
   3546    int16_t luma_weight_l1[32];
   3547    int16_t luma_offset_l1[32];
   3548    uint8_t chroma_weight_l1_flag;
   3549    int16_t chroma_weight_l1[32][2];
   3550    int16_t chroma_offset_l1[32][2];
   3551 
   3552    /** \brief Reserved bytes for future use, must be zero */
   3553    uint32_t                va_reserved[VA_PADDING_LOW];
   3554 } VASliceParameterBufferH264;
   3555 
   3556 /****************************
   3557 * Common encode data structures
   3558 ****************************/
   3559 typedef enum {
   3560    VAEncPictureTypeIntra       = 0,
   3561    VAEncPictureTypePredictive      = 1,
   3562    VAEncPictureTypeBidirectional   = 2,
   3563 } VAEncPictureType;
   3564 
   3565 /**
   3566 * \brief Encode Slice Parameter Buffer.
   3567 *
   3568 * @deprecated
   3569 * This is a deprecated encode slice parameter buffer, All applications
   3570 * \c can use VAEncSliceParameterBufferXXX (XXX = MPEG2, HEVC, H264, JPEG)
   3571 */
   3572 typedef struct _VAEncSliceParameterBuffer {
   3573    uint32_t start_row_number;  /* starting MB row number for this slice */
   3574    uint32_t slice_height;  /* slice height measured in MB */
   3575    union {
   3576        struct {
   3577            uint32_t is_intra   : 1;
   3578            uint32_t disable_deblocking_filter_idc : 2;
   3579            uint32_t uses_long_term_ref     : 1;
   3580            uint32_t is_long_term_ref       : 1;
   3581        } bits;
   3582        uint32_t value;
   3583    } slice_flags;
   3584 
   3585    /** \brief Reserved bytes for future use, must be zero */
   3586    uint32_t                va_reserved[VA_PADDING_LOW];
   3587 } VAEncSliceParameterBuffer;
   3588 
   3589 
   3590 /****************************
   3591 * H.263 specific encode data structures
   3592 ****************************/
   3593 
   3594 typedef struct _VAEncSequenceParameterBufferH263 {
   3595    uint32_t intra_period;
   3596    uint32_t bits_per_second;
   3597    uint32_t frame_rate;
   3598    uint32_t initial_qp;
   3599    uint32_t min_qp;
   3600 
   3601    /** \brief Reserved bytes for future use, must be zero */
   3602    uint32_t                va_reserved[VA_PADDING_LOW];
   3603 } VAEncSequenceParameterBufferH263;
   3604 
   3605 typedef struct _VAEncPictureParameterBufferH263 {
   3606    VASurfaceID reference_picture;
   3607    VASurfaceID reconstructed_picture;
   3608    VABufferID coded_buf;
   3609    uint16_t picture_width;
   3610    uint16_t picture_height;
   3611    VAEncPictureType picture_type;
   3612 
   3613    /** \brief Reserved bytes for future use, must be zero */
   3614    uint32_t                va_reserved[VA_PADDING_LOW];
   3615 } VAEncPictureParameterBufferH263;
   3616 
   3617 /****************************
   3618 * MPEG-4 specific encode data structures
   3619 ****************************/
   3620 
   3621 typedef struct _VAEncSequenceParameterBufferMPEG4 {
   3622    uint8_t profile_and_level_indication;
   3623    uint32_t intra_period;
   3624    uint32_t video_object_layer_width;
   3625    uint32_t video_object_layer_height;
   3626    uint32_t vop_time_increment_resolution;
   3627    uint32_t fixed_vop_rate;
   3628    uint32_t fixed_vop_time_increment;
   3629    uint32_t bits_per_second;
   3630    uint32_t frame_rate;
   3631    uint32_t initial_qp;
   3632    uint32_t min_qp;
   3633 
   3634    /** \brief Reserved bytes for future use, must be zero */
   3635    uint32_t                va_reserved[VA_PADDING_LOW];
   3636 } VAEncSequenceParameterBufferMPEG4;
   3637 
   3638 typedef struct _VAEncPictureParameterBufferMPEG4 {
   3639    VASurfaceID reference_picture;
   3640    VASurfaceID reconstructed_picture;
   3641    VABufferID coded_buf;
   3642    uint16_t picture_width;
   3643    uint16_t picture_height;
   3644    uint32_t modulo_time_base; /* number of 1s */
   3645    uint32_t vop_time_increment;
   3646    VAEncPictureType picture_type;
   3647 
   3648    /** \brief Reserved bytes for future use, must be zero */
   3649    uint32_t                va_reserved[VA_PADDING_LOW];
   3650 } VAEncPictureParameterBufferMPEG4;
   3651 
   3652 
   3653 
   3654 /** Buffer functions */
   3655 
   3656 /**
   3657 * Creates a buffer for "num_elements" elements of "size" bytes and
   3658 * initalize with "data".
   3659 * if "data" is null, then the contents of the buffer data store
   3660 * are undefined.
   3661 * Basically there are two ways to get buffer data to the server side. One is
   3662 * to call vaCreateBuffer() with a non-null "data", which results the data being
   3663 * copied to the data store on the server side.  A different method that
   3664 * eliminates this copy is to pass null as "data" when calling vaCreateBuffer(),
   3665 * and then use vaMapBuffer() to map the data store from the server side to the
   3666 * client address space for access.
   3667 * The user must call vaDestroyBuffer() to destroy a buffer.
   3668 *  Note: image buffers are created by the library, not the client. Please see
   3669 *        vaCreateImage on how image buffers are managed.
   3670 */
   3671 VAStatus vaCreateBuffer(
   3672    VADisplay dpy,
   3673    VAContextID context,
   3674    VABufferType type,  /* in */
   3675    unsigned int size,  /* in */
   3676    unsigned int num_elements, /* in */
   3677    void *data,     /* in */
   3678    VABufferID *buf_id  /* out */
   3679 );
   3680 
   3681 /**
   3682 * Create a buffer for given width & height get unit_size, pitch, buf_id for 2D buffer
   3683 * for permb qp buffer, it will return unit_size for one MB or LCU and the pitch for alignments
   3684 * can call vaMapBuffer with this Buffer ID to get virtual address.
   3685 * e.g. AVC 1080P encode, 1920x1088, the size in MB is 120x68,but inside driver,
   3686 * maybe it should align with 256, and one byte present one Qp.so, call the function.
   3687 * then get unit_size = 1, pitch = 256. call vaMapBuffer to get the virtual address (pBuf).
   3688 * then read write the memory like 2D. the size is 256x68, application can only use 120x68
   3689 * pBuf + 256 is the start of next line.
   3690 * different driver implementation maybe return different unit_size and pitch
   3691 */
   3692 VAStatus vaCreateBuffer2(
   3693    VADisplay dpy,
   3694    VAContextID context,
   3695    VABufferType type,
   3696    unsigned int width,
   3697    unsigned int height,
   3698    unsigned int *unit_size,
   3699    unsigned int *pitch,
   3700    VABufferID *buf_id
   3701 );
   3702 
   3703 /**
   3704 * Convey to the server how many valid elements are in the buffer.
   3705 * e.g. if multiple slice parameters are being held in a single buffer,
   3706 * this will communicate to the server the number of slice parameters
   3707 * that are valid in the buffer.
   3708 */
   3709 VAStatus vaBufferSetNumElements(
   3710    VADisplay dpy,
   3711    VABufferID buf_id,  /* in */
   3712    unsigned int num_elements /* in */
   3713 );
   3714 
   3715 
   3716 /**
   3717 * device independent data structure for codedbuffer
   3718 */
   3719 
   3720 /*
   3721 * FICTURE_AVE_QP(bit7-0): The average Qp value used during this frame
   3722 * LARGE_SLICE(bit8):At least one slice in the current frame was large
   3723 *              enough for the encoder to attempt to limit its size.
   3724 * SLICE_OVERFLOW(bit9): At least one slice in the current frame has
   3725 *              exceeded the maximum slice size specified.
   3726 * BITRATE_OVERFLOW(bit10): The peak bitrate was exceeded for this frame.
   3727 * BITRATE_HIGH(bit11): The frame size got within the safety margin of the maximum size (VCM only)
   3728 * AIR_MB_OVER_THRESHOLD: the number of MBs adapted to Intra MB
   3729 */
   3730 #define VA_CODED_BUF_STATUS_PICTURE_AVE_QP_MASK         0xff
   3731 #define VA_CODED_BUF_STATUS_LARGE_SLICE_MASK            0x100
   3732 #define VA_CODED_BUF_STATUS_SLICE_OVERFLOW_MASK         0x200
   3733 #define VA_CODED_BUF_STATUS_BITRATE_OVERFLOW        0x400
   3734 #define VA_CODED_BUF_STATUS_BITRATE_HIGH        0x800
   3735 /**
   3736 * \brief The frame has exceeded the maximum requested size.
   3737 *
   3738 * This flag indicates that the encoded frame size exceeds the value
   3739 * specified through a misc parameter buffer of type
   3740 * #VAEncMiscParameterTypeMaxFrameSize.
   3741 */
   3742 #define VA_CODED_BUF_STATUS_FRAME_SIZE_OVERFLOW         0x1000
   3743 /**
   3744 * \brief the bitstream is bad or corrupt.
   3745 */
   3746 #define VA_CODED_BUF_STATUS_BAD_BITSTREAM               0x8000
   3747 #define VA_CODED_BUF_STATUS_AIR_MB_OVER_THRESHOLD   0xff0000
   3748 
   3749 /**
   3750 * \brief The coded buffer segment status contains frame encoding passes number
   3751 *
   3752 * This is the mask to get the number of encoding passes from the coded
   3753 * buffer segment status.
   3754 * NUMBER_PASS(bit24~bit27): the number for encoding passes executed for the coded frame.
   3755 *
   3756 */
   3757 #define VA_CODED_BUF_STATUS_NUMBER_PASSES_MASK          0xf000000
   3758 
   3759 /**
   3760 * \brief The coded buffer segment contains a single NAL unit.
   3761 *
   3762 * This flag indicates that the coded buffer segment contains a
   3763 * single NAL unit. This flag might be useful to the user for
   3764 * processing the coded buffer.
   3765 */
   3766 #define VA_CODED_BUF_STATUS_SINGLE_NALU                 0x10000000
   3767 
   3768 /**
   3769 * \brief Coded buffer segment.
   3770 *
   3771 * #VACodedBufferSegment is an element of a linked list describing
   3772 * some information on the coded buffer. The coded buffer segment
   3773 * could contain either a single NAL unit, or more than one NAL unit.
   3774 * It is recommended (but not required) to return a single NAL unit
   3775 * in a coded buffer segment, and the implementation should set the
   3776 * VA_CODED_BUF_STATUS_SINGLE_NALU status flag if that is the case.
   3777 */
   3778 typedef  struct _VACodedBufferSegment  {
   3779    /**
   3780     * \brief Size of the data buffer in this segment (in bytes).
   3781     */
   3782    uint32_t        size;
   3783    /** \brief Bit offset into the data buffer where the video data starts. */
   3784    uint32_t        bit_offset;
   3785    /** \brief Status set by the driver. See \c VA_CODED_BUF_STATUS_*. */
   3786    uint32_t        status;
   3787    /** \brief Reserved for future use. */
   3788    uint32_t        reserved;
   3789    /** \brief Pointer to the start of the data buffer. */
   3790    void               *buf;
   3791    /**
   3792     * \brief Pointer to the next #VACodedBufferSegment element,
   3793     * or \c NULL if there is none.
   3794     */
   3795    void               *next;
   3796 
   3797    /** \brief Reserved bytes for future use, must be zero */
   3798    uint32_t                va_reserved[VA_PADDING_LOW];
   3799 } VACodedBufferSegment;
   3800 
   3801 /**
   3802 * Map data store of the buffer into the client's address space
   3803 * vaCreateBuffer() needs to be called with "data" set to NULL before
   3804 * calling vaMapBuffer()
   3805 *
   3806 * if buffer type is VAEncCodedBufferType, pbuf points to link-list of
   3807 * VACodedBufferSegment, and the list is terminated if "next" is NULL
   3808 */
   3809 VAStatus vaMapBuffer(
   3810    VADisplay dpy,
   3811    VABufferID buf_id,  /* in */
   3812    void **pbuf     /* out */
   3813 );
   3814 
   3815 /**
   3816 * After client making changes to a mapped data store, it needs to
   3817 * "Unmap" it to let the server know that the data is ready to be
   3818 * consumed by the server
   3819 */
   3820 VAStatus vaUnmapBuffer(
   3821    VADisplay dpy,
   3822    VABufferID buf_id   /* in */
   3823 );
   3824 
   3825 /**
   3826 * After this call, the buffer is deleted and this buffer_id is no longer valid
   3827 *
   3828 * A buffer can be re-used and sent to the server by another Begin/Render/End
   3829 * sequence if vaDestroyBuffer() is not called with this buffer.
   3830 *
   3831 * Note re-using a shared buffer (e.g. a slice data buffer) between the host and the
   3832 * hardware accelerator can result in performance dropping.
   3833 */
   3834 VAStatus vaDestroyBuffer(
   3835    VADisplay dpy,
   3836    VABufferID buffer_id
   3837 );
   3838 
   3839 /** \brief VA buffer information */
   3840 typedef struct {
   3841    /** \brief Buffer handle */
   3842    uintptr_t           handle;
   3843    /** \brief Buffer type (See \ref VABufferType). */
   3844    uint32_t            type;
   3845    /**
   3846     * \brief Buffer memory type (See \ref VASurfaceAttribMemoryType).
   3847     *
   3848     * On input to vaAcquireBufferHandle(), this field can serve as a hint
   3849     * to specify the set of memory types the caller is interested in.
   3850     * On successful return from vaAcquireBufferHandle(), the field is
   3851     * updated with the best matching memory type.
   3852     */
   3853    uint32_t            mem_type;
   3854    /** \brief Size of the underlying buffer. */
   3855    size_t              mem_size;
   3856 
   3857    /** \brief Reserved bytes for future use, must be zero */
   3858    uint32_t                va_reserved[VA_PADDING_LOW];
   3859 } VABufferInfo;
   3860 
   3861 /**
   3862 * \brief Acquires buffer handle for external API usage
   3863 *
   3864 * Locks the VA buffer object \ref buf_id for external API usage like
   3865 * EGL or OpenCL (OCL). This function is a synchronization point. This
   3866 * means that any pending operation is guaranteed to be completed
   3867 * prior to returning from the function.
   3868 *
   3869 * If the referenced VA buffer object is the backing store of a VA
   3870 * surface, then this function acts as if vaSyncSurface() on the
   3871 * parent surface was called first.
   3872 *
   3873 * The \ref VABufferInfo argument shall be zero'ed on input. On
   3874 * successful output, the data structure is filled in with all the
   3875 * necessary buffer level implementation details like handle, type,
   3876 * memory type and memory size.
   3877 *
   3878 * Note: the external API implementation, or the application, can
   3879 * express the memory types it is interested in by filling in the \ref
   3880 * mem_type field accordingly. On successful output, the memory type
   3881 * that fits best the request and that was used is updated in the \ref
   3882 * VABufferInfo data structure. If none of the supplied memory types
   3883 * is supported, then a \ref VA_STATUS_ERROR_UNSUPPORTED_MEMORY_TYPE
   3884 * error is returned.
   3885 *
   3886 * The \ref VABufferInfo data is valid until vaReleaseBufferHandle()
   3887 * is called. Besides, no additional operation is allowed on any of
   3888 * the buffer parent object until vaReleaseBufferHandle() is called.
   3889 * e.g. decoding into a VA surface backed with the supplied VA buffer
   3890 * object \ref buf_id would fail with a \ref VA_STATUS_ERROR_SURFACE_BUSY
   3891 * error.
   3892 *
   3893 * Possible errors:
   3894 * - \ref VA_STATUS_ERROR_UNIMPLEMENTED: the VA driver implementation
   3895 *   does not support this interface
   3896 * - \ref VA_STATUS_ERROR_INVALID_DISPLAY: an invalid display was supplied
   3897 * - \ref VA_STATUS_ERROR_INVALID_BUFFER: an invalid buffer was supplied
   3898 * - \ref VA_STATUS_ERROR_UNSUPPORTED_BUFFERTYPE: the implementation
   3899 *   does not support exporting buffers of the specified type
   3900 * - \ref VA_STATUS_ERROR_UNSUPPORTED_MEMORY_TYPE: none of the requested
   3901 *   memory types in \ref VABufferInfo.mem_type was supported
   3902 *
   3903 * @param[in] dpy               the VA display
   3904 * @param[in] buf_id            the VA buffer
   3905 * @param[in,out] buf_info      the associated VA buffer information
   3906 * @return VA_STATUS_SUCCESS if successful
   3907 */
   3908 VAStatus
   3909 vaAcquireBufferHandle(VADisplay dpy, VABufferID buf_id, VABufferInfo *buf_info);
   3910 
   3911 /**
   3912 * \brief Releases buffer after usage from external API
   3913 *
   3914 * Unlocks the VA buffer object \ref buf_id from external API usage like
   3915 * EGL or OpenCL (OCL). This function is a synchronization point. This
   3916 * means that any pending operation is guaranteed to be completed
   3917 * prior to returning from the function.
   3918 *
   3919 * The \ref VABufferInfo argument shall point to the original data
   3920 * structure that was obtained from vaAcquireBufferHandle(), unaltered.
   3921 * This is necessary so that the VA driver implementation could
   3922 * deallocate any resources that were needed.
   3923 *
   3924 * In any case, returning from this function invalidates any contents
   3925 * in \ref VABufferInfo. i.e. the underlyng buffer handle is no longer
   3926 * valid. Therefore, VA driver implementations are free to reset this
   3927 * data structure to safe defaults.
   3928 *
   3929 * Possible errors:
   3930 * - \ref VA_STATUS_ERROR_UNIMPLEMENTED: the VA driver implementation
   3931 *   does not support this interface
   3932 * - \ref VA_STATUS_ERROR_INVALID_DISPLAY: an invalid display was supplied
   3933 * - \ref VA_STATUS_ERROR_INVALID_BUFFER: an invalid buffer was supplied
   3934 * - \ref VA_STATUS_ERROR_UNSUPPORTED_BUFFERTYPE: the implementation
   3935 *   does not support exporting buffers of the specified type
   3936 *
   3937 * @param[in] dpy               the VA display
   3938 * @param[in] buf_id            the VA buffer
   3939 * @return VA_STATUS_SUCCESS if successful
   3940 */
   3941 VAStatus
   3942 vaReleaseBufferHandle(VADisplay dpy, VABufferID buf_id);
   3943 
   3944 /** @name vaExportSurfaceHandle() flags
   3945 *
   3946 * @{
   3947 */
   3948 /** Export surface to be read by external API. */
   3949 #define VA_EXPORT_SURFACE_READ_ONLY        0x0001
   3950 /** Export surface to be written by external API. */
   3951 #define VA_EXPORT_SURFACE_WRITE_ONLY       0x0002
   3952 /** Export surface to be both read and written by external API. */
   3953 #define VA_EXPORT_SURFACE_READ_WRITE       0x0003
   3954 /** Export surface with separate layers.
   3955 *
   3956 * For example, NV12 surfaces should be exported as two separate
   3957 * planes for luma and chroma.
   3958 */
   3959 #define VA_EXPORT_SURFACE_SEPARATE_LAYERS  0x0004
   3960 /** Export surface with composed layers.
   3961 *
   3962 * For example, NV12 surfaces should be exported as a single NV12
   3963 * composed object.
   3964 */
   3965 #define VA_EXPORT_SURFACE_COMPOSED_LAYERS  0x0008
   3966 
   3967 /** @} */
   3968 
   3969 /**
   3970 * \brief Export a handle to a surface for use with an external API
   3971 *
   3972 * The exported handles are owned by the caller, and the caller is
   3973 * responsible for freeing them when no longer needed (e.g. by closing
   3974 * DRM PRIME file descriptors).
   3975 *
   3976 * This does not perform any synchronisation.  If the contents of the
   3977 * surface will be read, vaSyncSurface() must be called before doing so.
   3978 * If the contents of the surface are written, then all operations must
   3979 * be completed externally before using the surface again by via VA-API
   3980 * functions.
   3981 *
   3982 * @param[in] dpy          VA display.
   3983 * @param[in] surface_id   Surface to export.
   3984 * @param[in] mem_type     Memory type to export to.
   3985 * @param[in] flags        Combination of flags to apply
   3986 *   (VA_EXPORT_SURFACE_*).
   3987 * @param[out] descriptor  Pointer to the descriptor structure to fill
   3988 *   with the handle details.  The type of this structure depends on
   3989 *   the value of mem_type.
   3990 *
   3991 * @return Status code:
   3992 * - VA_STATUS_SUCCESS:    Success.
   3993 * - VA_STATUS_ERROR_INVALID_DISPLAY:  The display is not valid.
   3994 * - VA_STATUS_ERROR_UNIMPLEMENTED:  The driver does not implement
   3995 *     this interface.
   3996 * - VA_STATUS_ERROR_INVALID_SURFACE:  The surface is not valid, or
   3997 *     the surface is not exportable in the specified way.
   3998 * - VA_STATUS_ERROR_UNSUPPORTED_MEMORY_TYPE:  The driver does not
   3999 *     support exporting surfaces to the specified memory type.
   4000 */
   4001 VAStatus vaExportSurfaceHandle(VADisplay dpy,
   4002                               VASurfaceID surface_id,
   4003                               uint32_t mem_type, uint32_t flags,
   4004                               void *descriptor);
   4005 
   4006 /**
   4007 * Render (Video Decode/Encode/Processing) Pictures
   4008 *
   4009 * A picture represents either a frame or a field.
   4010 *
   4011 * The Begin/Render/End sequence sends the video decode/encode/processing buffers
   4012 * to the server
   4013 */
   4014 
   4015 /**
   4016 * Get ready for a video pipeline
   4017 * - decode a picture to a target surface
   4018 * - encode a picture from a target surface
   4019 * - process a picture to a target surface
   4020 */
   4021 VAStatus vaBeginPicture(
   4022    VADisplay dpy,
   4023    VAContextID context,
   4024    VASurfaceID render_target
   4025 );
   4026 
   4027 /**
   4028 * Send video decode, encode or processing buffers to the server.
   4029 */
   4030 VAStatus vaRenderPicture(
   4031    VADisplay dpy,
   4032    VAContextID context,
   4033    VABufferID *buffers,
   4034    int num_buffers
   4035 );
   4036 
   4037 /**
   4038 * Make the end of rendering for a picture.
   4039 * The server should start processing all pending operations for this
   4040 * surface. This call is non-blocking. The client can start another
   4041 * Begin/Render/End sequence on a different render target.
   4042 * if VAContextID used in this function previously successfully passed
   4043 * vaMFAddContext call, real processing will be started during vaMFSubmit
   4044 */
   4045 VAStatus vaEndPicture(
   4046    VADisplay dpy,
   4047    VAContextID context
   4048 );
   4049 
   4050 /**
   4051 * Make the end of rendering for a pictures in contexts passed with submission.
   4052 * The server should start processing all pending operations for contexts.
   4053 * All contexts passed should be associated through vaMFAddContext
   4054 * and call sequence Begin/Render/End performed.
   4055 * This call is non-blocking. The client can start another
   4056 * Begin/Render/End/vaMFSubmit sequence on a different render targets.
   4057 * Return values:
   4058 * VA_STATUS_SUCCESS - operation successful, context was removed.
   4059 * VA_STATUS_ERROR_INVALID_CONTEXT - mf_context or one of contexts are invalid
   4060 * due to mf_context not created or one of contexts not assotiated with mf_context
   4061 * through vaAddContext.
   4062 * VA_STATUS_ERROR_INVALID_PARAMETER - one of context has not submitted it's frame
   4063 * through vaBeginPicture vaRenderPicture vaEndPicture call sequence.
   4064 * dpy: display
   4065 * mf_context: Multi-Frame context
   4066 * contexts: list of contexts submitting their tasks for multi-frame operation.
   4067 * num_contexts: number of passed contexts.
   4068 */
   4069 VAStatus vaMFSubmit(
   4070    VADisplay dpy,
   4071    VAMFContextID mf_context,
   4072    VAContextID * contexts,
   4073    int num_contexts
   4074 );
   4075 
   4076 /*
   4077 
   4078 Synchronization
   4079 
   4080 */
   4081 
   4082 /**
   4083 * This function blocks until all pending operations on the render target
   4084 * have been completed.  Upon return it is safe to use the render target for a
   4085 * different picture.
   4086 */
   4087 VAStatus vaSyncSurface(
   4088    VADisplay dpy,
   4089    VASurfaceID render_target
   4090 );
   4091 
   4092 /** \brief Indicates an infinite timeout. */
   4093 #define VA_TIMEOUT_INFINITE 0xFFFFFFFFFFFFFFFF
   4094 
   4095 /**
   4096 * \brief Synchronizes pending operations associated with the supplied surface.
   4097 *
   4098 * This function blocks during specified timeout (in nanoseconds) until
   4099 * all pending operations on the render target have been completed.
   4100 * If timeout is zero, the function returns immediately.
   4101 *
   4102 * Possible errors:
   4103 * - \ref VA_STATUS_ERROR_UNIMPLEMENTED: the VA driver implementation
   4104 *   does not support this interface
   4105 * - \ref VA_STATUS_ERROR_INVALID_DISPLAY: an invalid display was supplied
   4106 * - \ref VA_STATUS_ERROR_INVALID_SURFACE: an invalid surface was supplied
   4107 * - \ref VA_STATUS_ERROR_TIMEDOUT: synchronization is still in progress,
   4108 *   client should call the function again to complete synchronization
   4109 *
   4110 * @param[in] dpy         the VA display
   4111 * @param[in] surface     the surface for which synchronization is performed
   4112 * @param[in] timeout_ns  the timeout in nanoseconds
   4113 *
   4114 */
   4115 VAStatus vaSyncSurface2(
   4116    VADisplay dpy,
   4117    VASurfaceID surface,
   4118    uint64_t timeout_ns
   4119 );
   4120 
   4121 typedef enum {
   4122    VASurfaceRendering  = 1, /* Rendering in progress */
   4123    VASurfaceDisplaying = 2, /* Displaying in progress (not safe to render into it) */
   4124    /* this status is useful if surface is used as the source */
   4125    /* of an overlay */
   4126    VASurfaceReady  = 4, /* not being rendered or displayed */
   4127    VASurfaceSkipped    = 8  /* Indicate a skipped frame during encode */
   4128 } VASurfaceStatus;
   4129 
   4130 /**
   4131 * Find out any pending ops on the render target
   4132 */
   4133 VAStatus vaQuerySurfaceStatus(
   4134    VADisplay dpy,
   4135    VASurfaceID render_target,
   4136    VASurfaceStatus *status /* out */
   4137 );
   4138 
   4139 typedef enum {
   4140    VADecodeSliceMissing            = 0,
   4141    VADecodeMBError                 = 1,
   4142 } VADecodeErrorType;
   4143 
   4144 /**
   4145 * Client calls vaQuerySurfaceError with VA_STATUS_ERROR_DECODING_ERROR, server side returns
   4146 * an array of structure VASurfaceDecodeMBErrors, and the array is terminated by setting status=-1
   4147 */
   4148 typedef struct _VASurfaceDecodeMBErrors {
   4149    int32_t status; /* 1 if hardware has returned detailed info below, -1 means this record is invalid */
   4150    uint32_t start_mb; /* start mb address with errors */
   4151    uint32_t end_mb;  /* end mb address with errors */
   4152    VADecodeErrorType decode_error_type;
   4153    uint32_t num_mb;   /* number of mbs with errors */
   4154    /** \brief Reserved bytes for future use, must be zero */
   4155    uint32_t                va_reserved[VA_PADDING_LOW - 1];
   4156 } VASurfaceDecodeMBErrors;
   4157 
   4158 /**
   4159 * After the application gets VA_STATUS_ERROR_DECODING_ERROR after calling vaSyncSurface(),
   4160 * it can call vaQuerySurfaceError to find out further details on the particular error.
   4161 * VA_STATUS_ERROR_DECODING_ERROR should be passed in as "error_status",
   4162 * upon the return, error_info will point to an array of _VASurfaceDecodeMBErrors structure,
   4163 * which is allocated and filled by libVA with detailed information on the missing or error macroblocks.
   4164 * The array is terminated if "status==-1" is detected.
   4165 */
   4166 VAStatus vaQuerySurfaceError(
   4167    VADisplay dpy,
   4168    VASurfaceID surface,
   4169    VAStatus error_status,
   4170    void **error_info
   4171 );
   4172 
   4173 /**
   4174 * \brief Synchronizes pending operations associated with the supplied buffer.
   4175 *
   4176 * This function blocks during specified timeout (in nanoseconds) until
   4177 * all pending operations on the supplied buffer have been completed.
   4178 * If timeout is zero, the function returns immediately.
   4179 *
   4180 * Possible errors:
   4181 * - \ref VA_STATUS_ERROR_UNIMPLEMENTED: the VA driver implementation
   4182 *   does not support this interface
   4183 * - \ref VA_STATUS_ERROR_INVALID_DISPLAY: an invalid display was supplied
   4184 * - \ref VA_STATUS_ERROR_INVALID_BUFFER: an invalid buffer was supplied
   4185 * - \ref VA_STATUS_ERROR_TIMEDOUT: synchronization is still in progress,
   4186 *   client should call the function again to complete synchronization
   4187 *
   4188 * @param[in] dpy         the VA display
   4189 * @param[in] buf_id      the buffer for which synchronization is performed
   4190 * @param[in] timeout_ns  the timeout in nanoseconds
   4191 *
   4192 */
   4193 VAStatus vaSyncBuffer(
   4194    VADisplay dpy,
   4195    VABufferID buf_id,
   4196    uint64_t timeout_ns
   4197 );
   4198 
   4199 /**
   4200 * Notes about synchronization interfaces:
   4201 * vaSyncSurface:
   4202 * 1. Allows to synchronize output surface (i.e. from decoding or VP)
   4203 * 2. Allows to synchronize all bitstreams being encoded from the given input surface (1->N pipelines).
   4204 *
   4205 * vaSyncSurface2:
   4206 * 1. The same as vaSyncSurface but allows to specify a timeout
   4207 *
   4208 * vaSyncBuffer:
   4209 * 1. Allows to synchronize output buffer (e.g. bitstream from encoding).
   4210 *    Comparing to vaSyncSurface this function synchronizes given bitstream only.
   4211 */
   4212 
   4213 /**
   4214 * Images and Subpictures
   4215 * VAImage is used to either get the surface data to client memory, or
   4216 * to copy image data in client memory to a surface.
   4217 * Both images, subpictures and surfaces follow the same 2D coordinate system where origin
   4218 * is at the upper left corner with positive X to the right and positive Y down
   4219 */
   4220 #define VA_FOURCC(ch0, ch1, ch2, ch3) \
   4221    ((unsigned long)(unsigned char) (ch0) | ((unsigned long)(unsigned char) (ch1) << 8) | \
   4222    ((unsigned long)(unsigned char) (ch2) << 16) | ((unsigned long)(unsigned char) (ch3) << 24 ))
   4223 
   4224 /* Pre-defined fourcc codes. */
   4225 
   4226 /** NV12: two-plane 8-bit YUV 4:2:0.
   4227 * The first plane contains Y, the second plane contains U and V in pairs of bytes.
   4228 */
   4229 #define VA_FOURCC_NV12      0x3231564E
   4230 /** NV21: two-plane 8-bit YUV 4:2:0.
   4231 * Same as NV12, but with U and V swapped.
   4232 */
   4233 #define VA_FOURCC_NV21      0x3132564E
   4234 
   4235 /** AI44: packed 4-bit YA.
   4236 *
   4237 * The bottom half of each byte contains luma, the top half contains alpha.
   4238 */
   4239 #define VA_FOURCC_AI44      0x34344149
   4240 
   4241 /** RGBA: packed 8-bit RGBA.
   4242 *
   4243 * Four bytes per pixel: red, green, blue, alpha.
   4244 */
   4245 #define VA_FOURCC_RGBA      0x41424752
   4246 /** RGBX: packed 8-bit RGB.
   4247 *
   4248 * Four bytes per pixel: red, green, blue, unspecified.
   4249 */
   4250 #define VA_FOURCC_RGBX      0x58424752
   4251 /** BGRA: packed 8-bit RGBA.
   4252 *
   4253 * Four bytes per pixel: blue, green, red, alpha.
   4254 */
   4255 #define VA_FOURCC_BGRA      0x41524742
   4256 /** BGRX: packed 8-bit RGB.
   4257 *
   4258 * Four bytes per pixel: blue, green, red, unspecified.
   4259 */
   4260 #define VA_FOURCC_BGRX      0x58524742
   4261 /** ARGB: packed 8-bit RGBA.
   4262 *
   4263 * Four bytes per pixel: alpha, red, green, blue.
   4264 */
   4265 #define VA_FOURCC_ARGB      0x42475241
   4266 /** XRGB: packed 8-bit RGB.
   4267 *
   4268 * Four bytes per pixel: unspecified, red, green, blue.
   4269 */
   4270 #define VA_FOURCC_XRGB      0x42475258
   4271 /** ABGR: packed 8-bit RGBA.
   4272 *
   4273 * Four bytes per pixel: alpha, blue, green, red.
   4274 */
   4275 #define VA_FOURCC_ABGR          0x52474241
   4276 /** XBGR: packed 8-bit RGB.
   4277 *
   4278 * Four bytes per pixel: unspecified, blue, green, red.
   4279 */
   4280 #define VA_FOURCC_XBGR          0x52474258
   4281 
   4282 /** UYUV: packed 8-bit YUV 4:2:2.
   4283 *
   4284 * Four bytes per pair of pixels: U, Y, U, V.
   4285 */
   4286 #define VA_FOURCC_UYVY          0x59565955
   4287 /** YUY2: packed 8-bit YUV 4:2:2.
   4288 *
   4289 * Four bytes per pair of pixels: Y, U, Y, V.
   4290 */
   4291 #define VA_FOURCC_YUY2          0x32595559
   4292 /** AYUV: packed 8-bit YUVA 4:4:4.
   4293 *
   4294 * Four bytes per pixel: A, Y, U, V.
   4295 */
   4296 #define VA_FOURCC_AYUV          0x56555941
   4297 /** NV11: two-plane 8-bit YUV 4:1:1.
   4298 *
   4299 * The first plane contains Y, the second plane contains U and V in pairs of bytes.
   4300 */
   4301 #define VA_FOURCC_NV11          0x3131564e
   4302 /** YV12: three-plane 8-bit YUV 4:2:0.
   4303 *
   4304 * The three planes contain Y, V and U respectively.
   4305 */
   4306 #define VA_FOURCC_YV12          0x32315659
   4307 /** P208: two-plane 8-bit YUV 4:2:2.
   4308 *
   4309 * The first plane contains Y, the second plane contains U and V in pairs of bytes.
   4310 */
   4311 #define VA_FOURCC_P208          0x38303250
   4312 /** I420: three-plane 8-bit YUV 4:2:0.
   4313 *
   4314 * The three planes contain Y, U and V respectively.
   4315 */
   4316 #define VA_FOURCC_I420          0x30323449
   4317 /** YV24: three-plane 8-bit YUV 4:4:4.
   4318 *
   4319 * The three planes contain Y, V and U respectively.
   4320 */
   4321 #define VA_FOURCC_YV24          0x34325659
   4322 /** YV32: four-plane 8-bit YUVA 4:4:4
   4323 *
   4324 * The four planes contain Y, V, U and A respectively.
   4325 */
   4326 #define VA_FOURCC_YV32          0x32335659
   4327 /** Y800: 8-bit greyscale.
   4328 */
   4329 #define VA_FOURCC_Y800          0x30303859
   4330 /** IMC3: three-plane 8-bit YUV 4:2:0.
   4331 *
   4332 * Equivalent to YV12, but with the additional constraint that the pitch of all three planes
   4333 * must be the same.
   4334 */
   4335 #define VA_FOURCC_IMC3          0x33434D49
   4336 /** 411P: three-plane 8-bit YUV 4:1:1.
   4337 *
   4338 * The three planes contain Y, U and V respectively.
   4339 */
   4340 #define VA_FOURCC_411P          0x50313134
   4341 /** 411R: three-plane 8-bit YUV.
   4342 *
   4343 * The subsampling is the transpose of 4:1:1 - full chroma appears on every fourth line.
   4344 * The three planes contain Y, U and V respectively.
   4345 */
   4346 #define VA_FOURCC_411R          0x52313134
   4347 /** 422H: three-plane 8-bit YUV 4:2:2.
   4348 *
   4349 * The three planes contain Y, U and V respectively.
   4350 */
   4351 #define VA_FOURCC_422H          0x48323234
   4352 /** 422V: three-plane 8-bit YUV 4:4:0.
   4353 *
   4354 * The three planes contain Y, U and V respectively.
   4355 */
   4356 #define VA_FOURCC_422V          0x56323234
   4357 /** 444P: three-plane 8-bit YUV 4:4:4.
   4358 *
   4359 * The three planes contain Y, U and V respectively.
   4360 */
   4361 #define VA_FOURCC_444P          0x50343434
   4362 
   4363 /** RGBP: three-plane 8-bit RGB.
   4364 *
   4365 * The three planes contain red, green and blue respectively.
   4366 */
   4367 #define VA_FOURCC_RGBP          0x50424752
   4368 /** BGRP: three-plane 8-bit RGB.
   4369 *
   4370 * The three planes contain blue, green and red respectively.
   4371 */
   4372 #define VA_FOURCC_BGRP          0x50524742
   4373 /** RG16: packed 5/6-bit RGB.
   4374 *
   4375 * Each pixel is a two-byte little-endian value.
   4376 * Red, green and blue are found in bits 15:11, 10:5, 4:0 respectively.
   4377 */
   4378 #define VA_FOURCC_RGB565        0x36314752
   4379 /** BG16: packed 5/6-bit RGB.
   4380 *
   4381 * Each pixel is a two-byte little-endian value.
   4382 * Blue, green and red are found in bits 15:11, 10:5, 4:0 respectively.
   4383 */
   4384 #define VA_FOURCC_BGR565        0x36314742
   4385 
   4386 /** Y210: packed 10-bit YUV 4:2:2.
   4387 *
   4388 * Eight bytes represent a pair of pixels.  Each sample is a two-byte little-endian value,
   4389 * with the bottom six bits ignored.  The samples are in the order Y, U, Y, V.
   4390 */
   4391 #define VA_FOURCC_Y210          0x30313259
   4392 /** Y212: packed 12-bit YUV 4:2:2.
   4393 *
   4394 * Eight bytes represent a pair of pixels.  Each sample is a two-byte little-endian value.
   4395 * The samples are in the order Y, U, Y, V.
   4396 */
   4397 #define VA_FOURCC_Y212          0x32313259
   4398 /** Y216: packed 16-bit YUV 4:2:2.
   4399 *
   4400 * Eight bytes represent a pair of pixels.  Each sample is a two-byte little-endian value.
   4401 * The samples are in the order Y, U, Y, V.
   4402 */
   4403 #define VA_FOURCC_Y216          0x36313259
   4404 /** Y410: packed 10-bit YUVA 4:4:4.
   4405 *
   4406 * Each pixel is a four-byte little-endian value.
   4407 * A, V, Y, U are found in bits 31:30, 29:20, 19:10, 9:0 respectively.
   4408 */
   4409 #define VA_FOURCC_Y410          0x30313459
   4410 /** Y412 packed 12-bit YUVA 4:4:4.
   4411 *
   4412 * Each pixel is a set of four samples, each of which is a two-byte little-endian value.
   4413 * The samples are in the order A, V, Y, U.
   4414 */
   4415 #define VA_FOURCC_Y412          0x32313459
   4416 /** Y416: packed 16-bit YUVA 4:4:4.
   4417 *
   4418 * Each pixel is a set of four samples, each of which is a two-byte little-endian value.
   4419 * The samples are in the order A, V, Y, U.
   4420 */
   4421 #define VA_FOURCC_Y416          0x36313459
   4422 
   4423 /** YV16: three-plane 8-bit YUV 4:2:2.
   4424 *
   4425 * The three planes contain Y, V and U respectively.
   4426 */
   4427 #define VA_FOURCC_YV16          0x36315659
   4428 /** P010: two-plane 10-bit YUV 4:2:0.
   4429 *
   4430 * Each sample is a two-byte little-endian value with the bottom six bits ignored.
   4431 * The first plane contains Y, the second plane contains U and V in pairs of samples.
   4432 */
   4433 #define VA_FOURCC_P010          0x30313050
   4434 /** P012: two-plane 12-bit YUV 4:2:0.
   4435 *
   4436 * Each sample is a two-byte little-endian value with the bottom four bits ignored.
   4437 * The first plane contains Y, the second plane contains U and V in pairs of samples.
   4438 */
   4439 #define VA_FOURCC_P012          0x32313050
   4440 /** P016: two-plane 16-bit YUV 4:2:0.
   4441 *
   4442 * Each sample is a two-byte little-endian value.  The first plane contains Y, the second
   4443 * plane contains U and V in pairs of samples.
   4444 */
   4445 #define VA_FOURCC_P016          0x36313050
   4446 
   4447 /** I010: three-plane 10-bit YUV 4:2:0.
   4448 *
   4449 * Each sample is a two-byte little-endian value with the top six bits ignored.
   4450 * The three planes contain Y, V and U respectively.
   4451 */
   4452 #define VA_FOURCC_I010          0x30313049
   4453 
   4454 /** IYUV: three-plane 8-bit YUV 4:2:0.
   4455 *
   4456 * @deprecated Use I420 instead.
   4457 */
   4458 #define VA_FOURCC_IYUV          0x56555949
   4459 /**
   4460 * 10-bit Pixel RGB formats.
   4461 */
   4462 #define VA_FOURCC_A2R10G10B10   0x30335241 /* VA_FOURCC('A','R','3','0') */
   4463 /**
   4464 * 10-bit Pixel BGR formats.
   4465 */
   4466 #define VA_FOURCC_A2B10G10R10   0x30334241 /* VA_FOURCC('A','B','3','0') */
   4467 /**
   4468 * 10-bit Pixel RGB formats without alpha.
   4469 */
   4470 #define VA_FOURCC_X2R10G10B10   0x30335258 /* VA_FOURCC('X','R','3','0') */
   4471 /**
   4472 * 10-bit Pixel BGR formats without alpha.
   4473 */
   4474 #define VA_FOURCC_X2B10G10R10   0x30334258 /* VA_FOURCC('X','B','3','0') */
   4475 
   4476 /** Y8: 8-bit greyscale.
   4477 *
   4478 * Only a single sample, 8 bit Y plane for monochrome images
   4479 */
   4480 #define VA_FOURCC_Y8            0x20203859
   4481 /** Y16: 16-bit greyscale.
   4482 *
   4483 * Only a single sample, 16 bit Y plane for monochrome images
   4484 */
   4485 #define VA_FOURCC_Y16           0x20363159
   4486 /** VYUV: packed 8-bit YUV 4:2:2.
   4487 *
   4488 * Four bytes per pair of pixels: V, Y, U, V.
   4489 */
   4490 #define VA_FOURCC_VYUY          0x59555956
   4491 /** YVYU: packed 8-bit YUV 4:2:2.
   4492 *
   4493 * Four bytes per pair of pixels: Y, V, Y, U.
   4494 */
   4495 #define VA_FOURCC_YVYU          0x55595659
   4496 /** AGRB64: three-plane 16-bit ARGB 16:16:16:16
   4497 *
   4498 * The four planes contain: alpha, red, green, blue respectively.
   4499 */
   4500 #define VA_FOURCC_ARGB64        0x34475241
   4501 /** ABGR64: three-plane 16-bit ABGR 16:16:16:16
   4502 *
   4503 * The four planes contain: alpha, blue, green, red respectively.
   4504 */
   4505 #define VA_FOURCC_ABGR64        0x34474241
   4506 /** XYUV: packed 8-bit YUVX 4:4:4.
   4507 *
   4508 * Four bytes per pixel: X, Y, U, V.
   4509 */
   4510 #define VA_FOURCC_XYUV          0x56555958
   4511 
   4512 /* byte order */
   4513 #define VA_LSB_FIRST        1
   4514 #define VA_MSB_FIRST        2
   4515 
   4516 typedef struct _VAImageFormat {
   4517    uint32_t    fourcc;
   4518    uint32_t    byte_order; /* VA_LSB_FIRST, VA_MSB_FIRST */
   4519    uint32_t    bits_per_pixel;
   4520    /* for RGB formats */
   4521    uint32_t    depth; /* significant bits per pixel */
   4522    uint32_t    red_mask;
   4523    uint32_t    green_mask;
   4524    uint32_t    blue_mask;
   4525    uint32_t    alpha_mask;
   4526 
   4527    /** \brief Reserved bytes for future use, must be zero */
   4528    uint32_t                va_reserved[VA_PADDING_LOW];
   4529 } VAImageFormat;
   4530 
   4531 typedef VAGenericID VAImageID;
   4532 
   4533 typedef struct _VAImage {
   4534    VAImageID       image_id; /* uniquely identify this image */
   4535    VAImageFormat   format;
   4536    VABufferID      buf;    /* image data buffer */
   4537    /*
   4538     * Image data will be stored in a buffer of type VAImageBufferType to facilitate
   4539     * data store on the server side for optimal performance. The buffer will be
   4540     * created by the CreateImage function, and proper storage allocated based on the image
   4541     * size and format. This buffer is managed by the library implementation, and
   4542     * accessed by the client through the buffer Map/Unmap functions.
   4543     */
   4544    uint16_t    width;
   4545    uint16_t    height;
   4546    uint32_t    data_size;
   4547    uint32_t    num_planes; /* can not be greater than 3 */
   4548    /*
   4549     * An array indicating the scanline pitch in bytes for each plane.
   4550     * Each plane may have a different pitch. Maximum 3 planes for planar formats
   4551     */
   4552    uint32_t    pitches[3];
   4553    /*
   4554     * An array indicating the byte offset from the beginning of the image data
   4555     * to the start of each plane.
   4556     */
   4557    uint32_t    offsets[3];
   4558 
   4559    /* The following fields are only needed for paletted formats */
   4560    int32_t num_palette_entries;   /* set to zero for non-palette images */
   4561    /*
   4562     * Each component is one byte and entry_bytes indicates the number of components in
   4563     * each entry (eg. 3 for YUV palette entries). set to zero for non-palette images
   4564     */
   4565    int32_t entry_bytes;
   4566    /*
   4567     * An array of ascii characters describing the order of the components within the bytes.
   4568     * Only entry_bytes characters of the string are used.
   4569     */
   4570    int8_t component_order[4];
   4571 
   4572    /** \brief Reserved bytes for future use, must be zero */
   4573    uint32_t                va_reserved[VA_PADDING_LOW];
   4574 } VAImage;
   4575 
   4576 /** Get maximum number of image formats supported by the implementation */
   4577 int vaMaxNumImageFormats(
   4578    VADisplay dpy
   4579 );
   4580 
   4581 /**
   4582 * Query supported image formats
   4583 * The caller must provide a "format_list" array that can hold at
   4584 * least vaMaxNumImageFormats() entries. The actual number of formats
   4585 * returned in "format_list" is returned in "num_formats".
   4586 */
   4587 VAStatus vaQueryImageFormats(
   4588    VADisplay dpy,
   4589    VAImageFormat *format_list, /* out */
   4590    int *num_formats        /* out */
   4591 );
   4592 
   4593 /**
   4594 * Create a VAImage structure
   4595 * The width and height fields returned in the VAImage structure may get
   4596 * enlarged for some YUV formats. Upon return from this function,
   4597 * image->buf has been created and proper storage allocated by the library.
   4598 * The client can access the image through the Map/Unmap calls.
   4599 */
   4600 VAStatus vaCreateImage(
   4601    VADisplay dpy,
   4602    VAImageFormat *format,
   4603    int width,
   4604    int height,
   4605    VAImage *image  /* out */
   4606 );
   4607 
   4608 /**
   4609 * Should call DestroyImage before destroying the surface it is bound to
   4610 */
   4611 VAStatus vaDestroyImage(
   4612    VADisplay dpy,
   4613    VAImageID image
   4614 );
   4615 
   4616 VAStatus vaSetImagePalette(
   4617    VADisplay dpy,
   4618    VAImageID image,
   4619    /*
   4620     * pointer to an array holding the palette data.  The size of the array is
   4621     * num_palette_entries * entry_bytes in size.  The order of the components
   4622     * in the palette is described by the component_order in VAImage struct
   4623     */
   4624    unsigned char *palette
   4625 );
   4626 
   4627 /**
   4628 * Retrive surface data into a VAImage
   4629 * Image must be in a format supported by the implementation
   4630 */
   4631 VAStatus vaGetImage(
   4632    VADisplay dpy,
   4633    VASurfaceID surface,
   4634    int x,  /* coordinates of the upper left source pixel */
   4635    int y,
   4636    unsigned int width, /* width and height of the region */
   4637    unsigned int height,
   4638    VAImageID image
   4639 );
   4640 
   4641 /**
   4642 * Copy data from a VAImage to a surface
   4643 * Image must be in a format supported by the implementation
   4644 * Returns a VA_STATUS_ERROR_SURFACE_BUSY if the surface
   4645 * shouldn't be rendered into when this is called
   4646 */
   4647 VAStatus vaPutImage(
   4648    VADisplay dpy,
   4649    VASurfaceID surface,
   4650    VAImageID image,
   4651    int src_x,
   4652    int src_y,
   4653    unsigned int src_width,
   4654    unsigned int src_height,
   4655    int dest_x,
   4656    int dest_y,
   4657    unsigned int dest_width,
   4658    unsigned int dest_height
   4659 );
   4660 
   4661 /**
   4662 * Derive an VAImage from an existing surface.
   4663 * This interface will derive a VAImage and corresponding image buffer from
   4664 * an existing VA Surface. The image buffer can then be mapped/unmapped for
   4665 * direct CPU access. This operation is only possible on implementations with
   4666 * direct rendering capabilities and internal surface formats that can be
   4667 * represented with a VAImage. When the operation is not possible this interface
   4668 * will return VA_STATUS_ERROR_OPERATION_FAILED. Clients should then fall back
   4669 * to using vaCreateImage + vaPutImage to accomplish the same task in an
   4670 * indirect manner.
   4671 *
   4672 * Implementations should only return success when the resulting image buffer
   4673 * would be useable with vaMap/Unmap.
   4674 *
   4675 * When directly accessing a surface special care must be taken to insure
   4676 * proper synchronization with the graphics hardware. Clients should call
   4677 * vaQuerySurfaceStatus to insure that a surface is not the target of concurrent
   4678 * rendering or currently being displayed by an overlay.
   4679 *
   4680 * Additionally nothing about the contents of a surface should be assumed
   4681 * following a vaPutSurface. Implementations are free to modify the surface for
   4682 * scaling or subpicture blending within a call to vaPutImage.
   4683 *
   4684 * Calls to vaPutImage or vaGetImage using the same surface from which the image
   4685 * has been derived will return VA_STATUS_ERROR_SURFACE_BUSY. vaPutImage or
   4686 * vaGetImage with other surfaces is supported.
   4687 *
   4688 * An image created with vaDeriveImage should be freed with vaDestroyImage. The
   4689 * image and image buffer structures will be destroyed; however, the underlying
   4690 * surface will remain unchanged until freed with vaDestroySurfaces.
   4691 */
   4692 VAStatus vaDeriveImage(
   4693    VADisplay dpy,
   4694    VASurfaceID surface,
   4695    VAImage *image  /* out */
   4696 );
   4697 
   4698 /**
   4699 * Subpictures
   4700 * Subpicture is a special type of image that can be blended
   4701 * with a surface during vaPutSurface(). Subpicture can be used to render
   4702 * DVD sub-titles or closed captioning text etc.
   4703 */
   4704 
   4705 typedef VAGenericID VASubpictureID;
   4706 
   4707 /** Get maximum number of subpicture formats supported by the implementation */
   4708 int vaMaxNumSubpictureFormats(
   4709    VADisplay dpy
   4710 );
   4711 
   4712 /** flags for subpictures */
   4713 #define VA_SUBPICTURE_CHROMA_KEYING         0x0001
   4714 #define VA_SUBPICTURE_GLOBAL_ALPHA          0x0002
   4715 #define VA_SUBPICTURE_DESTINATION_IS_SCREEN_COORD   0x0004
   4716 /**
   4717 * Query supported subpicture formats
   4718 * The caller must provide a "format_list" array that can hold at
   4719 * least vaMaxNumSubpictureFormats() entries. The flags arrary holds the flag
   4720 * for each format to indicate additional capabilities for that format. The actual
   4721 * number of formats returned in "format_list" is returned in "num_formats".
   4722 *  flags: returned value to indicate addtional capabilities
   4723 *         VA_SUBPICTURE_CHROMA_KEYING - supports chroma-keying
   4724 *         VA_SUBPICTURE_GLOBAL_ALPHA - supports global alpha
   4725 *     VA_SUBPICTURE_DESTINATION_IS_SCREEN_COORD - supports unscaled screen relative subpictures for On Screen Display
   4726 */
   4727 
   4728 VAStatus vaQuerySubpictureFormats(
   4729    VADisplay dpy,
   4730    VAImageFormat *format_list, /* out */
   4731    unsigned int *flags,    /* out */
   4732    unsigned int *num_formats   /* out */
   4733 );
   4734 
   4735 /**
   4736 * Subpictures are created with an image associated.
   4737 */
   4738 VAStatus vaCreateSubpicture(
   4739    VADisplay dpy,
   4740    VAImageID image,
   4741    VASubpictureID *subpicture  /* out */
   4742 );
   4743 
   4744 /**
   4745 * Destroy the subpicture before destroying the image it is assocated to
   4746 */
   4747 VAStatus vaDestroySubpicture(
   4748    VADisplay dpy,
   4749    VASubpictureID subpicture
   4750 );
   4751 
   4752 /**
   4753 * Bind an image to the subpicture. This image will now be associated with
   4754 * the subpicture instead of the one at creation.
   4755 */
   4756 VAStatus vaSetSubpictureImage(
   4757    VADisplay dpy,
   4758    VASubpictureID subpicture,
   4759    VAImageID image
   4760 );
   4761 
   4762 /**
   4763 * If chromakey is enabled, then the area where the source value falls within
   4764 * the chromakey [min, max] range is transparent
   4765 * The chromakey component format is the following:
   4766 *  For RGB: [0:7] Red [8:15] Blue [16:23] Green
   4767 *  For YUV: [0:7] V [8:15] U [16:23] Y
   4768 * The chromakey mask can be used to mask out certain components for chromakey
   4769 * comparision
   4770 */
   4771 VAStatus vaSetSubpictureChromakey(
   4772    VADisplay dpy,
   4773    VASubpictureID subpicture,
   4774    unsigned int chromakey_min,
   4775    unsigned int chromakey_max,
   4776    unsigned int chromakey_mask
   4777 );
   4778 
   4779 /**
   4780 * Global alpha value is between 0 and 1. A value of 1 means fully opaque and
   4781 * a value of 0 means fully transparent. If per-pixel alpha is also specified then
   4782 * the overall alpha is per-pixel alpha multiplied by the global alpha
   4783 */
   4784 VAStatus vaSetSubpictureGlobalAlpha(
   4785    VADisplay dpy,
   4786    VASubpictureID subpicture,
   4787    float global_alpha
   4788 );
   4789 
   4790 /**
   4791 * vaAssociateSubpicture associates the subpicture with target_surfaces.
   4792 * It defines the region mapping between the subpicture and the target
   4793 * surfaces through source and destination rectangles (with the same width and height).
   4794 * Both will be displayed at the next call to vaPutSurface.  Additional
   4795 * associations before the call to vaPutSurface simply overrides the association.
   4796 */
   4797 VAStatus vaAssociateSubpicture(
   4798    VADisplay dpy,
   4799    VASubpictureID subpicture,
   4800    VASurfaceID *target_surfaces,
   4801    int num_surfaces,
   4802    int16_t src_x, /* upper left offset in subpicture */
   4803    int16_t src_y,
   4804    uint16_t src_width,
   4805    uint16_t src_height,
   4806    int16_t dest_x, /* upper left offset in surface */
   4807    int16_t dest_y,
   4808    uint16_t dest_width,
   4809    uint16_t dest_height,
   4810    /*
   4811     * whether to enable chroma-keying, global-alpha, or screen relative mode
   4812     * see VA_SUBPICTURE_XXX values
   4813     */
   4814    uint32_t flags
   4815 );
   4816 
   4817 /**
   4818 * vaDeassociateSubpicture removes the association of the subpicture with target_surfaces.
   4819 */
   4820 VAStatus vaDeassociateSubpicture(
   4821    VADisplay dpy,
   4822    VASubpictureID subpicture,
   4823    VASurfaceID *target_surfaces,
   4824    int num_surfaces
   4825 );
   4826 
   4827 /**
   4828 * Display attributes
   4829 * Display attributes are used to control things such as contrast, hue, saturation,
   4830 * brightness etc. in the rendering process.  The application can query what
   4831 * attributes are supported by the driver, and then set the appropriate attributes
   4832 * before calling vaPutSurface()
   4833 *
   4834 * Display attributes can also be used to query/set platform or display adaptor (vaDisplay)
   4835 * related information. These attributes do not depend on vaConfig, and could not be used
   4836 * for vaPutSurface. Application can use vaQueryDisplayAttributes/vaGetDisplayAttributes
   4837 * at anytime after vaInitialize, but (for settable attributes) vaSetDisplayAttributes should be
   4838 * called after vaInitialize and before any other function call.
   4839 *
   4840 * To distinguish these two types of display attributes, display adaptor related attributes
   4841 * should be marked as "HW attribute" in the description.
   4842 */
   4843 
   4844 /* PowerVR IEP Lite attributes */
   4845 typedef enum {
   4846    VADISPLAYATTRIB_BLE_OFF              = 0x00,
   4847    VADISPLAYATTRIB_BLE_LOW,
   4848    VADISPLAYATTRIB_BLE_MEDIUM,
   4849    VADISPLAYATTRIB_BLE_HIGH,
   4850    VADISPLAYATTRIB_BLE_NONE,
   4851 } VADisplayAttribBLEMode;
   4852 
   4853 /** attribute value for VADisplayAttribRotation   */
   4854 #define VA_ROTATION_NONE        0x00000000
   4855 #define VA_ROTATION_90          0x00000001
   4856 #define VA_ROTATION_180         0x00000002
   4857 #define VA_ROTATION_270         0x00000003
   4858 /**@}*/
   4859 
   4860 /**
   4861 * @name Mirroring directions
   4862 *
   4863 * Those values could be used for VADisplayAttribMirror attribute or
   4864 * VAProcPipelineParameterBuffer::mirror_state.
   4865 
   4866 */
   4867 /**@{*/
   4868 /** \brief No Mirroring. */
   4869 #define VA_MIRROR_NONE              0x00000000
   4870 /** \brief Horizontal Mirroring. */
   4871 #define VA_MIRROR_HORIZONTAL        0x00000001
   4872 /** \brief Vertical Mirroring. */
   4873 #define VA_MIRROR_VERTICAL          0x00000002
   4874 /**@}*/
   4875 
   4876 /** attribute value for VADisplayAttribOutOfLoopDeblock */
   4877 #define VA_OOL_DEBLOCKING_FALSE 0x00000000
   4878 #define VA_OOL_DEBLOCKING_TRUE  0x00000001
   4879 
   4880 /** Render mode */
   4881 #define VA_RENDER_MODE_UNDEFINED           0
   4882 #define VA_RENDER_MODE_LOCAL_OVERLAY       1
   4883 #define VA_RENDER_MODE_LOCAL_GPU           2
   4884 #define VA_RENDER_MODE_EXTERNAL_OVERLAY    4
   4885 #define VA_RENDER_MODE_EXTERNAL_GPU        8
   4886 
   4887 /** Render device */
   4888 #define VA_RENDER_DEVICE_UNDEFINED  0
   4889 #define VA_RENDER_DEVICE_LOCAL      1
   4890 #define VA_RENDER_DEVICE_EXTERNAL   2
   4891 
   4892 /**\brief sub device info
   4893 * Sub-device is the concept basing on the "device" behind "vaDisplay".
   4894 * If a device could be divided to several sub devices, the task of
   4895 * decode/encode/vpp could be assigned on one sub-device. So, application
   4896 * could choose the sub device before any other operations. After that,
   4897 * all of the task execution/resource allocation will be dispatched to
   4898 * the sub device. If application does not choose the sub device, driver
   4899 * will assign one as default.
   4900 *
   4901 * If the value == VA_ATTRIB_NOT_SUPPORTED, it mean that the attribute
   4902 * is unsupport or UNKNOWN.
   4903 */
   4904 
   4905 typedef union _VADisplayAttribValSubDevice {
   4906    struct {
   4907        /** \brief current sub device index, read - write */
   4908        uint32_t current_sub_device     : 4;
   4909        /** \brief sub devices count, read - only */
   4910        uint32_t sub_device_count       : 4;
   4911        /** \brief reserved bits for future, must be zero*/
   4912        uint32_t reserved               : 8;
   4913        /** \brief bit mask to indicate which sub_device is available, read only
   4914         * \code
   4915         * VADisplayAttribValSubDevice reg;
   4916         * VADisplayAttribute reg_attr;
   4917         * reg_attr.type = VADisplayAttribSubDevice;
   4918         * vaGetDisplayAttributes(dpy, &reg_attr, 1);
   4919         * reg.value = reg_attr.value;
   4920         *
   4921         * for(int i = 0; i < reg.bits.sub_device_count; i ++ ){
   4922         *    if((1<<i) & reg.bits.sub_device_mask){
   4923         *        printf("sub device  %d can be selected", i);
   4924         *    }
   4925         *}
   4926         * \endcode
   4927         */
   4928        uint32_t sub_device_mask       : 16;
   4929    } bits;
   4930    uint32_t value;
   4931 } VADisplayAttribValSubDevice;
   4932 
   4933 /** Currently defined display attribute types */
   4934 typedef enum {
   4935    VADisplayAttribBrightness       = 0,
   4936    VADisplayAttribContrast     = 1,
   4937    VADisplayAttribHue          = 2,
   4938    VADisplayAttribSaturation       = 3,
   4939    /* client can specifiy a background color for the target window
   4940     * the new feature of video conference,
   4941     * the uncovered area of the surface is filled by this color
   4942     * also it will blend with the decoded video color
   4943     */
   4944    VADisplayAttribBackgroundColor      = 4,
   4945    /*
   4946     * this is a gettable only attribute. For some implementations that use the
   4947     * hardware overlay, after PutSurface is called, the surface can not be
   4948     * re-used until after the subsequent PutSurface call. If this is the case
   4949     * then the value for this attribute will be set to 1 so that the client
   4950     * will not attempt to re-use the surface right after returning from a call
   4951     * to PutSurface.
   4952     *
   4953     * Don't use it, use flag VASurfaceDisplaying of vaQuerySurfaceStatus since
   4954     * driver may use overlay or GPU alternatively
   4955     */
   4956    VADisplayAttribDirectSurface       = 5,
   4957    VADisplayAttribRotation            = 6,
   4958    VADisplayAttribOutofLoopDeblock    = 7,
   4959 
   4960    /* PowerVR IEP Lite specific attributes */
   4961    VADisplayAttribBLEBlackMode        = 8,
   4962    VADisplayAttribBLEWhiteMode        = 9,
   4963    VADisplayAttribBlueStretch         = 10,
   4964    VADisplayAttribSkinColorCorrection = 11,
   4965    /*
   4966     * For type VADisplayAttribCSCMatrix, "value" field is a pointer to the color
   4967     * conversion matrix. Each element in the matrix is float-point
   4968     */
   4969    VADisplayAttribCSCMatrix           = 12,
   4970    /* specify the constant color used to blend with video surface
   4971     * Cd = Cv*Cc*Ac + Cb *(1 - Ac) C means the constant RGB
   4972     *      d: the final color to overwrite into the frame buffer
   4973     *      v: decoded video after color conversion,
   4974     *      c: video color specified by VADisplayAttribBlendColor
   4975     *      b: background color of the drawable
   4976     */
   4977    VADisplayAttribBlendColor          = 13,
   4978    /*
   4979     * Indicate driver to skip painting color key or not.
   4980     * only applicable if the render is overlay
   4981     */
   4982    VADisplayAttribOverlayAutoPaintColorKey   = 14,
   4983    /*
   4984     * customized overlay color key, the format is RGB888
   4985     * [23:16] = Red, [15:08] = Green, [07:00] = Blue.
   4986     */
   4987    VADisplayAttribOverlayColorKey  = 15,
   4988    /*
   4989     * The hint for the implementation of vaPutSurface
   4990     * normally, the driver could use an overlay or GPU to render the surface on the screen
   4991     * this flag provides APP the flexibity to switch the render dynamically
   4992     */
   4993    VADisplayAttribRenderMode           = 16,
   4994    /*
   4995     * specify if vaPutSurface needs to render into specified monitors
   4996     * one example is that one external monitor (e.g. HDMI) is enabled,
   4997     * but the window manager is not aware of it, and there is no associated drawable
   4998     */
   4999    VADisplayAttribRenderDevice        = 17,
   5000    /*
   5001     * specify vaPutSurface render area if there is no drawable on the monitor
   5002     */
   5003    VADisplayAttribRenderRect          = 18,
   5004    /*
   5005     * HW attribute, read/write, specify the sub device configure
   5006     */
   5007    VADisplayAttribSubDevice           = 19,
   5008    /*
   5009     * HW attribute. read only. specify whether vaCopy support on current HW
   5010     * The value of each bit should equal to 1 << VA_EXEC_MODE_XXX to represent
   5011     * modes of vaCopy
   5012     */
   5013    VADisplayAttribCopy                 = 20,
   5014 } VADisplayAttribType;
   5015 
   5016 /* flags for VADisplayAttribute */
   5017 #define VA_DISPLAY_ATTRIB_NOT_SUPPORTED 0x0000
   5018 #define VA_DISPLAY_ATTRIB_GETTABLE  0x0001
   5019 #define VA_DISPLAY_ATTRIB_SETTABLE  0x0002
   5020 
   5021 typedef struct _VADisplayAttribute {
   5022    VADisplayAttribType type;
   5023    int32_t min_value;
   5024    int32_t max_value;
   5025    int32_t value;  /* used by the set/get attribute functions */
   5026    /* flags can be VA_DISPLAY_ATTRIB_GETTABLE or VA_DISPLAY_ATTRIB_SETTABLE or OR'd together */
   5027    uint32_t flags;
   5028 
   5029    /** \brief Reserved bytes for future use, must be zero */
   5030    uint32_t                va_reserved[VA_PADDING_LOW];
   5031 } VADisplayAttribute;
   5032 
   5033 /** Get maximum number of display attributs supported by the implementation */
   5034 int vaMaxNumDisplayAttributes(
   5035    VADisplay dpy
   5036 );
   5037 
   5038 /**
   5039 * Query display attributes
   5040 * The caller must provide a "attr_list" array that can hold at
   5041 * least vaMaxNumDisplayAttributes() entries. The actual number of attributes
   5042 * returned in "attr_list" is returned in "num_attributes".
   5043 */
   5044 VAStatus vaQueryDisplayAttributes(
   5045    VADisplay dpy,
   5046    VADisplayAttribute *attr_list,  /* out */
   5047    int *num_attributes         /* out */
   5048 );
   5049 
   5050 /**
   5051 * Get display attributes
   5052 * This function returns the current attribute values in "attr_list".
   5053 * Only attributes returned with VA_DISPLAY_ATTRIB_GETTABLE set in the "flags" field
   5054 * from vaQueryDisplayAttributes() can have their values retrieved.
   5055 */
   5056 VAStatus vaGetDisplayAttributes(
   5057    VADisplay dpy,
   5058    VADisplayAttribute *attr_list,  /* in/out */
   5059    int num_attributes
   5060 );
   5061 
   5062 /**
   5063 * Set display attributes
   5064 * Only attributes returned with VA_DISPLAY_ATTRIB_SETTABLE set in the "flags" field
   5065 * from vaQueryDisplayAttributes() can be set.  If the attribute is not settable or
   5066 * the value is out of range, the function returns VA_STATUS_ERROR_ATTR_NOT_SUPPORTED
   5067 */
   5068 VAStatus vaSetDisplayAttributes(
   5069    VADisplay dpy,
   5070    VADisplayAttribute *attr_list,
   5071    int num_attributes
   5072 );
   5073 
   5074 /****************************
   5075 * HEVC data structures
   5076 ****************************/
   5077 /**
   5078 * \brief Description of picture properties of those in DPB surfaces.
   5079 *
   5080 * If only progressive scan is supported, each surface contains one whole
   5081 * frame picture.
   5082 * Otherwise, each surface contains two fields of whole picture.
   5083 * In this case, two entries of ReferenceFrames[] may share same picture_id
   5084 * value.
   5085 */
   5086 typedef struct _VAPictureHEVC {
   5087    /** \brief reconstructed picture buffer surface index
   5088     * invalid when taking value VA_INVALID_SURFACE.
   5089     */
   5090    VASurfaceID             picture_id;
   5091    /** \brief picture order count.
   5092     * in HEVC, POCs for top and bottom fields of same picture should
   5093     * take different values.
   5094     */
   5095    int32_t                 pic_order_cnt;
   5096    /* described below */
   5097    uint32_t                flags;
   5098 
   5099    /** \brief Reserved bytes for future use, must be zero */
   5100    uint32_t                va_reserved[VA_PADDING_LOW];
   5101 } VAPictureHEVC;
   5102 
   5103 /* flags in VAPictureHEVC could be OR of the following */
   5104 #define VA_PICTURE_HEVC_INVALID                 0x00000001
   5105 /** \brief indication of interlace scan picture.
   5106 * should take same value for all the pictures in sequence.
   5107 */
   5108 #define VA_PICTURE_HEVC_FIELD_PIC               0x00000002
   5109 /** \brief polarity of the field picture.
   5110 * top field takes even lines of buffer surface.
   5111 * bottom field takes odd lines of buffer surface.
   5112 */
   5113 #define VA_PICTURE_HEVC_BOTTOM_FIELD            0x00000004
   5114 /** \brief Long term reference picture */
   5115 #define VA_PICTURE_HEVC_LONG_TERM_REFERENCE     0x00000008
   5116 /**
   5117 * VA_PICTURE_HEVC_RPS_ST_CURR_BEFORE, VA_PICTURE_HEVC_RPS_ST_CURR_AFTER
   5118 * and VA_PICTURE_HEVC_RPS_LT_CURR of any picture in ReferenceFrames[] should
   5119 * be exclusive. No more than one of them can be set for any picture.
   5120 * Sum of NumPocStCurrBefore, NumPocStCurrAfter and NumPocLtCurr
   5121 * equals NumPocTotalCurr, which should be equal to or smaller than 8.
   5122 * Application should provide valid values for both short format and long format.
   5123 * The pictures in DPB with any of these three flags turned on are referred by
   5124 * the current picture.
   5125 */
   5126 /** \brief RefPicSetStCurrBefore of HEVC spec variable
   5127 * Number of ReferenceFrames[] entries with this bit set equals
   5128 * NumPocStCurrBefore.
   5129 */
   5130 #define VA_PICTURE_HEVC_RPS_ST_CURR_BEFORE      0x00000010
   5131 /** \brief RefPicSetStCurrAfter of HEVC spec variable
   5132 * Number of ReferenceFrames[] entries with this bit set equals
   5133 * NumPocStCurrAfter.
   5134 */
   5135 #define VA_PICTURE_HEVC_RPS_ST_CURR_AFTER       0x00000020
   5136 /** \brief RefPicSetLtCurr of HEVC spec variable
   5137 * Number of ReferenceFrames[] entries with this bit set equals
   5138 * NumPocLtCurr.
   5139 */
   5140 #define VA_PICTURE_HEVC_RPS_LT_CURR             0x00000040
   5141 
   5142 typedef enum {
   5143    VACopyObjectSurface = 0,
   5144    VACopyObjectBuffer  = 1,
   5145 } VACopyObjectType;
   5146 
   5147 typedef struct _VACopyObject {
   5148    VACopyObjectType  obj_type;    // type of object.
   5149    union {
   5150        VASurfaceID surface_id;
   5151        VABufferID  buffer_id;
   5152    } object;
   5153 
   5154    uint32_t    va_reserved[VA_PADDING_MEDIUM];
   5155 } VACopyObject;
   5156 
   5157 typedef union _VACopyOption {
   5158    struct {
   5159        /** \brief va copy synchronization, the value should be /c VA_EXEC_SYNC or /c VA_EXEC_ASYNC */
   5160        uint32_t va_copy_sync : 2;
   5161        /** \brief va copy mode, the value should be VA_EXEC_MODE_XXX */
   5162        uint32_t va_copy_mode : 4;
   5163        uint32_t reserved     : 26;
   5164    } bits;
   5165    uint32_t value;
   5166 } VACopyOption;
   5167 
   5168 /** \brief Copies an object.
   5169 *
   5170 * Copies specified object (surface or buffer). If non-blocking copy
   5171 * is requested (VA_COPY_NONBLOCK), then need vaSyncBuffer or vaSyncSurface/vaSyncSurface2
   5172 * to sync the destination object.
   5173 *
   5174 * @param[in] dpy               the VA display
   5175 * @param[in] dst               Destination object to copy to
   5176 * @param[in] src               Source object to copy from
   5177 * @param[in] option            VA copy option
   5178 * @return VA_STATUS_SUCCESS if successful
   5179 */
   5180 VAStatus vaCopy(VADisplay dpy, VACopyObject * dst, VACopyObject * src, VACopyOption option);
   5181 
   5182 //#include <va/va_dec_hevc.h>
   5183 //#include <va/va_dec_jpeg.h>
   5184 #include <va/va_dec_vp8.h>
   5185 #include <va/va_dec_vp9.h>
   5186 #include <va/va_dec_av1.h>
   5187 //#include <va/va_enc_hevc.h>
   5188 //#include <va/va_fei_hevc.h>
   5189 //#include <va/va_enc_h264.h>
   5190 //#include <va/va_enc_jpeg.h>
   5191 //#include <va/va_enc_mpeg2.h>
   5192 //#include <va/va_enc_vp8.h>
   5193 //#include <va/va_enc_vp9.h>
   5194 //#include <va/va_fei.h>
   5195 //#include <va/va_fei_h264.h>
   5196 //#include <va/va_vpp.h>
   5197 //#include <va/va_prot.h>
   5198 
   5199 /**@}*/
   5200 
   5201 #ifdef __cplusplus
   5202 }
   5203 #endif
   5204 
   5205 #endif /* _VA_H_ */