2 * Copyright (c) 2007-2009 Intel Corporation. All Rights Reserved.
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:
12 * The above copyright notice and this permission notice (including the
13 * next paragraph) shall be included in all copies or substantial portions
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.
25 * Video Acceleration (VA) API Specification
28 * <jonathan.bian@intel.com>
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
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.
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
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.
75 * This file contains the \ref api_core "Core API".
83 #include <va/va_version.h>
90 #define va_deprecated __attribute__((deprecated))
92 #define va_deprecated_enum va_deprecated
94 #define va_deprecated_enum
98 #define va_deprecated_enum
102 * \mainpage Video Acceleration (VA) API
104 * \section intro Introduction
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
113 * VA-API is split into several modules:
115 * - \ref api_enc_xxx (xxx = h264, hevc, jpec, mpeg2, vp8, vp9)
116 * - \ref api_dec_xxx (xxx = hevc, jpec, vp8, vp9)
118 * - \ref api_fei_xxx (xxx = h264, hevc)
122 * \defgroup api_core Core API
130 The VA API is intended to provide an interface between a video decode/encode/processing
131 application (client) and a hardware accelerator (server), to off-load
132 video decode/encode/processing operations from the host to the hardware accelerator at various
135 The basic operation steps are:
137 - Negotiate a mutually acceptable configuration with the server to lock
138 down profile, entrypoints, and other attributes that will not change on
139 a frame-by-frame basis.
140 - Create a video decode, encode or processing context which represents a
141 "virtualized" hardware device
142 - Get and fill the render buffers with the corresponding data (depending on
143 profiles and entrypoints)
144 - Pass the render buffers to the server to handle the current frame
146 Initialization & Configuration Management
148 - Find out supported profiles
149 - Find out entrypoints for a given profile
150 - Find out configuration attributes for a given profile/entrypoint pair
151 - Create a configuration for use by the application
155 typedef void* VADisplay; /* window system dependent */
157 typedef int VAStatus; /** Return status type from functions */
158 /** Values for the return status */
159 #define VA_STATUS_SUCCESS 0x00000000
160 #define VA_STATUS_ERROR_OPERATION_FAILED 0x00000001
161 #define VA_STATUS_ERROR_ALLOCATION_FAILED 0x00000002
162 #define VA_STATUS_ERROR_INVALID_DISPLAY 0x00000003
163 #define VA_STATUS_ERROR_INVALID_CONFIG 0x00000004
164 #define VA_STATUS_ERROR_INVALID_CONTEXT 0x00000005
165 #define VA_STATUS_ERROR_INVALID_SURFACE 0x00000006
166 #define VA_STATUS_ERROR_INVALID_BUFFER 0x00000007
167 #define VA_STATUS_ERROR_INVALID_IMAGE 0x00000008
168 #define VA_STATUS_ERROR_INVALID_SUBPICTURE 0x00000009
169 #define VA_STATUS_ERROR_ATTR_NOT_SUPPORTED 0x0000000a
170 #define VA_STATUS_ERROR_MAX_NUM_EXCEEDED 0x0000000b
171 #define VA_STATUS_ERROR_UNSUPPORTED_PROFILE 0x0000000c
172 #define VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT 0x0000000d
173 #define VA_STATUS_ERROR_UNSUPPORTED_RT_FORMAT 0x0000000e
174 #define VA_STATUS_ERROR_UNSUPPORTED_BUFFERTYPE 0x0000000f
175 #define VA_STATUS_ERROR_SURFACE_BUSY 0x00000010
176 #define VA_STATUS_ERROR_FLAG_NOT_SUPPORTED 0x00000011
177 #define VA_STATUS_ERROR_INVALID_PARAMETER 0x00000012
178 #define VA_STATUS_ERROR_RESOLUTION_NOT_SUPPORTED 0x00000013
179 #define VA_STATUS_ERROR_UNIMPLEMENTED 0x00000014
180 #define VA_STATUS_ERROR_SURFACE_IN_DISPLAYING 0x00000015
181 #define VA_STATUS_ERROR_INVALID_IMAGE_FORMAT 0x00000016
182 #define VA_STATUS_ERROR_DECODING_ERROR 0x00000017
183 #define VA_STATUS_ERROR_ENCODING_ERROR 0x00000018
185 * \brief An invalid/unsupported value was supplied.
187 * This is a catch-all error code for invalid or unsupported values.
188 * e.g. value exceeding the valid range, invalid type in the context
189 * of generic attribute values.
191 #define VA_STATUS_ERROR_INVALID_VALUE 0x00000019
192 /** \brief An unsupported filter was supplied. */
193 #define VA_STATUS_ERROR_UNSUPPORTED_FILTER 0x00000020
194 /** \brief An invalid filter chain was supplied. */
195 #define VA_STATUS_ERROR_INVALID_FILTER_CHAIN 0x00000021
196 /** \brief Indicate HW busy (e.g. run multiple encoding simultaneously). */
197 #define VA_STATUS_ERROR_HW_BUSY 0x00000022
198 /** \brief An unsupported memory type was supplied. */
199 #define VA_STATUS_ERROR_UNSUPPORTED_MEMORY_TYPE 0x00000024
200 #define VA_STATUS_ERROR_UNKNOWN 0xFFFFFFFF
202 /** De-interlacing flags for vaPutSurface() */
203 #define VA_FRAME_PICTURE 0x00000000
204 #define VA_TOP_FIELD 0x00000001
205 #define VA_BOTTOM_FIELD 0x00000002
208 * Enabled the positioning/cropping/blending feature:
209 * 1, specify the video playback position in the isurface
210 * 2, specify the cropping info for video playback
211 * 3, encoded video will blend with background color
213 #define VA_ENABLE_BLEND 0x00000004 /* video area blend with the constant color */
216 * Clears the drawable with background color.
217 * for hardware overlay based implementation this flag
218 * can be used to turn off the overlay
220 #define VA_CLEAR_DRAWABLE 0x00000008
222 /** Color space conversion flags for vaPutSurface() */
223 #define VA_SRC_COLOR_MASK 0x000000f0
224 #define VA_SRC_BT601 0x00000010
225 #define VA_SRC_BT709 0x00000020
226 #define VA_SRC_SMPTE_240 0x00000040
228 /** Scaling flags for vaPutSurface() */
229 #define VA_FILTER_SCALING_DEFAULT 0x00000000
230 #define VA_FILTER_SCALING_FAST 0x00000100
231 #define VA_FILTER_SCALING_HQ 0x00000200
232 #define VA_FILTER_SCALING_NL_ANAMORPHIC 0x00000300
233 #define VA_FILTER_SCALING_MASK 0x00000f00
235 /** Padding size in 4-bytes */
236 #define VA_PADDING_LOW 4
237 #define VA_PADDING_MEDIUM 8
238 #define VA_PADDING_HIGH 16
239 #define VA_PADDING_LARGE 32
242 * Returns a short english description of error_status
244 const char *vaErrorStr(VAStatus error_status);
246 typedef struct _VARectangle
254 /** \brief Generic motion vector data structure. */
255 typedef struct _VAMotionVector {
256 /** \mv0[0]: horizontal motion vector for past reference */
257 /** \mv0[1]: vertical motion vector for past reference */
258 /** \mv1[0]: horizontal motion vector for future reference */
259 /** \mv1[1]: vertical motion vector for future reference */
260 int16_t mv0[2]; /* past reference */
261 int16_t mv1[2]; /* future reference */
264 /** Type of a message callback, used for both error and info log. */
265 typedef void (*VAMessageCallback)(void *user_context, const char *message);
268 * Set the callback for error messages, or NULL for no logging.
269 * Returns the previous one, or NULL if it was disabled.
271 VAMessageCallback vaSetErrorCallback(VADisplay dpy, VAMessageCallback callback, void *user_context);
274 * Set the callback for info messages, or NULL for no logging.
275 * Returns the previous one, or NULL if it was disabled.
277 VAMessageCallback vaSetInfoCallback(VADisplay dpy, VAMessageCallback callback, void *user_context);
281 * A display must be obtained by calling vaGetDisplay() before calling
282 * vaInitialize() and other functions. This connects the API to the
283 * native window system.
284 * For X Windows, native_dpy would be from XOpenDisplay()
286 typedef void* VANativeDisplay; /* window system dependent */
288 int vaDisplayIsValid(VADisplay dpy);
291 * Set the override driver name instead of queried driver driver.
293 VAStatus vaSetDriverName(VADisplay dpy,
298 * Initialize the library
300 VAStatus vaInitialize (
302 int *major_version, /* out */
303 int *minor_version /* out */
307 * After this call, all library internal resources will be cleaned up
309 VAStatus vaTerminate (
314 * vaQueryVendorString returns a pointer to a zero-terminated string
315 * describing some aspects of the VA implemenation on a specific
316 * hardware accelerator. The format of the returned string is vendor
317 * specific and at the discretion of the implementer.
318 * e.g. for the Intel GMA500 implementation, an example would be:
319 * "Intel GMA500 - 2.0.0.32L.0005"
321 const char *vaQueryVendorString (
325 typedef int (*VAPrivFunc)(void);
328 * Return a function pointer given a function name in the library.
329 * This allows private interfaces into the library
331 VAPrivFunc vaGetLibFunc (
336 /** Currently defined profiles */
339 /** \brief Profile ID used for video processing. */
341 VAProfileMPEG2Simple = 0,
342 VAProfileMPEG2Main = 1,
343 VAProfileMPEG4Simple = 2,
344 VAProfileMPEG4AdvancedSimple = 3,
345 VAProfileMPEG4Main = 4,
346 VAProfileH264Baseline va_deprecated_enum = 5,
347 VAProfileH264Main = 6,
348 VAProfileH264High = 7,
349 VAProfileVC1Simple = 8,
350 VAProfileVC1Main = 9,
351 VAProfileVC1Advanced = 10,
352 VAProfileH263Baseline = 11,
353 VAProfileJPEGBaseline = 12,
354 VAProfileH264ConstrainedBaseline = 13,
355 VAProfileVP8Version0_3 = 14,
356 VAProfileH264MultiviewHigh = 15,
357 VAProfileH264StereoHigh = 16,
358 VAProfileHEVCMain = 17,
359 VAProfileHEVCMain10 = 18,
360 VAProfileVP9Profile0 = 19,
361 VAProfileVP9Profile1 = 20,
362 VAProfileVP9Profile2 = 21,
363 VAProfileVP9Profile3 = 22
367 * Currently defined entrypoints
373 VAEntrypointIDCT = 3,
374 VAEntrypointMoComp = 4,
375 VAEntrypointDeblocking = 5,
376 VAEntrypointEncSlice = 6, /* slice level encode */
377 VAEntrypointEncPicture = 7, /* pictuer encode, JPEG, etc */
379 * For an implementation that supports a low power/high performance variant
380 * for slice level encode, it can choose to expose the
381 * VAEntrypointEncSliceLP entrypoint. Certain encoding tools may not be
382 * available with this entrypoint (e.g. interlace, MBAFF) and the
383 * application can query the encoding configuration attributes to find
384 * out more details if this entrypoint is supported.
386 VAEntrypointEncSliceLP = 8,
387 VAEntrypointVideoProc = 10, /**< Video pre/post-processing. */
389 * \brief VAEntrypointFEI
391 * The purpose of FEI (Flexible Encoding Infrastructure) is to allow applications to
392 * have more controls and trade off quality for speed with their own IPs.
393 * The application can optionally provide input to ENC for extra encode control
394 * and get the output from ENC. Application can chose to modify the ENC
395 * output/PAK input during encoding, but the performance impact is significant.
397 * On top of the existing buffers for normal encode, there will be
398 * one extra input buffer (VAEncMiscParameterFEIFrameControl) and
399 * three extra output buffers (VAEncFEIMVBufferType, VAEncFEIMBModeBufferType
400 * and VAEncFEIDistortionBufferType) for VAEntrypointFEI entry function.
401 * If separate PAK is set, two extra input buffers
402 * (VAEncFEIMVBufferType, VAEncFEIMBModeBufferType) are needed for PAK input.
404 VAEntrypointFEI = 11,
406 * \brief VAEntrypointStats
408 * A pre-processing function for getting some statistics and motion vectors is added,
409 * and some extra controls for Encode pipeline are provided. The application can
410 * optionally call the statistics function to get motion vectors and statistics like
411 * variances, distortions before calling Encode function via this entry point.
413 * Checking whether Statistics is supported can be performed with vaQueryConfigEntrypoints().
414 * If Statistics entry point is supported, then the list of returned entry-points will
415 * include #VAEntrypointStats. Supported pixel format, maximum resolution and statistics
416 * specific attributes can be obtained via normal attribute query. One input buffer
417 * (VAStatsStatisticsParameterBufferType) and one or two output buffers
418 * (VAStatsStatisticsBufferType, VAStatsStatisticsBottomFieldBufferType (for interlace only)
419 * and VAStatsMVBufferType) are needed for this entry point.
421 VAEntrypointStats = 12,
424 /** Currently defined configuration attribute types */
427 VAConfigAttribRTFormat = 0,
428 VAConfigAttribSpatialResidual = 1,
429 VAConfigAttribSpatialClipping = 2,
430 VAConfigAttribIntraResidual = 3,
431 VAConfigAttribEncryption = 4,
432 VAConfigAttribRateControl = 5,
434 /** @name Attributes for decoding */
437 * \brief Slice Decoding mode. Read/write.
439 * This attribute determines what mode the driver supports for slice
440 * decoding, through vaGetConfigAttributes(); and what mode the user
441 * will be providing to the driver, through vaCreateConfig(), if the
442 * driver supports those. If this attribute is not set by the user then
443 * it is assumed that VA_DEC_SLICE_MODE_NORMAL mode is used.
445 * See \c VA_DEC_SLICE_MODE_xxx for the list of slice decoding modes.
447 VAConfigAttribDecSliceMode = 6,
449 * \brief JPEG decoding attribute. Read-only.
451 * This attribute exposes a number of capabilities of the underlying
452 * JPEG implementation. The attribute value is partitioned into fields as defined in the
453 * VAConfigAttribValDecJPEG union.
455 VAConfigAttribDecJPEG = 7,
457 * \brief Decode processing support. Read/write.
459 * This attribute determines if the driver supports video processing
460 * with decoding using the decoding context in a single call, through
461 * vaGetConfigAttributes(); and if the user may use this feature,
462 * through vaCreateConfig(), if the driver supports the user scenario.
463 * The user will essentially create a regular decode VAContext. Therefore,
464 * the parameters of vaCreateContext() such as picture_width, picture_height
465 * and render_targets are in relation to the decode output parameters
466 * (not processing output parameters) as normal.
467 * If this attribute is not set by the user then it is assumed that no
468 * extra processing is done after decoding for this decode context.
470 * Since essentially the application is creating a decoder config and context,
471 * all function calls that take in the config (e.g. vaQuerySurfaceAttributes())
472 * or context are in relation to the decoder, except those video processing
473 * function specified in the next paragraph.
475 * Once the decode config and context are created, the user must further
476 * query the supported processing filters using vaQueryVideoProcFilters(),
477 * vaQueryVideoProcFilterCaps(), vaQueryVideoProcPipelineCaps() by specifying
478 * the created decode context. The user must provide processing information
479 * and extra processing output surfaces as "additional_outputs" to the driver
480 * through VAProcPipelineParameterBufferType. The render_target specified
481 * at vaBeginPicture() time refers to the decode output surface. The
482 * target surface for the output of processing needs to be a different
483 * surface since the decode process requires the original reconstructed buffer.
484 * The “surface” member of VAProcPipelineParameterBuffer should be set to the
485 * same as “render_target” set in vaBeginPicture(), but the driver may choose
486 * to ignore this parameter.
488 VAConfigAttribDecProcessing = 8,
489 /** @name Attributes for encoding */
492 * \brief Packed headers mode. Read/write.
494 * This attribute determines what packed headers the driver supports,
495 * through vaGetConfigAttributes(); and what packed headers the user
496 * will be providing to the driver, through vaCreateConfig(), if the
497 * driver supports those.
499 * See \c VA_ENC_PACKED_HEADER_xxx for the list of packed headers.
501 VAConfigAttribEncPackedHeaders = 10,
503 * \brief Interlaced mode. Read/write.
505 * This attribute determines what kind of interlaced encoding mode
506 * the driver supports.
508 * See \c VA_ENC_INTERLACED_xxx for the list of interlaced modes.
510 VAConfigAttribEncInterlaced = 11,
512 * \brief Maximum number of reference frames. Read-only.
514 * This attribute determines the maximum number of reference
515 * frames supported for encoding.
517 * Note: for H.264 encoding, the value represents the maximum number
518 * of reference frames for both the reference picture list 0 (bottom
519 * 16 bits) and the reference picture list 1 (top 16 bits).
521 VAConfigAttribEncMaxRefFrames = 13,
523 * \brief Maximum number of slices per frame. Read-only.
525 * This attribute determines the maximum number of slices the
526 * driver can support to encode a single frame.
528 VAConfigAttribEncMaxSlices = 14,
530 * \brief Slice structure. Read-only.
532 * This attribute determines slice structures supported by the
533 * driver for encoding. This attribute is a hint to the user so
534 * that he can choose a suitable surface size and how to arrange
535 * the encoding process of multiple slices per frame.
537 * More specifically, for H.264 encoding, this attribute
538 * determines the range of accepted values to
539 * VAEncSliceParameterBufferH264::macroblock_address and
540 * VAEncSliceParameterBufferH264::num_macroblocks.
542 * See \c VA_ENC_SLICE_STRUCTURE_xxx for the supported slice
545 VAConfigAttribEncSliceStructure = 15,
547 * \brief Macroblock information. Read-only.
549 * This attribute determines whether the driver supports extra
550 * encoding information per-macroblock. e.g. QP.
552 * More specifically, for H.264 encoding, if the driver returns a non-zero
553 * value for this attribute, this means the application can create
554 * additional #VAEncMacroblockParameterBufferH264 buffers referenced
555 * through VAEncSliceParameterBufferH264::macroblock_info.
557 VAConfigAttribEncMacroblockInfo = 16,
559 * \brief Maximum picture width. Read-only.
561 * This attribute determines the maximum picture width the driver supports
562 * for a given configuration.
564 VAConfigAttribMaxPictureWidth = 18,
566 * \brief Maximum picture height. Read-only.
568 * This attribute determines the maximum picture height the driver supports
569 * for a given configuration.
571 VAConfigAttribMaxPictureHeight = 19,
573 * \brief JPEG encoding attribute. Read-only.
575 * This attribute exposes a number of capabilities of the underlying
576 * JPEG implementation. The attribute value is partitioned into fields as defined in the
577 * VAConfigAttribValEncJPEG union.
579 VAConfigAttribEncJPEG = 20,
581 * \brief Encoding quality range attribute. Read-only.
583 * This attribute conveys whether the driver supports different quality level settings
584 * for encoding. A value less than or equal to 1 means that the encoder only has a single
585 * quality setting, and a value greater than 1 represents the number of quality levels
586 * that can be configured. e.g. a value of 2 means there are two distinct quality levels.
588 VAConfigAttribEncQualityRange = 21,
590 * \brief Encoding quantization attribute. Read-only.
592 * This attribute conveys whether the driver supports certain types of quantization methods
593 * for encoding (e.g. trellis). See \c VA_ENC_QUANTIZATION_xxx for the list of quantization methods
595 VAConfigAttribEncQuantization = 22,
597 * \brief Encoding intra refresh attribute. Read-only.
599 * This attribute conveys whether the driver supports certain types of intra refresh methods
600 * for encoding (e.g. adaptive intra refresh or rolling intra refresh).
601 * See \c VA_ENC_INTRA_REFRESH_xxx for intra refresh methods
603 VAConfigAttribEncIntraRefresh = 23,
605 * \brief Encoding skip frame attribute. Read-only.
607 * This attribute conveys whether the driver supports sending skip frame parameters
608 * (VAEncMiscParameterTypeSkipFrame) to the encoder's rate control, when the user has
609 * externally skipped frames.
611 VAConfigAttribEncSkipFrame = 24,
613 * \brief Encoding region-of-interest (ROI) attribute. Read-only.
615 * This attribute conveys whether the driver supports region-of-interest (ROI) encoding,
616 * based on user provided ROI rectangles. The attribute value is partitioned into fields
617 * as defined in the VAConfigAttribValEncROI union.
619 * If ROI encoding is supported, the ROI information is passed to the driver using
620 * VAEncMiscParameterTypeROI.
622 VAConfigAttribEncROI = 25,
624 * \brief Encoding extended rate control attribute. Read-only.
626 * This attribute conveys whether the driver supports any extended rate control features
627 * The attribute value is partitioned into fields as defined in the
628 * VAConfigAttribValEncRateControlExt union.
630 VAConfigAttribEncRateControlExt = 26,
632 * \brief Processing rate reporting attribute. Read-only.
634 * This attribute conveys whether the driver supports reporting of
635 * encode/decode processing rate based on certain set of parameters
636 * (i.e. levels, I frame internvals) for a given configuration.
637 * If this is supported, vaQueryProcessingRate() can be used to get
638 * encode or decode processing rate.
639 * See \c VA_PROCESSING_RATE_xxx for encode/decode processing rate
641 VAConfigAttribProcessingRate = 27,
643 * \brief Encoding dirty rectangle. Read-only.
645 * This attribute conveys whether the driver supports dirty rectangle.
646 * encoding, based on user provided ROI rectangles which indicate the rectangular areas
647 * where the content has changed as compared to the previous picture. The regions of the
648 * picture that are not covered by dirty rect rectangles are assumed to have not changed
649 * compared to the previous picture. The encoder may do some optimizations based on
650 * this information. The attribute value returned indicates the number of regions that
651 * are supported. e.g. A value of 0 means dirty rect encoding is not supported. If dirty
652 * rect encoding is supported, the ROI information is passed to the driver using
653 * VAEncMiscParameterTypeDirtyRect.
655 VAConfigAttribEncDirtyRect = 28,
657 * \brief Parallel Rate Control (hierachical B) attribute. Read-only.
659 * This attribute conveys whether the encoder supports parallel rate control.
660 * It is a integer value 0 - unsupported, > 0 - maximum layer supported.
661 * This is the way when hireachical B frames are encoded, multiple independent B frames
662 * on the same layer may be processed at same time. If supported, app may enable it by
663 * setting enable_parallel_brc in VAEncMiscParameterRateControl,and the number of B frames
664 * per layer per GOP will be passed to driver through VAEncMiscParameterParallelRateControl
665 * structure.Currently three layers are defined.
667 VAConfigAttribEncParallelRateControl = 29,
669 * \brief Dynamic Scaling Attribute. Read-only.
671 * This attribute conveys whether encoder is capable to determine dynamic frame
672 * resolutions adaptive to bandwidth utilization and processing power, etc.
673 * It is a boolean value 0 - unsupported, 1 - supported.
674 * If it is supported,for VP9, suggested frame resolution can be retrieved from VACodedBufferVP9Status.
676 VAConfigAttribEncDynamicScaling = 30,
678 * \brief frame size tolerance support
679 * it indicates the tolerance of frame size
681 VAConfigAttribFrameSizeToleranceSupport = 31,
683 * \brief Encode function type for FEI.
685 * This attribute conveys whether the driver supports different function types for encode.
686 * It can be VA_FEI_FUNCTION_ENC, VA_FEI_FUNCTION_PAK, or VA_FEI_FUNCTION_ENC_PAK. Currently
687 * it is for FEI entry point only.
688 * Default is VA_FEI_FUNCTION_ENC_PAK.
690 VAConfigAttribFEIFunctionType = 32,
692 * \brief Maximum number of FEI MV predictors. Read-only.
694 * This attribute determines the maximum number of MV predictors the driver
695 * can support to encode a single frame. 0 means no MV predictor is supported.
696 * Currently it is for FEI entry point only.
698 VAConfigAttribFEIMVPredictors = 33,
700 * \brief Statistics attribute. Read-only.
702 * This attribute exposes a number of capabilities of the VAEntrypointStats entry
703 * point. The attribute value is partitioned into fields as defined in the
704 * VAConfigAttribValStats union. Currently it is for VAEntrypointStats only.
706 VAConfigAttribStats = 34,
708 * \brief Tile Support Attribute. Read-only.
710 * This attribute conveys whether encoder is capable to support tiles.
711 * If not supported, the tile related parameters sent to encoder, such as
712 * tiling structure, should be ignored. 0 - unsupported, 1 - supported.
714 VAConfigAttribEncTileSupport = 35,
716 * \brief whether accept rouding setting from application. Read-only.
717 * This attribute is for encode quality, if it is report,
718 * application can change the rounding setting by VAEncMiscParameterTypeCustomRoundingControl
720 VAConfigAttribCustomRoundingControl = 36,
722 * \brief Encoding QP info block size attribute. Read-only.
723 * This attribute conveys the block sizes that underlying driver
724 * support for QP info for buffer #VAEncQpBuffer.
726 VAConfigAttribQPBlockSize = 37,
728 VAConfigAttribTypeMax
729 } VAConfigAttribType;
732 * Configuration attributes
733 * If there is more than one value for an attribute, a default
734 * value will be assigned to the attribute if the client does not
735 * specify the attribute when creating a configuration
737 typedef struct _VAConfigAttrib {
738 VAConfigAttribType type;
739 uint32_t value; /* OR'd flags (bits) for this attribute */
742 /** attribute value for VAConfigAttribRTFormat */
743 #define VA_RT_FORMAT_YUV420 0x00000001
744 #define VA_RT_FORMAT_YUV422 0x00000002
745 #define VA_RT_FORMAT_YUV444 0x00000004
746 #define VA_RT_FORMAT_YUV411 0x00000008
747 #define VA_RT_FORMAT_YUV400 0x00000010
748 /** YUV formats with more than 8 bpp */
749 #define VA_RT_FORMAT_YUV420_10BPP 0x00000100
751 #define VA_RT_FORMAT_RGB16 0x00010000
752 #define VA_RT_FORMAT_RGB32 0x00020000
753 /* RGBP covers RGBP and BGRP fourcc */
754 #define VA_RT_FORMAT_RGBP 0x00100000
756 * RGB 10-bit packed format with upper 2 bits as alpha channel.
757 * The existing pre-defined fourcc codes can be used to signal
758 * the position of each component for this RT format.
760 #define VA_RT_FORMAT_RGB32_10BPP 0x00200000
761 #define VA_RT_FORMAT_PROTECTED 0x80000000
763 /** @name Attribute values for VAConfigAttribRateControl */
765 /** \brief Driver does not support any form of rate control. */
766 #define VA_RC_NONE 0x00000001
767 /** \brief Constant bitrate. */
768 #define VA_RC_CBR 0x00000002
769 /** \brief Variable bitrate. */
770 #define VA_RC_VBR 0x00000004
771 /** \brief Video conference mode. */
772 #define VA_RC_VCM 0x00000008
773 /** \brief Constant QP. */
774 #define VA_RC_CQP 0x00000010
775 /** \brief Variable bitrate with peak rate higher than average bitrate. */
776 #define VA_RC_VBR_CONSTRAINED 0x00000020
777 /** \brief Intelligent Constant Quality. Provided an initial ICQ_quality_factor,
778 * adjusts QP at a frame and MB level based on motion to improve subjective quality. */
779 #define VA_RC_ICQ 0x00000040
780 /** \brief Macroblock based rate control. Per MB control is decided
781 * internally in the encoder. It may be combined with other RC modes, except CQP. */
782 #define VA_RC_MB 0x00000080
783 /** \brief Constant Frame Size, it is used for small tolerent */
784 #define VA_RC_CFS 0x00000100
785 /** \brief Parallel BRC, for hierachical B.
787 * For hierachical B, B frames can be refered by other B frames.
788 * Currently three layers of hierachy are defined:
789 * B0 - regular B, no reference to other B frames.
790 * B1 - reference to only I, P and regular B0 frames.
791 * B2 - reference to any other frames, including B1.
792 * In Hierachical B structure, B frames on the same layer can be processed
793 * simultaneously. And BRC would adjust accordingly. This is so called
795 #define VA_RC_PARALLEL 0x00000200
799 /** @name Attribute values for VAConfigAttribDecSliceMode */
801 /** \brief Driver supports normal mode for slice decoding */
802 #define VA_DEC_SLICE_MODE_NORMAL 0x00000001
803 /** \brief Driver supports base mode for slice decoding */
804 #define VA_DEC_SLICE_MODE_BASE 0x00000002
806 /** @name Attribute values for VAConfigAttribDecJPEG */
808 typedef union _VAConfigAttribValDecJPEG {
810 /** \brief Set to (1 << VA_ROTATION_xxx) for supported rotation angles. */
811 uint32_t rotation : 4;
812 /** \brief Reserved for future use. */
813 uint32_t reserved : 28;
816 uint32_t va_reserved[VA_PADDING_LOW];
817 } VAConfigAttribValDecJPEG;
818 /** @name Attribute values for VAConfigAttribDecProcessing */
820 /** \brief No decoding + processing in a single decoding call. */
821 #define VA_DEC_PROCESSING_NONE 0x00000000
822 /** \brief Decode + processing in a single decoding call. */
823 #define VA_DEC_PROCESSING 0x00000001
826 /** @name Attribute values for VAConfigAttribEncPackedHeaders */
828 /** \brief Driver does not support any packed headers mode. */
829 #define VA_ENC_PACKED_HEADER_NONE 0x00000000
831 * \brief Driver supports packed sequence headers. e.g. SPS for H.264.
833 * Application must provide it to driver once this flag is returned through
834 * vaGetConfigAttributes()
836 #define VA_ENC_PACKED_HEADER_SEQUENCE 0x00000001
838 * \brief Driver supports packed picture headers. e.g. PPS for H.264.
840 * Application must provide it to driver once this falg is returned through
841 * vaGetConfigAttributes()
843 #define VA_ENC_PACKED_HEADER_PICTURE 0x00000002
845 * \brief Driver supports packed slice headers. e.g. slice_header() for H.264.
847 * Application must provide it to driver once this flag is returned through
848 * vaGetConfigAttributes()
850 #define VA_ENC_PACKED_HEADER_SLICE 0x00000004
852 * \brief Driver supports misc packed headers. e.g. SEI for H.264.
855 * This is a deprecated packed header flag, All applications can use
856 * \c VA_ENC_PACKED_HEADER_RAW_DATA to pass the corresponding packed
857 * header data buffer to the driver
859 #define VA_ENC_PACKED_HEADER_MISC 0x00000008
860 /** \brief Driver supports raw packed header, see VAEncPackedHeaderRawData */
861 #define VA_ENC_PACKED_HEADER_RAW_DATA 0x00000010
864 /** @name Attribute values for VAConfigAttribEncInterlaced */
866 /** \brief Driver does not support interlaced coding. */
867 #define VA_ENC_INTERLACED_NONE 0x00000000
868 /** \brief Driver supports interlaced frame coding. */
869 #define VA_ENC_INTERLACED_FRAME 0x00000001
870 /** \brief Driver supports interlaced field coding. */
871 #define VA_ENC_INTERLACED_FIELD 0x00000002
872 /** \brief Driver supports macroblock adaptive frame field coding. */
873 #define VA_ENC_INTERLACED_MBAFF 0x00000004
874 /** \brief Driver supports picture adaptive frame field coding. */
875 #define VA_ENC_INTERLACED_PAFF 0x00000008
878 /** @name Attribute values for VAConfigAttribEncSliceStructure */
880 /** \brief Driver supports a power-of-two number of rows per slice. */
881 #define VA_ENC_SLICE_STRUCTURE_POWER_OF_TWO_ROWS 0x00000001
882 /** \brief Driver supports an arbitrary number of macroblocks per slice. */
883 #define VA_ENC_SLICE_STRUCTURE_ARBITRARY_MACROBLOCKS 0x00000002
884 /** \brief Dirver support 1 rows per slice */
885 #define VA_ENC_SLICE_STRUCTURE_EQUAL_ROWS 0x00000004
886 /** \brief Dirver support max encoded slice size per slice */
887 #define VA_ENC_SLICE_STRUCTURE_MAX_SLICE_SIZE 0x00000008
888 /** \brief Driver supports an arbitrary number of rows per slice. */
889 #define VA_ENC_SLICE_STRUCTURE_ARBITRARY_ROWS 0x00000010
892 /** \brief Attribute value for VAConfigAttribEncJPEG */
893 typedef union _VAConfigAttribValEncJPEG {
895 /** \brief set to 1 for arithmatic coding. */
896 uint32_t arithmatic_coding_mode : 1;
897 /** \brief set to 1 for progressive dct. */
898 uint32_t progressive_dct_mode : 1;
899 /** \brief set to 1 for non-interleaved. */
900 uint32_t non_interleaved_mode : 1;
901 /** \brief set to 1 for differential. */
902 uint32_t differential_mode : 1;
903 uint32_t max_num_components : 3;
904 uint32_t max_num_scans : 4;
905 uint32_t max_num_huffman_tables : 3;
906 uint32_t max_num_quantization_tables : 3;
909 } VAConfigAttribValEncJPEG;
911 /** @name Attribute values for VAConfigAttribEncQuantization */
913 /** \brief Driver does not support special types of quantization */
914 #define VA_ENC_QUANTIZATION_NONE 0x00000000
915 /** \brief Driver supports trellis quantization */
916 #define VA_ENC_QUANTIZATION_TRELLIS_SUPPORTED 0x00000001
919 /** @name Attribute values for VAConfigAttribEncIntraRefresh */
921 /** \brief Driver does not support intra refresh */
922 #define VA_ENC_INTRA_REFRESH_NONE 0x00000000
923 /** \brief Driver supports column based rolling intra refresh */
924 #define VA_ENC_INTRA_REFRESH_ROLLING_COLUMN 0x00000001
925 /** \brief Driver supports row based rolling intra refresh */
926 #define VA_ENC_INTRA_REFRESH_ROLLING_ROW 0x00000002
927 /** \brief Driver supports adaptive intra refresh */
928 #define VA_ENC_INTRA_REFRESH_ADAPTIVE 0x00000010
929 /** \brief Driver supports cyclic intra refresh */
930 #define VA_ENC_INTRA_REFRESH_CYCLIC 0x00000020
931 /** \brief Driver supports intra refresh of P frame*/
932 #define VA_ENC_INTRA_REFRESH_P_FRAME 0x00010000
933 /** \brief Driver supports intra refresh of B frame */
934 #define VA_ENC_INTRA_REFRESH_B_FRAME 0x00020000
935 /** \brief Driver supports intra refresh of multiple reference encoder */
936 #define VA_ENC_INTRA_REFRESH_MULTI_REF 0x00040000
940 /** \brief Attribute value for VAConfigAttribEncROI */
941 typedef union _VAConfigAttribValEncROI {
943 /** \brief The number of ROI regions supported, 0 if ROI is not supported. */
944 uint32_t num_roi_regions : 8;
946 * \brief A flag indicates whether ROI priority is supported
948 * \ref roi_rc_priority_support equal to 1 specifies the underlying driver supports
949 * ROI priority when VAConfigAttribRateControl != VA_RC_CQP, user can use \c roi_value
950 * in #VAEncROI to set ROI priority. \ref roi_rc_priority_support equal to 0 specifies
951 * the underlying driver doesn't support ROI priority.
953 * User should ignore \ref roi_rc_priority_support when VAConfigAttribRateControl == VA_RC_CQP
954 * because ROI delta QP is always required when VAConfigAttribRateControl == VA_RC_CQP.
956 uint32_t roi_rc_priority_support : 1;
958 * \brief A flag indicates whether ROI delta QP is supported
960 * \ref roi_rc_qp_delta_support equal to 1 specifies the underlying driver supports
961 * ROI delta QP when VAConfigAttribRateControl != VA_RC_CQP, user can use \c roi_value
962 * in #VAEncROI to set ROI delta QP. \ref roi_rc_qp_delta_support equal to 0 specifies
963 * the underlying driver doesn't support ROI delta QP.
965 * User should ignore \ref roi_rc_qp_delta_support when VAConfigAttribRateControl == VA_RC_CQP
966 * because ROI delta QP is always required when VAConfigAttribRateControl == VA_RC_CQP.
968 uint32_t roi_rc_qp_delta_support : 1;
969 uint32_t reserved : 22;
972 } VAConfigAttribValEncROI;
974 /** \brief Attribute value for VAConfigAttribEncRateControlExt */
975 typedef union _VAConfigAttribValEncRateControlExt {
978 * \brief The maximum number of temporal layers minus 1
980 * \ref max_num_temporal_layers_minus1 plus 1 specifies the maximum number of temporal
981 * layers that supported by the underlying driver. \ref max_num_temporal_layers_minus1
982 * equal to 0 implies the underlying driver doesn't support encoding with temporal layer.
984 uint32_t max_num_temporal_layers_minus1 : 8;
987 * /brief support temporal layer bit-rate control flag
989 * \ref temporal_layer_bitrate_control_flag equal to 1 specifies the underlying driver
990 * can support bit-rate control per temporal layer when (#VAConfigAttribRateControl == #VA_RC_CBR ||
991 * #VAConfigAttribRateControl == #VA_RC_VBR).
993 * The underlying driver must set \ref temporal_layer_bitrate_control_flag to 0 when
994 * \c max_num_temporal_layers_minus1 is equal to 0
996 * To use bit-rate control per temporal layer, an application must send the right layer
997 * structure via #VAEncMiscParameterTemporalLayerStructure at the beginning of a coded sequence
998 * and then followed by #VAEncMiscParameterRateControl and #VAEncMiscParameterFrameRate structures
999 * for each layer, using the \c temporal_id field as the layer identifier. Otherwise
1000 * the driver doesn't use bitrate control per temporal layer if an application doesn't send the
1001 * layer structure via #VAEncMiscParameterTemporalLayerStructure to the driver. The driver returns
1002 * VA_STATUS_ERROR_INVALID_PARAMETER if an application sends a wrong layer structure or doesn't send
1003 * #VAEncMiscParameterRateControl and #VAEncMiscParameterFrameRate for each layer.
1005 * The driver will ignore #VAEncMiscParameterTemporalLayerStructure and the \c temporal_id field
1006 * in #VAEncMiscParameterRateControl and #VAEncMiscParameterFrameRate if
1007 * \ref temporal_layer_bitrate_control_flag is equal to 0 or #VAConfigAttribRateControl == #VA_RC_CQP
1009 uint32_t temporal_layer_bitrate_control_flag : 1;
1010 uint32_t reserved : 23;
1013 } VAConfigAttribValEncRateControlExt;
1015 /** @name Attribute values for VAConfigAttribProcessingRate. */
1017 /** \brief Driver does not support processing rate report */
1018 #define VA_PROCESSING_RATE_NONE 0x00000000
1019 /** \brief Driver supports encode processing rate report */
1020 #define VA_PROCESSING_RATE_ENCODE 0x00000001
1021 /** \brief Driver supports decode processing rate report */
1022 #define VA_PROCESSING_RATE_DECODE 0x00000002
1025 * if an attribute is not applicable for a given
1026 * profile/entrypoint pair, then set the value to the following
1028 #define VA_ATTRIB_NOT_SUPPORTED 0x80000000
1030 /** Get maximum number of profiles supported by the implementation */
1031 int vaMaxNumProfiles (
1035 /** Get maximum number of entrypoints supported by the implementation */
1036 int vaMaxNumEntrypoints (
1040 /** Get maximum number of attributs supported by the implementation */
1041 int vaMaxNumConfigAttributes (
1046 * Query supported profiles
1047 * The caller must provide a "profile_list" array that can hold at
1048 * least vaMaxNumProfile() entries. The actual number of profiles
1049 * returned in "profile_list" is returned in "num_profile".
1051 VAStatus vaQueryConfigProfiles (
1053 VAProfile *profile_list, /* out */
1054 int *num_profiles /* out */
1058 * Query supported entrypoints for a given profile
1059 * The caller must provide an "entrypoint_list" array that can hold at
1060 * least vaMaxNumEntrypoints() entries. The actual number of entrypoints
1061 * returned in "entrypoint_list" is returned in "num_entrypoints".
1063 VAStatus vaQueryConfigEntrypoints (
1066 VAEntrypoint *entrypoint_list, /* out */
1067 int *num_entrypoints /* out */
1071 * Get attributes for a given profile/entrypoint pair
1072 * The caller must provide an "attrib_list" with all attributes to be
1073 * retrieved. Upon return, the attributes in "attrib_list" have been
1074 * updated with their value. Unknown attributes or attributes that are
1075 * not supported for the given profile/entrypoint pair will have their
1076 * value set to VA_ATTRIB_NOT_SUPPORTED
1078 VAStatus vaGetConfigAttributes (
1081 VAEntrypoint entrypoint,
1082 VAConfigAttrib *attrib_list, /* in/out */
1086 /** Generic ID type, can be re-typed for specific implementation */
1087 typedef unsigned int VAGenericID;
1089 typedef VAGenericID VAConfigID;
1092 * Create a configuration for the video decode/encode/processing pipeline
1093 * it passes in the attribute list that specifies the attributes it cares
1094 * about, with the rest taking default values.
1096 VAStatus vaCreateConfig (
1099 VAEntrypoint entrypoint,
1100 VAConfigAttrib *attrib_list,
1102 VAConfigID *config_id /* out */
1106 * Free resources associdated with a given config
1108 VAStatus vaDestroyConfig (
1110 VAConfigID config_id
1114 * Query all attributes for a given configuration
1115 * The profile of the configuration is returned in "profile"
1116 * The entrypoint of the configuration is returned in "entrypoint"
1117 * The caller must provide an "attrib_list" array that can hold at least
1118 * vaMaxNumConfigAttributes() entries. The actual number of attributes
1119 * returned in "attrib_list" is returned in "num_attribs"
1121 VAStatus vaQueryConfigAttributes (
1123 VAConfigID config_id,
1124 VAProfile *profile, /* out */
1125 VAEntrypoint *entrypoint, /* out */
1126 VAConfigAttrib *attrib_list,/* out */
1127 int *num_attribs /* out */
1132 * Contexts and Surfaces
1134 * Context represents a "virtual" video decode, encode or video processing
1135 * pipeline. Surfaces are render targets for a given context. The data in the
1136 * surfaces are not accessible to the client except if derived image is supported
1137 * and the internal data format of the surface is implementation specific.
1139 * Surfaces are provided as a hint of what surfaces will be used when the context
1140 * is created through vaCreateContext(). A surface may be used by different contexts
1141 * at the same time as soon as application can make sure the operations are synchronized
1142 * between different contexts, e.g. a surface is used as the output of a decode context
1143 * and the input of a video process context. Surfaces can only be destroyed after all
1144 * contexts using these surfaces have been destroyed.
1146 * Both contexts and surfaces are identified by unique IDs and its
1147 * implementation specific internals are kept opaque to the clients
1150 typedef VAGenericID VAContextID;
1152 typedef VAGenericID VASurfaceID;
1154 #define VA_INVALID_ID 0xffffffff
1155 #define VA_INVALID_SURFACE VA_INVALID_ID
1157 /** \brief Generic value types. */
1159 VAGenericValueTypeInteger = 1, /**< 32-bit signed integer. */
1160 VAGenericValueTypeFloat, /**< 32-bit floating-point value. */
1161 VAGenericValueTypePointer, /**< Generic pointer type */
1162 VAGenericValueTypeFunc /**< Pointer to function */
1163 } VAGenericValueType;
1165 /** \brief Generic function type. */
1166 typedef void (*VAGenericFunc)(void);
1168 /** \brief Generic value. */
1169 typedef struct _VAGenericValue {
1170 /** \brief Value type. See #VAGenericValueType. */
1171 VAGenericValueType type;
1172 /** \brief Value holder. */
1174 /** \brief 32-bit signed integer. */
1176 /** \brief 32-bit float. */
1178 /** \brief Generic pointer. */
1180 /** \brief Pointer to function. */
1185 /** @name Surface attribute flags */
1187 /** \brief Surface attribute is not supported. */
1188 #define VA_SURFACE_ATTRIB_NOT_SUPPORTED 0x00000000
1189 /** \brief Surface attribute can be got through vaQuerySurfaceAttributes(). */
1190 #define VA_SURFACE_ATTRIB_GETTABLE 0x00000001
1191 /** \brief Surface attribute can be set through vaCreateSurfaces(). */
1192 #define VA_SURFACE_ATTRIB_SETTABLE 0x00000002
1195 /** \brief Surface attribute types. */
1197 VASurfaceAttribNone = 0,
1199 * \brief Pixel format (fourcc).
1201 * The value is meaningful as input to vaQuerySurfaceAttributes().
1202 * If zero, the driver returns the optimal pixel format for the
1203 * specified config. Otherwise, if non-zero, the value represents
1204 * a pixel format (FOURCC) that is kept as is on output, if the
1205 * driver supports it. Otherwise, the driver sets the value to
1206 * zero and drops the \c VA_SURFACE_ATTRIB_SETTABLE flag.
1208 VASurfaceAttribPixelFormat,
1209 /** \brief Minimal width in pixels (int, read-only). */
1210 VASurfaceAttribMinWidth,
1211 /** \brief Maximal width in pixels (int, read-only). */
1212 VASurfaceAttribMaxWidth,
1213 /** \brief Minimal height in pixels (int, read-only). */
1214 VASurfaceAttribMinHeight,
1215 /** \brief Maximal height in pixels (int, read-only). */
1216 VASurfaceAttribMaxHeight,
1217 /** \brief Surface memory type expressed in bit fields (int, read/write). */
1218 VASurfaceAttribMemoryType,
1219 /** \brief External buffer descriptor (pointer, write). */
1220 VASurfaceAttribExternalBufferDescriptor,
1221 /** \brief Surface usage hint, gives the driver a hint of intended usage
1222 * to optimize allocation (e.g. tiling) (int, read/write). */
1223 VASurfaceAttribUsageHint,
1224 /** \brief Number of surface attributes. */
1225 VASurfaceAttribCount
1226 } VASurfaceAttribType;
1228 /** \brief Surface attribute. */
1229 typedef struct _VASurfaceAttrib {
1231 VASurfaceAttribType type;
1232 /** \brief Flags. See "Surface attribute flags". */
1234 /** \brief Value. See "Surface attribute types" for the expected types. */
1235 VAGenericValue value;
1239 * @name VASurfaceAttribMemoryType values in bit fields.
1240 * Bit 0:7 are reserved for generic types, Bit 31:28 are reserved for
1241 * Linux DRM, Bit 23:20 are reserved for Android. DRM and Android specific
1242 * types are defined in DRM and Android header files.
1245 /** \brief VA memory type (default) is supported. */
1246 #define VA_SURFACE_ATTRIB_MEM_TYPE_VA 0x00000001
1247 /** \brief V4L2 buffer memory type is supported. */
1248 #define VA_SURFACE_ATTRIB_MEM_TYPE_V4L2 0x00000002
1249 /** \brief User pointer memory type is supported. */
1250 #define VA_SURFACE_ATTRIB_MEM_TYPE_USER_PTR 0x00000004
1254 * \brief VASurfaceAttribExternalBuffers structure for
1255 * the VASurfaceAttribExternalBufferDescriptor attribute.
1257 typedef struct _VASurfaceAttribExternalBuffers {
1258 /** \brief pixel format in fourcc. */
1259 uint32_t pixel_format;
1260 /** \brief width in pixels. */
1262 /** \brief height in pixels. */
1264 /** \brief total size of the buffer in bytes. */
1266 /** \brief number of planes for planar layout */
1267 uint32_t num_planes;
1268 /** \brief pitch for each plane in bytes */
1269 uint32_t pitches[4];
1270 /** \brief offset for each plane in bytes */
1271 uint32_t offsets[4];
1272 /** \brief buffer handles or user pointers */
1274 /** \brief number of elements in the "buffers" array */
1275 uint32_t num_buffers;
1276 /** \brief flags. See "Surface external buffer descriptor flags". */
1278 /** \brief reserved for passing private data */
1280 } VASurfaceAttribExternalBuffers;
1282 /** @name VASurfaceAttribExternalBuffers flags */
1284 /** \brief Enable memory tiling */
1285 #define VA_SURFACE_EXTBUF_DESC_ENABLE_TILING 0x00000001
1286 /** \brief Memory is cacheable */
1287 #define VA_SURFACE_EXTBUF_DESC_CACHED 0x00000002
1288 /** \brief Memory is non-cacheable */
1289 #define VA_SURFACE_EXTBUF_DESC_UNCACHED 0x00000004
1290 /** \brief Memory is write-combined */
1291 #define VA_SURFACE_EXTBUF_DESC_WC 0x00000008
1292 /** \brief Memory is protected */
1293 #define VA_SURFACE_EXTBUF_DESC_PROTECTED 0x80000000
1295 /** @name VASurfaceAttribUsageHint attribute usage hint flags */
1297 /** \brief Surface usage not indicated. */
1298 #define VA_SURFACE_ATTRIB_USAGE_HINT_GENERIC 0x00000000
1299 /** \brief Surface used by video decoder. */
1300 #define VA_SURFACE_ATTRIB_USAGE_HINT_DECODER 0x00000001
1301 /** \brief Surface used by video encoder. */
1302 #define VA_SURFACE_ATTRIB_USAGE_HINT_ENCODER 0x00000002
1303 /** \brief Surface read by video post-processing. */
1304 #define VA_SURFACE_ATTRIB_USAGE_HINT_VPP_READ 0x00000004
1305 /** \brief Surface written by video post-processing. */
1306 #define VA_SURFACE_ATTRIB_USAGE_HINT_VPP_WRITE 0x00000008
1307 /** \brief Surface used for display. */
1308 #define VA_SURFACE_ATTRIB_USAGE_HINT_DISPLAY 0x00000010
1313 * \brief Queries surface attributes for the supplied config.
1315 * This function queries for all supported attributes for the
1316 * supplied VA @config. In particular, if the underlying hardware
1317 * supports the creation of VA surfaces in various formats, then
1318 * this function will enumerate all pixel formats that are supported.
1320 * The \c attrib_list array is allocated by the user and \c
1321 * num_attribs shall be initialized to the number of allocated
1322 * elements in that array. Upon successful return, the actual number
1323 * of attributes will be overwritten into \c num_attribs. Otherwise,
1324 * \c VA_STATUS_ERROR_MAX_NUM_EXCEEDED is returned and \c num_attribs
1325 * is adjusted to the number of elements that would be returned if
1326 * enough space was available.
1328 * Note: it is perfectly valid to pass NULL to the \c attrib_list
1329 * argument when vaQuerySurfaceAttributes() is used to determine the
1330 * actual number of elements that need to be allocated.
1332 * @param[in] dpy the VA display
1333 * @param[in] config the config identifying a codec or a video
1334 * processing pipeline
1335 * @param[out] attrib_list the output array of #VASurfaceAttrib elements
1336 * @param[in,out] num_attribs the number of elements allocated on
1337 * input, the number of elements actually filled in output
1340 vaQuerySurfaceAttributes(
1343 VASurfaceAttrib *attrib_list,
1344 unsigned int *num_attribs
1348 * \brief Creates an array of surfaces
1350 * Creates an array of surfaces. The optional list of attributes shall
1351 * be constructed based on what the underlying hardware could expose
1352 * through vaQuerySurfaceAttributes().
1354 * @param[in] dpy the VA display
1355 * @param[in] format the desired surface format. See \c VA_RT_FORMAT_*
1356 * @param[in] width the surface width
1357 * @param[in] height the surface height
1358 * @param[out] surfaces the array of newly created surfaces
1359 * @param[in] num_surfaces the number of surfaces to create
1360 * @param[in] attrib_list the list of (optional) attributes, or \c NULL
1361 * @param[in] num_attribs the number of attributes supplied in
1362 * \c attrib_list, or zero
1367 unsigned int format,
1369 unsigned int height,
1370 VASurfaceID *surfaces,
1371 unsigned int num_surfaces,
1372 VASurfaceAttrib *attrib_list,
1373 unsigned int num_attribs
1377 * vaDestroySurfaces - Destroy resources associated with surfaces.
1378 * Surfaces can only be destroyed after all contexts using these surfaces have been
1381 * surfaces: array of surfaces to destroy
1382 * num_surfaces: number of surfaces in the array to be destroyed.
1384 VAStatus vaDestroySurfaces (
1386 VASurfaceID *surfaces,
1390 #define VA_PROGRESSIVE 0x1
1392 * vaCreateContext - Create a context
1394 * config_id: configuration for the context
1395 * picture_width: coded picture width
1396 * picture_height: coded picture height
1397 * flag: any combination of the following:
1398 * VA_PROGRESSIVE (only progressive frame pictures in the sequence when set)
1399 * render_targets: a hint for render targets (surfaces) tied to the context
1400 * num_render_targets: number of render targets in the above array
1401 * context: created context id upon return
1403 VAStatus vaCreateContext (
1405 VAConfigID config_id,
1409 VASurfaceID *render_targets,
1410 int num_render_targets,
1411 VAContextID *context /* out */
1415 * vaDestroyContext - Destroy a context
1417 * context: context to be destroyed
1419 VAStatus vaDestroyContext (
1424 //Multi-frame context
1425 typedef VAGenericID VAMFContextID;
1427 * vaCreateMFContext - Create a multi-frame context
1428 * interface encapsulating common for all streams memory objects and structures
1429 * required for single GPU task submission from several VAContextID's.
1430 * Allocation: This call only creates an instance, doesn't allocate any additional memory.
1431 * Support identification: Application can identify multi-frame feature support by ability
1432 * to create multi-frame context. If driver supports multi-frame - call successful,
1433 * mf_context != NULL and VAStatus = VA_STATUS_SUCCESS, otherwise if multi-frame processing
1434 * not supported driver returns VA_STATUS_ERROR_UNIMPLEMENTED and mf_context = NULL.
1436 * VA_STATUS_SUCCESS - operation successful.
1437 * VA_STATUS_ERROR_UNIMPLEMENTED - no support for multi-frame.
1438 * dpy: display adapter.
1439 * mf_context: Multi-Frame context encapsulating all associated context
1440 * for multi-frame submission.
1442 VAStatus vaCreateMFContext (
1444 VAMFContextID *mf_context /* out */
1448 * vaMFAddContext - Provide ability to associate each context used for
1449 * Multi-Frame submission and common Multi-Frame context.
1450 * Try to add context to understand if it is supported.
1451 * Allocation: this call allocates and/or reallocates all memory objects
1452 * common for all contexts associated with particular Multi-Frame context.
1453 * All memory required for each context(pixel buffers, internal driver
1454 * buffers required for processing) allocated during standard vaCreateContext call for each context.
1455 * Runtime dependency - if current implementation doesn't allow to run different entry points/profile,
1456 * first context added will set entry point/profile for whole Multi-Frame context,
1457 * all other entry points and profiles can be rejected to be added.
1459 * VA_STATUS_SUCCESS - operation successful, context was added.
1460 * VA_STATUS_ERROR_OPERATION_FAILED - something unexpected happened - application have to close
1461 * current mf_context and associated contexts and start working with new ones.
1462 * VA_STATUS_ERROR_INVALID_CONTEXT - ContextID is invalid, means:
1463 * 1 - mf_context is not valid context or
1464 * 2 - driver can't suport different VAEntrypoint or VAProfile simultaneosly
1465 * and current context contradicts with previously added, application can continue with current mf_context
1466 * and other contexts passed this call, rejected context can continue work in stand-alone
1467 * mode or other mf_context.
1468 * VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT - particular context being added was created with with
1469 * unsupported VAEntrypoint. Application can continue with current mf_context
1470 * and other contexts passed this call, rejected context can continue work in stand-alone
1472 * VA_STATUS_ERROR_UNSUPPORTED_PROFILE - Current context with Particular VAEntrypoint is supported
1473 * but VAProfile is not supported. Application can continue with current mf_context
1474 * and other contexts passed this call, rejected context can continue work in stand-alone
1476 * dpy: display adapter.
1477 * context: context being associated with Multi-Frame context.
1478 * mf_context: - multi-frame context used to associate contexts for multi-frame submission.
1480 VAStatus vaMFAddContext (
1482 VAMFContextID mf_context,
1487 * vaMFReleaseContext - Removes context from multi-frame and
1488 * association with multi-frame context.
1489 * After association removed vaEndPicture will submit tasks, but not vaMFSubmit.
1491 * VA_STATUS_SUCCESS - operation successful, context was removed.
1492 * VA_STATUS_ERROR_OPERATION_FAILED - something unexpected happened.
1493 * application need to destroy this VAMFContextID and all assotiated VAContextID
1495 * mf_context: VAMFContextID where context is added
1496 * context: VAContextID to be added
1498 VAStatus vaMFReleaseContext (
1500 VAMFContextID mf_context,
1506 * Buffers are used to pass various types of data from the
1507 * client to the server. The server maintains a data store
1508 * for each buffer created, and the client idenfies a buffer
1509 * through a unique buffer id assigned by the server.
1512 typedef VAGenericID VABufferID;
1516 VAPictureParameterBufferType = 0,
1517 VAIQMatrixBufferType = 1,
1518 VABitPlaneBufferType = 2,
1519 VASliceGroupMapBufferType = 3,
1520 VASliceParameterBufferType = 4,
1521 VASliceDataBufferType = 5,
1522 VAMacroblockParameterBufferType = 6,
1523 VAResidualDataBufferType = 7,
1524 VADeblockingParameterBufferType = 8,
1525 VAImageBufferType = 9,
1526 VAProtectedSliceDataBufferType = 10,
1527 VAQMatrixBufferType = 11,
1528 VAHuffmanTableBufferType = 12,
1529 VAProbabilityBufferType = 13,
1531 /* Following are encode buffer types */
1532 VAEncCodedBufferType = 21,
1533 VAEncSequenceParameterBufferType = 22,
1534 VAEncPictureParameterBufferType = 23,
1535 VAEncSliceParameterBufferType = 24,
1536 VAEncPackedHeaderParameterBufferType = 25,
1537 VAEncPackedHeaderDataBufferType = 26,
1538 VAEncMiscParameterBufferType = 27,
1539 VAEncMacroblockParameterBufferType = 28,
1540 VAEncMacroblockMapBufferType = 29,
1543 * \brief Encoding QP buffer
1545 * This buffer contains QP per MB for encoding. Currently
1546 * VAEncQPBufferH264 is defined for H.264 encoding, see
1547 * #VAEncQPBufferH264 for details
1549 VAEncQPBufferType = 30,
1550 /* Following are video processing buffer types */
1552 * \brief Video processing pipeline parameter buffer.
1554 * This buffer describes the video processing pipeline. See
1555 * #VAProcPipelineParameterBuffer for details.
1557 VAProcPipelineParameterBufferType = 41,
1559 * \brief Video filter parameter buffer.
1561 * This buffer describes the video filter parameters. All buffers
1562 * inherit from #VAProcFilterParameterBufferBase, thus including
1563 * a unique filter buffer type.
1565 * The default buffer used by most filters is #VAProcFilterParameterBuffer.
1566 * Filters requiring advanced parameters include, but are not limited to,
1567 * deinterlacing (#VAProcFilterParameterBufferDeinterlacing),
1568 * color balance (#VAProcFilterParameterBufferColorBalance), etc.
1570 VAProcFilterParameterBufferType = 42,
1572 * \brief FEI specific buffer types
1574 VAEncFEIMVBufferType = 43,
1575 VAEncFEIMBCodeBufferType = 44,
1576 VAEncFEIDistortionBufferType = 45,
1577 VAEncFEIMBControlBufferType = 46,
1578 VAEncFEIMVPredictorBufferType = 47,
1579 VAStatsStatisticsParameterBufferType = 48,
1580 /** \brief Statistics output for VAEntrypointStats progressive and top field of interlaced case*/
1581 VAStatsStatisticsBufferType = 49,
1582 /** \brief Statistics output for VAEntrypointStats bottom field of interlaced case*/
1583 VAStatsStatisticsBottomFieldBufferType = 50,
1584 VAStatsMVBufferType = 51,
1585 VAStatsMVPredictorBufferType = 52,
1586 /** Force MB's to be non skip for encode.it's per-mb control buffer, The width of the MB map
1587 * Surface is (width of the Picture in MB unit) * 1 byte, multiple of 64 bytes.
1588 * The height is (height of the picture in MB unit). The picture is either
1589 * frame or non-interleaved top or bottom field. If the application provides this
1590 *surface, it will override the "skipCheckDisable" setting in VAEncMiscParameterEncQuality.
1592 VAEncMacroblockDisableSkipMapBufferType = 53,
1594 * \brief HEVC FEI CTB level cmd buffer
1595 * it is CTB level information for future usage.
1597 VAEncFEICTBCmdBufferType = 54,
1599 * \brief HEVC FEI CU level data buffer
1600 * it's CTB level information for future usage
1602 VAEncFEICURecordBufferType = 55,
1603 /** decode stream out buffer, intermedia data of decode, it may include MV, MB mode etc.
1604 * it can be used to detect motion and analyze the frame contain */
1605 VADecodeStreamoutBufferType = 56,
1610 * Processing rate parameter for encode.
1612 typedef struct _VAProcessingRateParameterEnc {
1613 /** \brief Profile level */
1615 uint8_t reserved[3];
1616 /** \brief quality level. When set to 0, default quality
1619 uint32_t quality_level;
1620 /** \brief Period between I frames. */
1621 uint32_t intra_period;
1622 /** \brief Period between I/P frames. */
1624 } VAProcessingRateParameterEnc;
1627 * Processing rate parameter for decode.
1629 typedef struct _VAProcessingRateParameterDec {
1630 /** \brief Profile level */
1632 uint8_t reserved0[3];
1634 } VAProcessingRateParameterDec;
1636 typedef struct _VAProcessingRateParameter {
1638 VAProcessingRateParameterEnc proc_buf_enc;
1639 VAProcessingRateParameterDec proc_buf_dec;
1641 } VAProcessingRateParameter;
1644 * \brief Queries processing rate for the supplied config.
1646 * This function queries the processing rate based on parameters in
1647 * \c proc_buf for the given \c config. Upon successful return, the processing
1648 * rate value will be stored in \c processing_rate. Processing rate is
1649 * specified as the number of macroblocks/CTU per second.
1651 * If NULL is passed to the \c proc_buf, the default processing rate for the
1652 * given configuration will be returned.
1654 * @param[in] dpy the VA display
1655 * @param[in] config the config identifying a codec or a video
1656 * processing pipeline
1657 * @param[in] proc_buf the buffer that contains the parameters for
1658 either the encode or decode processing rate
1659 * @param[out] processing_rate processing rate in number of macroblocks per
1660 second constrained by parameters specified in proc_buf
1664 vaQueryProcessingRate(
1667 VAProcessingRateParameter *proc_buf,
1668 unsigned int *processing_rate
1673 VAEncMiscParameterTypeFrameRate = 0,
1674 VAEncMiscParameterTypeRateControl = 1,
1675 VAEncMiscParameterTypeMaxSliceSize = 2,
1676 VAEncMiscParameterTypeAIR = 3,
1677 /** \brief Buffer type used to express a maximum frame size (in bits). */
1678 VAEncMiscParameterTypeMaxFrameSize = 4,
1679 /** \brief Buffer type used for HRD parameters. */
1680 VAEncMiscParameterTypeHRD = 5,
1681 VAEncMiscParameterTypeQualityLevel = 6,
1682 /** \brief Buffer type used for Rolling intra refresh */
1683 VAEncMiscParameterTypeRIR = 7,
1684 /** \brief Buffer type used for quantization parameters, it's per-sequence parameter*/
1685 VAEncMiscParameterTypeQuantization = 8,
1686 /** \brief Buffer type used for sending skip frame parameters to the encoder's
1687 * rate control, when the user has externally skipped frames. */
1688 VAEncMiscParameterTypeSkipFrame = 9,
1689 /** \brief Buffer type used for region-of-interest (ROI) parameters. */
1690 VAEncMiscParameterTypeROI = 10,
1691 /** \brief Buffer type used for temporal layer structure */
1692 VAEncMiscParameterTypeTemporalLayerStructure = 12,
1693 /** \brief Buffer type used for dirty region-of-interest (ROI) parameters. */
1694 VAEncMiscParameterTypeDirtyRect = 13,
1695 /** \brief Buffer type used for parallel BRC parameters. */
1696 VAEncMiscParameterTypeParallelBRC = 14,
1697 /** \brief Set MB partion mode mask and Half-pel/Quant-pel motion search */
1698 VAEncMiscParameterTypeSubMbPartPel = 15,
1699 /** \brief set encode quality tuning */
1700 VAEncMiscParameterTypeEncQuality = 16,
1701 /** \brief Buffer type used for encoder rounding offset parameters. */
1702 VAEncMiscParameterTypeCustomRoundingControl = 17,
1703 /** \brief Buffer type used for FEI input frame level parameters */
1704 VAEncMiscParameterTypeFEIFrameControl = 18,
1705 /** \brief encode extension buffer, ect. MPEG2 Sequence extenstion data */
1706 VAEncMiscParameterTypeExtensionData = 19
1707 } VAEncMiscParameterType;
1709 /** \brief Packed header type. */
1711 /** \brief Packed sequence header. */
1712 VAEncPackedHeaderSequence = 1,
1713 /** \brief Packed picture header. */
1714 VAEncPackedHeaderPicture = 2,
1715 /** \brief Packed slice header. */
1716 VAEncPackedHeaderSlice = 3,
1718 * \brief Packed raw header.
1720 * Packed raw data header can be used by the client to insert a header
1721 * into the bitstream data buffer at the point it is passed, the driver
1722 * will handle the raw packed header based on "has_emulation_bytes" field
1723 * in the packed header parameter structure.
1725 VAEncPackedHeaderRawData = 4,
1727 * \brief Misc packed header. See codec-specific definitions.
1730 * This is a deprecated packed header type. All applications can use
1731 * \c VAEncPackedHeaderRawData to insert a codec-specific packed header
1733 VAEncPackedHeaderMiscMask va_deprecated_enum = 0x80000000,
1734 } VAEncPackedHeaderType;
1736 /** \brief Packed header parameter. */
1737 typedef struct _VAEncPackedHeaderParameterBuffer {
1738 /** Type of the packed header buffer. See #VAEncPackedHeaderType. */
1740 /** \brief Size of the #VAEncPackedHeaderDataBuffer in bits. */
1741 uint32_t bit_length;
1742 /** \brief Flag: buffer contains start code emulation prevention bytes? */
1743 uint8_t has_emulation_bytes;
1745 /** \brief Reserved bytes for future use, must be zero */
1746 uint32_t va_reserved[VA_PADDING_LOW];
1747 } VAEncPackedHeaderParameterBuffer;
1750 * For application, e.g. set a new bitrate
1751 * VABufferID buf_id;
1752 * VAEncMiscParameterBuffer *misc_param;
1753 * VAEncMiscParameterRateControl *misc_rate_ctrl;
1755 * vaCreateBuffer(dpy, context, VAEncMiscParameterBufferType,
1756 * sizeof(VAEncMiscParameterBuffer) + sizeof(VAEncMiscParameterRateControl),
1757 * 1, NULL, &buf_id);
1759 * vaMapBuffer(dpy,buf_id,(void **)&misc_param);
1760 * misc_param->type = VAEncMiscParameterTypeRateControl;
1761 * misc_rate_ctrl= (VAEncMiscParameterRateControl *)misc_param->data;
1762 * misc_rate_ctrl->bits_per_second = 6400000;
1763 * vaUnmapBuffer(dpy, buf_id);
1764 * vaRenderPicture(dpy, context, &buf_id, 1);
1766 typedef struct _VAEncMiscParameterBuffer
1768 VAEncMiscParameterType type;
1770 } VAEncMiscParameterBuffer;
1772 /** \brief Temporal layer Structure*/
1773 typedef struct _VAEncMiscParameterTemporalLayerStructure
1775 /** \brief The number of temporal layers */
1776 uint32_t number_of_layers;
1777 /** \brief The length of the array defining frame layer membership. Should be 1-32 */
1778 uint32_t periodicity;
1780 * \brief The array indicating the layer id for each frame
1782 * The layer id for the first frame in a coded sequence is always 0, so layer_id[] specifies the layer
1783 * ids for frames starting from the 2nd frame.
1785 uint32_t layer_id[32];
1787 /** \brief Reserved bytes for future use, must be zero */
1788 uint32_t va_reserved[VA_PADDING_LOW];
1789 } VAEncMiscParameterTemporalLayerStructure;
1792 /** \brief Rate control parameters */
1793 typedef struct _VAEncMiscParameterRateControl
1795 /* this is the maximum bit-rate to be constrained by the rate control implementation */
1796 uint32_t bits_per_second;
1797 /* this is the bit-rate the rate control is targeting, as a percentage of the maximum
1798 * bit-rate for example if target_percentage is 95 then the rate control will target
1799 * a bit-rate that is 95% of the maximum bit-rate
1801 uint32_t target_percentage;
1802 /* windows size in milliseconds. For example if this is set to 500,
1803 * then the rate control will guarantee the target bit-rate over a 500 ms window
1805 uint32_t window_size;
1806 /* initial QP at I frames */
1807 uint32_t initial_qp;
1809 uint32_t basic_unit_size;
1815 uint32_t disable_frame_skip : 1; /* Disable frame skip in rate control mode */
1816 uint32_t disable_bit_stuffing : 1; /* Disable bit stuffing in rate control mode */
1817 uint32_t mb_rate_control : 4; /* Control VA_RC_MB 0: default, 1: enable, 2: disable, other: reserved*/
1819 * The temporal layer that the rate control parameters are specified for.
1821 uint32_t temporal_id : 8;
1822 uint32_t cfs_I_frames : 1; /* I frame also follows CFS */
1823 uint32_t enable_parallel_brc : 1;
1824 uint32_t enable_dynamic_scaling : 1;
1825 /** \brief Frame Tolerance Mode
1826 * Indicates the tolerance the application has to variations in the frame size.
1827 * For example, wireless display scenarios may require very steady bit rate to
1828 * reduce buffering time. It affects the rate control algorithm used,
1829 * but may or may not have an effect based on the combination of other BRC
1830 * parameters. Only valid when the driver reports support for
1831 * #VAConfigAttribFrameSizeToleranceSupport.
1833 * equals 0 -- normal mode;
1834 * equals 1 -- maps to sliding window;
1835 * equals 2 -- maps to low delay mode;
1838 uint32_t frame_tolerance_mode : 2;
1839 uint32_t reserved : 12;
1843 uint32_t ICQ_quality_factor; /* Initial ICQ quality factor: 1-51. */
1844 /** \brief Reserved bytes for future use, must be zero */
1846 uint32_t va_reserved[VA_PADDING_MEDIUM - 2];
1847 } VAEncMiscParameterRateControl;
1849 typedef struct _VAEncMiscParameterFrameRate
1852 * The framerate is specified as a number of frames per second, as a
1853 * fraction. The denominator of the fraction is given in the top half
1854 * (the high two bytes) of the framerate field, and the numerator is
1855 * given in the bottom half (the low two bytes).
1858 * denominator = framerate >> 16 & 0xffff;
1859 * numerator = framerate & 0xffff;
1860 * fps = numerator / denominator;
1862 * For example, if framerate is set to (100 << 16 | 750), this is
1863 * 750 / 100, hence 7.5fps.
1865 * If the denominator is zero (the high two bytes are both zero) then
1866 * it takes the value one instead, so the framerate is just the integer
1867 * in the low 2 bytes.
1875 * The temporal id the framerate parameters are specified for.
1877 uint32_t temporal_id : 8;
1878 uint32_t reserved : 24;
1883 /** \brief Reserved bytes for future use, must be zero */
1884 uint32_t va_reserved[VA_PADDING_LOW];
1885 } VAEncMiscParameterFrameRate;
1888 * Allow a maximum slice size to be specified (in bits).
1889 * The encoder will attempt to make sure that individual slices do not exceed this size
1890 * Or to signal applicate if the slice size exceed this size, see "status" of VACodedBufferSegment
1892 typedef struct _VAEncMiscParameterMaxSliceSize
1894 uint32_t max_slice_size;
1896 /** \brief Reserved bytes for future use, must be zero */
1897 uint32_t va_reserved[VA_PADDING_LOW];
1898 } VAEncMiscParameterMaxSliceSize;
1900 typedef struct _VAEncMiscParameterAIR
1902 uint32_t air_num_mbs;
1903 uint32_t air_threshold;
1904 uint32_t air_auto; /* if set to 1 then hardware auto-tune the AIR threshold */
1906 /** \brief Reserved bytes for future use, must be zero */
1907 uint32_t va_reserved[VA_PADDING_LOW];
1908 } VAEncMiscParameterAIR;
1911 * \brief Rolling intra refresh data structure for encoding.
1913 typedef struct _VAEncMiscParameterRIR
1919 * \brief Indicate if intra refresh is enabled in column/row.
1921 * App should query VAConfigAttribEncIntraRefresh to confirm RIR support
1922 * by the driver before sending this structure.
1925 /* \brief enable RIR in column */
1926 uint32_t enable_rir_column : 1;
1927 /* \brief enable RIR in row */
1928 uint32_t enable_rir_row : 1;
1929 uint32_t reserved : 30;
1934 * \brief Indicates the column or row location in MB. It is ignored if
1937 uint16_t intra_insertion_location;
1939 * \brief Indicates the number of columns or rows in MB. It is ignored if
1942 uint16_t intra_insert_size;
1944 * \brief indicates the Qp difference for inserted intra columns or rows.
1945 * App can use this to adjust intra Qp based on bitrate & max frame size.
1947 uint8_t qp_delta_for_inserted_intra;
1948 /** \brief Reserved bytes for future use, must be zero */
1949 uint32_t va_reserved[VA_PADDING_LOW];
1950 } VAEncMiscParameterRIR;
1952 typedef struct _VAEncMiscParameterHRD
1954 uint32_t initial_buffer_fullness; /* in bits */
1955 uint32_t buffer_size; /* in bits */
1957 /** \brief Reserved bytes for future use, must be zero */
1958 uint32_t va_reserved[VA_PADDING_LOW];
1959 } VAEncMiscParameterHRD;
1962 * \brief Defines a maximum frame size (in bits).
1964 * This misc parameter buffer defines the maximum size of a frame (in
1965 * bits). The encoder will try to make sure that each frame does not
1966 * exceed this size. Otherwise, if the frame size exceeds this size,
1967 * the \c status flag of #VACodedBufferSegment will contain
1968 * #VA_CODED_BUF_STATUS_FRAME_SIZE_OVERFLOW.
1970 typedef struct _VAEncMiscParameterBufferMaxFrameSize {
1971 /** \brief Type. Shall be set to #VAEncMiscParameterTypeMaxFrameSize. */
1972 VAEncMiscParameterType type;
1973 /** \brief Maximum size of a frame (in bits). */
1974 uint32_t max_frame_size;
1976 /** \brief Reserved bytes for future use, must be zero */
1977 uint32_t va_reserved[VA_PADDING_LOW];
1978 } VAEncMiscParameterBufferMaxFrameSize;
1981 * \brief Encoding quality level.
1983 * The encoding quality could be set through this structure, if the implementation
1984 * supports multiple quality levels. The quality level set through this structure is
1985 * persistent over the entire coded sequence, or until a new structure is being sent.
1986 * The quality level range can be queried through the VAConfigAttribEncQualityRange
1987 * attribute. A lower value means higher quality, and a value of 1 represents the highest
1988 * quality. The quality level setting is used as a trade-off between quality and speed/power
1989 * consumption, with higher quality corresponds to lower speed and higher power consumption.
1991 typedef struct _VAEncMiscParameterBufferQualityLevel {
1992 /** \brief Encoding quality level setting. When set to 0, default quality
1995 uint32_t quality_level;
1997 /** \brief Reserved bytes for future use, must be zero */
1998 uint32_t va_reserved[VA_PADDING_LOW];
1999 } VAEncMiscParameterBufferQualityLevel;
2002 * \brief Quantization settings for encoding.
2004 * Some encoders support special types of quantization such as trellis, and this structure
2005 * can be used by the app to control these special types of quantization by the encoder.
2007 typedef struct _VAEncMiscParameterQuantization
2011 /* if no flags is set then quantization is determined by the driver */
2014 /* \brief disable trellis for all frames/fields */
2015 uint64_t disable_trellis : 1;
2016 /* \brief enable trellis for I frames/fields */
2017 uint64_t enable_trellis_I : 1;
2018 /* \brief enable trellis for P frames/fields */
2019 uint64_t enable_trellis_P : 1;
2020 /* \brief enable trellis for B frames/fields */
2021 uint64_t enable_trellis_B : 1;
2022 uint64_t reserved : 28;
2025 } quantization_flags;
2026 } VAEncMiscParameterQuantization;
2029 * \brief Encoding skip frame.
2031 * The application may choose to skip frames externally to the encoder (e.g. drop completely or
2032 * code as all skip's). For rate control purposes the encoder will need to know the size and number
2033 * of skipped frames. Skip frame(s) indicated through this structure is applicable only to the
2034 * current frame. It is allowed for the application to still send in packed headers for the driver to
2035 * pack, although no frame will be encoded (e.g. for HW to encrypt the frame).
2037 typedef struct _VAEncMiscParameterSkipFrame {
2038 /** \brief Indicates skip frames as below.
2039 * 0: Encode as normal, no skip.
2040 * 1: One or more frames were skipped prior to the current frame, encode the current frame as normal.
2041 * 2: The current frame is to be skipped, do not encode it but pack/encrypt the packed header contents
2042 * (all except VAEncPackedHeaderSlice) which could contain actual frame contents (e.g. pack the frame
2043 * in VAEncPackedHeaderPicture). */
2044 uint8_t skip_frame_flag;
2045 /** \brief The number of frames skipped prior to the current frame. Valid when skip_frame_flag = 1. */
2046 uint8_t num_skip_frames;
2047 /** \brief When skip_frame_flag = 1, the size of the skipped frames in bits. When skip_frame_flag = 2,
2048 * the size of the current skipped frame that is to be packed/encrypted in bits. */
2049 uint32_t size_skip_frames;
2051 /** \brief Reserved bytes for future use, must be zero */
2052 uint32_t va_reserved[VA_PADDING_LOW];
2053 } VAEncMiscParameterSkipFrame;
2056 * \brief Encoding region-of-interest (ROI).
2058 * The encoding ROI can be set through VAEncMiscParameterBufferROI, if the implementation
2059 * supports ROI input. The ROI set through this structure is applicable only to the
2060 * current frame or field, so must be sent every frame or field to be applied. The number of
2061 * supported ROIs can be queried through the VAConfigAttribEncROI. The encoder will use the
2062 * ROI information to adjust the QP values of the MB's that fall within the ROIs.
2064 typedef struct _VAEncROI
2066 /** \brief Defines the ROI boundary in pixels, the driver will map it to appropriate
2067 * codec coding units. It is relative to frame coordinates for the frame case and
2068 * to field coordinates for the field case. */
2069 VARectangle roi_rectangle;
2073 * \ref roi_value specifies ROI delta QP or ROI priority.
2074 * -- ROI delta QP is the value that will be added on top of the frame level QP.
2075 * -- ROI priority specifies the priority of a region, it can be positive (more important)
2076 * or negative (less important) values and is compared with non-ROI region (taken as value 0),
2077 * E.g. ROI region with \ref roi_value -3 is less important than the non-ROI region (\ref roi_value
2078 * implied to be 0) which is less important than ROI region with roi_value +2. For overlapping
2079 * regions, the roi_value that is first in the ROI array will have priority.
2081 * \ref roi_value always specifes ROI delta QP when VAConfigAttribRateControl == VA_RC_CQP, no matter
2082 * the value of \c roi_value_is_qp_delta in #VAEncMiscParameterBufferROI.
2084 * \ref roi_value depends on \c roi_value_is_qp_delta in #VAEncMiscParameterBufferROI when
2085 * VAConfigAttribRateControl != VA_RC_CQP. \ref roi_value specifies ROI_delta QP if \c roi_value_is_qp_delta
2086 * in VAEncMiscParameterBufferROI is 1, otherwise \ref roi_value specifies ROI priority.
2091 typedef struct _VAEncMiscParameterBufferROI {
2092 /** \brief Number of ROIs being sent.*/
2095 /** \brief Valid when VAConfigAttribRateControl != VA_RC_CQP, then the encoder's
2096 * rate control will determine actual delta QPs. Specifies the max/min allowed delta
2098 int8_t max_delta_qp;
2099 int8_t min_delta_qp;
2101 /** \brief Pointer to a VAEncROI array with num_roi elements. It is relative to frame
2102 * coordinates for the frame case and to field coordinates for the field case.*/
2107 * \brief An indication for roi value.
2109 * \ref roi_value_is_qp_delta equal to 1 indicates \c roi_value in #VAEncROI should
2110 * be used as ROI delta QP. \ref roi_value_is_qp_delta equal to 0 indicates \c roi_value
2111 * in #VAEncROI should be used as ROI priority.
2113 * \ref roi_value_is_qp_delta is only available when VAConfigAttribRateControl != VA_RC_CQP,
2114 * the setting must comply with \c roi_rc_priority_support and \c roi_rc_qp_delta_support in
2115 * #VAConfigAttribValEncROI. The underlying driver should ignore this field
2116 * when VAConfigAttribRateControl == VA_RC_CQP.
2118 uint32_t roi_value_is_qp_delta : 1;
2119 uint32_t reserved : 31;
2124 /** \brief Reserved bytes for future use, must be zero */
2125 uint32_t va_reserved[VA_PADDING_LOW];
2126 } VAEncMiscParameterBufferROI;
2128 * \brief Dirty rectangle data structure for encoding.
2130 * The encoding dirty rect can be set through VAEncMiscParameterBufferDirtyRect, if the
2131 * implementation supports dirty rect input. The rect set through this structure is applicable
2132 * only to the current frame or field, so must be sent every frame or field to be applied.
2133 * The number of supported rects can be queried through the VAConfigAttribEncDirtyRect. The
2134 * encoder will use the rect information to know those rectangle areas have changed while the
2135 * areas not covered by dirty rect rectangles are assumed to have not changed compared to the
2136 * previous picture. The encoder may do some internal optimizations.
2138 typedef struct _VAEncMiscParameterBufferDirtyRect
2140 /** \brief Number of Rectangle being sent.*/
2141 uint32_t num_roi_rectangle;
2143 /** \brief Pointer to a VARectangle array with num_roi_rectangle elements.*/
2144 VARectangle *roi_rectangle;
2145 } VAEncMiscParameterBufferDirtyRect;
2147 /** \brief Attribute value for VAConfigAttribEncParallelRateControl */
2148 typedef struct _VAEncMiscParameterParallelRateControl {
2149 /** brief Number of layers*/
2150 uint32_t num_layers;
2151 /** brief Number of B frames per layer per GOP.
2153 * it should be allocated by application, and the is num_layers.
2154 * num_b_in_gop[0] is the number of regular B which refers to only I or P frames. */
2155 uint32_t *num_b_in_gop;
2156 } VAEncMiscParameterParallelRateControl;
2158 /** per frame encoder quality controls, once set they will persist for all future frames
2159 *till it is updated again. */
2160 typedef struct _VAEncMiscParameterEncQuality
2166 /** Use raw frames for reference instead of reconstructed frames.
2167 * it only impact motion estimation (ME) stage, and will not impact MC stage
2168 * so the reconstruct picture will can match with decode side */
2169 uint32_t useRawPicForRef : 1;
2170 /** Disables skip check for ME stage, it will increase the bistream size
2171 * but will improve the qulity */
2172 uint32_t skipCheckDisable : 1;
2173 /** Indicates app will override default driver FTQ settings using FTQEnable.
2174 * FTQ is forward transform quantization */
2175 uint32_t FTQOverride : 1;
2176 /** Enables/disables FTQ. */
2177 uint32_t FTQEnable : 1;
2178 /** Indicates the app will provide the Skip Threshold LUT to use when FTQ is
2179 * enabled (FTQSkipThresholdLUT), else default driver thresholds will be used. */
2180 uint32_t FTQSkipThresholdLUTInput : 1;
2181 /** Indicates the app will provide the Skip Threshold LUT to use when FTQ is
2182 * disabled (NonFTQSkipThresholdLUT), else default driver thresholds will be used. */
2183 uint32_t NonFTQSkipThresholdLUTInput : 1;
2184 uint32_t ReservedBit : 1;
2185 /** Control to enable the ME mode decision algorithm to bias to fewer B Direct/Skip types.
2186 * Applies only to B frames, all other frames will ignore this setting. */
2187 uint32_t directBiasAdjustmentEnable : 1;
2188 /** Enables global motion bias. global motion also is called HME (Heirarchical Motion Estimation )
2189 * HME is used to handle large motions and avoiding local minima in the video encoding process
2190 * down scaled the input and reference picture, then do ME. the result will be a predictor to next level HME or ME
2191 * current interface divide the HME to 3 level. UltraHME , SuperHME, and HME, result of UltraHME will be input of SurperHME,
2192 * result of superHME will be a input for HME. HME result will be input of ME. it is a switch for HMEMVCostScalingFactor
2193 * can change the HME bias inside RDO stage*/
2194 uint32_t globalMotionBiasAdjustmentEnable : 1;
2195 /** MV cost scaling ratio for HME ( predictors. It is used when
2196 * globalMotionBiasAdjustmentEnable == 1, else it is ignored. Values are:
2197 * 0: set MV cost to be 0 for HME predictor.
2198 * 1: scale MV cost to be 1/2 of the default value for HME predictor.
2199 * 2: scale MV cost to be 1/4 of the default value for HME predictor.
2200 * 3: scale MV cost to be 1/8 of the default value for HME predictor. */
2201 uint32_t HMEMVCostScalingFactor : 2;
2202 /**disable HME, if it is disabled. Super*ultraHME should also be disabled */
2203 uint32_t HMEDisable : 1;
2204 /**disable Super HME, if it is disabled, ultraHME should be disabled */
2205 uint32_t SuperHMEDisable : 1;
2206 /** disable Ultra HME */
2207 uint32_t UltraHMEDisable : 1;
2208 /** disable panic mode. Panic mode happened when there are extreme BRC (bit rate control) requirement
2209 * frame size cant achieve the target of BRC. when Panic mode is triggered, Coefficients will
2210 * be set to zero. disable panic mode will improve quality but will impact BRC */
2211 uint32_t PanicModeDisable : 1;
2212 /** Force RepartitionCheck
2213 * 0: DEFAULT - follow driver default settings.
2214 * 1: FORCE_ENABLE - enable this feature totally for all cases.
2215 * 2: FORCE_DISABLE - disable this feature totally for all cases. */
2216 uint32_t ForceRepartitionCheck : 2;
2219 uint32_t encControls;
2222 /** Maps QP to skip thresholds when FTQ is enabled. Valid range is 0-255. */
2223 uint8_t FTQSkipThresholdLUT[52];
2224 /** Maps QP to skip thresholds when FTQ is disabled. Valid range is 0-65535. */
2225 uint16_t NonFTQSkipThresholdLUT[52];
2227 uint32_t reserved[VA_PADDING_HIGH]; // Reserved for future use.
2229 } VAEncMiscParameterEncQuality;
2232 * \brief Custom Encoder Rounding Offset Control.
2233 * Application may use this structure to set customized rounding
2234 * offset parameters for quantization.
2235 * Valid when \c VAConfigAttribCustomRoundingControl equals 1.
2237 typedef struct _VAEncMiscParameterCustomRoundingControl
2241 /** \brief Enable customized rounding offset for intra blocks.
2242 * If 0, default value would be taken by driver for intra
2245 uint32_t enable_custom_rouding_intra : 1 ;
2247 /** \brief Intra rounding offset
2248 * Ignored if \c enable_custom_rouding_intra equals 0.
2250 uint32_t rounding_offset_intra : 7;
2252 /** \brief Enable customized rounding offset for inter blocks.
2253 * If 0, default value would be taken by driver for inter
2256 uint32_t enable_custom_rounding_inter : 1 ;
2258 /** \brief Inter rounding offset
2259 * Ignored if \c enable_custom_rouding_inter equals 0.
2261 uint32_t rounding_offset_inter : 7;
2264 uint32_t reserved :16;
2267 } rounding_offset_setting;
2268 } VAEncMiscParameterCustomRoundingControl;
2270 * There will be cases where the bitstream buffer will not have enough room to hold
2271 * the data for the entire slice, and the following flags will be used in the slice
2272 * parameter to signal to the server for the possible cases.
2273 * If a slice parameter buffer and slice data buffer pair is sent to the server with
2274 * the slice data partially in the slice data buffer (BEGIN and MIDDLE cases below),
2275 * then a slice parameter and data buffer needs to be sent again to complete this slice.
2277 #define VA_SLICE_DATA_FLAG_ALL 0x00 /* whole slice is in the buffer */
2278 #define VA_SLICE_DATA_FLAG_BEGIN 0x01 /* The beginning of the slice is in the buffer but the end if not */
2279 #define VA_SLICE_DATA_FLAG_MIDDLE 0x02 /* Neither beginning nor end of the slice is in the buffer */
2280 #define VA_SLICE_DATA_FLAG_END 0x04 /* end of the slice is in the buffer */
2282 /* Codec-independent Slice Parameter Buffer base */
2283 typedef struct _VASliceParameterBufferBase
2285 uint32_t slice_data_size; /* number of bytes in the slice data buffer for this slice */
2286 uint32_t slice_data_offset; /* the offset to the first byte of slice data */
2287 uint32_t slice_data_flag; /* see VA_SLICE_DATA_FLAG_XXX definitions */
2288 } VASliceParameterBufferBase;
2290 /**********************************
2291 * JPEG common data structures
2292 **********************************/
2294 * \brief Huffman table for JPEG decoding.
2296 * This structure holds the complete Huffman tables. This is an
2297 * aggregation of all Huffman table (DHT) segments maintained by the
2298 * application. i.e. up to 2 Huffman tables are stored in there for
2301 * The #load_huffman_table array can be used as a hint to notify the
2302 * VA driver implementation about which table(s) actually changed
2303 * since the last submission of this buffer.
2305 typedef struct _VAHuffmanTableBufferJPEGBaseline {
2306 /** \brief Specifies which #huffman_table is valid. */
2307 uint8_t load_huffman_table[2];
2308 /** \brief Huffman tables indexed by table identifier (Th). */
2310 /** @name DC table (up to 12 categories) */
2312 /** \brief Number of Huffman codes of length i + 1 (Li). */
2313 uint8_t num_dc_codes[16];
2314 /** \brief Value associated with each Huffman code (Vij). */
2315 uint8_t dc_values[12];
2317 /** @name AC table (2 special codes + up to 16 * 10 codes) */
2319 /** \brief Number of Huffman codes of length i + 1 (Li). */
2320 uint8_t num_ac_codes[16];
2321 /** \brief Value associated with each Huffman code (Vij). */
2322 uint8_t ac_values[162];
2323 /** \brief Padding to 4-byte boundaries. Must be set to zero. */
2328 /** \brief Reserved bytes for future use, must be zero */
2329 uint32_t va_reserved[VA_PADDING_LOW];
2330 } VAHuffmanTableBufferJPEGBaseline;
2332 /****************************
2333 * MPEG-2 data structures
2334 ****************************/
2336 /* MPEG-2 Picture Parameter Buffer */
2338 * For each frame or field, and before any slice data, a single
2339 * picture parameter buffer must be send.
2341 typedef struct _VAPictureParameterBufferMPEG2
2343 uint16_t horizontal_size;
2344 uint16_t vertical_size;
2345 VASurfaceID forward_reference_picture;
2346 VASurfaceID backward_reference_picture;
2347 /* meanings of the following fields are the same as in the standard */
2348 int32_t picture_coding_type;
2349 int32_t f_code; /* pack all four fcode into this */
2352 uint32_t intra_dc_precision : 2;
2353 uint32_t picture_structure : 2;
2354 uint32_t top_field_first : 1;
2355 uint32_t frame_pred_frame_dct : 1;
2356 uint32_t concealment_motion_vectors : 1;
2357 uint32_t q_scale_type : 1;
2358 uint32_t intra_vlc_format : 1;
2359 uint32_t alternate_scan : 1;
2360 uint32_t repeat_first_field : 1;
2361 uint32_t progressive_frame : 1;
2362 uint32_t is_first_field : 1; /* indicate whether the current field
2363 * is the first field for field picture
2367 } picture_coding_extension;
2369 /** \brief Reserved bytes for future use, must be zero */
2370 uint32_t va_reserved[VA_PADDING_LOW];
2371 } VAPictureParameterBufferMPEG2;
2373 /** MPEG-2 Inverse Quantization Matrix Buffer */
2374 typedef struct _VAIQMatrixBufferMPEG2
2376 /** \brief Same as the MPEG-2 bitstream syntax element. */
2377 int32_t load_intra_quantiser_matrix;
2378 /** \brief Same as the MPEG-2 bitstream syntax element. */
2379 int32_t load_non_intra_quantiser_matrix;
2380 /** \brief Same as the MPEG-2 bitstream syntax element. */
2381 int32_t load_chroma_intra_quantiser_matrix;
2382 /** \brief Same as the MPEG-2 bitstream syntax element. */
2383 int32_t load_chroma_non_intra_quantiser_matrix;
2384 /** \brief Luminance intra matrix, in zig-zag scan order. */
2385 uint8_t intra_quantiser_matrix[64];
2386 /** \brief Luminance non-intra matrix, in zig-zag scan order. */
2387 uint8_t non_intra_quantiser_matrix[64];
2388 /** \brief Chroma intra matrix, in zig-zag scan order. */
2389 uint8_t chroma_intra_quantiser_matrix[64];
2390 /** \brief Chroma non-intra matrix, in zig-zag scan order. */
2391 uint8_t chroma_non_intra_quantiser_matrix[64];
2393 /** \brief Reserved bytes for future use, must be zero */
2394 uint32_t va_reserved[VA_PADDING_LOW];
2395 } VAIQMatrixBufferMPEG2;
2397 /** MPEG-2 Slice Parameter Buffer */
2398 typedef struct _VASliceParameterBufferMPEG2
2400 uint32_t slice_data_size;/* number of bytes in the slice data buffer for this slice */
2401 uint32_t slice_data_offset;/* the offset to the first byte of slice data */
2402 uint32_t slice_data_flag; /* see VA_SLICE_DATA_FLAG_XXX defintions */
2403 uint32_t macroblock_offset;/* the offset to the first bit of MB from the first byte of slice data */
2404 uint32_t slice_horizontal_position;
2405 uint32_t slice_vertical_position;
2406 int32_t quantiser_scale_code;
2407 int32_t intra_slice_flag;
2409 /** \brief Reserved bytes for future use, must be zero */
2410 uint32_t va_reserved[VA_PADDING_LOW];
2411 } VASliceParameterBufferMPEG2;
2413 /** MPEG-2 Macroblock Parameter Buffer */
2414 typedef struct _VAMacroblockParameterBufferMPEG2
2416 uint16_t macroblock_address;
2418 * macroblock_address (in raster scan order)
2420 * bottom-right: picture-height-in-mb*picture-width-in-mb - 1
2422 uint8_t macroblock_type; /* see definition below */
2425 uint32_t frame_motion_type : 2;
2426 uint32_t field_motion_type : 2;
2427 uint32_t dct_type : 1;
2431 uint8_t motion_vertical_field_select;
2433 * motion_vertical_field_select:
2434 * see section 6.3.17.2 in the spec
2435 * only the lower 4 bits are used
2436 * bit 0: first vector forward
2437 * bit 1: first vector backward
2438 * bit 2: second vector forward
2439 * bit 3: second vector backward
2441 int16_t PMV[2][2][2]; /* see Table 7-7 in the spec */
2442 uint16_t coded_block_pattern;
2444 * The bitplanes for coded_block_pattern are described
2445 * in Figure 6.10-12 in the spec
2448 /* Number of skipped macroblocks after this macroblock */
2449 uint16_t num_skipped_macroblocks;
2451 /** \brief Reserved bytes for future use, must be zero */
2452 uint32_t va_reserved[VA_PADDING_LOW];
2453 } VAMacroblockParameterBufferMPEG2;
2456 * OR'd flags for macroblock_type (section 6.3.17.1 in the spec)
2458 #define VA_MB_TYPE_MOTION_FORWARD 0x02
2459 #define VA_MB_TYPE_MOTION_BACKWARD 0x04
2460 #define VA_MB_TYPE_MOTION_PATTERN 0x08
2461 #define VA_MB_TYPE_MOTION_INTRA 0x10
2464 * MPEG-2 Residual Data Buffer
2465 * For each macroblock, there wil be 64 shorts (16-bit) in the
2466 * residual data buffer
2469 /****************************
2470 * MPEG-4 Part 2 data structures
2471 ****************************/
2473 /* MPEG-4 Picture Parameter Buffer */
2475 * For each frame or field, and before any slice data, a single
2476 * picture parameter buffer must be send.
2478 typedef struct _VAPictureParameterBufferMPEG4
2481 uint16_t vop_height;
2482 VASurfaceID forward_reference_picture;
2483 VASurfaceID backward_reference_picture;
2486 uint32_t short_video_header : 1;
2487 uint32_t chroma_format : 2;
2488 uint32_t interlaced : 1;
2489 uint32_t obmc_disable : 1;
2490 uint32_t sprite_enable : 2;
2491 uint32_t sprite_warping_accuracy : 2;
2492 uint32_t quant_type : 1;
2493 uint32_t quarter_sample : 1;
2494 uint32_t data_partitioned : 1;
2495 uint32_t reversible_vlc : 1;
2496 uint32_t resync_marker_disable : 1;
2500 uint8_t no_of_sprite_warping_points;
2501 int16_t sprite_trajectory_du[3];
2502 int16_t sprite_trajectory_dv[3];
2503 uint8_t quant_precision;
2506 uint32_t vop_coding_type : 2;
2507 uint32_t backward_reference_vop_coding_type : 2;
2508 uint32_t vop_rounding_type : 1;
2509 uint32_t intra_dc_vlc_thr : 3;
2510 uint32_t top_field_first : 1;
2511 uint32_t alternate_vertical_scan_flag : 1;
2515 uint8_t vop_fcode_forward;
2516 uint8_t vop_fcode_backward;
2517 uint16_t vop_time_increment_resolution;
2518 /* short header related */
2519 uint8_t num_gobs_in_vop;
2520 uint8_t num_macroblocks_in_gob;
2521 /* for direct mode prediction */
2525 /** \brief Reserved bytes for future use, must be zero */
2526 uint32_t va_reserved[VA_PADDING_LOW];
2527 } VAPictureParameterBufferMPEG4;
2529 /** MPEG-4 Inverse Quantization Matrix Buffer */
2530 typedef struct _VAIQMatrixBufferMPEG4
2532 /** Same as the MPEG-4:2 bitstream syntax element. */
2533 int32_t load_intra_quant_mat;
2534 /** Same as the MPEG-4:2 bitstream syntax element. */
2535 int32_t load_non_intra_quant_mat;
2536 /** The matrix for intra blocks, in zig-zag scan order. */
2537 uint8_t intra_quant_mat[64];
2538 /** The matrix for non-intra blocks, in zig-zag scan order. */
2539 uint8_t non_intra_quant_mat[64];
2541 /** \brief Reserved bytes for future use, must be zero */
2542 uint32_t va_reserved[VA_PADDING_LOW];
2543 } VAIQMatrixBufferMPEG4;
2545 /** MPEG-4 Slice Parameter Buffer */
2546 typedef struct _VASliceParameterBufferMPEG4
2548 uint32_t slice_data_size;/* number of bytes in the slice data buffer for this slice */
2549 uint32_t slice_data_offset;/* the offset to the first byte of slice data */
2550 uint32_t slice_data_flag; /* see VA_SLICE_DATA_FLAG_XXX defintions */
2551 uint32_t macroblock_offset;/* the offset to the first bit of MB from the first byte of slice data */
2552 uint32_t macroblock_number;
2553 int32_t quant_scale;
2555 /** \brief Reserved bytes for future use, must be zero */
2556 uint32_t va_reserved[VA_PADDING_LOW];
2557 } VASliceParameterBufferMPEG4;
2560 VC-1 data structures
2563 typedef enum /* see 7.1.1.32 */
2566 VAMvMode1MvHalfPel = 1,
2567 VAMvMode1MvHalfPelBilinear = 2,
2568 VAMvModeMixedMv = 3,
2569 VAMvModeIntensityCompensation = 4
2572 /** VC-1 Picture Parameter Buffer */
2574 * For each picture, and before any slice data, a picture parameter
2575 * buffer must be send. Multiple picture parameter buffers may be
2576 * sent for a single picture. In that case picture parameters will
2577 * apply to all slice data that follow it until a new picture
2578 * parameter buffer is sent.
2581 * pic_quantizer_type should be set to the applicable quantizer
2582 * type as defined by QUANTIZER (J.1.19) and either
2583 * PQUANTIZER (7.1.1.8) or PQINDEX (7.1.1.6)
2585 typedef struct _VAPictureParameterBufferVC1
2587 VASurfaceID forward_reference_picture;
2588 VASurfaceID backward_reference_picture;
2589 /* if out-of-loop post-processing is done on the render
2590 target, then we need to keep the in-loop decoded
2591 picture as a reference picture */
2592 VASurfaceID inloop_decoded_picture;
2594 /* sequence layer for AP or meta data for SP and MP */
2597 uint32_t pulldown : 1; /* SEQUENCE_LAYER::PULLDOWN */
2598 uint32_t interlace : 1; /* SEQUENCE_LAYER::INTERLACE */
2599 uint32_t tfcntrflag : 1; /* SEQUENCE_LAYER::TFCNTRFLAG */
2600 uint32_t finterpflag : 1; /* SEQUENCE_LAYER::FINTERPFLAG */
2601 uint32_t psf : 1; /* SEQUENCE_LAYER::PSF */
2602 uint32_t multires : 1; /* METADATA::MULTIRES */
2603 uint32_t overlap : 1; /* METADATA::OVERLAP */
2604 uint32_t syncmarker : 1; /* METADATA::SYNCMARKER */
2605 uint32_t rangered : 1; /* METADATA::RANGERED */
2606 uint32_t max_b_frames : 3; /* METADATA::MAXBFRAMES */
2607 uint32_t profile : 2; /* SEQUENCE_LAYER::PROFILE or The MSB of METADATA::PROFILE */
2612 uint16_t coded_width; /* ENTRY_POINT_LAYER::CODED_WIDTH */
2613 uint16_t coded_height; /* ENTRY_POINT_LAYER::CODED_HEIGHT */
2616 uint32_t broken_link : 1; /* ENTRY_POINT_LAYER::BROKEN_LINK */
2617 uint32_t closed_entry : 1; /* ENTRY_POINT_LAYER::CLOSED_ENTRY */
2618 uint32_t panscan_flag : 1; /* ENTRY_POINT_LAYER::PANSCAN_FLAG */
2619 uint32_t loopfilter : 1; /* ENTRY_POINT_LAYER::LOOPFILTER */
2622 } entrypoint_fields;
2623 uint8_t conditional_overlap_flag; /* ENTRY_POINT_LAYER::CONDOVER */
2624 uint8_t fast_uvmc_flag; /* ENTRY_POINT_LAYER::FASTUVMC */
2627 uint32_t luma_flag : 1; /* ENTRY_POINT_LAYER::RANGE_MAPY_FLAG */
2628 uint32_t luma : 3; /* ENTRY_POINT_LAYER::RANGE_MAPY */
2629 uint32_t chroma_flag : 1; /* ENTRY_POINT_LAYER::RANGE_MAPUV_FLAG */
2630 uint32_t chroma : 3; /* ENTRY_POINT_LAYER::RANGE_MAPUV */
2633 } range_mapping_fields;
2635 uint8_t b_picture_fraction; /* Index for PICTURE_LAYER::BFRACTION value in Table 40 (7.1.1.14) */
2636 uint8_t cbp_table; /* PICTURE_LAYER::CBPTAB/ICBPTAB */
2637 uint8_t mb_mode_table; /* PICTURE_LAYER::MBMODETAB */
2638 uint8_t range_reduction_frame;/* PICTURE_LAYER::RANGEREDFRM */
2639 uint8_t rounding_control; /* PICTURE_LAYER::RNDCTRL */
2640 uint8_t post_processing; /* PICTURE_LAYER::POSTPROC */
2641 uint8_t picture_resolution_index; /* PICTURE_LAYER::RESPIC */
2642 uint8_t luma_scale; /* PICTURE_LAYER::LUMSCALE */
2643 uint8_t luma_shift; /* PICTURE_LAYER::LUMSHIFT */
2647 uint32_t picture_type : 3; /* PICTURE_LAYER::PTYPE */
2648 uint32_t frame_coding_mode : 3; /* PICTURE_LAYER::FCM */
2649 uint32_t top_field_first : 1; /* PICTURE_LAYER::TFF */
2650 uint32_t is_first_field : 1; /* set to 1 if it is the first field */
2651 uint32_t intensity_compensation : 1; /* PICTURE_LAYER::INTCOMP */
2657 uint32_t mv_type_mb : 1; /* PICTURE::MVTYPEMB */
2658 uint32_t direct_mb : 1; /* PICTURE::DIRECTMB */
2659 uint32_t skip_mb : 1; /* PICTURE::SKIPMB */
2660 uint32_t field_tx : 1; /* PICTURE::FIELDTX */
2661 uint32_t forward_mb : 1; /* PICTURE::FORWARDMB */
2662 uint32_t ac_pred : 1; /* PICTURE::ACPRED */
2663 uint32_t overflags : 1; /* PICTURE::OVERFLAGS */
2669 uint32_t bp_mv_type_mb : 1; /* PICTURE::MVTYPEMB */
2670 uint32_t bp_direct_mb : 1; /* PICTURE::DIRECTMB */
2671 uint32_t bp_skip_mb : 1; /* PICTURE::SKIPMB */
2672 uint32_t bp_field_tx : 1; /* PICTURE::FIELDTX */
2673 uint32_t bp_forward_mb : 1; /* PICTURE::FORWARDMB */
2674 uint32_t bp_ac_pred : 1; /* PICTURE::ACPRED */
2675 uint32_t bp_overflags : 1; /* PICTURE::OVERFLAGS */
2678 } bitplane_present; /* signal what bitplane is being passed via the bitplane buffer */
2681 uint32_t reference_distance_flag : 1;/* PICTURE_LAYER::REFDIST_FLAG */
2682 uint32_t reference_distance : 5;/* PICTURE_LAYER::REFDIST */
2683 uint32_t num_reference_pictures: 1;/* PICTURE_LAYER::NUMREF */
2684 uint32_t reference_field_pic_indicator : 1;/* PICTURE_LAYER::REFFIELD */
2690 uint32_t mv_mode : 3; /* PICTURE_LAYER::MVMODE */
2691 uint32_t mv_mode2 : 3; /* PICTURE_LAYER::MVMODE2 */
2692 uint32_t mv_table : 3; /* PICTURE_LAYER::MVTAB/IMVTAB */
2693 uint32_t two_mv_block_pattern_table: 2; /* PICTURE_LAYER::2MVBPTAB */
2694 uint32_t four_mv_switch : 1; /* PICTURE_LAYER::4MVSWITCH */
2695 uint32_t four_mv_block_pattern_table : 2; /* PICTURE_LAYER::4MVBPTAB */
2696 uint32_t extended_mv_flag : 1; /* ENTRY_POINT_LAYER::EXTENDED_MV */
2697 uint32_t extended_mv_range : 2; /* PICTURE_LAYER::MVRANGE */
2698 uint32_t extended_dmv_flag : 1; /* ENTRY_POINT_LAYER::EXTENDED_DMV */
2699 uint32_t extended_dmv_range : 2; /* PICTURE_LAYER::DMVRANGE */
2705 uint32_t dquant : 2; /* ENTRY_POINT_LAYER::DQUANT */
2706 uint32_t quantizer : 2; /* ENTRY_POINT_LAYER::QUANTIZER */
2707 uint32_t half_qp : 1; /* PICTURE_LAYER::HALFQP */
2708 uint32_t pic_quantizer_scale : 5;/* PICTURE_LAYER::PQUANT */
2709 uint32_t pic_quantizer_type : 1;/* PICTURE_LAYER::PQUANTIZER */
2710 uint32_t dq_frame : 1; /* VOPDQUANT::DQUANTFRM */
2711 uint32_t dq_profile : 2; /* VOPDQUANT::DQPROFILE */
2712 uint32_t dq_sb_edge : 2; /* VOPDQUANT::DQSBEDGE */
2713 uint32_t dq_db_edge : 2; /* VOPDQUANT::DQDBEDGE */
2714 uint32_t dq_binary_level : 1; /* VOPDQUANT::DQBILEVEL */
2715 uint32_t alt_pic_quantizer : 5;/* VOPDQUANT::ALTPQUANT */
2718 } pic_quantizer_fields;
2721 uint32_t variable_sized_transform_flag : 1;/* ENTRY_POINT_LAYER::VSTRANSFORM */
2722 uint32_t mb_level_transform_type_flag : 1;/* PICTURE_LAYER::TTMBF */
2723 uint32_t frame_level_transform_type : 2;/* PICTURE_LAYER::TTFRM */
2724 uint32_t transform_ac_codingset_idx1 : 2;/* PICTURE_LAYER::TRANSACFRM */
2725 uint32_t transform_ac_codingset_idx2 : 2;/* PICTURE_LAYER::TRANSACFRM2 */
2726 uint32_t intra_transform_dc_table : 1;/* PICTURE_LAYER::TRANSDCTAB */
2731 uint8_t luma_scale2; /* PICTURE_LAYER::LUMSCALE2 */
2732 uint8_t luma_shift2; /* PICTURE_LAYER::LUMSHIFT2 */
2733 uint8_t intensity_compensation_field; /* Index for PICTURE_LAYER::INTCOMPFIELD value in Table 109 (9.1.1.48) */
2735 /** \brief Reserved bytes for future use, must be zero */
2736 uint32_t va_reserved[VA_PADDING_MEDIUM - 1];
2737 } VAPictureParameterBufferVC1;
2739 /** VC-1 Bitplane Buffer
2740 There will be at most three bitplanes coded in any picture header. To send
2741 the bitplane data more efficiently, each byte is divided in two nibbles, with
2742 each nibble carrying three bitplanes for one macroblock. The following table
2743 shows the bitplane data arrangement within each nibble based on the picture
2746 Picture Type Bit3 Bit2 Bit1 Bit0
2747 I or BI OVERFLAGS ACPRED FIELDTX
2748 P MYTYPEMB SKIPMB DIRECTMB
2749 B FORWARDMB SKIPMB DIRECTMB
2751 Within each byte, the lower nibble is for the first MB and the upper nibble is
2752 for the second MB. E.g. the lower nibble of the first byte in the bitplane
2753 buffer is for Macroblock #1 and the upper nibble of the first byte is for
2754 Macroblock #2 in the first row.
2757 /* VC-1 Slice Parameter Buffer */
2758 typedef struct _VASliceParameterBufferVC1
2760 uint32_t slice_data_size;/* number of bytes in the slice data buffer for this slice */
2761 uint32_t slice_data_offset;/* the offset to the first byte of slice data */
2762 uint32_t slice_data_flag; /* see VA_SLICE_DATA_FLAG_XXX defintions */
2763 uint32_t macroblock_offset;/* the offset to the first bit of MB from the first byte of slice data */
2764 uint32_t slice_vertical_position;
2766 /** \brief Reserved bytes for future use, must be zero */
2767 uint32_t va_reserved[VA_PADDING_LOW];
2768 } VASliceParameterBufferVC1;
2770 /* VC-1 Slice Data Buffer */
2772 This is simplely a buffer containing raw bit-stream bytes
2775 /****************************
2776 * H.264/AVC data structures
2777 ****************************/
2779 typedef struct _VAPictureH264
2781 VASurfaceID picture_id;
2784 int32_t TopFieldOrderCnt;
2785 int32_t BottomFieldOrderCnt;
2787 /** \brief Reserved bytes for future use, must be zero */
2788 uint32_t va_reserved[VA_PADDING_LOW];
2790 /* flags in VAPictureH264 could be OR of the following */
2791 #define VA_PICTURE_H264_INVALID 0x00000001
2792 #define VA_PICTURE_H264_TOP_FIELD 0x00000002
2793 #define VA_PICTURE_H264_BOTTOM_FIELD 0x00000004
2794 #define VA_PICTURE_H264_SHORT_TERM_REFERENCE 0x00000008
2795 #define VA_PICTURE_H264_LONG_TERM_REFERENCE 0x00000010
2797 /** H.264 Picture Parameter Buffer */
2799 * For each picture, and before any slice data, a single
2800 * picture parameter buffer must be send.
2802 typedef struct _VAPictureParameterBufferH264
2804 VAPictureH264 CurrPic;
2805 VAPictureH264 ReferenceFrames[16]; /* in DPB */
2806 uint16_t picture_width_in_mbs_minus1;
2807 uint16_t picture_height_in_mbs_minus1;
2808 uint8_t bit_depth_luma_minus8;
2809 uint8_t bit_depth_chroma_minus8;
2810 uint8_t num_ref_frames;
2813 uint32_t chroma_format_idc : 2;
2814 uint32_t residual_colour_transform_flag : 1; /* Renamed to separate_colour_plane_flag in newer standard versions. */
2815 uint32_t gaps_in_frame_num_value_allowed_flag : 1;
2816 uint32_t frame_mbs_only_flag : 1;
2817 uint32_t mb_adaptive_frame_field_flag : 1;
2818 uint32_t direct_8x8_inference_flag : 1;
2819 uint32_t MinLumaBiPredSize8x8 : 1; /* see A.3.3.2 */
2820 uint32_t log2_max_frame_num_minus4 : 4;
2821 uint32_t pic_order_cnt_type : 2;
2822 uint32_t log2_max_pic_order_cnt_lsb_minus4 : 4;
2823 uint32_t delta_pic_order_always_zero_flag : 1;
2827 // FMO is not supported.
2828 va_deprecated uint8_t num_slice_groups_minus1;
2829 va_deprecated uint8_t slice_group_map_type;
2830 va_deprecated uint16_t slice_group_change_rate_minus1;
2831 int8_t pic_init_qp_minus26;
2832 int8_t pic_init_qs_minus26;
2833 int8_t chroma_qp_index_offset;
2834 int8_t second_chroma_qp_index_offset;
2837 uint32_t entropy_coding_mode_flag : 1;
2838 uint32_t weighted_pred_flag : 1;
2839 uint32_t weighted_bipred_idc : 2;
2840 uint32_t transform_8x8_mode_flag : 1;
2841 uint32_t field_pic_flag : 1;
2842 uint32_t constrained_intra_pred_flag : 1;
2843 uint32_t pic_order_present_flag : 1; /* Renamed to bottom_field_pic_order_in_frame_present_flag in newer standard versions. */
2844 uint32_t deblocking_filter_control_present_flag : 1;
2845 uint32_t redundant_pic_cnt_present_flag : 1;
2846 uint32_t reference_pic_flag : 1; /* nal_ref_idc != 0 */
2852 /** \brief Reserved bytes for future use, must be zero */
2853 uint32_t va_reserved[VA_PADDING_MEDIUM];
2854 } VAPictureParameterBufferH264;
2856 /** H.264 Inverse Quantization Matrix Buffer */
2857 typedef struct _VAIQMatrixBufferH264
2859 /** \brief 4x4 scaling list, in raster scan order. */
2860 uint8_t ScalingList4x4[6][16];
2861 /** \brief 8x8 scaling list, in raster scan order. */
2862 uint8_t ScalingList8x8[2][64];
2864 /** \brief Reserved bytes for future use, must be zero */
2865 uint32_t va_reserved[VA_PADDING_LOW];
2866 } VAIQMatrixBufferH264;
2868 /** H.264 Slice Parameter Buffer */
2869 typedef struct _VASliceParameterBufferH264
2871 uint32_t slice_data_size;/* number of bytes in the slice data buffer for this slice */
2872 /** \brief Byte offset to the NAL Header Unit for this slice. */
2873 uint32_t slice_data_offset;
2874 uint32_t slice_data_flag; /* see VA_SLICE_DATA_FLAG_XXX defintions */
2876 * \brief Bit offset from NAL Header Unit to the begining of slice_data().
2878 * This bit offset is relative to and includes the NAL unit byte
2879 * and represents the number of bits parsed in the slice_header()
2880 * after the removal of any emulation prevention bytes in
2881 * there. However, the slice data buffer passed to the hardware is
2882 * the original bitstream, thus including any emulation prevention
2885 uint16_t slice_data_bit_offset;
2886 uint16_t first_mb_in_slice;
2888 uint8_t direct_spatial_mv_pred_flag;
2890 * H264/AVC syntax element
2892 * if num_ref_idx_active_override_flag equals 0, host decoder should
2893 * set its value to num_ref_idx_l0_default_active_minus1.
2895 uint8_t num_ref_idx_l0_active_minus1;
2897 * H264/AVC syntax element
2899 * if num_ref_idx_active_override_flag equals 0, host decoder should
2900 * set its value to num_ref_idx_l1_default_active_minus1.
2902 uint8_t num_ref_idx_l1_active_minus1;
2903 uint8_t cabac_init_idc;
2904 int8_t slice_qp_delta;
2905 uint8_t disable_deblocking_filter_idc;
2906 int8_t slice_alpha_c0_offset_div2;
2907 int8_t slice_beta_offset_div2;
2908 VAPictureH264 RefPicList0[32]; /* See 8.2.4.2 */
2909 VAPictureH264 RefPicList1[32]; /* See 8.2.4.2 */
2910 uint8_t luma_log2_weight_denom;
2911 uint8_t chroma_log2_weight_denom;
2912 uint8_t luma_weight_l0_flag;
2913 int16_t luma_weight_l0[32];
2914 int16_t luma_offset_l0[32];
2915 uint8_t chroma_weight_l0_flag;
2916 int16_t chroma_weight_l0[32][2];
2917 int16_t chroma_offset_l0[32][2];
2918 uint8_t luma_weight_l1_flag;
2919 int16_t luma_weight_l1[32];
2920 int16_t luma_offset_l1[32];
2921 uint8_t chroma_weight_l1_flag;
2922 int16_t chroma_weight_l1[32][2];
2923 int16_t chroma_offset_l1[32][2];
2925 /** \brief Reserved bytes for future use, must be zero */
2926 uint32_t va_reserved[VA_PADDING_LOW];
2927 } VASliceParameterBufferH264;
2929 /****************************
2930 * Common encode data structures
2931 ****************************/
2934 VAEncPictureTypeIntra = 0,
2935 VAEncPictureTypePredictive = 1,
2936 VAEncPictureTypeBidirectional = 2,
2940 * \brief Encode Slice Parameter Buffer.
2943 * This is a deprecated encode slice parameter buffer, All applications
2944 * \c can use VAEncSliceParameterBufferXXX (XXX = MPEG2, HEVC, H264, JPEG)
2946 typedef struct _VAEncSliceParameterBuffer
2948 uint32_t start_row_number; /* starting MB row number for this slice */
2949 uint32_t slice_height; /* slice height measured in MB */
2952 uint32_t is_intra : 1;
2953 uint32_t disable_deblocking_filter_idc : 2;
2954 uint32_t uses_long_term_ref :1;
2955 uint32_t is_long_term_ref :1;
2960 /** \brief Reserved bytes for future use, must be zero */
2961 uint32_t va_reserved[VA_PADDING_LOW];
2962 } VAEncSliceParameterBuffer;
2965 /****************************
2966 * H.263 specific encode data structures
2967 ****************************/
2969 typedef struct _VAEncSequenceParameterBufferH263
2971 uint32_t intra_period;
2972 uint32_t bits_per_second;
2973 uint32_t frame_rate;
2974 uint32_t initial_qp;
2977 /** \brief Reserved bytes for future use, must be zero */
2978 uint32_t va_reserved[VA_PADDING_LOW];
2979 } VAEncSequenceParameterBufferH263;
2981 typedef struct _VAEncPictureParameterBufferH263
2983 VASurfaceID reference_picture;
2984 VASurfaceID reconstructed_picture;
2985 VABufferID coded_buf;
2986 uint16_t picture_width;
2987 uint16_t picture_height;
2988 VAEncPictureType picture_type;
2990 /** \brief Reserved bytes for future use, must be zero */
2991 uint32_t va_reserved[VA_PADDING_LOW];
2992 } VAEncPictureParameterBufferH263;
2994 /****************************
2995 * MPEG-4 specific encode data structures
2996 ****************************/
2998 typedef struct _VAEncSequenceParameterBufferMPEG4
3000 uint8_t profile_and_level_indication;
3001 uint32_t intra_period;
3002 uint32_t video_object_layer_width;
3003 uint32_t video_object_layer_height;
3004 uint32_t vop_time_increment_resolution;
3005 uint32_t fixed_vop_rate;
3006 uint32_t fixed_vop_time_increment;
3007 uint32_t bits_per_second;
3008 uint32_t frame_rate;
3009 uint32_t initial_qp;
3012 /** \brief Reserved bytes for future use, must be zero */
3013 uint32_t va_reserved[VA_PADDING_LOW];
3014 } VAEncSequenceParameterBufferMPEG4;
3016 typedef struct _VAEncPictureParameterBufferMPEG4
3018 VASurfaceID reference_picture;
3019 VASurfaceID reconstructed_picture;
3020 VABufferID coded_buf;
3021 uint16_t picture_width;
3022 uint16_t picture_height;
3023 uint32_t modulo_time_base; /* number of 1s */
3024 uint32_t vop_time_increment;
3025 VAEncPictureType picture_type;
3027 /** \brief Reserved bytes for future use, must be zero */
3028 uint32_t va_reserved[VA_PADDING_LOW];
3029 } VAEncPictureParameterBufferMPEG4;
3033 /** Buffer functions */
3036 * Creates a buffer for "num_elements" elements of "size" bytes and
3037 * initalize with "data".
3038 * if "data" is null, then the contents of the buffer data store
3040 * Basically there are two ways to get buffer data to the server side. One is
3041 * to call vaCreateBuffer() with a non-null "data", which results the data being
3042 * copied to the data store on the server side. A different method that
3043 * eliminates this copy is to pass null as "data" when calling vaCreateBuffer(),
3044 * and then use vaMapBuffer() to map the data store from the server side to the
3045 * client address space for access.
3046 * The user must call vaDestroyBuffer() to destroy a buffer.
3047 * Note: image buffers are created by the library, not the client. Please see
3048 * vaCreateImage on how image buffers are managed.
3050 VAStatus vaCreateBuffer (
3052 VAContextID context,
3053 VABufferType type, /* in */
3054 unsigned int size, /* in */
3055 unsigned int num_elements, /* in */
3056 void *data, /* in */
3057 VABufferID *buf_id /* out */
3061 * Create a buffer for given width & height get unit_size, pitch, buf_id for 2D buffer
3062 * for permb qp buffer, it will return unit_size for one MB or LCU and the pitch for alignments
3063 * can call vaMapBuffer with this Buffer ID to get virtual address.
3064 * e.g. AVC 1080P encode, 1920x1088, the size in MB is 120x68,but inside driver,
3065 * maybe it should align with 256, and one byte present one Qp.so, call the function.
3066 * then get unit_size = 1, pitch = 256. call vaMapBuffer to get the virtual address (pBuf).
3067 * then read write the memory like 2D. the size is 256x68, application can only use 120x68
3068 * pBuf + 256 is the start of next line.
3069 * different driver implementation maybe return different unit_size and pitch
3071 VAStatus vaCreateBuffer2(
3073 VAContextID context,
3076 unsigned int height,
3077 unsigned int *unit_size,
3078 unsigned int *pitch,
3083 * Convey to the server how many valid elements are in the buffer.
3084 * e.g. if multiple slice parameters are being held in a single buffer,
3085 * this will communicate to the server the number of slice parameters
3086 * that are valid in the buffer.
3088 VAStatus vaBufferSetNumElements (
3090 VABufferID buf_id, /* in */
3091 unsigned int num_elements /* in */
3096 * device independent data structure for codedbuffer
3100 * FICTURE_AVE_QP(bit7-0): The average Qp value used during this frame
3101 * LARGE_SLICE(bit8):At least one slice in the current frame was large
3102 * enough for the encoder to attempt to limit its size.
3103 * SLICE_OVERFLOW(bit9): At least one slice in the current frame has
3104 * exceeded the maximum slice size specified.
3105 * BITRATE_OVERFLOW(bit10): The peak bitrate was exceeded for this frame.
3106 * BITRATE_HIGH(bit11): The frame size got within the safety margin of the maximum size (VCM only)
3107 * AIR_MB_OVER_THRESHOLD: the number of MBs adapted to Intra MB
3109 #define VA_CODED_BUF_STATUS_PICTURE_AVE_QP_MASK 0xff
3110 #define VA_CODED_BUF_STATUS_LARGE_SLICE_MASK 0x100
3111 #define VA_CODED_BUF_STATUS_SLICE_OVERFLOW_MASK 0x200
3112 #define VA_CODED_BUF_STATUS_BITRATE_OVERFLOW 0x400
3113 #define VA_CODED_BUF_STATUS_BITRATE_HIGH 0x800
3115 * \brief The frame has exceeded the maximum requested size.
3117 * This flag indicates that the encoded frame size exceeds the value
3118 * specified through a misc parameter buffer of type
3119 * #VAEncMiscParameterTypeMaxFrameSize.
3121 #define VA_CODED_BUF_STATUS_FRAME_SIZE_OVERFLOW 0x1000
3123 * \brief the bitstream is bad or corrupt.
3125 #define VA_CODED_BUF_STATUS_BAD_BITSTREAM 0x8000
3126 #define VA_CODED_BUF_STATUS_AIR_MB_OVER_THRESHOLD 0xff0000
3129 * \brief The coded buffer segment status contains frame encoding passes number
3131 * This is the mask to get the number of encoding passes from the coded
3132 * buffer segment status.
3133 * NUMBER_PASS(bit24~bit27): the number for encoding passes executed for the coded frame.
3136 #define VA_CODED_BUF_STATUS_NUMBER_PASSES_MASK 0xf000000
3139 * \brief The coded buffer segment contains a single NAL unit.
3141 * This flag indicates that the coded buffer segment contains a
3142 * single NAL unit. This flag might be useful to the user for
3143 * processing the coded buffer.
3145 #define VA_CODED_BUF_STATUS_SINGLE_NALU 0x10000000
3148 * \brief Coded buffer segment.
3150 * #VACodedBufferSegment is an element of a linked list describing
3151 * some information on the coded buffer. The coded buffer segment
3152 * could contain either a single NAL unit, or more than one NAL unit.
3153 * It is recommended (but not required) to return a single NAL unit
3154 * in a coded buffer segment, and the implementation should set the
3155 * VA_CODED_BUF_STATUS_SINGLE_NALU status flag if that is the case.
3157 typedef struct _VACodedBufferSegment {
3159 * \brief Size of the data buffer in this segment (in bytes).
3162 /** \brief Bit offset into the data buffer where the video data starts. */
3163 uint32_t bit_offset;
3164 /** \brief Status set by the driver. See \c VA_CODED_BUF_STATUS_*. */
3166 /** \brief Reserved for future use. */
3168 /** \brief Pointer to the start of the data buffer. */
3171 * \brief Pointer to the next #VACodedBufferSegment element,
3172 * or \c NULL if there is none.
3176 /** \brief Reserved bytes for future use, must be zero */
3177 uint32_t va_reserved[VA_PADDING_LOW];
3178 } VACodedBufferSegment;
3181 * Map data store of the buffer into the client's address space
3182 * vaCreateBuffer() needs to be called with "data" set to NULL before
3183 * calling vaMapBuffer()
3185 * if buffer type is VAEncCodedBufferType, pbuf points to link-list of
3186 * VACodedBufferSegment, and the list is terminated if "next" is NULL
3188 VAStatus vaMapBuffer (
3190 VABufferID buf_id, /* in */
3191 void **pbuf /* out */
3195 * After client making changes to a mapped data store, it needs to
3196 * "Unmap" it to let the server know that the data is ready to be
3197 * consumed by the server
3199 VAStatus vaUnmapBuffer (
3201 VABufferID buf_id /* in */
3205 * After this call, the buffer is deleted and this buffer_id is no longer valid
3207 * A buffer can be re-used and sent to the server by another Begin/Render/End
3208 * sequence if vaDestroyBuffer() is not called with this buffer.
3210 * Note re-using a shared buffer (e.g. a slice data buffer) between the host and the
3211 * hardware accelerator can result in performance dropping.
3213 VAStatus vaDestroyBuffer (
3215 VABufferID buffer_id
3218 /** \brief VA buffer information */
3220 /** \brief Buffer handle */
3222 /** \brief Buffer type (See \ref VABufferType). */
3225 * \brief Buffer memory type (See \ref VASurfaceAttribMemoryType).
3227 * On input to vaAcquireBufferHandle(), this field can serve as a hint
3228 * to specify the set of memory types the caller is interested in.
3229 * On successful return from vaAcquireBufferHandle(), the field is
3230 * updated with the best matching memory type.
3233 /** \brief Size of the underlying buffer. */
3236 /** \brief Reserved bytes for future use, must be zero */
3237 uint32_t va_reserved[VA_PADDING_LOW];
3241 * \brief Acquires buffer handle for external API usage
3243 * Locks the VA buffer object \ref buf_id for external API usage like
3244 * EGL or OpenCL (OCL). This function is a synchronization point. This
3245 * means that any pending operation is guaranteed to be completed
3246 * prior to returning from the function.
3248 * If the referenced VA buffer object is the backing store of a VA
3249 * surface, then this function acts as if vaSyncSurface() on the
3250 * parent surface was called first.
3252 * The \ref VABufferInfo argument shall be zero'ed on input. On
3253 * successful output, the data structure is filled in with all the
3254 * necessary buffer level implementation details like handle, type,
3255 * memory type and memory size.
3257 * Note: the external API implementation, or the application, can
3258 * express the memory types it is interested in by filling in the \ref
3259 * mem_type field accordingly. On successful output, the memory type
3260 * that fits best the request and that was used is updated in the \ref
3261 * VABufferInfo data structure. If none of the supplied memory types
3262 * is supported, then a \ref VA_STATUS_ERROR_UNSUPPORTED_MEMORY_TYPE
3263 * error is returned.
3265 * The \ref VABufferInfo data is valid until vaReleaseBufferHandle()
3266 * is called. Besides, no additional operation is allowed on any of
3267 * the buffer parent object until vaReleaseBufferHandle() is called.
3268 * e.g. decoding into a VA surface backed with the supplied VA buffer
3269 * object \ref buf_id would fail with a \ref VA_STATUS_ERROR_SURFACE_BUSY
3273 * - \ref VA_STATUS_ERROR_UNIMPLEMENTED: the VA driver implementation
3274 * does not support this interface
3275 * - \ref VA_STATUS_ERROR_INVALID_DISPLAY: an invalid display was supplied
3276 * - \ref VA_STATUS_ERROR_INVALID_BUFFER: an invalid buffer was supplied
3277 * - \ref VA_STATUS_ERROR_UNSUPPORTED_BUFFERTYPE: the implementation
3278 * does not support exporting buffers of the specified type
3279 * - \ref VA_STATUS_ERROR_UNSUPPORTED_MEMORY_TYPE: none of the requested
3280 * memory types in \ref VABufferInfo.mem_type was supported
3282 * @param[in] dpy the VA display
3283 * @param[in] buf_id the VA buffer
3284 * @param[in,out] buf_info the associated VA buffer information
3285 * @return VA_STATUS_SUCCESS if successful
3288 vaAcquireBufferHandle(VADisplay dpy, VABufferID buf_id, VABufferInfo *buf_info);
3291 * \brief Releases buffer after usage from external API
3293 * Unlocks the VA buffer object \ref buf_id from external API usage like
3294 * EGL or OpenCL (OCL). This function is a synchronization point. This
3295 * means that any pending operation is guaranteed to be completed
3296 * prior to returning from the function.
3298 * The \ref VABufferInfo argument shall point to the original data
3299 * structure that was obtained from vaAcquireBufferHandle(), unaltered.
3300 * This is necessary so that the VA driver implementation could
3301 * deallocate any resources that were needed.
3303 * In any case, returning from this function invalidates any contents
3304 * in \ref VABufferInfo. i.e. the underlyng buffer handle is no longer
3305 * valid. Therefore, VA driver implementations are free to reset this
3306 * data structure to safe defaults.
3309 * - \ref VA_STATUS_ERROR_UNIMPLEMENTED: the VA driver implementation
3310 * does not support this interface
3311 * - \ref VA_STATUS_ERROR_INVALID_DISPLAY: an invalid display was supplied
3312 * - \ref VA_STATUS_ERROR_INVALID_BUFFER: an invalid buffer was supplied
3313 * - \ref VA_STATUS_ERROR_UNSUPPORTED_BUFFERTYPE: the implementation
3314 * does not support exporting buffers of the specified type
3316 * @param[in] dpy the VA display
3317 * @param[in] buf_id the VA buffer
3318 * @return VA_STATUS_SUCCESS if successful
3321 vaReleaseBufferHandle(VADisplay dpy, VABufferID buf_id);
3323 /** @name vaExportSurfaceHandle() flags
3327 /** Export surface to be read by external API. */
3328 #define VA_EXPORT_SURFACE_READ_ONLY 0x0001
3329 /** Export surface to be written by external API. */
3330 #define VA_EXPORT_SURFACE_WRITE_ONLY 0x0002
3331 /** Export surface to be both read and written by external API. */
3332 #define VA_EXPORT_SURFACE_READ_WRITE 0x0003
3333 /** Export surface with separate layers.
3335 * For example, NV12 surfaces should be exported as two separate
3336 * planes for luma and chroma.
3338 #define VA_EXPORT_SURFACE_SEPARATE_LAYERS 0x0004
3339 /** Export surface with composed layers.
3341 * For example, NV12 surfaces should be exported as a single NV12
3344 #define VA_EXPORT_SURFACE_COMPOSED_LAYERS 0x0008
3349 * \brief Export a handle to a surface for use with an external API
3351 * The exported handles are owned by the caller, and the caller is
3352 * responsible for freeing them when no longer needed (e.g. by closing
3353 * DRM PRIME file descriptors).
3355 * This does not perform any synchronisation. If the contents of the
3356 * surface will be read, vaSyncSurface() must be called before doing so.
3357 * If the contents of the surface are written, then all operations must
3358 * be completed externally before using the surface again by via VA-API
3361 * @param[in] dpy VA display.
3362 * @param[in] surface_id Surface to export.
3363 * @param[in] mem_type Memory type to export to.
3364 * @param[in] flags Combination of flags to apply
3365 * (VA_EXPORT_SURFACE_*).
3366 * @param[out] descriptor Pointer to the descriptor structure to fill
3367 * with the handle details. The type of this structure depends on
3368 * the value of mem_type.
3370 * @return Status code:
3371 * - VA_STATUS_SUCCESS: Success.
3372 * - VA_STATUS_ERROR_INVALID_DISPLAY: The display is not valid.
3373 * - VA_STATUS_ERROR_UNIMPLEMENTED: The driver does not implement
3375 * - VA_STATUS_ERROR_INVALID_SURFACE: The surface is not valid, or
3376 * the surface is not exportable in the specified way.
3377 * - VA_STATUS_ERROR_UNSUPPORTED_MEMORY_TYPE: The driver does not
3378 * support exporting surfaces to the specified memory type.
3380 VAStatus vaExportSurfaceHandle(VADisplay dpy,
3381 VASurfaceID surface_id,
3382 uint32_t mem_type, uint32_t flags,
3386 * Render (Video Decode/Encode/Processing) Pictures
3388 * A picture represents either a frame or a field.
3390 * The Begin/Render/End sequence sends the video decode/encode/processing buffers
3395 * Get ready for a video pipeline
3396 * - decode a picture to a target surface
3397 * - encode a picture from a target surface
3398 * - process a picture to a target surface
3400 VAStatus vaBeginPicture (
3402 VAContextID context,
3403 VASurfaceID render_target
3407 * Send video decode, encode or processing buffers to the server.
3409 VAStatus vaRenderPicture (
3411 VAContextID context,
3412 VABufferID *buffers,
3417 * Make the end of rendering for a picture.
3418 * The server should start processing all pending operations for this
3419 * surface. This call is non-blocking. The client can start another
3420 * Begin/Render/End sequence on a different render target.
3421 * if VAContextID used in this function previously successfully passed
3422 * vaMFAddContext call, real processing will be started during vaMFSubmit
3424 VAStatus vaEndPicture (
3430 * Make the end of rendering for a pictures in contexts passed with submission.
3431 * The server should start processing all pending operations for contexts.
3432 * All contexts passed should be associated through vaMFAddContext
3433 * and call sequence Begin/Render/End performed.
3434 * This call is non-blocking. The client can start another
3435 * Begin/Render/End/vaMFSubmit sequence on a different render targets.
3437 * VA_STATUS_SUCCESS - operation successful, context was removed.
3438 * VA_STATUS_ERROR_INVALID_CONTEXT - mf_context or one of contexts are invalid
3439 * due to mf_context not created or one of contexts not assotiated with mf_context
3440 * through vaAddContext.
3441 * VA_STATUS_ERROR_INVALID_PARAMETER - one of context has not submitted it's frame
3442 * through vaBeginPicture vaRenderPicture vaEndPicture call sequence.
3444 * mf_context: Multi-Frame context
3445 * contexts: list of contexts submitting their tasks for multi-frame operation.
3446 * num_contexts: number of passed contexts.
3448 VAStatus vaMFSubmit (
3450 VAMFContextID mf_context,
3451 VAContextID * contexts,
3462 * This function blocks until all pending operations on the render target
3463 * have been completed. Upon return it is safe to use the render target for a
3464 * different picture.
3466 VAStatus vaSyncSurface (
3468 VASurfaceID render_target
3473 VASurfaceRendering = 1, /* Rendering in progress */
3474 VASurfaceDisplaying = 2, /* Displaying in progress (not safe to render into it) */
3475 /* this status is useful if surface is used as the source */
3477 VASurfaceReady = 4, /* not being rendered or displayed */
3478 VASurfaceSkipped = 8 /* Indicate a skipped frame during encode */
3482 * Find out any pending ops on the render target
3484 VAStatus vaQuerySurfaceStatus (
3486 VASurfaceID render_target,
3487 VASurfaceStatus *status /* out */
3492 VADecodeSliceMissing = 0,
3493 VADecodeMBError = 1,
3494 } VADecodeErrorType;
3497 * Client calls vaQuerySurfaceError with VA_STATUS_ERROR_DECODING_ERROR, server side returns
3498 * an array of structure VASurfaceDecodeMBErrors, and the array is terminated by setting status=-1
3500 typedef struct _VASurfaceDecodeMBErrors
3502 int32_t status; /* 1 if hardware has returned detailed info below, -1 means this record is invalid */
3503 uint32_t start_mb; /* start mb address with errors */
3504 uint32_t end_mb; /* end mb address with errors */
3505 VADecodeErrorType decode_error_type;
3506 uint32_t num_mb; /* number of mbs with errors */
3507 /** \brief Reserved bytes for future use, must be zero */
3508 uint32_t va_reserved[VA_PADDING_LOW - 1];
3509 } VASurfaceDecodeMBErrors;
3512 * After the application gets VA_STATUS_ERROR_DECODING_ERROR after calling vaSyncSurface(),
3513 * it can call vaQuerySurfaceError to find out further details on the particular error.
3514 * VA_STATUS_ERROR_DECODING_ERROR should be passed in as "error_status",
3515 * upon the return, error_info will point to an array of _VASurfaceDecodeMBErrors structure,
3516 * which is allocated and filled by libVA with detailed information on the missing or error macroblocks.
3517 * The array is terminated if "status==-1" is detected.
3519 VAStatus vaQuerySurfaceError(
3521 VASurfaceID surface,
3522 VAStatus error_status,
3527 * Images and Subpictures
3528 * VAImage is used to either get the surface data to client memory, or
3529 * to copy image data in client memory to a surface.
3530 * Both images, subpictures and surfaces follow the same 2D coordinate system where origin
3531 * is at the upper left corner with positive X to the right and positive Y down
3533 #define VA_FOURCC(ch0, ch1, ch2, ch3) \
3534 ((unsigned long)(unsigned char) (ch0) | ((unsigned long)(unsigned char) (ch1) << 8) | \
3535 ((unsigned long)(unsigned char) (ch2) << 16) | ((unsigned long)(unsigned char) (ch3) << 24 ))
3538 * Pre-defined fourcc codes
3540 #define VA_FOURCC_NV12 0x3231564E
3541 #define VA_FOURCC_NV21 0x3132564E
3542 #define VA_FOURCC_AI44 0x34344149
3543 #define VA_FOURCC_RGBA 0x41424752
3544 #define VA_FOURCC_RGBX 0x58424752
3545 #define VA_FOURCC_BGRA 0x41524742
3546 #define VA_FOURCC_BGRX 0x58524742
3547 #define VA_FOURCC_ARGB 0x42475241
3548 #define VA_FOURCC_XRGB 0x42475258
3549 #define VA_FOURCC_ABGR 0x52474241
3550 #define VA_FOURCC_XBGR 0x52474258
3551 #define VA_FOURCC_UYVY 0x59565955
3552 #define VA_FOURCC_YUY2 0x32595559
3553 #define VA_FOURCC_AYUV 0x56555941
3554 #define VA_FOURCC_NV11 0x3131564e
3555 #define VA_FOURCC_YV12 0x32315659
3556 #define VA_FOURCC_P208 0x38303250
3557 /* IYUV same as I420, but most user perfer I420, will deprecate it */
3558 #define VA_FOURCC_IYUV 0x56555949
3559 #define VA_FOURCC_I420 0x30323449
3560 #define VA_FOURCC_YV24 0x34325659
3561 #define VA_FOURCC_YV32 0x32335659
3562 #define VA_FOURCC_Y800 0x30303859
3563 #define VA_FOURCC_IMC3 0x33434D49
3564 #define VA_FOURCC_411P 0x50313134
3565 #define VA_FOURCC_422H 0x48323234
3566 #define VA_FOURCC_422V 0x56323234
3567 #define VA_FOURCC_444P 0x50343434
3568 #define VA_FOURCC_RGBP 0x50424752
3569 #define VA_FOURCC_BGRP 0x50524742
3570 #define VA_FOURCC_411R 0x52313134 /* rotated 411P */
3573 * 8-bit Y plane, followed by 8-bit 2x1 subsampled V and U planes
3575 #define VA_FOURCC_YV16 0x36315659
3577 * 10-bit and 16-bit Planar YUV 4:2:0.
3579 #define VA_FOURCC_P010 0x30313050
3580 #define VA_FOURCC_P016 0x36313050
3583 * 10-bit Planar YUV 420 and occupy the lower 10-bit.
3585 #define VA_FOURCC_I010 0x30313049
3588 #define VA_LSB_FIRST 1
3589 #define VA_MSB_FIRST 2
3591 typedef struct _VAImageFormat
3594 uint32_t byte_order; /* VA_LSB_FIRST, VA_MSB_FIRST */
3595 uint32_t bits_per_pixel;
3596 /* for RGB formats */
3597 uint32_t depth; /* significant bits per pixel */
3599 uint32_t green_mask;
3601 uint32_t alpha_mask;
3603 /** \brief Reserved bytes for future use, must be zero */
3604 uint32_t va_reserved[VA_PADDING_LOW];
3607 typedef VAGenericID VAImageID;
3609 typedef struct _VAImage
3611 VAImageID image_id; /* uniquely identify this image */
3612 VAImageFormat format;
3613 VABufferID buf; /* image data buffer */
3615 * Image data will be stored in a buffer of type VAImageBufferType to facilitate
3616 * data store on the server side for optimal performance. The buffer will be
3617 * created by the CreateImage function, and proper storage allocated based on the image
3618 * size and format. This buffer is managed by the library implementation, and
3619 * accessed by the client through the buffer Map/Unmap functions.
3624 uint32_t num_planes; /* can not be greater than 3 */
3626 * An array indicating the scanline pitch in bytes for each plane.
3627 * Each plane may have a different pitch. Maximum 3 planes for planar formats
3629 uint32_t pitches[3];
3631 * An array indicating the byte offset from the beginning of the image data
3632 * to the start of each plane.
3634 uint32_t offsets[3];
3636 /* The following fields are only needed for paletted formats */
3637 int32_t num_palette_entries; /* set to zero for non-palette images */
3639 * Each component is one byte and entry_bytes indicates the number of components in
3640 * each entry (eg. 3 for YUV palette entries). set to zero for non-palette images
3642 int32_t entry_bytes;
3644 * An array of ascii characters describing the order of the components within the bytes.
3645 * Only entry_bytes characters of the string are used.
3647 int8_t component_order[4];
3649 /** \brief Reserved bytes for future use, must be zero */
3650 uint32_t va_reserved[VA_PADDING_LOW];
3653 /** Get maximum number of image formats supported by the implementation */
3654 int vaMaxNumImageFormats (
3659 * Query supported image formats
3660 * The caller must provide a "format_list" array that can hold at
3661 * least vaMaxNumImageFormats() entries. The actual number of formats
3662 * returned in "format_list" is returned in "num_formats".
3664 VAStatus vaQueryImageFormats (
3666 VAImageFormat *format_list, /* out */
3667 int *num_formats /* out */
3671 * Create a VAImage structure
3672 * The width and height fields returned in the VAImage structure may get
3673 * enlarged for some YUV formats. Upon return from this function,
3674 * image->buf has been created and proper storage allocated by the library.
3675 * The client can access the image through the Map/Unmap calls.
3677 VAStatus vaCreateImage (
3679 VAImageFormat *format,
3682 VAImage *image /* out */
3686 * Should call DestroyImage before destroying the surface it is bound to
3688 VAStatus vaDestroyImage (
3693 VAStatus vaSetImagePalette (
3697 * pointer to an array holding the palette data. The size of the array is
3698 * num_palette_entries * entry_bytes in size. The order of the components
3699 * in the palette is described by the component_order in VAImage struct
3701 unsigned char *palette
3705 * Retrive surface data into a VAImage
3706 * Image must be in a format supported by the implementation
3708 VAStatus vaGetImage (
3710 VASurfaceID surface,
3711 int x, /* coordinates of the upper left source pixel */
3713 unsigned int width, /* width and height of the region */
3714 unsigned int height,
3719 * Copy data from a VAImage to a surface
3720 * Image must be in a format supported by the implementation
3721 * Returns a VA_STATUS_ERROR_SURFACE_BUSY if the surface
3722 * shouldn't be rendered into when this is called
3724 VAStatus vaPutImage (
3726 VASurfaceID surface,
3730 unsigned int src_width,
3731 unsigned int src_height,
3734 unsigned int dest_width,
3735 unsigned int dest_height
3739 * Derive an VAImage from an existing surface.
3740 * This interface will derive a VAImage and corresponding image buffer from
3741 * an existing VA Surface. The image buffer can then be mapped/unmapped for
3742 * direct CPU access. This operation is only possible on implementations with
3743 * direct rendering capabilities and internal surface formats that can be
3744 * represented with a VAImage. When the operation is not possible this interface
3745 * will return VA_STATUS_ERROR_OPERATION_FAILED. Clients should then fall back
3746 * to using vaCreateImage + vaPutImage to accomplish the same task in an
3749 * Implementations should only return success when the resulting image buffer
3750 * would be useable with vaMap/Unmap.
3752 * When directly accessing a surface special care must be taken to insure
3753 * proper synchronization with the graphics hardware. Clients should call
3754 * vaQuerySurfaceStatus to insure that a surface is not the target of concurrent
3755 * rendering or currently being displayed by an overlay.
3757 * Additionally nothing about the contents of a surface should be assumed
3758 * following a vaPutSurface. Implementations are free to modify the surface for
3759 * scaling or subpicture blending within a call to vaPutImage.
3761 * Calls to vaPutImage or vaGetImage using the same surface from which the image
3762 * has been derived will return VA_STATUS_ERROR_SURFACE_BUSY. vaPutImage or
3763 * vaGetImage with other surfaces is supported.
3765 * An image created with vaDeriveImage should be freed with vaDestroyImage. The
3766 * image and image buffer structures will be destroyed; however, the underlying
3767 * surface will remain unchanged until freed with vaDestroySurfaces.
3769 VAStatus vaDeriveImage (
3771 VASurfaceID surface,
3772 VAImage *image /* out */
3777 * Subpicture is a special type of image that can be blended
3778 * with a surface during vaPutSurface(). Subpicture can be used to render
3779 * DVD sub-titles or closed captioning text etc.
3782 typedef VAGenericID VASubpictureID;
3784 /** Get maximum number of subpicture formats supported by the implementation */
3785 int vaMaxNumSubpictureFormats (
3789 /** flags for subpictures */
3790 #define VA_SUBPICTURE_CHROMA_KEYING 0x0001
3791 #define VA_SUBPICTURE_GLOBAL_ALPHA 0x0002
3792 #define VA_SUBPICTURE_DESTINATION_IS_SCREEN_COORD 0x0004
3794 * Query supported subpicture formats
3795 * The caller must provide a "format_list" array that can hold at
3796 * least vaMaxNumSubpictureFormats() entries. The flags arrary holds the flag
3797 * for each format to indicate additional capabilities for that format. The actual
3798 * number of formats returned in "format_list" is returned in "num_formats".
3799 * flags: returned value to indicate addtional capabilities
3800 * VA_SUBPICTURE_CHROMA_KEYING - supports chroma-keying
3801 * VA_SUBPICTURE_GLOBAL_ALPHA - supports global alpha
3802 * VA_SUBPICTURE_DESTINATION_IS_SCREEN_COORD - supports unscaled screen relative subpictures for On Screen Display
3805 VAStatus vaQuerySubpictureFormats (
3807 VAImageFormat *format_list, /* out */
3808 unsigned int *flags, /* out */
3809 unsigned int *num_formats /* out */
3813 * Subpictures are created with an image associated.
3815 VAStatus vaCreateSubpicture (
3818 VASubpictureID *subpicture /* out */
3822 * Destroy the subpicture before destroying the image it is assocated to
3824 VAStatus vaDestroySubpicture (
3826 VASubpictureID subpicture
3830 * Bind an image to the subpicture. This image will now be associated with
3831 * the subpicture instead of the one at creation.
3833 VAStatus vaSetSubpictureImage (
3835 VASubpictureID subpicture,
3840 * If chromakey is enabled, then the area where the source value falls within
3841 * the chromakey [min, max] range is transparent
3842 * The chromakey component format is the following:
3843 * For RGB: [0:7] Red [8:15] Blue [16:23] Green
3844 * For YUV: [0:7] V [8:15] U [16:23] Y
3845 * The chromakey mask can be used to mask out certain components for chromakey
3848 VAStatus vaSetSubpictureChromakey (
3850 VASubpictureID subpicture,
3851 unsigned int chromakey_min,
3852 unsigned int chromakey_max,
3853 unsigned int chromakey_mask
3857 * Global alpha value is between 0 and 1. A value of 1 means fully opaque and
3858 * a value of 0 means fully transparent. If per-pixel alpha is also specified then
3859 * the overall alpha is per-pixel alpha multiplied by the global alpha
3861 VAStatus vaSetSubpictureGlobalAlpha (
3863 VASubpictureID subpicture,
3868 * vaAssociateSubpicture associates the subpicture with target_surfaces.
3869 * It defines the region mapping between the subpicture and the target
3870 * surfaces through source and destination rectangles (with the same width and height).
3871 * Both will be displayed at the next call to vaPutSurface. Additional
3872 * associations before the call to vaPutSurface simply overrides the association.
3874 VAStatus vaAssociateSubpicture (
3876 VASubpictureID subpicture,
3877 VASurfaceID *target_surfaces,
3879 int16_t src_x, /* upper left offset in subpicture */
3882 uint16_t src_height,
3883 int16_t dest_x, /* upper left offset in surface */
3885 uint16_t dest_width,
3886 uint16_t dest_height,
3888 * whether to enable chroma-keying, global-alpha, or screen relative mode
3889 * see VA_SUBPICTURE_XXX values
3895 * vaDeassociateSubpicture removes the association of the subpicture with target_surfaces.
3897 VAStatus vaDeassociateSubpicture (
3899 VASubpictureID subpicture,
3900 VASurfaceID *target_surfaces,
3905 * Display attributes
3906 * Display attributes are used to control things such as contrast, hue, saturation,
3907 * brightness etc. in the rendering process. The application can query what
3908 * attributes are supported by the driver, and then set the appropriate attributes
3909 * before calling vaPutSurface()
3911 /* PowerVR IEP Lite attributes */
3914 VADISPLAYATTRIB_BLE_OFF = 0x00,
3915 VADISPLAYATTRIB_BLE_LOW,
3916 VADISPLAYATTRIB_BLE_MEDIUM,
3917 VADISPLAYATTRIB_BLE_HIGH,
3918 VADISPLAYATTRIB_BLE_NONE,
3919 } VADisplayAttribBLEMode;
3921 /** attribute value for VADisplayAttribRotation */
3922 #define VA_ROTATION_NONE 0x00000000
3923 #define VA_ROTATION_90 0x00000001
3924 #define VA_ROTATION_180 0x00000002
3925 #define VA_ROTATION_270 0x00000003
3929 * @name Mirroring directions
3931 * Those values could be used for VADisplayAttribMirror attribute or
3932 * VAProcPipelineParameterBuffer::mirror_state.
3936 /** \brief No Mirroring. */
3937 #define VA_MIRROR_NONE 0x00000000
3938 /** \brief Horizontal Mirroring. */
3939 #define VA_MIRROR_HORIZONTAL 0x00000001
3940 /** \brief Vertical Mirroring. */
3941 #define VA_MIRROR_VERTICAL 0x00000002
3944 /** attribute value for VADisplayAttribOutOfLoopDeblock */
3945 #define VA_OOL_DEBLOCKING_FALSE 0x00000000
3946 #define VA_OOL_DEBLOCKING_TRUE 0x00000001
3949 #define VA_RENDER_MODE_UNDEFINED 0
3950 #define VA_RENDER_MODE_LOCAL_OVERLAY 1
3951 #define VA_RENDER_MODE_LOCAL_GPU 2
3952 #define VA_RENDER_MODE_EXTERNAL_OVERLAY 4
3953 #define VA_RENDER_MODE_EXTERNAL_GPU 8
3955 /** Render device */
3956 #define VA_RENDER_DEVICE_UNDEFINED 0
3957 #define VA_RENDER_DEVICE_LOCAL 1
3958 #define VA_RENDER_DEVICE_EXTERNAL 2
3960 /** Currently defined display attribute types */
3963 VADisplayAttribBrightness = 0,
3964 VADisplayAttribContrast = 1,
3965 VADisplayAttribHue = 2,
3966 VADisplayAttribSaturation = 3,
3967 /* client can specifiy a background color for the target window
3968 * the new feature of video conference,
3969 * the uncovered area of the surface is filled by this color
3970 * also it will blend with the decoded video color
3972 VADisplayAttribBackgroundColor = 4,
3974 * this is a gettable only attribute. For some implementations that use the
3975 * hardware overlay, after PutSurface is called, the surface can not be
3976 * re-used until after the subsequent PutSurface call. If this is the case
3977 * then the value for this attribute will be set to 1 so that the client
3978 * will not attempt to re-use the surface right after returning from a call
3981 * Don't use it, use flag VASurfaceDisplaying of vaQuerySurfaceStatus since
3982 * driver may use overlay or GPU alternatively
3984 VADisplayAttribDirectSurface = 5,
3985 VADisplayAttribRotation = 6,
3986 VADisplayAttribOutofLoopDeblock = 7,
3988 /* PowerVR IEP Lite specific attributes */
3989 VADisplayAttribBLEBlackMode = 8,
3990 VADisplayAttribBLEWhiteMode = 9,
3991 VADisplayAttribBlueStretch = 10,
3992 VADisplayAttribSkinColorCorrection = 11,
3994 * For type VADisplayAttribCSCMatrix, "value" field is a pointer to the color
3995 * conversion matrix. Each element in the matrix is float-point
3997 VADisplayAttribCSCMatrix = 12,
3998 /* specify the constant color used to blend with video surface
3999 * Cd = Cv*Cc*Ac + Cb *(1 - Ac) C means the constant RGB
4000 * d: the final color to overwrite into the frame buffer
4001 * v: decoded video after color conversion,
4002 * c: video color specified by VADisplayAttribBlendColor
4003 * b: background color of the drawable
4005 VADisplayAttribBlendColor = 13,
4007 * Indicate driver to skip painting color key or not.
4008 * only applicable if the render is overlay
4010 VADisplayAttribOverlayAutoPaintColorKey = 14,
4012 * customized overlay color key, the format is RGB888
4013 * [23:16] = Red, [15:08] = Green, [07:00] = Blue.
4015 VADisplayAttribOverlayColorKey = 15,
4017 * The hint for the implementation of vaPutSurface
4018 * normally, the driver could use an overlay or GPU to render the surface on the screen
4019 * this flag provides APP the flexibity to switch the render dynamically
4021 VADisplayAttribRenderMode = 16,
4023 * specify if vaPutSurface needs to render into specified monitors
4024 * one example is that one external monitor (e.g. HDMI) is enabled,
4025 * but the window manager is not aware of it, and there is no associated drawable
4027 VADisplayAttribRenderDevice = 17,
4029 * specify vaPutSurface render area if there is no drawable on the monitor
4031 VADisplayAttribRenderRect = 18,
4032 } VADisplayAttribType;
4034 /* flags for VADisplayAttribute */
4035 #define VA_DISPLAY_ATTRIB_NOT_SUPPORTED 0x0000
4036 #define VA_DISPLAY_ATTRIB_GETTABLE 0x0001
4037 #define VA_DISPLAY_ATTRIB_SETTABLE 0x0002
4039 typedef struct _VADisplayAttribute
4041 VADisplayAttribType type;
4044 int32_t value; /* used by the set/get attribute functions */
4045 /* flags can be VA_DISPLAY_ATTRIB_GETTABLE or VA_DISPLAY_ATTRIB_SETTABLE or OR'd together */
4048 /** \brief Reserved bytes for future use, must be zero */
4049 uint32_t va_reserved[VA_PADDING_LOW];
4050 } VADisplayAttribute;
4052 /** Get maximum number of display attributs supported by the implementation */
4053 int vaMaxNumDisplayAttributes (
4058 * Query display attributes
4059 * The caller must provide a "attr_list" array that can hold at
4060 * least vaMaxNumDisplayAttributes() entries. The actual number of attributes
4061 * returned in "attr_list" is returned in "num_attributes".
4063 VAStatus vaQueryDisplayAttributes (
4065 VADisplayAttribute *attr_list, /* out */
4066 int *num_attributes /* out */
4070 * Get display attributes
4071 * This function returns the current attribute values in "attr_list".
4072 * Only attributes returned with VA_DISPLAY_ATTRIB_GETTABLE set in the "flags" field
4073 * from vaQueryDisplayAttributes() can have their values retrieved.
4075 VAStatus vaGetDisplayAttributes (
4077 VADisplayAttribute *attr_list, /* in/out */
4082 * Set display attributes
4083 * Only attributes returned with VA_DISPLAY_ATTRIB_SETTABLE set in the "flags" field
4084 * from vaQueryDisplayAttributes() can be set. If the attribute is not settable or
4085 * the value is out of range, the function returns VA_STATUS_ERROR_ATTR_NOT_SUPPORTED
4087 VAStatus vaSetDisplayAttributes (
4089 VADisplayAttribute *attr_list,
4093 /****************************
4094 * HEVC data structures
4095 ****************************/
4097 * \brief Description of picture properties of those in DPB surfaces.
4099 * If only progressive scan is supported, each surface contains one whole
4101 * Otherwise, each surface contains two fields of whole picture.
4102 * In this case, two entries of ReferenceFrames[] may share same picture_id
4105 typedef struct _VAPictureHEVC
4107 /** \brief reconstructed picture buffer surface index
4108 * invalid when taking value VA_INVALID_SURFACE.
4110 VASurfaceID picture_id;
4111 /** \brief picture order count.
4112 * in HEVC, POCs for top and bottom fields of same picture should
4113 * take different values.
4115 int32_t pic_order_cnt;
4116 /* described below */
4119 /** \brief Reserved bytes for future use, must be zero */
4120 uint32_t va_reserved[VA_PADDING_LOW];
4123 /* flags in VAPictureHEVC could be OR of the following */
4124 #define VA_PICTURE_HEVC_INVALID 0x00000001
4125 /** \brief indication of interlace scan picture.
4126 * should take same value for all the pictures in sequence.
4128 #define VA_PICTURE_HEVC_FIELD_PIC 0x00000002
4129 /** \brief polarity of the field picture.
4130 * top field takes even lines of buffer surface.
4131 * bottom field takes odd lines of buffer surface.
4133 #define VA_PICTURE_HEVC_BOTTOM_FIELD 0x00000004
4134 /** \brief Long term reference picture */
4135 #define VA_PICTURE_HEVC_LONG_TERM_REFERENCE 0x00000008
4137 * VA_PICTURE_HEVC_RPS_ST_CURR_BEFORE, VA_PICTURE_HEVC_RPS_ST_CURR_AFTER
4138 * and VA_PICTURE_HEVC_RPS_LT_CURR of any picture in ReferenceFrames[] should
4139 * be exclusive. No more than one of them can be set for any picture.
4140 * Sum of NumPocStCurrBefore, NumPocStCurrAfter and NumPocLtCurr
4141 * equals NumPocTotalCurr, which should be equal to or smaller than 8.
4142 * Application should provide valid values for both short format and long format.
4143 * The pictures in DPB with any of these three flags turned on are referred by
4144 * the current picture.
4146 /** \brief RefPicSetStCurrBefore of HEVC spec variable
4147 * Number of ReferenceFrames[] entries with this bit set equals
4148 * NumPocStCurrBefore.
4150 #define VA_PICTURE_HEVC_RPS_ST_CURR_BEFORE 0x00000010
4151 /** \brief RefPicSetStCurrAfter of HEVC spec variable
4152 * Number of ReferenceFrames[] entries with this bit set equals
4153 * NumPocStCurrAfter.
4155 #define VA_PICTURE_HEVC_RPS_ST_CURR_AFTER 0x00000020
4156 /** \brief RefPicSetLtCurr of HEVC spec variable
4157 * Number of ReferenceFrames[] entries with this bit set equals
4160 #define VA_PICTURE_HEVC_RPS_LT_CURR 0x00000040
4162 #include <va/va_dec_hevc.h>
4163 #include <va/va_dec_jpeg.h>
4164 #include <va/va_dec_vp8.h>
4165 #include <va/va_dec_vp9.h>
4166 #include <va/va_enc_hevc.h>
4167 #include <va/va_fei_hevc.h>
4168 #include <va/va_enc_h264.h>
4169 #include <va/va_enc_jpeg.h>
4170 #include <va/va_enc_mpeg2.h>
4171 #include <va/va_enc_vp8.h>
4172 #include <va/va_enc_vp9.h>
4173 #include <va/va_fei.h>
4174 #include <va/va_fei_h264.h>
4175 #include <va/va_vpp.h>