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

source code of include/va/va.h