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