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 * \mainpage Video Acceleration (VA) API
92 * \section intro Introduction
94 * The main motivation for VA-API (Video Acceleration API) is to
95 * enable hardware accelerated video decode and encode at various
96 * entry-points (VLD, IDCT, Motion Compensation etc.) for the
97 * prevailing coding standards today (MPEG-2, MPEG-4 ASP/H.263, MPEG-4
98 * AVC/H.264, VC-1/VMW3, and JPEG).
100 * VA-API is split into several modules:
102 * - \ref api_enc_h264
107 * \defgroup api_core Core API
115 The VA API is intended to provide an interface between a video decode/encode/display
116 application (client) and a hardware accelerator (server), to off-load
117 video decode/encode/display operations from the host to the hardware accelerator at various
120 The basic operation steps are:
122 - Negotiate a mutually acceptable configuration with the server to lock
123 down profile, entrypoints, and other attributes that will not change on
124 a frame-by-frame basis.
125 - Create a decode context which represents a "virtualized" hardware decode
127 - Get and fill decode buffers with picture level, slice level and macroblock
128 level data (depending on entrypoints)
129 - Pass the decode buffers to the server to decode the current frame
131 Initialization & Configuration Management
133 - Find out supported profiles
134 - Find out entrypoints for a given profile
135 - Find out configuration attributes for a given profile/entrypoint pair
136 - Create a configuration for use by the decoder
140 typedef void* VADisplay; /* window system dependent */
142 typedef int VAStatus; /** Return status type from functions */
143 /** Values for the return status */
144 #define VA_STATUS_SUCCESS 0x00000000
145 #define VA_STATUS_ERROR_OPERATION_FAILED 0x00000001
146 #define VA_STATUS_ERROR_ALLOCATION_FAILED 0x00000002
147 #define VA_STATUS_ERROR_INVALID_DISPLAY 0x00000003
148 #define VA_STATUS_ERROR_INVALID_CONFIG 0x00000004
149 #define VA_STATUS_ERROR_INVALID_CONTEXT 0x00000005
150 #define VA_STATUS_ERROR_INVALID_SURFACE 0x00000006
151 #define VA_STATUS_ERROR_INVALID_BUFFER 0x00000007
152 #define VA_STATUS_ERROR_INVALID_IMAGE 0x00000008
153 #define VA_STATUS_ERROR_INVALID_SUBPICTURE 0x00000009
154 #define VA_STATUS_ERROR_ATTR_NOT_SUPPORTED 0x0000000a
155 #define VA_STATUS_ERROR_MAX_NUM_EXCEEDED 0x0000000b
156 #define VA_STATUS_ERROR_UNSUPPORTED_PROFILE 0x0000000c
157 #define VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT 0x0000000d
158 #define VA_STATUS_ERROR_UNSUPPORTED_RT_FORMAT 0x0000000e
159 #define VA_STATUS_ERROR_UNSUPPORTED_BUFFERTYPE 0x0000000f
160 #define VA_STATUS_ERROR_SURFACE_BUSY 0x00000010
161 #define VA_STATUS_ERROR_FLAG_NOT_SUPPORTED 0x00000011
162 #define VA_STATUS_ERROR_INVALID_PARAMETER 0x00000012
163 #define VA_STATUS_ERROR_RESOLUTION_NOT_SUPPORTED 0x00000013
164 #define VA_STATUS_ERROR_UNIMPLEMENTED 0x00000014
165 #define VA_STATUS_ERROR_SURFACE_IN_DISPLAYING 0x00000015
166 #define VA_STATUS_ERROR_INVALID_IMAGE_FORMAT 0x00000016
167 #define VA_STATUS_ERROR_DECODING_ERROR 0x00000017
168 #define VA_STATUS_ERROR_ENCODING_ERROR 0x00000018
170 * \brief An invalid/unsupported value was supplied.
172 * This is a catch-all error code for invalid or unsupported values.
173 * e.g. value exceeding the valid range, invalid type in the context
174 * of generic attribute values.
176 #define VA_STATUS_ERROR_INVALID_VALUE 0x00000019
177 /** \brief An unsupported filter was supplied. */
178 #define VA_STATUS_ERROR_UNSUPPORTED_FILTER 0x00000020
179 /** \brief An invalid filter chain was supplied. */
180 #define VA_STATUS_ERROR_INVALID_FILTER_CHAIN 0x00000021
181 /** \brief Indicate HW busy (e.g. run multiple encoding simultaneously). */
182 #define VA_STATUS_ERROR_HW_BUSY 0x00000022
183 /** \brief An unsupported memory type was supplied. */
184 #define VA_STATUS_ERROR_UNSUPPORTED_MEMORY_TYPE 0x00000024
185 #define VA_STATUS_ERROR_UNKNOWN 0xFFFFFFFF
187 /** De-interlacing flags for vaPutSurface() */
188 #define VA_FRAME_PICTURE 0x00000000
189 #define VA_TOP_FIELD 0x00000001
190 #define VA_BOTTOM_FIELD 0x00000002
193 * Enabled the positioning/cropping/blending feature:
194 * 1, specify the video playback position in the isurface
195 * 2, specify the cropping info for video playback
196 * 3, encoded video will blend with background color
198 #define VA_ENABLE_BLEND 0x00000004 /* video area blend with the constant color */
201 * Clears the drawable with background color.
202 * for hardware overlay based implementation this flag
203 * can be used to turn off the overlay
205 #define VA_CLEAR_DRAWABLE 0x00000008
207 /** Color space conversion flags for vaPutSurface() */
208 #define VA_SRC_COLOR_MASK 0x000000f0
209 #define VA_SRC_BT601 0x00000010
210 #define VA_SRC_BT709 0x00000020
211 #define VA_SRC_SMPTE_240 0x00000040
213 /** Scaling flags for vaPutSurface() */
214 #define VA_FILTER_SCALING_DEFAULT 0x00000000
215 #define VA_FILTER_SCALING_FAST 0x00000100
216 #define VA_FILTER_SCALING_HQ 0x00000200
217 #define VA_FILTER_SCALING_NL_ANAMORPHIC 0x00000300
218 #define VA_FILTER_SCALING_MASK 0x00000f00
221 * Returns a short english description of error_status
223 const char *vaErrorStr(VAStatus error_status);
225 typedef struct _VARectangle
229 unsigned short width;
230 unsigned short height;
235 * A display must be obtained by calling vaGetDisplay() before calling
236 * vaInitialize() and other functions. This connects the API to the
237 * native window system.
238 * For X Windows, native_dpy would be from XOpenDisplay()
240 typedef void* VANativeDisplay; /* window system dependent */
242 int vaDisplayIsValid(VADisplay dpy);
245 * Set the override driver name instead of queried driver driver.
247 VAStatus vaSetDriverName(VADisplay dpy,
252 * Initialize the library
254 VAStatus vaInitialize (
256 int *major_version, /* out */
257 int *minor_version /* out */
261 * After this call, all library internal resources will be cleaned up
263 VAStatus vaTerminate (
268 * vaQueryVendorString returns a pointer to a zero-terminated string
269 * describing some aspects of the VA implemenation on a specific
270 * hardware accelerator. The format of the returned string is vendor
271 * specific and at the discretion of the implementer.
272 * e.g. for the Intel GMA500 implementation, an example would be:
273 * "Intel GMA500 - 2.0.0.32L.0005"
275 const char *vaQueryVendorString (
279 typedef int (*VAPrivFunc)();
282 * Return a function pointer given a function name in the library.
283 * This allows private interfaces into the library
285 VAPrivFunc vaGetLibFunc (
290 /** Currently defined profiles */
293 /** \brief Profile ID used for video processing. */
295 VAProfileMPEG2Simple = 0,
296 VAProfileMPEG2Main = 1,
297 VAProfileMPEG4Simple = 2,
298 VAProfileMPEG4AdvancedSimple = 3,
299 VAProfileMPEG4Main = 4,
300 VAProfileH264Baseline = 5,
301 VAProfileH264Main = 6,
302 VAProfileH264High = 7,
303 VAProfileVC1Simple = 8,
304 VAProfileVC1Main = 9,
305 VAProfileVC1Advanced = 10,
306 VAProfileH263Baseline = 11,
307 VAProfileJPEGBaseline = 12,
308 VAProfileH264ConstrainedBaseline = 13,
309 VAProfileVP8Version0_3 = 14,
310 VAProfileH264MultiviewHigh = 15,
311 VAProfileH264StereoHigh = 16,
312 VAProfileHEVCMain = 17,
313 VAProfileHEVCMain10 = 18,
314 VAProfileVP9Profile0 = 19,
315 VAProfileVP9Profile1 = 20,
316 VAProfileVP9Profile2 = 21,
317 VAProfileVP9Profile3 = 22
321 * Currently defined entrypoints
327 VAEntrypointIDCT = 3,
328 VAEntrypointMoComp = 4,
329 VAEntrypointDeblocking = 5,
330 VAEntrypointEncSlice = 6, /* slice level encode */
331 VAEntrypointEncPicture = 7, /* pictuer encode, JPEG, etc */
333 * For an implementation that supports a low power/high performance variant
334 * for slice level encode, it can choose to expose the
335 * VAEntrypointEncSliceLP entrypoint. Certain encoding tools may not be
336 * available with this entrypoint (e.g. interlace, MBAFF) and the
337 * application can query the encoding configuration attributes to find
338 * out more details if this entrypoint is supported.
340 VAEntrypointEncSliceLP = 8,
341 VAEntrypointVideoProc = 10, /**< Video pre/post-processing. */
344 /** Currently defined configuration attribute types */
347 VAConfigAttribRTFormat = 0,
348 VAConfigAttribSpatialResidual = 1,
349 VAConfigAttribSpatialClipping = 2,
350 VAConfigAttribIntraResidual = 3,
351 VAConfigAttribEncryption = 4,
352 VAConfigAttribRateControl = 5,
354 /** @name Attributes for decoding */
357 * \brief Slice Decoding mode. Read/write.
359 * This attribute determines what mode the driver supports for slice
360 * decoding, through vaGetConfigAttributes(); and what mode the user
361 * will be providing to the driver, through vaCreateConfig(), if the
362 * driver supports those. If this attribute is not set by the user then
363 * it is assumed that VA_DEC_SLICE_MODE_NORMAL mode is used.
365 * See \c VA_DEC_SLICE_MODE_xxx for the list of slice decoding modes.
367 VAConfigAttribDecSliceMode = 6,
369 /** @name Attributes for encoding */
372 * \brief Packed headers mode. Read/write.
374 * This attribute determines what packed headers the driver supports,
375 * through vaGetConfigAttributes(); and what packed headers the user
376 * will be providing to the driver, through vaCreateConfig(), if the
377 * driver supports those.
379 * See \c VA_ENC_PACKED_HEADER_xxx for the list of packed headers.
381 VAConfigAttribEncPackedHeaders = 10,
383 * \brief Interlaced mode. Read/write.
385 * This attribute determines what kind of interlaced encoding mode
386 * the driver supports.
388 * See \c VA_ENC_INTERLACED_xxx for the list of interlaced modes.
390 VAConfigAttribEncInterlaced = 11,
392 * \brief Maximum number of reference frames. Read-only.
394 * This attribute determines the maximum number of reference
395 * frames supported for encoding.
397 * Note: for H.264 encoding, the value represents the maximum number
398 * of reference frames for both the reference picture list 0 (bottom
399 * 16 bits) and the reference picture list 1 (top 16 bits).
401 VAConfigAttribEncMaxRefFrames = 13,
403 * \brief Maximum number of slices per frame. Read-only.
405 * This attribute determines the maximum number of slices the
406 * driver can support to encode a single frame.
408 VAConfigAttribEncMaxSlices = 14,
410 * \brief Slice structure. Read-only.
412 * This attribute determines slice structures supported by the
413 * driver for encoding. This attribute is a hint to the user so
414 * that he can choose a suitable surface size and how to arrange
415 * the encoding process of multiple slices per frame.
417 * More specifically, for H.264 encoding, this attribute
418 * determines the range of accepted values to
419 * VAEncSliceParameterBufferH264::macroblock_address and
420 * VAEncSliceParameterBufferH264::num_macroblocks.
422 * See \c VA_ENC_SLICE_STRUCTURE_xxx for the supported slice
425 VAConfigAttribEncSliceStructure = 15,
427 * \brief Macroblock information. Read-only.
429 * This attribute determines whether the driver supports extra
430 * encoding information per-macroblock. e.g. QP.
432 * More specifically, for H.264 encoding, if the driver returns a non-zero
433 * value for this attribute, this means the application can create
434 * additional #VAEncMacroblockParameterBufferH264 buffers referenced
435 * through VAEncSliceParameterBufferH264::macroblock_info.
437 VAConfigAttribEncMacroblockInfo = 16,
439 * \brief JPEG encoding attribute. Read-only.
441 * This attribute exposes a number of capabilities of the underlying
442 * JPEG implementation. The attribute value is partitioned into fields as defined in the
443 * VAConfigAttribValEncJPEG union.
445 VAConfigAttribEncJPEG = 20,
447 * \brief Encoding quality range attribute. Read-only.
449 * This attribute conveys whether the driver supports different quality level settings
450 * for encoding. A value less than or equal to 1 means that the encoder only has a single
451 * quality setting, and a value greater than 1 represents the number of quality levels
452 * that can be configured. e.g. a value of 2 means there are two distinct quality levels.
454 VAConfigAttribEncQualityRange = 21,
456 * \brief Encoding skip frame attribute. Read-only.
458 * This attribute conveys whether the driver supports sending skip frame parameters
459 * (VAEncMiscParameterTypeSkipFrame) to the encoder's rate control, when the user has
460 * externally skipped frames.
462 VAConfigAttribEncSkipFrame = 24,
464 * \brief Encoding region-of-interest (ROI) attribute. Read-only.
466 * This attribute conveys whether the driver supports region-of-interest (ROI) encoding,
467 * based on user provided ROI rectangles. The attribute value is partitioned into fields
468 * as defined in the VAConfigAttribValEncROI union.
470 * If ROI encoding is supported, the ROI information is passed to the driver using
471 * VAEncMiscParameterTypeROI.
473 VAConfigAttribEncROI = 25,
475 * \brief Encoding extended rate control attribute. Read-only.
477 * This attribute conveys whether the driver supports any extended rate control features
478 * The attribute value is partitioned into fields as defined in the
479 * VAConfigAttribValEncRateControlExt union.
481 VAConfigAttribEncRateControlExt = 26,
484 VAConfigAttribTypeMax
485 } VAConfigAttribType;
488 * Configuration attributes
489 * If there is more than one value for an attribute, a default
490 * value will be assigned to the attribute if the client does not
491 * specify the attribute when creating a configuration
493 typedef struct _VAConfigAttrib {
494 VAConfigAttribType type;
495 unsigned int value; /* OR'd flags (bits) for this attribute */
498 /** attribute value for VAConfigAttribRTFormat */
499 #define VA_RT_FORMAT_YUV420 0x00000001
500 #define VA_RT_FORMAT_YUV422 0x00000002
501 #define VA_RT_FORMAT_YUV444 0x00000004
502 #define VA_RT_FORMAT_YUV411 0x00000008
503 #define VA_RT_FORMAT_YUV400 0x00000010
504 /** YUV formats with more than 8 bpp */
505 #define VA_RT_FORMAT_YUV420_10BPP 0x00000100
507 #define VA_RT_FORMAT_RGB16 0x00010000
508 #define VA_RT_FORMAT_RGB32 0x00020000
509 /* RGBP covers RGBP and BGRP fourcc */
510 #define VA_RT_FORMAT_RGBP 0x00100000
511 #define VA_RT_FORMAT_PROTECTED 0x80000000
513 /** @name Attribute values for VAConfigAttribRateControl */
515 /** \brief Driver does not support any form of rate control. */
516 #define VA_RC_NONE 0x00000001
517 /** \brief Constant bitrate. */
518 #define VA_RC_CBR 0x00000002
519 /** \brief Variable bitrate. */
520 #define VA_RC_VBR 0x00000004
521 /** \brief Video conference mode. */
522 #define VA_RC_VCM 0x00000008
523 /** \brief Constant QP. */
524 #define VA_RC_CQP 0x00000010
525 /** \brief Variable bitrate with peak rate higher than average bitrate. */
526 #define VA_RC_VBR_CONSTRAINED 0x00000020
527 /** \brief Macroblock based rate control. Per MB control is decided
528 * internally in the encoder. It may be combined with other RC modes, except CQP. */
529 #define VA_RC_MB 0x00000080
533 /** @name Attribute values for VAConfigAttribDecSliceMode */
535 /** \brief Driver supports normal mode for slice decoding */
536 #define VA_DEC_SLICE_MODE_NORMAL 0x00000001
537 /** \brief Driver supports base mode for slice decoding */
538 #define VA_DEC_SLICE_MODE_BASE 0x00000002
541 /** @name Attribute values for VAConfigAttribEncPackedHeaders */
543 /** \brief Driver does not support any packed headers mode. */
544 #define VA_ENC_PACKED_HEADER_NONE 0x00000000
545 /** \brief Driver supports packed sequence headers. e.g. SPS for H.264. */
546 #define VA_ENC_PACKED_HEADER_SEQUENCE 0x00000001
547 /** \brief Driver supports packed picture headers. e.g. PPS for H.264. */
548 #define VA_ENC_PACKED_HEADER_PICTURE 0x00000002
549 /** \brief Driver supports packed slice headers. e.g. \c slice_header() for H.264. */
550 #define VA_ENC_PACKED_HEADER_SLICE 0x00000004
551 /** \brief Driver supports misc packed headers. e.g. SEI for H.264. */
552 #define VA_ENC_PACKED_HEADER_MISC 0x00000008
553 /** \brief Driver supports raw packed header, see VAEncPackedHeaderRawData */
554 #define VA_ENC_PACKED_HEADER_RAW_DATA 0x00000010
557 /** @name Attribute values for VAConfigAttribEncInterlaced */
559 /** \brief Driver does not support interlaced coding. */
560 #define VA_ENC_INTERLACED_NONE 0x00000000
561 /** \brief Driver supports interlaced frame coding. */
562 #define VA_ENC_INTERLACED_FRAME 0x00000001
563 /** \brief Driver supports interlaced field coding. */
564 #define VA_ENC_INTERLACED_FIELD 0x00000002
565 /** \brief Driver supports macroblock adaptive frame field coding. */
566 #define VA_ENC_INTERLACED_MBAFF 0x00000004
567 /** \brief Driver supports picture adaptive frame field coding. */
568 #define VA_ENC_INTERLACED_PAFF 0x00000008
571 /** @name Attribute values for VAConfigAttribEncSliceStructure */
573 /** \brief Driver supports an arbitrary number of rows per slice. */
574 #define VA_ENC_SLICE_STRUCTURE_ARBITRARY_ROWS 0x00000000
575 /** \brief Driver supports a power-of-two number of rows per slice. */
576 #define VA_ENC_SLICE_STRUCTURE_POWER_OF_TWO_ROWS 0x00000001
577 /** \brief Driver supports an arbitrary number of rows per slice. */
578 #define VA_ENC_SLICE_STRUCTURE_ARBITRARY_MACROBLOCKS 0x00000002
581 /** \brief Attribute value for VAConfigAttribEncJPEG */
582 typedef union _VAConfigAttribValEncJPEG {
584 /** \brief set to 1 for arithmatic coding. */
585 unsigned int arithmatic_coding_mode : 1;
586 /** \brief set to 1 for progressive dct. */
587 unsigned int progressive_dct_mode : 1;
588 /** \brief set to 1 for non-interleaved. */
589 unsigned int non_interleaved_mode : 1;
590 /** \brief set to 1 for differential. */
591 unsigned int differential_mode : 1;
592 unsigned int max_num_components : 3;
593 unsigned int max_num_scans : 4;
594 unsigned int max_num_huffman_tables : 3;
595 unsigned int max_num_quantization_tables : 3;
598 } VAConfigAttribValEncJPEG;
600 /** \brief Attribute value for VAConfigAttribEncROI */
601 typedef union _VAConfigAttribValEncROI {
603 /** \brief The number of ROI regions supported, 0 if ROI is not supported. */
604 unsigned int num_roi_regions : 8;
606 * \brief A flag indicates whether ROI priority is supported
608 * \ref roi_rc_priority_support equal to 1 specifies the underlying driver supports
609 * ROI priority when VAConfigAttribRateControl != VA_RC_CQP, user can use \c roi_value
610 * in #VAEncROI to set ROI priority. \ref roi_rc_priority_support equal to 0 specifies
611 * the underlying driver doesn't support ROI priority.
613 * User should ignore \ref roi_rc_priority_support when VAConfigAttribRateControl == VA_RC_CQP
614 * because ROI delta QP is always required when VAConfigAttribRateControl == VA_RC_CQP.
616 unsigned int roi_rc_priority_support : 1;
618 * \brief A flag indicates whether ROI delta QP is supported
620 * \ref roi_rc_qp_delat_support equal to 1 specifies the underlying driver supports
621 * ROI delta QP when VAConfigAttribRateControl != VA_RC_CQP, user can use \c roi_value
622 * in #VAEncROI to set ROI delta QP. \ref roi_rc_qp_delat_support equal to 0 specifies
623 * the underlying driver doesn't support ROI delta QP.
625 * User should ignore \ref roi_rc_qp_delat_support when VAConfigAttribRateControl == VA_RC_CQP
626 * because ROI delta QP is always required when VAConfigAttribRateControl == VA_RC_CQP.
628 unsigned int roi_rc_qp_delat_support : 1;
629 unsigned int reserved : 22;
632 } VAConfigAttribValEncROI;
634 /** \brief Attribute value for VAConfigAttribEncRateControlExt */
635 typedef union _VAConfigAttribValEncRateControlExt {
638 * \brief The maximum number of temporal layers minus 1
640 * \ref max_num_temporal_layers_minus1 plus 1 specifies the maximum number of temporal
641 * layers that supported by the underlying driver. \ref max_num_temporal_layers_minus1
642 * equal to 0 implies the underlying driver doesn't support encoding with temporal layer.
644 unsigned int max_num_temporal_layers_minus1 : 8;
647 * /brief support temporal layer bit-rate control flag
649 * \ref temporal_layer_bitrate_control_flag equal to 1 specifies the underlying driver
650 * can support bit-rate control per temporal layer when (#VAConfigAttribRateControl == #VA_RC_CBR ||
651 * #VAConfigAttribRateControl == #VA_RC_VBR).
653 * The underlying driver must set \ref temporal_layer_bitrate_control_flag to 0 when
654 * \c max_num_temporal_layers_minus1 is equal to 0
656 * To use bit-rate control per temporal layer, an application must send the right layer
657 * structure via #VAEncMiscParameterTemporalLayerStructure at the beginning of a coded sequence
658 * and then followed by #VAEncMiscParameterRateControl and #VAEncMiscParameterFrameRate structures
659 * for each layer, using the \c temporal_id field as the layer identifier. Otherwise
660 * the driver doesn't use bitrate control per temporal layer if an application doesn't send the
661 * layer structure via #VAEncMiscParameterTemporalLayerStructure to the driver. The driver returns
662 * VA_STATUS_ERROR_INVALID_PARAMETER if an application sends a wrong layer structure or doesn't send
663 * #VAEncMiscParameterRateControl and #VAEncMiscParameterFrameRate for each layer.
665 * The driver will ignore #VAEncMiscParameterTemporalLayerStructure and the \c temporal_id field
666 * in #VAEncMiscParameterRateControl and #VAEncMiscParameterFrameRate if
667 * \ref temporal_layer_bitrate_control_flag is equal to 0 or #VAConfigAttribRateControl == #VA_RC_CQP
669 unsigned int temporal_layer_bitrate_control_flag : 1;
670 unsigned int reserved : 23;
673 } VAConfigAttribValEncRateControlExt;
676 * if an attribute is not applicable for a given
677 * profile/entrypoint pair, then set the value to the following
679 #define VA_ATTRIB_NOT_SUPPORTED 0x80000000
681 /** Get maximum number of profiles supported by the implementation */
682 int vaMaxNumProfiles (
686 /** Get maximum number of entrypoints supported by the implementation */
687 int vaMaxNumEntrypoints (
691 /** Get maximum number of attributs supported by the implementation */
692 int vaMaxNumConfigAttributes (
697 * Query supported profiles
698 * The caller must provide a "profile_list" array that can hold at
699 * least vaMaxNumProfile() entries. The actual number of profiles
700 * returned in "profile_list" is returned in "num_profile".
702 VAStatus vaQueryConfigProfiles (
704 VAProfile *profile_list, /* out */
705 int *num_profiles /* out */
709 * Query supported entrypoints for a given profile
710 * The caller must provide an "entrypoint_list" array that can hold at
711 * least vaMaxNumEntrypoints() entries. The actual number of entrypoints
712 * returned in "entrypoint_list" is returned in "num_entrypoints".
714 VAStatus vaQueryConfigEntrypoints (
717 VAEntrypoint *entrypoint_list, /* out */
718 int *num_entrypoints /* out */
722 * Get attributes for a given profile/entrypoint pair
723 * The caller must provide an "attrib_list" with all attributes to be
724 * retrieved. Upon return, the attributes in "attrib_list" have been
725 * updated with their value. Unknown attributes or attributes that are
726 * not supported for the given profile/entrypoint pair will have their
727 * value set to VA_ATTRIB_NOT_SUPPORTED
729 VAStatus vaGetConfigAttributes (
732 VAEntrypoint entrypoint,
733 VAConfigAttrib *attrib_list, /* in/out */
737 /** Generic ID type, can be re-typed for specific implementation */
738 typedef unsigned int VAGenericID;
740 typedef VAGenericID VAConfigID;
743 * Create a configuration for the decode pipeline
744 * it passes in the attribute list that specifies the attributes it cares
745 * about, with the rest taking default values.
747 VAStatus vaCreateConfig (
750 VAEntrypoint entrypoint,
751 VAConfigAttrib *attrib_list,
753 VAConfigID *config_id /* out */
757 * Free resources associdated with a given config
759 VAStatus vaDestroyConfig (
765 * Query all attributes for a given configuration
766 * The profile of the configuration is returned in "profile"
767 * The entrypoint of the configuration is returned in "entrypoint"
768 * The caller must provide an "attrib_list" array that can hold at least
769 * vaMaxNumConfigAttributes() entries. The actual number of attributes
770 * returned in "attrib_list" is returned in "num_attribs"
772 VAStatus vaQueryConfigAttributes (
774 VAConfigID config_id,
775 VAProfile *profile, /* out */
776 VAEntrypoint *entrypoint, /* out */
777 VAConfigAttrib *attrib_list,/* out */
778 int *num_attribs /* out */
783 * Contexts and Surfaces
785 * Context represents a "virtual" video decode pipeline. Surfaces are render
786 * targets for a given context. The data in the surfaces are not accessible
787 * to the client and the internal data format of the surface is implementatin
790 * Surfaces will be bound to a context when the context is created. Once
791 * a surface is bound to a given context, it can not be used to create
792 * another context. The association is removed when the context is destroyed
794 * Both contexts and surfaces are identified by unique IDs and its
795 * implementation specific internals are kept opaque to the clients
798 typedef VAGenericID VAContextID;
800 typedef VAGenericID VASurfaceID;
802 #define VA_INVALID_ID 0xffffffff
803 #define VA_INVALID_SURFACE VA_INVALID_ID
805 /** \brief Generic value types. */
807 VAGenericValueTypeInteger = 1, /**< 32-bit signed integer. */
808 VAGenericValueTypeFloat, /**< 32-bit floating-point value. */
809 VAGenericValueTypePointer, /**< Generic pointer type */
810 VAGenericValueTypeFunc /**< Pointer to function */
811 } VAGenericValueType;
813 /** \brief Generic function type. */
814 typedef void (*VAGenericFunc)(void);
816 /** \brief Generic value. */
817 typedef struct _VAGenericValue {
818 /** \brief Value type. See #VAGenericValueType. */
819 VAGenericValueType type;
820 /** \brief Value holder. */
822 /** \brief 32-bit signed integer. */
824 /** \brief 32-bit float. */
826 /** \brief Generic pointer. */
828 /** \brief Pointer to function. */
833 /** @name Surface attribute flags */
835 /** \brief Surface attribute is not supported. */
836 #define VA_SURFACE_ATTRIB_NOT_SUPPORTED 0x00000000
837 /** \brief Surface attribute can be got through vaQuerySurfaceAttributes(). */
838 #define VA_SURFACE_ATTRIB_GETTABLE 0x00000001
839 /** \brief Surface attribute can be set through vaCreateSurfaces(). */
840 #define VA_SURFACE_ATTRIB_SETTABLE 0x00000002
843 /** \brief Surface attribute types. */
845 VASurfaceAttribNone = 0,
847 * \brief Pixel format (fourcc).
849 * The value is meaningful as input to vaQuerySurfaceAttributes().
850 * If zero, the driver returns the optimal pixel format for the
851 * specified config. Otherwise, if non-zero, the value represents
852 * a pixel format (FOURCC) that is kept as is on output, if the
853 * driver supports it. Otherwise, the driver sets the value to
854 * zero and drops the \c VA_SURFACE_ATTRIB_SETTABLE flag.
856 VASurfaceAttribPixelFormat,
857 /** \brief Minimal width in pixels (int, read-only). */
858 VASurfaceAttribMinWidth,
859 /** \brief Maximal width in pixels (int, read-only). */
860 VASurfaceAttribMaxWidth,
861 /** \brief Minimal height in pixels (int, read-only). */
862 VASurfaceAttribMinHeight,
863 /** \brief Maximal height in pixels (int, read-only). */
864 VASurfaceAttribMaxHeight,
865 /** \brief Surface memory type expressed in bit fields (int, read/write). */
866 VASurfaceAttribMemoryType,
867 /** \brief External buffer descriptor (pointer, write). */
868 VASurfaceAttribExternalBufferDescriptor,
869 /** \brief Surface usage hint, gives the driver a hint of intended usage
870 * to optimize allocation (e.g. tiling) (int, read/write). */
871 VASurfaceAttribUsageHint,
872 /** \brief Number of surface attributes. */
874 } VASurfaceAttribType;
876 /** \brief Surface attribute. */
877 typedef struct _VASurfaceAttrib {
879 VASurfaceAttribType type;
880 /** \brief Flags. See "Surface attribute flags". */
882 /** \brief Value. See "Surface attribute types" for the expected types. */
883 VAGenericValue value;
887 * @name VASurfaceAttribMemoryType values in bit fields.
888 * Bit 0:7 are reserved for generic types, Bit 31:28 are reserved for
889 * Linux DRM, Bit 23:20 are reserved for Android. DRM and Android specific
890 * types are defined in DRM and Android header files.
893 /** \brief VA memory type (default) is supported. */
894 #define VA_SURFACE_ATTRIB_MEM_TYPE_VA 0x00000001
895 /** \brief V4L2 buffer memory type is supported. */
896 #define VA_SURFACE_ATTRIB_MEM_TYPE_V4L2 0x00000002
897 /** \brief User pointer memory type is supported. */
898 #define VA_SURFACE_ATTRIB_MEM_TYPE_USER_PTR 0x00000004
902 * \brief VASurfaceAttribExternalBuffers structure for
903 * the VASurfaceAttribExternalBufferDescriptor attribute.
905 typedef struct _VASurfaceAttribExternalBuffers {
906 /** \brief pixel format in fourcc. */
907 unsigned int pixel_format;
908 /** \brief width in pixels. */
910 /** \brief height in pixels. */
912 /** \brief total size of the buffer in bytes. */
913 unsigned int data_size;
914 /** \brief number of planes for planar layout */
915 unsigned int num_planes;
916 /** \brief pitch for each plane in bytes */
917 unsigned int pitches[4];
918 /** \brief offset for each plane in bytes */
919 unsigned int offsets[4];
920 /** \brief buffer handles or user pointers */
921 unsigned long *buffers;
922 /** \brief number of elements in the "buffers" array */
923 unsigned int num_buffers;
924 /** \brief flags. See "Surface external buffer descriptor flags". */
926 /** \brief reserved for passing private data */
928 } VASurfaceAttribExternalBuffers;
930 /** @name VASurfaceAttribExternalBuffers flags */
932 /** \brief Enable memory tiling */
933 #define VA_SURFACE_EXTBUF_DESC_ENABLE_TILING 0x00000001
934 /** \brief Memory is cacheable */
935 #define VA_SURFACE_EXTBUF_DESC_CACHED 0x00000002
936 /** \brief Memory is non-cacheable */
937 #define VA_SURFACE_EXTBUF_DESC_UNCACHED 0x00000004
938 /** \brief Memory is write-combined */
939 #define VA_SURFACE_EXTBUF_DESC_WC 0x00000008
940 /** \brief Memory is protected */
941 #define VA_SURFACE_EXTBUF_DESC_PROTECTED 0x80000000
943 /** @name VASurfaceAttribUsageHint attribute usage hint flags */
945 /** \brief Surface usage not indicated. */
946 #define VA_SURFACE_ATTRIB_USAGE_HINT_GENERIC 0x00000000
947 /** \brief Surface used by video decoder. */
948 #define VA_SURFACE_ATTRIB_USAGE_HINT_DECODER 0x00000001
949 /** \brief Surface used by video encoder. */
950 #define VA_SURFACE_ATTRIB_USAGE_HINT_ENCODER 0x00000002
951 /** \brief Surface read by video post-processing. */
952 #define VA_SURFACE_ATTRIB_USAGE_HINT_VPP_READ 0x00000004
953 /** \brief Surface written by video post-processing. */
954 #define VA_SURFACE_ATTRIB_USAGE_HINT_VPP_WRITE 0x00000008
955 /** \brief Surface used for display. */
956 #define VA_SURFACE_ATTRIB_USAGE_HINT_DISPLAY 0x00000010
961 * \brief Queries surface attributes for the supplied config.
963 * Unlike vaGetSurfaceAttributes(), this function queries for all
964 * supported attributes for the supplied VA @config. In particular, if
965 * the underlying hardware supports the creation of VA surfaces in
966 * various formats, then this function will enumerate all pixel
967 * formats that are supported.
969 * The \c attrib_list array is allocated by the user and \c
970 * num_attribs shall be initialized to the number of allocated
971 * elements in that array. Upon successful return, the actual number
972 * of attributes will be overwritten into \c num_attribs. Otherwise,
973 * \c VA_STATUS_ERROR_MAX_NUM_EXCEEDED is returned and \c num_attribs
974 * is adjusted to the number of elements that would be returned if
975 * enough space was available.
977 * Note: it is perfectly valid to pass NULL to the \c attrib_list
978 * argument when vaQuerySurfaceAttributes() is used to determine the
979 * actual number of elements that need to be allocated.
981 * @param[in] dpy the VA display
982 * @param[in] config the config identifying a codec or a video
983 * processing pipeline
984 * @param[out] attrib_list the output array of #VASurfaceAttrib elements
985 * @param[in,out] num_attribs the number of elements allocated on
986 * input, the number of elements actually filled in output
989 vaQuerySurfaceAttributes(
992 VASurfaceAttrib *attrib_list,
993 unsigned int *num_attribs
997 * \brief Creates an array of surfaces
999 * Creates an array of surfaces. The optional list of attributes shall
1000 * be constructed and validated through vaGetSurfaceAttributes() or
1001 * constructed based based on what the underlying hardware could
1002 * expose through vaQuerySurfaceAttributes().
1004 * @param[in] dpy the VA display
1005 * @param[in] format the desired surface format. See \c VA_RT_FORMAT_*
1006 * @param[in] width the surface width
1007 * @param[in] height the surface height
1008 * @param[out] surfaces the array of newly created surfaces
1009 * @param[in] num_surfaces the number of surfaces to create
1010 * @param[in] attrib_list the list of (optional) attributes, or \c NULL
1011 * @param[in] num_attribs the number of attributes supplied in
1012 * \c attrib_list, or zero
1017 unsigned int format,
1019 unsigned int height,
1020 VASurfaceID *surfaces,
1021 unsigned int num_surfaces,
1022 VASurfaceAttrib *attrib_list,
1023 unsigned int num_attribs
1027 * vaDestroySurfaces - Destroy resources associated with surfaces.
1028 * Surfaces can only be destroyed after the context associated has been
1031 * surfaces: array of surfaces to destroy
1032 * num_surfaces: number of surfaces in the array to be destroyed.
1034 VAStatus vaDestroySurfaces (
1036 VASurfaceID *surfaces,
1040 #define VA_PROGRESSIVE 0x1
1042 * vaCreateContext - Create a context
1044 * config_id: configuration for the context
1045 * picture_width: coded picture width
1046 * picture_height: coded picture height
1047 * flag: any combination of the following:
1048 * VA_PROGRESSIVE (only progressive frame pictures in the sequence when set)
1049 * render_targets: render targets (surfaces) tied to the context
1050 * num_render_targets: number of render targets in the above array
1051 * context: created context id upon return
1053 VAStatus vaCreateContext (
1055 VAConfigID config_id,
1059 VASurfaceID *render_targets,
1060 int num_render_targets,
1061 VAContextID *context /* out */
1065 * vaDestroyContext - Destroy a context
1067 * context: context to be destroyed
1069 VAStatus vaDestroyContext (
1076 * Buffers are used to pass various types of data from the
1077 * client to the server. The server maintains a data store
1078 * for each buffer created, and the client idenfies a buffer
1079 * through a unique buffer id assigned by the server.
1082 typedef VAGenericID VABufferID;
1086 VAPictureParameterBufferType = 0,
1087 VAIQMatrixBufferType = 1,
1088 VABitPlaneBufferType = 2,
1089 VASliceGroupMapBufferType = 3,
1090 VASliceParameterBufferType = 4,
1091 VASliceDataBufferType = 5,
1092 VAMacroblockParameterBufferType = 6,
1093 VAResidualDataBufferType = 7,
1094 VADeblockingParameterBufferType = 8,
1095 VAImageBufferType = 9,
1096 VAProtectedSliceDataBufferType = 10,
1097 VAQMatrixBufferType = 11,
1098 VAHuffmanTableBufferType = 12,
1099 VAProbabilityBufferType = 13,
1101 /* Following are encode buffer types */
1102 VAEncCodedBufferType = 21,
1103 VAEncSequenceParameterBufferType = 22,
1104 VAEncPictureParameterBufferType = 23,
1105 VAEncSliceParameterBufferType = 24,
1106 VAEncPackedHeaderParameterBufferType = 25,
1107 VAEncPackedHeaderDataBufferType = 26,
1108 VAEncMiscParameterBufferType = 27,
1109 VAEncMacroblockParameterBufferType = 28,
1110 VAEncMacroblockMapBufferType = 29,
1111 /* Following are video processing buffer types */
1113 * \brief Video processing pipeline parameter buffer.
1115 * This buffer describes the video processing pipeline. See
1116 * #VAProcPipelineParameterBuffer for details.
1118 VAProcPipelineParameterBufferType = 41,
1120 * \brief Video filter parameter buffer.
1122 * This buffer describes the video filter parameters. All buffers
1123 * inherit from #VAProcFilterParameterBufferBase, thus including
1124 * a unique filter buffer type.
1126 * The default buffer used by most filters is #VAProcFilterParameterBuffer.
1127 * Filters requiring advanced parameters include, but are not limited to,
1128 * deinterlacing (#VAProcFilterParameterBufferDeinterlacing),
1129 * color balance (#VAProcFilterParameterBufferColorBalance), etc.
1131 VAProcFilterParameterBufferType = 42,
1137 VAEncMiscParameterTypeFrameRate = 0,
1138 VAEncMiscParameterTypeRateControl = 1,
1139 VAEncMiscParameterTypeMaxSliceSize = 2,
1140 VAEncMiscParameterTypeAIR = 3,
1141 /** \brief Buffer type used to express a maximum frame size (in bits). */
1142 VAEncMiscParameterTypeMaxFrameSize = 4,
1143 /** \brief Buffer type used for HRD parameters. */
1144 VAEncMiscParameterTypeHRD = 5,
1145 VAEncMiscParameterTypeQualityLevel = 6,
1146 /** \brief Buffer type used for sending skip frame parameters to the encoder's
1147 * rate control, when the user has externally skipped frames. */
1148 VAEncMiscParameterTypeSkipFrame = 9,
1149 /** \brief Buffer type used for region-of-interest (ROI) parameters. */
1150 VAEncMiscParameterTypeROI = 10,
1151 /** \brief Buffer type used for temporal layer structure */
1152 VAEncMiscParameterTypeTemporalLayerStructure = 12,
1153 } VAEncMiscParameterType;
1155 /** \brief Packed header type. */
1157 /** \brief Packed sequence header. */
1158 VAEncPackedHeaderSequence = 1,
1159 /** \brief Packed picture header. */
1160 VAEncPackedHeaderPicture = 2,
1161 /** \brief Packed slice header. */
1162 VAEncPackedHeaderSlice = 3,
1164 * \brief Packed raw header.
1166 * Packed raw data header can be used by the client to insert a header
1167 * into the bitstream data buffer at the point it is passed, the driver
1168 * will handle the raw packed header based on "has_emulation_bytes" field
1169 * in the packed header parameter structure.
1171 VAEncPackedHeaderRawData = 4,
1172 /** \brief Misc packed header. See codec-specific definitions. */
1173 VAEncPackedHeaderMiscMask = 0x80000000,
1174 } VAEncPackedHeaderType;
1176 /** \brief Packed header parameter. */
1177 typedef struct _VAEncPackedHeaderParameterBuffer {
1178 /** Type of the packed header buffer. See #VAEncPackedHeaderType. */
1180 /** \brief Size of the #VAEncPackedHeaderDataBuffer in bits. */
1181 unsigned int bit_length;
1182 /** \brief Flag: buffer contains start code emulation prevention bytes? */
1183 unsigned char has_emulation_bytes;
1184 } VAEncPackedHeaderParameterBuffer;
1187 * For application, e.g. set a new bitrate
1188 * VABufferID buf_id;
1189 * VAEncMiscParameterBuffer *misc_param;
1190 * VAEncMiscParameterRateControl *misc_rate_ctrl;
1192 * vaCreateBuffer(dpy, context, VAEncMiscParameterBufferType,
1193 * sizeof(VAEncMiscParameterBuffer) + sizeof(VAEncMiscParameterRateControl),
1194 * 1, NULL, &buf_id);
1196 * vaMapBuffer(dpy,buf_id,(void **)&misc_param);
1197 * misc_param->type = VAEncMiscParameterTypeRateControl;
1198 * misc_rate_ctrl= (VAEncMiscParameterRateControl *)misc_param->data;
1199 * misc_rate_ctrl->bits_per_second = 6400000;
1200 * vaUnmapBuffer(dpy, buf_id);
1201 * vaRenderPicture(dpy, context, &buf_id, 1);
1203 typedef struct _VAEncMiscParameterBuffer
1205 VAEncMiscParameterType type;
1206 unsigned int data[0];
1207 } VAEncMiscParameterBuffer;
1209 /** \brief Temporal layer Structure*/
1210 typedef struct _VAEncMiscParameterTemporalLayerStructure
1212 /** \brief The number of temporal layers */
1213 unsigned int number_of_layers;
1214 /** \brief The length of the array defining frame layer membership. Should be 1-32 */
1215 unsigned int periodicity;
1217 * \brief The array indicating the layer id for each frame
1219 * The layer id for the first frame in a coded sequence is always 0, so layer_id[] specifies the layer
1220 * ids for frames starting from the 2nd frame.
1222 unsigned int layer_id[32];
1223 } VAEncMiscParameterTemporalLayerStructure;
1226 /** \brief Rate control parameters */
1227 typedef struct _VAEncMiscParameterRateControl
1229 /* this is the maximum bit-rate to be constrained by the rate control implementation */
1230 unsigned int bits_per_second;
1231 /* this is the bit-rate the rate control is targeting, as a percentage of the maximum
1232 * bit-rate for example if target_percentage is 95 then the rate control will target
1233 * a bit-rate that is 95% of the maximum bit-rate
1235 unsigned int target_percentage;
1236 /* windows size in milliseconds. For example if this is set to 500,
1237 * then the rate control will guarantee the target bit-rate over a 500 ms window
1239 unsigned int window_size;
1240 /* initial QP at I frames */
1241 unsigned int initial_qp;
1242 unsigned int min_qp;
1243 unsigned int basic_unit_size;
1248 unsigned int reset : 1;
1249 unsigned int disable_frame_skip : 1; /* Disable frame skip in rate control mode */
1250 unsigned int disable_bit_stuffing : 1; /* Disable bit stuffing in rate control mode */
1251 unsigned int mb_rate_control : 4; /* Control VA_RC_MB 0: default, 1: enable, 2: disable, other: reserved*/
1253 * The temporal layer that the rate control parameters are specified for.
1255 unsigned int temporal_id : 8;
1256 unsigned int reserved : 17;
1260 } VAEncMiscParameterRateControl;
1262 typedef struct _VAEncMiscParameterFrameRate
1265 * fps = numerator / denominator
1266 * The high 2 bytes (bits 16 to 31) of framerate specifies the numerator, and
1267 * the low 2 bytes (bits 0 to 15) of framerate specifies the denominator. For
1268 * example, ((100 < 16 ) | 750) is 7.5 fps
1270 * If the high 2 btyes is 0, the frame rate is specified by the low 2 bytes.
1272 unsigned int framerate;
1278 * The temporal id the framerate parameters are specified for.
1280 unsigned int temporal_id : 8;
1281 unsigned int reserved : 24;
1285 } VAEncMiscParameterFrameRate;
1288 * Allow a maximum slice size to be specified (in bits).
1289 * The encoder will attempt to make sure that individual slices do not exceed this size
1290 * Or to signal applicate if the slice size exceed this size, see "status" of VACodedBufferSegment
1292 typedef struct _VAEncMiscParameterMaxSliceSize
1294 unsigned int max_slice_size;
1295 } VAEncMiscParameterMaxSliceSize;
1297 typedef struct _VAEncMiscParameterAIR
1299 unsigned int air_num_mbs;
1300 unsigned int air_threshold;
1301 unsigned int air_auto; /* if set to 1 then hardware auto-tune the AIR threshold */
1302 } VAEncMiscParameterAIR;
1304 typedef struct _VAEncMiscParameterHRD
1306 unsigned int initial_buffer_fullness; /* in bits */
1307 unsigned int buffer_size; /* in bits */
1308 } VAEncMiscParameterHRD;
1311 * \brief Defines a maximum frame size (in bits).
1313 * This misc parameter buffer defines the maximum size of a frame (in
1314 * bits). The encoder will try to make sure that each frame does not
1315 * exceed this size. Otherwise, if the frame size exceeds this size,
1316 * the \c status flag of #VACodedBufferSegment will contain
1317 * #VA_CODED_BUF_STATUS_FRAME_SIZE_OVERFLOW.
1319 typedef struct _VAEncMiscParameterBufferMaxFrameSize {
1320 /** \brief Type. Shall be set to #VAEncMiscParameterTypeMaxFrameSize. */
1321 VAEncMiscParameterType type;
1322 /** \brief Maximum size of a frame (in bits). */
1323 unsigned int max_frame_size;
1324 } VAEncMiscParameterBufferMaxFrameSize;
1327 * \brief Encoding quality level.
1329 * The encoding quality could be set through this structure, if the implementation
1330 * supports multiple quality levels. The quality level set through this structure is
1331 * persistent over the entire coded sequence, or until a new structure is being sent.
1332 * The quality level range can be queried through the VAConfigAttribEncQualityRange
1333 * attribute. A lower value means higher quality, and a value of 1 represents the highest
1334 * quality. The quality level setting is used as a trade-off between quality and speed/power
1335 * consumption, with higher quality corresponds to lower speed and higher power consumption.
1337 typedef struct _VAEncMiscParameterBufferQualityLevel {
1338 /** \brief Encoding quality level setting. When set to 0, default quality
1341 unsigned int quality_level;
1342 } VAEncMiscParameterBufferQualityLevel;
1345 * \brief Encoding skip frame.
1347 * The application may choose to skip frames externally to the encoder (e.g. drop completely or
1348 * code as all skip's). For rate control purposes the encoder will need to know the size and number
1349 * of skipped frames. Skip frame(s) indicated through this structure is applicable only to the
1350 * current frame. It is allowed for the application to still send in packed headers for the driver to
1351 * pack, although no frame will be encoded (e.g. for HW to encrypt the frame).
1353 typedef struct _VAEncMiscParameterSkipFrame {
1354 /** \brief Indicates skip frames as below.
1355 * 0: Encode as normal, no skip.
1356 * 1: One or more frames were skipped prior to the current frame, encode the current frame as normal.
1357 * 2: The current frame is to be skipped, do not encode it but pack/encrypt the packed header contents
1358 * (all except VAEncPackedHeaderSlice) which could contain actual frame contents (e.g. pack the frame
1359 * in VAEncPackedHeaderPicture). */
1360 unsigned char skip_frame_flag;
1361 /** \brief The number of frames skipped prior to the current frame. Valid when skip_frame_flag = 1. */
1362 unsigned char num_skip_frames;
1363 /** \brief When skip_frame_flag = 1, the size of the skipped frames in bits. When skip_frame_flag = 2,
1364 * the size of the current skipped frame that is to be packed/encrypted in bits. */
1365 unsigned int size_skip_frames;
1366 } VAEncMiscParameterSkipFrame;
1369 * \brief Encoding region-of-interest (ROI).
1371 * The encoding ROI can be set through VAEncMiscParameterBufferROI, if the implementation
1372 * supports ROI input. The ROI set through this structure is applicable only to the
1373 * current frame or field, so must be sent every frame or field to be applied. The number of
1374 * supported ROIs can be queried through the VAConfigAttribEncROI. The encoder will use the
1375 * ROI information to adjust the QP values of the MB's that fall within the ROIs.
1377 typedef struct _VAEncROI
1379 /** \brief Defines the ROI boundary in pixels, the driver will map it to appropriate
1380 * codec coding units. It is relative to frame coordinates for the frame case and
1381 * to field coordinates for the field case. */
1382 VARectangle roi_rectangle;
1386 * \ref roi_value specifies ROI delta QP or ROI priority.
1387 * -- ROI delta QP is the value that will be added on top of the frame level QP.
1388 * -- ROI priority specifies the priority of a region, it can be positive (more important)
1389 * or negative (less important) values and is compared with non-ROI region (taken as value 0),
1390 * E.g. ROI region with \ref roi_value -3 is less important than the non-ROI region (\ref roi_value
1391 * implied to be 0) which is less important than ROI region with roi_value +2. For overlapping
1392 * regions, the roi_value that is first in the ROI array will have priority.
1394 * \ref roi_value always specifes ROI delta QP when VAConfigAttribRateControl == VA_RC_CQP, no matter
1395 * the value of \c roi_value_is_qp_delta in #VAEncMiscParameterBufferROI.
1397 * \ref roi_value depends on \c roi_value_is_qp_delta in #VAEncMiscParameterBufferROI when
1398 * VAConfigAttribRateControl != VA_RC_CQP. \ref roi_value specifies ROI_delta QP if \c roi_value_is_qp_delta
1399 * in VAEncMiscParameterBufferROI is 1, otherwise \ref roi_value specifies ROI priority.
1404 typedef struct _VAEncMiscParameterBufferROI {
1405 /** \brief Number of ROIs being sent.*/
1406 unsigned int num_roi;
1408 /** \brief Valid when VAConfigAttribRateControl != VA_RC_CQP, then the encoder's
1409 * rate control will determine actual delta QPs. Specifies the max/min allowed delta
1414 /** \brief Pointer to a VAEncROI array with num_roi elements. It is relative to frame
1415 * coordinates for the frame case and to field coordinates for the field case.*/
1420 * \brief An indication for roi value.
1422 * \ref roi_value_is_qp_delta equal to 1 indicates \c roi_value in #VAEncROI should
1423 * be used as ROI delta QP. \ref roi_value_is_qp_delta equal to 0 indicates \c roi_value
1424 * in #VAEncROI should be used as ROI priority.
1426 * \ref roi_value_is_qp_delta is only available when VAConfigAttribRateControl != VA_RC_CQP,
1427 * the setting must comply with \c roi_rc_priority_support and \c roi_rc_qp_delat_support in
1428 * #VAConfigAttribValEncROI. The underlying driver should ignore this field
1429 * when VAConfigAttribRateControl == VA_RC_CQP.
1431 uint32_t roi_value_is_qp_delta : 1;
1432 uint32_t reserved : 31;
1436 } VAEncMiscParameterBufferROI;
1439 * There will be cases where the bitstream buffer will not have enough room to hold
1440 * the data for the entire slice, and the following flags will be used in the slice
1441 * parameter to signal to the server for the possible cases.
1442 * If a slice parameter buffer and slice data buffer pair is sent to the server with
1443 * the slice data partially in the slice data buffer (BEGIN and MIDDLE cases below),
1444 * then a slice parameter and data buffer needs to be sent again to complete this slice.
1446 #define VA_SLICE_DATA_FLAG_ALL 0x00 /* whole slice is in the buffer */
1447 #define VA_SLICE_DATA_FLAG_BEGIN 0x01 /* The beginning of the slice is in the buffer but the end if not */
1448 #define VA_SLICE_DATA_FLAG_MIDDLE 0x02 /* Neither beginning nor end of the slice is in the buffer */
1449 #define VA_SLICE_DATA_FLAG_END 0x04 /* end of the slice is in the buffer */
1451 /* Codec-independent Slice Parameter Buffer base */
1452 typedef struct _VASliceParameterBufferBase
1454 unsigned int slice_data_size; /* number of bytes in the slice data buffer for this slice */
1455 unsigned int slice_data_offset; /* the offset to the first byte of slice data */
1456 unsigned int slice_data_flag; /* see VA_SLICE_DATA_FLAG_XXX definitions */
1457 } VASliceParameterBufferBase;
1459 /**********************************
1460 * JPEG common data structures
1461 **********************************/
1463 * \brief Huffman table for JPEG decoding.
1465 * This structure holds the complete Huffman tables. This is an
1466 * aggregation of all Huffman table (DHT) segments maintained by the
1467 * application. i.e. up to 2 Huffman tables are stored in there for
1470 * The #load_huffman_table array can be used as a hint to notify the
1471 * VA driver implementation about which table(s) actually changed
1472 * since the last submission of this buffer.
1474 typedef struct _VAHuffmanTableBufferJPEGBaseline {
1475 /** \brief Specifies which #huffman_table is valid. */
1476 unsigned char load_huffman_table[2];
1477 /** \brief Huffman tables indexed by table identifier (Th). */
1479 /** @name DC table (up to 12 categories) */
1481 /** \brief Number of Huffman codes of length i + 1 (Li). */
1482 unsigned char num_dc_codes[16];
1483 /** \brief Value associated with each Huffman code (Vij). */
1484 unsigned char dc_values[12];
1486 /** @name AC table (2 special codes + up to 16 * 10 codes) */
1488 /** \brief Number of Huffman codes of length i + 1 (Li). */
1489 unsigned char num_ac_codes[16];
1490 /** \brief Value associated with each Huffman code (Vij). */
1491 unsigned char ac_values[162];
1492 /** \brief Padding to 4-byte boundaries. Must be set to zero. */
1493 unsigned char pad[2];
1496 } VAHuffmanTableBufferJPEGBaseline;
1498 /****************************
1499 * MPEG-2 data structures
1500 ****************************/
1502 /* MPEG-2 Picture Parameter Buffer */
1504 * For each frame or field, and before any slice data, a single
1505 * picture parameter buffer must be send.
1507 typedef struct _VAPictureParameterBufferMPEG2
1509 unsigned short horizontal_size;
1510 unsigned short vertical_size;
1511 VASurfaceID forward_reference_picture;
1512 VASurfaceID backward_reference_picture;
1513 /* meanings of the following fields are the same as in the standard */
1514 int picture_coding_type;
1515 int f_code; /* pack all four fcode into this */
1518 unsigned int intra_dc_precision : 2;
1519 unsigned int picture_structure : 2;
1520 unsigned int top_field_first : 1;
1521 unsigned int frame_pred_frame_dct : 1;
1522 unsigned int concealment_motion_vectors : 1;
1523 unsigned int q_scale_type : 1;
1524 unsigned int intra_vlc_format : 1;
1525 unsigned int alternate_scan : 1;
1526 unsigned int repeat_first_field : 1;
1527 unsigned int progressive_frame : 1;
1528 unsigned int is_first_field : 1; /* indicate whether the current field
1529 * is the first field for field picture
1533 } picture_coding_extension;
1534 } VAPictureParameterBufferMPEG2;
1536 /** MPEG-2 Inverse Quantization Matrix Buffer */
1537 typedef struct _VAIQMatrixBufferMPEG2
1539 /** \brief Same as the MPEG-2 bitstream syntax element. */
1540 int load_intra_quantiser_matrix;
1541 /** \brief Same as the MPEG-2 bitstream syntax element. */
1542 int load_non_intra_quantiser_matrix;
1543 /** \brief Same as the MPEG-2 bitstream syntax element. */
1544 int load_chroma_intra_quantiser_matrix;
1545 /** \brief Same as the MPEG-2 bitstream syntax element. */
1546 int load_chroma_non_intra_quantiser_matrix;
1547 /** \brief Luminance intra matrix, in zig-zag scan order. */
1548 unsigned char intra_quantiser_matrix[64];
1549 /** \brief Luminance non-intra matrix, in zig-zag scan order. */
1550 unsigned char non_intra_quantiser_matrix[64];
1551 /** \brief Chroma intra matrix, in zig-zag scan order. */
1552 unsigned char chroma_intra_quantiser_matrix[64];
1553 /** \brief Chroma non-intra matrix, in zig-zag scan order. */
1554 unsigned char chroma_non_intra_quantiser_matrix[64];
1555 } VAIQMatrixBufferMPEG2;
1557 /** MPEG-2 Slice Parameter Buffer */
1558 typedef struct _VASliceParameterBufferMPEG2
1560 unsigned int slice_data_size;/* number of bytes in the slice data buffer for this slice */
1561 unsigned int slice_data_offset;/* the offset to the first byte of slice data */
1562 unsigned int slice_data_flag; /* see VA_SLICE_DATA_FLAG_XXX defintions */
1563 unsigned int macroblock_offset;/* the offset to the first bit of MB from the first byte of slice data */
1564 unsigned int slice_horizontal_position;
1565 unsigned int slice_vertical_position;
1566 int quantiser_scale_code;
1567 int intra_slice_flag;
1568 } VASliceParameterBufferMPEG2;
1570 /** MPEG-2 Macroblock Parameter Buffer */
1571 typedef struct _VAMacroblockParameterBufferMPEG2
1573 unsigned short macroblock_address;
1575 * macroblock_address (in raster scan order)
1577 * bottom-right: picture-height-in-mb*picture-width-in-mb - 1
1579 unsigned char macroblock_type; /* see definition below */
1582 unsigned int frame_motion_type : 2;
1583 unsigned int field_motion_type : 2;
1584 unsigned int dct_type : 1;
1588 unsigned char motion_vertical_field_select;
1590 * motion_vertical_field_select:
1591 * see section 6.3.17.2 in the spec
1592 * only the lower 4 bits are used
1593 * bit 0: first vector forward
1594 * bit 1: first vector backward
1595 * bit 2: second vector forward
1596 * bit 3: second vector backward
1598 short PMV[2][2][2]; /* see Table 7-7 in the spec */
1599 unsigned short coded_block_pattern;
1601 * The bitplanes for coded_block_pattern are described
1602 * in Figure 6.10-12 in the spec
1605 /* Number of skipped macroblocks after this macroblock */
1606 unsigned short num_skipped_macroblocks;
1607 } VAMacroblockParameterBufferMPEG2;
1610 * OR'd flags for macroblock_type (section 6.3.17.1 in the spec)
1612 #define VA_MB_TYPE_MOTION_FORWARD 0x02
1613 #define VA_MB_TYPE_MOTION_BACKWARD 0x04
1614 #define VA_MB_TYPE_MOTION_PATTERN 0x08
1615 #define VA_MB_TYPE_MOTION_INTRA 0x10
1618 * MPEG-2 Residual Data Buffer
1619 * For each macroblock, there wil be 64 shorts (16-bit) in the
1620 * residual data buffer
1623 /****************************
1624 * MPEG-4 Part 2 data structures
1625 ****************************/
1627 /* MPEG-4 Picture Parameter Buffer */
1629 * For each frame or field, and before any slice data, a single
1630 * picture parameter buffer must be send.
1632 typedef struct _VAPictureParameterBufferMPEG4
1634 unsigned short vop_width;
1635 unsigned short vop_height;
1636 VASurfaceID forward_reference_picture;
1637 VASurfaceID backward_reference_picture;
1640 unsigned int short_video_header : 1;
1641 unsigned int chroma_format : 2;
1642 unsigned int interlaced : 1;
1643 unsigned int obmc_disable : 1;
1644 unsigned int sprite_enable : 2;
1645 unsigned int sprite_warping_accuracy : 2;
1646 unsigned int quant_type : 1;
1647 unsigned int quarter_sample : 1;
1648 unsigned int data_partitioned : 1;
1649 unsigned int reversible_vlc : 1;
1650 unsigned int resync_marker_disable : 1;
1654 unsigned char no_of_sprite_warping_points;
1655 short sprite_trajectory_du[3];
1656 short sprite_trajectory_dv[3];
1657 unsigned char quant_precision;
1660 unsigned int vop_coding_type : 2;
1661 unsigned int backward_reference_vop_coding_type : 2;
1662 unsigned int vop_rounding_type : 1;
1663 unsigned int intra_dc_vlc_thr : 3;
1664 unsigned int top_field_first : 1;
1665 unsigned int alternate_vertical_scan_flag : 1;
1669 unsigned char vop_fcode_forward;
1670 unsigned char vop_fcode_backward;
1671 unsigned short vop_time_increment_resolution;
1672 /* short header related */
1673 unsigned char num_gobs_in_vop;
1674 unsigned char num_macroblocks_in_gob;
1675 /* for direct mode prediction */
1678 } VAPictureParameterBufferMPEG4;
1680 /** MPEG-4 Inverse Quantization Matrix Buffer */
1681 typedef struct _VAIQMatrixBufferMPEG4
1683 /** Same as the MPEG-4:2 bitstream syntax element. */
1684 int load_intra_quant_mat;
1685 /** Same as the MPEG-4:2 bitstream syntax element. */
1686 int load_non_intra_quant_mat;
1687 /** The matrix for intra blocks, in zig-zag scan order. */
1688 unsigned char intra_quant_mat[64];
1689 /** The matrix for non-intra blocks, in zig-zag scan order. */
1690 unsigned char non_intra_quant_mat[64];
1691 } VAIQMatrixBufferMPEG4;
1693 /** MPEG-4 Slice Parameter Buffer */
1694 typedef struct _VASliceParameterBufferMPEG4
1696 unsigned int slice_data_size;/* number of bytes in the slice data buffer for this slice */
1697 unsigned int slice_data_offset;/* the offset to the first byte of slice data */
1698 unsigned int slice_data_flag; /* see VA_SLICE_DATA_FLAG_XXX defintions */
1699 unsigned int macroblock_offset;/* the offset to the first bit of MB from the first byte of slice data */
1700 unsigned int macroblock_number;
1702 } VASliceParameterBufferMPEG4;
1705 VC-1 data structures
1708 typedef enum /* see 7.1.1.32 */
1711 VAMvMode1MvHalfPel = 1,
1712 VAMvMode1MvHalfPelBilinear = 2,
1713 VAMvModeMixedMv = 3,
1714 VAMvModeIntensityCompensation = 4
1717 /** VC-1 Picture Parameter Buffer */
1719 * For each picture, and before any slice data, a picture parameter
1720 * buffer must be send. Multiple picture parameter buffers may be
1721 * sent for a single picture. In that case picture parameters will
1722 * apply to all slice data that follow it until a new picture
1723 * parameter buffer is sent.
1726 * pic_quantizer_type should be set to the applicable quantizer
1727 * type as defined by QUANTIZER (J.1.19) and either
1728 * PQUANTIZER (7.1.1.8) or PQINDEX (7.1.1.6)
1730 typedef struct _VAPictureParameterBufferVC1
1732 VASurfaceID forward_reference_picture;
1733 VASurfaceID backward_reference_picture;
1734 /* if out-of-loop post-processing is done on the render
1735 target, then we need to keep the in-loop decoded
1736 picture as a reference picture */
1737 VASurfaceID inloop_decoded_picture;
1739 /* sequence layer for AP or meta data for SP and MP */
1742 unsigned int pulldown : 1; /* SEQUENCE_LAYER::PULLDOWN */
1743 unsigned int interlace : 1; /* SEQUENCE_LAYER::INTERLACE */
1744 unsigned int tfcntrflag : 1; /* SEQUENCE_LAYER::TFCNTRFLAG */
1745 unsigned int finterpflag : 1; /* SEQUENCE_LAYER::FINTERPFLAG */
1746 unsigned int psf : 1; /* SEQUENCE_LAYER::PSF */
1747 unsigned int multires : 1; /* METADATA::MULTIRES */
1748 unsigned int overlap : 1; /* METADATA::OVERLAP */
1749 unsigned int syncmarker : 1; /* METADATA::SYNCMARKER */
1750 unsigned int rangered : 1; /* METADATA::RANGERED */
1751 unsigned int max_b_frames : 3; /* METADATA::MAXBFRAMES */
1752 unsigned int profile : 2; /* SEQUENCE_LAYER::PROFILE or The MSB of METADATA::PROFILE */
1757 unsigned short coded_width; /* ENTRY_POINT_LAYER::CODED_WIDTH */
1758 unsigned short coded_height; /* ENTRY_POINT_LAYER::CODED_HEIGHT */
1761 unsigned int broken_link : 1; /* ENTRY_POINT_LAYER::BROKEN_LINK */
1762 unsigned int closed_entry : 1; /* ENTRY_POINT_LAYER::CLOSED_ENTRY */
1763 unsigned int panscan_flag : 1; /* ENTRY_POINT_LAYER::PANSCAN_FLAG */
1764 unsigned int loopfilter : 1; /* ENTRY_POINT_LAYER::LOOPFILTER */
1767 } entrypoint_fields;
1768 unsigned char conditional_overlap_flag; /* ENTRY_POINT_LAYER::CONDOVER */
1769 unsigned char fast_uvmc_flag; /* ENTRY_POINT_LAYER::FASTUVMC */
1772 unsigned int luma_flag : 1; /* ENTRY_POINT_LAYER::RANGE_MAPY_FLAG */
1773 unsigned int luma : 3; /* ENTRY_POINT_LAYER::RANGE_MAPY */
1774 unsigned int chroma_flag : 1; /* ENTRY_POINT_LAYER::RANGE_MAPUV_FLAG */
1775 unsigned int chroma : 3; /* ENTRY_POINT_LAYER::RANGE_MAPUV */
1778 } range_mapping_fields;
1780 unsigned char b_picture_fraction; /* PICTURE_LAYER::BFRACTION */
1781 unsigned char cbp_table; /* PICTURE_LAYER::CBPTAB/ICBPTAB */
1782 unsigned char mb_mode_table; /* PICTURE_LAYER::MBMODETAB */
1783 unsigned char range_reduction_frame;/* PICTURE_LAYER::RANGEREDFRM */
1784 unsigned char rounding_control; /* PICTURE_LAYER::RNDCTRL */
1785 unsigned char post_processing; /* PICTURE_LAYER::POSTPROC */
1786 unsigned char picture_resolution_index; /* PICTURE_LAYER::RESPIC */
1787 unsigned char luma_scale; /* PICTURE_LAYER::LUMSCALE */
1788 unsigned char luma_shift; /* PICTURE_LAYER::LUMSHIFT */
1791 unsigned int picture_type : 3; /* PICTURE_LAYER::PTYPE */
1792 unsigned int frame_coding_mode : 3; /* PICTURE_LAYER::FCM */
1793 unsigned int top_field_first : 1; /* PICTURE_LAYER::TFF */
1794 unsigned int is_first_field : 1; /* set to 1 if it is the first field */
1795 unsigned int intensity_compensation : 1; /* PICTURE_LAYER::INTCOMP */
1801 unsigned int mv_type_mb : 1; /* PICTURE::MVTYPEMB */
1802 unsigned int direct_mb : 1; /* PICTURE::DIRECTMB */
1803 unsigned int skip_mb : 1; /* PICTURE::SKIPMB */
1804 unsigned int field_tx : 1; /* PICTURE::FIELDTX */
1805 unsigned int forward_mb : 1; /* PICTURE::FORWARDMB */
1806 unsigned int ac_pred : 1; /* PICTURE::ACPRED */
1807 unsigned int overflags : 1; /* PICTURE::OVERFLAGS */
1813 unsigned int bp_mv_type_mb : 1; /* PICTURE::MVTYPEMB */
1814 unsigned int bp_direct_mb : 1; /* PICTURE::DIRECTMB */
1815 unsigned int bp_skip_mb : 1; /* PICTURE::SKIPMB */
1816 unsigned int bp_field_tx : 1; /* PICTURE::FIELDTX */
1817 unsigned int bp_forward_mb : 1; /* PICTURE::FORWARDMB */
1818 unsigned int bp_ac_pred : 1; /* PICTURE::ACPRED */
1819 unsigned int bp_overflags : 1; /* PICTURE::OVERFLAGS */
1822 } bitplane_present; /* signal what bitplane is being passed via the bitplane buffer */
1825 unsigned int reference_distance_flag : 1;/* PICTURE_LAYER::REFDIST_FLAG */
1826 unsigned int reference_distance : 5;/* PICTURE_LAYER::REFDIST */
1827 unsigned int num_reference_pictures: 1;/* PICTURE_LAYER::NUMREF */
1828 unsigned int reference_field_pic_indicator : 1;/* PICTURE_LAYER::REFFIELD */
1834 unsigned int mv_mode : 3; /* PICTURE_LAYER::MVMODE */
1835 unsigned int mv_mode2 : 3; /* PICTURE_LAYER::MVMODE2 */
1836 unsigned int mv_table : 3; /* PICTURE_LAYER::MVTAB/IMVTAB */
1837 unsigned int two_mv_block_pattern_table: 2; /* PICTURE_LAYER::2MVBPTAB */
1838 unsigned int four_mv_switch : 1; /* PICTURE_LAYER::4MVSWITCH */
1839 unsigned int four_mv_block_pattern_table : 2; /* PICTURE_LAYER::4MVBPTAB */
1840 unsigned int extended_mv_flag : 1; /* ENTRY_POINT_LAYER::EXTENDED_MV */
1841 unsigned int extended_mv_range : 2; /* PICTURE_LAYER::MVRANGE */
1842 unsigned int extended_dmv_flag : 1; /* ENTRY_POINT_LAYER::EXTENDED_DMV */
1843 unsigned int extended_dmv_range : 2; /* PICTURE_LAYER::DMVRANGE */
1849 unsigned int dquant : 2; /* ENTRY_POINT_LAYER::DQUANT */
1850 unsigned int quantizer : 2; /* ENTRY_POINT_LAYER::QUANTIZER */
1851 unsigned int half_qp : 1; /* PICTURE_LAYER::HALFQP */
1852 unsigned int pic_quantizer_scale : 5;/* PICTURE_LAYER::PQUANT */
1853 unsigned int pic_quantizer_type : 1;/* PICTURE_LAYER::PQUANTIZER */
1854 unsigned int dq_frame : 1; /* VOPDQUANT::DQUANTFRM */
1855 unsigned int dq_profile : 2; /* VOPDQUANT::DQPROFILE */
1856 unsigned int dq_sb_edge : 2; /* VOPDQUANT::DQSBEDGE */
1857 unsigned int dq_db_edge : 2; /* VOPDQUANT::DQDBEDGE */
1858 unsigned int dq_binary_level : 1; /* VOPDQUANT::DQBILEVEL */
1859 unsigned int alt_pic_quantizer : 5;/* VOPDQUANT::ALTPQUANT */
1862 } pic_quantizer_fields;
1865 unsigned int variable_sized_transform_flag : 1;/* ENTRY_POINT_LAYER::VSTRANSFORM */
1866 unsigned int mb_level_transform_type_flag : 1;/* PICTURE_LAYER::TTMBF */
1867 unsigned int frame_level_transform_type : 2;/* PICTURE_LAYER::TTFRM */
1868 unsigned int transform_ac_codingset_idx1 : 2;/* PICTURE_LAYER::TRANSACFRM */
1869 unsigned int transform_ac_codingset_idx2 : 2;/* PICTURE_LAYER::TRANSACFRM2 */
1870 unsigned int intra_transform_dc_table : 1;/* PICTURE_LAYER::TRANSDCTAB */
1874 } VAPictureParameterBufferVC1;
1876 /** VC-1 Bitplane Buffer
1877 There will be at most three bitplanes coded in any picture header. To send
1878 the bitplane data more efficiently, each byte is divided in two nibbles, with
1879 each nibble carrying three bitplanes for one macroblock. The following table
1880 shows the bitplane data arrangement within each nibble based on the picture
1883 Picture Type Bit3 Bit2 Bit1 Bit0
1884 I or BI OVERFLAGS ACPRED FIELDTX
1885 P MYTYPEMB SKIPMB DIRECTMB
1886 B FORWARDMB SKIPMB DIRECTMB
1888 Within each byte, the lower nibble is for the first MB and the upper nibble is
1889 for the second MB. E.g. the lower nibble of the first byte in the bitplane
1890 buffer is for Macroblock #1 and the upper nibble of the first byte is for
1891 Macroblock #2 in the first row.
1894 /* VC-1 Slice Parameter Buffer */
1895 typedef struct _VASliceParameterBufferVC1
1897 unsigned int slice_data_size;/* number of bytes in the slice data buffer for this slice */
1898 unsigned int slice_data_offset;/* the offset to the first byte of slice data */
1899 unsigned int slice_data_flag; /* see VA_SLICE_DATA_FLAG_XXX defintions */
1900 unsigned int macroblock_offset;/* the offset to the first bit of MB from the first byte of slice data */
1901 unsigned int slice_vertical_position;
1902 } VASliceParameterBufferVC1;
1904 /* VC-1 Slice Data Buffer */
1906 This is simplely a buffer containing raw bit-stream bytes
1909 /****************************
1910 * H.264/AVC data structures
1911 ****************************/
1913 typedef struct _VAPictureH264
1915 VASurfaceID picture_id;
1916 unsigned int frame_idx;
1918 signed int TopFieldOrderCnt;
1919 signed int BottomFieldOrderCnt;
1921 /* flags in VAPictureH264 could be OR of the following */
1922 #define VA_PICTURE_H264_INVALID 0x00000001
1923 #define VA_PICTURE_H264_TOP_FIELD 0x00000002
1924 #define VA_PICTURE_H264_BOTTOM_FIELD 0x00000004
1925 #define VA_PICTURE_H264_SHORT_TERM_REFERENCE 0x00000008
1926 #define VA_PICTURE_H264_LONG_TERM_REFERENCE 0x00000010
1928 /** H.264 Picture Parameter Buffer */
1930 * For each picture, and before any slice data, a single
1931 * picture parameter buffer must be send.
1933 typedef struct _VAPictureParameterBufferH264
1935 VAPictureH264 CurrPic;
1936 VAPictureH264 ReferenceFrames[16]; /* in DPB */
1937 unsigned short picture_width_in_mbs_minus1;
1938 unsigned short picture_height_in_mbs_minus1;
1939 unsigned char bit_depth_luma_minus8;
1940 unsigned char bit_depth_chroma_minus8;
1941 unsigned char num_ref_frames;
1944 unsigned int chroma_format_idc : 2;
1945 unsigned int residual_colour_transform_flag : 1;
1946 unsigned int gaps_in_frame_num_value_allowed_flag : 1;
1947 unsigned int frame_mbs_only_flag : 1;
1948 unsigned int mb_adaptive_frame_field_flag : 1;
1949 unsigned int direct_8x8_inference_flag : 1;
1950 unsigned int MinLumaBiPredSize8x8 : 1; /* see A.3.3.2 */
1951 unsigned int log2_max_frame_num_minus4 : 4;
1952 unsigned int pic_order_cnt_type : 2;
1953 unsigned int log2_max_pic_order_cnt_lsb_minus4 : 4;
1954 unsigned int delta_pic_order_always_zero_flag : 1;
1958 unsigned char num_slice_groups_minus1;
1959 unsigned char slice_group_map_type;
1960 unsigned short slice_group_change_rate_minus1;
1961 signed char pic_init_qp_minus26;
1962 signed char pic_init_qs_minus26;
1963 signed char chroma_qp_index_offset;
1964 signed char second_chroma_qp_index_offset;
1967 unsigned int entropy_coding_mode_flag : 1;
1968 unsigned int weighted_pred_flag : 1;
1969 unsigned int weighted_bipred_idc : 2;
1970 unsigned int transform_8x8_mode_flag : 1;
1971 unsigned int field_pic_flag : 1;
1972 unsigned int constrained_intra_pred_flag : 1;
1973 unsigned int pic_order_present_flag : 1;
1974 unsigned int deblocking_filter_control_present_flag : 1;
1975 unsigned int redundant_pic_cnt_present_flag : 1;
1976 unsigned int reference_pic_flag : 1; /* nal_ref_idc != 0 */
1980 unsigned short frame_num;
1981 } VAPictureParameterBufferH264;
1983 /** H.264 Inverse Quantization Matrix Buffer */
1984 typedef struct _VAIQMatrixBufferH264
1986 /** \brief 4x4 scaling list, in raster scan order. */
1987 unsigned char ScalingList4x4[6][16];
1988 /** \brief 8x8 scaling list, in raster scan order. */
1989 unsigned char ScalingList8x8[2][64];
1990 } VAIQMatrixBufferH264;
1993 * H.264 Slice Group Map Buffer
1994 * When VAPictureParameterBufferH264::num_slice_group_minus1 is not equal to 0,
1995 * A slice group map buffer should be sent for each picture if required. The buffer
1996 * is sent only when there is a change in the mapping values.
1997 * The slice group map buffer map "map units" to slice groups as specified in
1998 * section 8.2.2 of the H.264 spec. The buffer will contain one byte for each macroblock
1999 * in raster scan order
2002 /** H.264 Slice Parameter Buffer */
2003 typedef struct _VASliceParameterBufferH264
2005 unsigned int slice_data_size;/* number of bytes in the slice data buffer for this slice */
2006 /** \brief Byte offset to the NAL Header Unit for this slice. */
2007 unsigned int slice_data_offset;
2008 unsigned int slice_data_flag; /* see VA_SLICE_DATA_FLAG_XXX defintions */
2010 * \brief Bit offset from NAL Header Unit to the begining of slice_data().
2012 * This bit offset is relative to and includes the NAL unit byte
2013 * and represents the number of bits parsed in the slice_header()
2014 * after the removal of any emulation prevention bytes in
2015 * there. However, the slice data buffer passed to the hardware is
2016 * the original bitstream, thus including any emulation prevention
2019 unsigned short slice_data_bit_offset;
2020 unsigned short first_mb_in_slice;
2021 unsigned char slice_type;
2022 unsigned char direct_spatial_mv_pred_flag;
2023 unsigned char num_ref_idx_l0_active_minus1;
2024 unsigned char num_ref_idx_l1_active_minus1;
2025 unsigned char cabac_init_idc;
2026 char slice_qp_delta;
2027 unsigned char disable_deblocking_filter_idc;
2028 char slice_alpha_c0_offset_div2;
2029 char slice_beta_offset_div2;
2030 VAPictureH264 RefPicList0[32]; /* See 8.2.4.2 */
2031 VAPictureH264 RefPicList1[32]; /* See 8.2.4.2 */
2032 unsigned char luma_log2_weight_denom;
2033 unsigned char chroma_log2_weight_denom;
2034 unsigned char luma_weight_l0_flag;
2035 short luma_weight_l0[32];
2036 short luma_offset_l0[32];
2037 unsigned char chroma_weight_l0_flag;
2038 short chroma_weight_l0[32][2];
2039 short chroma_offset_l0[32][2];
2040 unsigned char luma_weight_l1_flag;
2041 short luma_weight_l1[32];
2042 short luma_offset_l1[32];
2043 unsigned char chroma_weight_l1_flag;
2044 short chroma_weight_l1[32][2];
2045 short chroma_offset_l1[32][2];
2046 } VASliceParameterBufferH264;
2048 /****************************
2049 * Common encode data structures
2050 ****************************/
2053 VAEncPictureTypeIntra = 0,
2054 VAEncPictureTypePredictive = 1,
2055 VAEncPictureTypeBidirectional = 2,
2058 /* Encode Slice Parameter Buffer */
2059 typedef struct _VAEncSliceParameterBuffer
2061 unsigned int start_row_number; /* starting MB row number for this slice */
2062 unsigned int slice_height; /* slice height measured in MB */
2065 unsigned int is_intra : 1;
2066 unsigned int disable_deblocking_filter_idc : 2;
2067 unsigned int uses_long_term_ref :1;
2068 unsigned int is_long_term_ref :1;
2072 } VAEncSliceParameterBuffer;
2075 /****************************
2076 * H.263 specific encode data structures
2077 ****************************/
2079 typedef struct _VAEncSequenceParameterBufferH263
2081 unsigned int intra_period;
2082 unsigned int bits_per_second;
2083 unsigned int frame_rate;
2084 unsigned int initial_qp;
2085 unsigned int min_qp;
2086 } VAEncSequenceParameterBufferH263;
2088 typedef struct _VAEncPictureParameterBufferH263
2090 VASurfaceID reference_picture;
2091 VASurfaceID reconstructed_picture;
2092 VABufferID coded_buf;
2093 unsigned short picture_width;
2094 unsigned short picture_height;
2095 VAEncPictureType picture_type;
2096 } VAEncPictureParameterBufferH263;
2098 /****************************
2099 * MPEG-4 specific encode data structures
2100 ****************************/
2102 typedef struct _VAEncSequenceParameterBufferMPEG4
2104 unsigned char profile_and_level_indication;
2105 unsigned int intra_period;
2106 unsigned int video_object_layer_width;
2107 unsigned int video_object_layer_height;
2108 unsigned int vop_time_increment_resolution;
2109 unsigned int fixed_vop_rate;
2110 unsigned int fixed_vop_time_increment;
2111 unsigned int bits_per_second;
2112 unsigned int frame_rate;
2113 unsigned int initial_qp;
2114 unsigned int min_qp;
2115 } VAEncSequenceParameterBufferMPEG4;
2117 typedef struct _VAEncPictureParameterBufferMPEG4
2119 VASurfaceID reference_picture;
2120 VASurfaceID reconstructed_picture;
2121 VABufferID coded_buf;
2122 unsigned short picture_width;
2123 unsigned short picture_height;
2124 unsigned int modulo_time_base; /* number of 1s */
2125 unsigned int vop_time_increment;
2126 VAEncPictureType picture_type;
2127 } VAEncPictureParameterBufferMPEG4;
2131 /** Buffer functions */
2134 * Creates a buffer for "num_elements" elements of "size" bytes and
2135 * initalize with "data".
2136 * if "data" is null, then the contents of the buffer data store
2138 * Basically there are two ways to get buffer data to the server side. One is
2139 * to call vaCreateBuffer() with a non-null "data", which results the data being
2140 * copied to the data store on the server side. A different method that
2141 * eliminates this copy is to pass null as "data" when calling vaCreateBuffer(),
2142 * and then use vaMapBuffer() to map the data store from the server side to the
2143 * client address space for access.
2144 * Note: image buffers are created by the library, not the client. Please see
2145 * vaCreateImage on how image buffers are managed.
2147 VAStatus vaCreateBuffer (
2149 VAContextID context,
2150 VABufferType type, /* in */
2151 unsigned int size, /* in */
2152 unsigned int num_elements, /* in */
2153 void *data, /* in */
2154 VABufferID *buf_id /* out */
2158 * Convey to the server how many valid elements are in the buffer.
2159 * e.g. if multiple slice parameters are being held in a single buffer,
2160 * this will communicate to the server the number of slice parameters
2161 * that are valid in the buffer.
2163 VAStatus vaBufferSetNumElements (
2165 VABufferID buf_id, /* in */
2166 unsigned int num_elements /* in */
2171 * device independent data structure for codedbuffer
2175 * FICTURE_AVE_QP(bit7-0): The average Qp value used during this frame
2176 * LARGE_SLICE(bit8):At least one slice in the current frame was large
2177 * enough for the encoder to attempt to limit its size.
2178 * SLICE_OVERFLOW(bit9): At least one slice in the current frame has
2179 * exceeded the maximum slice size specified.
2180 * BITRATE_OVERFLOW(bit10): The peak bitrate was exceeded for this frame.
2181 * BITRATE_HIGH(bit11): The frame size got within the safety margin of the maximum size (VCM only)
2182 * AIR_MB_OVER_THRESHOLD: the number of MBs adapted to Intra MB
2184 #define VA_CODED_BUF_STATUS_PICTURE_AVE_QP_MASK 0xff
2185 #define VA_CODED_BUF_STATUS_LARGE_SLICE_MASK 0x100
2186 #define VA_CODED_BUF_STATUS_SLICE_OVERFLOW_MASK 0x200
2187 #define VA_CODED_BUF_STATUS_BITRATE_OVERFLOW 0x400
2188 #define VA_CODED_BUF_STATUS_BITRATE_HIGH 0x800
2190 * \brief The frame has exceeded the maximum requested size.
2192 * This flag indicates that the encoded frame size exceeds the value
2193 * specified through a misc parameter buffer of type
2194 * #VAEncMiscParameterTypeMaxFrameSize.
2196 #define VA_CODED_BUF_STATUS_FRAME_SIZE_OVERFLOW 0x1000
2197 #define VA_CODED_BUF_STATUS_AIR_MB_OVER_THRESHOLD 0xff0000
2200 * \brief The coded buffer segment contains a single NAL unit.
2202 * This flag indicates that the coded buffer segment contains a
2203 * single NAL unit. This flag might be useful to the user for
2204 * processing the coded buffer.
2206 #define VA_CODED_BUF_STATUS_SINGLE_NALU 0x10000000
2209 * \brief Coded buffer segment.
2211 * #VACodedBufferSegment is an element of a linked list describing
2212 * some information on the coded buffer. The coded buffer segment
2213 * could contain either a single NAL unit, or more than one NAL unit.
2214 * It is recommended (but not required) to return a single NAL unit
2215 * in a coded buffer segment, and the implementation should set the
2216 * VA_CODED_BUF_STATUS_SINGLE_NALU status flag if that is the case.
2218 typedef struct _VACodedBufferSegment {
2220 * \brief Size of the data buffer in this segment (in bytes).
2223 /** \brief Bit offset into the data buffer where the video data starts. */
2224 unsigned int bit_offset;
2225 /** \brief Status set by the driver. See \c VA_CODED_BUF_STATUS_*. */
2226 unsigned int status;
2227 /** \brief Reserved for future use. */
2228 unsigned int reserved;
2229 /** \brief Pointer to the start of the data buffer. */
2232 * \brief Pointer to the next #VACodedBufferSegment element,
2233 * or \c NULL if there is none.
2236 } VACodedBufferSegment;
2239 * Map data store of the buffer into the client's address space
2240 * vaCreateBuffer() needs to be called with "data" set to NULL before
2241 * calling vaMapBuffer()
2243 * if buffer type is VAEncCodedBufferType, pbuf points to link-list of
2244 * VACodedBufferSegment, and the list is terminated if "next" is NULL
2246 VAStatus vaMapBuffer (
2248 VABufferID buf_id, /* in */
2249 void **pbuf /* out */
2253 * After client making changes to a mapped data store, it needs to
2254 * "Unmap" it to let the server know that the data is ready to be
2255 * consumed by the server
2257 VAStatus vaUnmapBuffer (
2259 VABufferID buf_id /* in */
2263 * After this call, the buffer is deleted and this buffer_id is no longer valid
2264 * Only call this if the buffer is not going to be passed to vaRenderBuffer
2266 VAStatus vaDestroyBuffer (
2268 VABufferID buffer_id
2271 /** \brief VA buffer information */
2273 /** \brief Buffer handle */
2275 /** \brief Buffer type (See \ref VABufferType). */
2278 * \brief Buffer memory type (See \ref VASurfaceAttribMemoryType).
2280 * On input to vaAcquireBufferHandle(), this field can serve as a hint
2281 * to specify the set of memory types the caller is interested in.
2282 * On successful return from vaAcquireBufferHandle(), the field is
2283 * updated with the best matching memory type.
2286 /** \brief Size of the underlying buffer. */
2291 * \brief Acquires buffer handle for external API usage
2293 * Locks the VA buffer object \ref buf_id for external API usage like
2294 * EGL or OpenCL (OCL). This function is a synchronization point. This
2295 * means that any pending operation is guaranteed to be completed
2296 * prior to returning from the function.
2298 * If the referenced VA buffer object is the backing store of a VA
2299 * surface, then this function acts as if vaSyncSurface() on the
2300 * parent surface was called first.
2302 * The \ref VABufferInfo argument shall be zero'ed on input. On
2303 * successful output, the data structure is filled in with all the
2304 * necessary buffer level implementation details like handle, type,
2305 * memory type and memory size.
2307 * Note: the external API implementation, or the application, can
2308 * express the memory types it is interested in by filling in the \ref
2309 * mem_type field accordingly. On successful output, the memory type
2310 * that fits best the request and that was used is updated in the \ref
2311 * VABufferInfo data structure. If none of the supplied memory types
2312 * is supported, then a \ref VA_STATUS_ERROR_UNSUPPORTED_MEMORY_TYPE
2313 * error is returned.
2315 * The \ref VABufferInfo data is valid until vaReleaseBufferHandle()
2316 * is called. Besides, no additional operation is allowed on any of
2317 * the buffer parent object until vaReleaseBufferHandle() is called.
2318 * e.g. decoding into a VA surface backed with the supplied VA buffer
2319 * object \ref buf_id would fail with a \ref VA_STATUS_ERROR_SURFACE_BUSY
2323 * - \ref VA_STATUS_ERROR_UNIMPLEMENTED: the VA driver implementation
2324 * does not support this interface
2325 * - \ref VA_STATUS_ERROR_INVALID_DISPLAY: an invalid display was supplied
2326 * - \ref VA_STATUS_ERROR_INVALID_BUFFER: an invalid buffer was supplied
2327 * - \ref VA_STATUS_ERROR_UNSUPPORTED_BUFFERTYPE: the implementation
2328 * does not support exporting buffers of the specified type
2329 * - \ref VA_STATUS_ERROR_UNSUPPORTED_MEMORY_TYPE: none of the requested
2330 * memory types in \ref VABufferInfo.mem_type was supported
2332 * @param[in] dpy the VA display
2333 * @param[in] buf_id the VA buffer
2334 * @param[in,out] buf_info the associated VA buffer information
2335 * @return VA_STATUS_SUCCESS if successful
2338 vaAcquireBufferHandle(VADisplay dpy, VABufferID buf_id, VABufferInfo *buf_info);
2341 * \brief Releases buffer after usage from external API
2343 * Unlocks the VA buffer object \ref buf_id from external API usage like
2344 * EGL or OpenCL (OCL). This function is a synchronization point. This
2345 * means that any pending operation is guaranteed to be completed
2346 * prior to returning from the function.
2348 * The \ref VABufferInfo argument shall point to the original data
2349 * structure that was obtained from vaAcquireBufferHandle(), unaltered.
2350 * This is necessary so that the VA driver implementation could
2351 * deallocate any resources that were needed.
2353 * In any case, returning from this function invalidates any contents
2354 * in \ref VABufferInfo. i.e. the underlyng buffer handle is no longer
2355 * valid. Therefore, VA driver implementations are free to reset this
2356 * data structure to safe defaults.
2359 * - \ref VA_STATUS_ERROR_UNIMPLEMENTED: the VA driver implementation
2360 * does not support this interface
2361 * - \ref VA_STATUS_ERROR_INVALID_DISPLAY: an invalid display was supplied
2362 * - \ref VA_STATUS_ERROR_INVALID_BUFFER: an invalid buffer was supplied
2363 * - \ref VA_STATUS_ERROR_UNSUPPORTED_BUFFERTYPE: the implementation
2364 * does not support exporting buffers of the specified type
2366 * @param[in] dpy the VA display
2367 * @param[in] buf_id the VA buffer
2368 * @return VA_STATUS_SUCCESS if successful
2371 vaReleaseBufferHandle(VADisplay dpy, VABufferID buf_id);
2374 Render (Decode) Pictures
2376 A picture represents either a frame or a field.
2378 The Begin/Render/End sequence sends the decode buffers to the server
2382 * Get ready to decode a picture to a target surface
2384 VAStatus vaBeginPicture (
2386 VAContextID context,
2387 VASurfaceID render_target
2391 * Send decode buffers to the server.
2392 * Buffers are automatically destroyed afterwards
2394 VAStatus vaRenderPicture (
2396 VAContextID context,
2397 VABufferID *buffers,
2402 * Make the end of rendering for a picture.
2403 * The server should start processing all pending operations for this
2404 * surface. This call is non-blocking. The client can start another
2405 * Begin/Render/End sequence on a different render target.
2407 VAStatus vaEndPicture (
2419 * This function blocks until all pending operations on the render target
2420 * have been completed. Upon return it is safe to use the render target for a
2421 * different picture.
2423 VAStatus vaSyncSurface (
2425 VASurfaceID render_target
2430 VASurfaceRendering = 1, /* Rendering in progress */
2431 VASurfaceDisplaying = 2, /* Displaying in progress (not safe to render into it) */
2432 /* this status is useful if surface is used as the source */
2434 VASurfaceReady = 4, /* not being rendered or displayed */
2435 VASurfaceSkipped = 8 /* Indicate a skipped frame during encode */
2439 * Find out any pending ops on the render target
2441 VAStatus vaQuerySurfaceStatus (
2443 VASurfaceID render_target,
2444 VASurfaceStatus *status /* out */
2449 VADecodeSliceMissing = 0,
2450 VADecodeMBError = 1,
2451 } VADecodeErrorType;
2454 * Client calls vaQuerySurfaceError with VA_STATUS_ERROR_DECODING_ERROR, server side returns
2455 * an array of structure VASurfaceDecodeMBErrors, and the array is terminated by setting status=-1
2457 typedef struct _VASurfaceDecodeMBErrors
2459 int status; /* 1 if hardware has returned detailed info below, -1 means this record is invalid */
2460 unsigned int start_mb; /* start mb address with errors */
2461 unsigned int end_mb; /* end mb address with errors */
2462 VADecodeErrorType decode_error_type;
2463 } VASurfaceDecodeMBErrors;
2466 * After the application gets VA_STATUS_ERROR_DECODING_ERROR after calling vaSyncSurface(),
2467 * it can call vaQuerySurfaceError to find out further details on the particular error.
2468 * VA_STATUS_ERROR_DECODING_ERROR should be passed in as "error_status",
2469 * upon the return, error_info will point to an array of _VASurfaceDecodeMBErrors structure,
2470 * which is allocated and filled by libVA with detailed information on the missing or error macroblocks.
2471 * The array is terminated if "status==-1" is detected.
2473 VAStatus vaQuerySurfaceError(
2475 VASurfaceID surface,
2476 VAStatus error_status,
2481 * Images and Subpictures
2482 * VAImage is used to either get the surface data to client memory, or
2483 * to copy image data in client memory to a surface.
2484 * Both images, subpictures and surfaces follow the same 2D coordinate system where origin
2485 * is at the upper left corner with positive X to the right and positive Y down
2487 #define VA_FOURCC(ch0, ch1, ch2, ch3) \
2488 ((unsigned long)(unsigned char) (ch0) | ((unsigned long)(unsigned char) (ch1) << 8) | \
2489 ((unsigned long)(unsigned char) (ch2) << 16) | ((unsigned long)(unsigned char) (ch3) << 24 ))
2492 * Pre-defined fourcc codes
2494 #define VA_FOURCC_NV12 0x3231564E
2495 #define VA_FOURCC_AI44 0x34344149
2496 #define VA_FOURCC_RGBA 0x41424752
2497 #define VA_FOURCC_RGBX 0x58424752
2498 #define VA_FOURCC_BGRA 0x41524742
2499 #define VA_FOURCC_BGRX 0x58524742
2500 #define VA_FOURCC_ARGB 0x42475241
2501 #define VA_FOURCC_XRGB 0x42475258
2502 #define VA_FOURCC_ABGR 0x52474241
2503 #define VA_FOURCC_XBGR 0x52474258
2504 #define VA_FOURCC_UYVY 0x59565955
2505 #define VA_FOURCC_YUY2 0x32595559
2506 #define VA_FOURCC_AYUV 0x56555941
2507 #define VA_FOURCC_NV11 0x3131564e
2508 #define VA_FOURCC_YV12 0x32315659
2509 #define VA_FOURCC_P208 0x38303250
2510 #define VA_FOURCC_IYUV 0x56555949
2511 #define VA_FOURCC_YV24 0x34325659
2512 #define VA_FOURCC_YV32 0x32335659
2513 #define VA_FOURCC_Y800 0x30303859
2514 #define VA_FOURCC_IMC3 0x33434D49
2515 #define VA_FOURCC_411P 0x50313134
2516 #define VA_FOURCC_422H 0x48323234
2517 #define VA_FOURCC_422V 0x56323234
2518 #define VA_FOURCC_444P 0x50343434
2519 #define VA_FOURCC_RGBP 0x50424752
2520 #define VA_FOURCC_BGRP 0x50524742
2521 #define VA_FOURCC_411R 0x52313134 /* rotated 411P */
2524 * 8-bit Y plane, followed by 8-bit 2x1 subsampled V and U planes
2526 #define VA_FOURCC_YV16 0x36315659
2528 * 10-bit and 16-bit Planar YUV 4:2:0.
2530 #define VA_FOURCC_P010 0x30313050
2531 #define VA_FOURCC_P016 0x36313050
2534 #define VA_LSB_FIRST 1
2535 #define VA_MSB_FIRST 2
2537 typedef struct _VAImageFormat
2539 unsigned int fourcc;
2540 unsigned int byte_order; /* VA_LSB_FIRST, VA_MSB_FIRST */
2541 unsigned int bits_per_pixel;
2542 /* for RGB formats */
2543 unsigned int depth; /* significant bits per pixel */
2544 unsigned int red_mask;
2545 unsigned int green_mask;
2546 unsigned int blue_mask;
2547 unsigned int alpha_mask;
2550 typedef VAGenericID VAImageID;
2552 typedef struct _VAImage
2554 VAImageID image_id; /* uniquely identify this image */
2555 VAImageFormat format;
2556 VABufferID buf; /* image data buffer */
2558 * Image data will be stored in a buffer of type VAImageBufferType to facilitate
2559 * data store on the server side for optimal performance. The buffer will be
2560 * created by the CreateImage function, and proper storage allocated based on the image
2561 * size and format. This buffer is managed by the library implementation, and
2562 * accessed by the client through the buffer Map/Unmap functions.
2564 unsigned short width;
2565 unsigned short height;
2566 unsigned int data_size;
2567 unsigned int num_planes; /* can not be greater than 3 */
2569 * An array indicating the scanline pitch in bytes for each plane.
2570 * Each plane may have a different pitch. Maximum 3 planes for planar formats
2572 unsigned int pitches[3];
2574 * An array indicating the byte offset from the beginning of the image data
2575 * to the start of each plane.
2577 unsigned int offsets[3];
2579 /* The following fields are only needed for paletted formats */
2580 int num_palette_entries; /* set to zero for non-palette images */
2582 * Each component is one byte and entry_bytes indicates the number of components in
2583 * each entry (eg. 3 for YUV palette entries). set to zero for non-palette images
2587 * An array of ascii characters describing the order of the components within the bytes.
2588 * Only entry_bytes characters of the string are used.
2590 char component_order[4];
2593 /** Get maximum number of image formats supported by the implementation */
2594 int vaMaxNumImageFormats (
2599 * Query supported image formats
2600 * The caller must provide a "format_list" array that can hold at
2601 * least vaMaxNumImageFormats() entries. The actual number of formats
2602 * returned in "format_list" is returned in "num_formats".
2604 VAStatus vaQueryImageFormats (
2606 VAImageFormat *format_list, /* out */
2607 int *num_formats /* out */
2611 * Create a VAImage structure
2612 * The width and height fields returned in the VAImage structure may get
2613 * enlarged for some YUV formats. Upon return from this function,
2614 * image->buf has been created and proper storage allocated by the library.
2615 * The client can access the image through the Map/Unmap calls.
2617 VAStatus vaCreateImage (
2619 VAImageFormat *format,
2622 VAImage *image /* out */
2626 * Should call DestroyImage before destroying the surface it is bound to
2628 VAStatus vaDestroyImage (
2633 VAStatus vaSetImagePalette (
2637 * pointer to an array holding the palette data. The size of the array is
2638 * num_palette_entries * entry_bytes in size. The order of the components
2639 * in the palette is described by the component_order in VAImage struct
2641 unsigned char *palette
2645 * Retrive surface data into a VAImage
2646 * Image must be in a format supported by the implementation
2648 VAStatus vaGetImage (
2650 VASurfaceID surface,
2651 int x, /* coordinates of the upper left source pixel */
2653 unsigned int width, /* width and height of the region */
2654 unsigned int height,
2659 * Copy data from a VAImage to a surface
2660 * Image must be in a format supported by the implementation
2661 * Returns a VA_STATUS_ERROR_SURFACE_BUSY if the surface
2662 * shouldn't be rendered into when this is called
2664 VAStatus vaPutImage (
2666 VASurfaceID surface,
2670 unsigned int src_width,
2671 unsigned int src_height,
2674 unsigned int dest_width,
2675 unsigned int dest_height
2679 * Derive an VAImage from an existing surface.
2680 * This interface will derive a VAImage and corresponding image buffer from
2681 * an existing VA Surface. The image buffer can then be mapped/unmapped for
2682 * direct CPU access. This operation is only possible on implementations with
2683 * direct rendering capabilities and internal surface formats that can be
2684 * represented with a VAImage. When the operation is not possible this interface
2685 * will return VA_STATUS_ERROR_OPERATION_FAILED. Clients should then fall back
2686 * to using vaCreateImage + vaPutImage to accomplish the same task in an
2689 * Implementations should only return success when the resulting image buffer
2690 * would be useable with vaMap/Unmap.
2692 * When directly accessing a surface special care must be taken to insure
2693 * proper synchronization with the graphics hardware. Clients should call
2694 * vaQuerySurfaceStatus to insure that a surface is not the target of concurrent
2695 * rendering or currently being displayed by an overlay.
2697 * Additionally nothing about the contents of a surface should be assumed
2698 * following a vaPutSurface. Implementations are free to modify the surface for
2699 * scaling or subpicture blending within a call to vaPutImage.
2701 * Calls to vaPutImage or vaGetImage using the same surface from which the image
2702 * has been derived will return VA_STATUS_ERROR_SURFACE_BUSY. vaPutImage or
2703 * vaGetImage with other surfaces is supported.
2705 * An image created with vaDeriveImage should be freed with vaDestroyImage. The
2706 * image and image buffer structures will be destroyed; however, the underlying
2707 * surface will remain unchanged until freed with vaDestroySurfaces.
2709 VAStatus vaDeriveImage (
2711 VASurfaceID surface,
2712 VAImage *image /* out */
2717 * Subpicture is a special type of image that can be blended
2718 * with a surface during vaPutSurface(). Subpicture can be used to render
2719 * DVD sub-titles or closed captioning text etc.
2722 typedef VAGenericID VASubpictureID;
2724 /** Get maximum number of subpicture formats supported by the implementation */
2725 int vaMaxNumSubpictureFormats (
2729 /** flags for subpictures */
2730 #define VA_SUBPICTURE_CHROMA_KEYING 0x0001
2731 #define VA_SUBPICTURE_GLOBAL_ALPHA 0x0002
2732 #define VA_SUBPICTURE_DESTINATION_IS_SCREEN_COORD 0x0004
2734 * Query supported subpicture formats
2735 * The caller must provide a "format_list" array that can hold at
2736 * least vaMaxNumSubpictureFormats() entries. The flags arrary holds the flag
2737 * for each format to indicate additional capabilities for that format. The actual
2738 * number of formats returned in "format_list" is returned in "num_formats".
2739 * flags: returned value to indicate addtional capabilities
2740 * VA_SUBPICTURE_CHROMA_KEYING - supports chroma-keying
2741 * VA_SUBPICTURE_GLOBAL_ALPHA - supports global alpha
2742 * VA_SUBPICTURE_DESTINATION_IS_SCREEN_COORD - supports unscaled screen relative subpictures for On Screen Display
2745 VAStatus vaQuerySubpictureFormats (
2747 VAImageFormat *format_list, /* out */
2748 unsigned int *flags, /* out */
2749 unsigned int *num_formats /* out */
2753 * Subpictures are created with an image associated.
2755 VAStatus vaCreateSubpicture (
2758 VASubpictureID *subpicture /* out */
2762 * Destroy the subpicture before destroying the image it is assocated to
2764 VAStatus vaDestroySubpicture (
2766 VASubpictureID subpicture
2770 * Bind an image to the subpicture. This image will now be associated with
2771 * the subpicture instead of the one at creation.
2773 VAStatus vaSetSubpictureImage (
2775 VASubpictureID subpicture,
2780 * If chromakey is enabled, then the area where the source value falls within
2781 * the chromakey [min, max] range is transparent
2782 * The chromakey component format is the following:
2783 * For RGB: [0:7] Red [8:15] Blue [16:23] Green
2784 * For YUV: [0:7] V [8:15] U [16:23] Y
2785 * The chromakey mask can be used to mask out certain components for chromakey
2788 VAStatus vaSetSubpictureChromakey (
2790 VASubpictureID subpicture,
2791 unsigned int chromakey_min,
2792 unsigned int chromakey_max,
2793 unsigned int chromakey_mask
2797 * Global alpha value is between 0 and 1. A value of 1 means fully opaque and
2798 * a value of 0 means fully transparent. If per-pixel alpha is also specified then
2799 * the overall alpha is per-pixel alpha multiplied by the global alpha
2801 VAStatus vaSetSubpictureGlobalAlpha (
2803 VASubpictureID subpicture,
2808 * vaAssociateSubpicture associates the subpicture with target_surfaces.
2809 * It defines the region mapping between the subpicture and the target
2810 * surfaces through source and destination rectangles (with the same width and height).
2811 * Both will be displayed at the next call to vaPutSurface. Additional
2812 * associations before the call to vaPutSurface simply overrides the association.
2814 VAStatus vaAssociateSubpicture (
2816 VASubpictureID subpicture,
2817 VASurfaceID *target_surfaces,
2819 short src_x, /* upper left offset in subpicture */
2821 unsigned short src_width,
2822 unsigned short src_height,
2823 short dest_x, /* upper left offset in surface */
2825 unsigned short dest_width,
2826 unsigned short dest_height,
2828 * whether to enable chroma-keying, global-alpha, or screen relative mode
2829 * see VA_SUBPICTURE_XXX values
2835 * vaDeassociateSubpicture removes the association of the subpicture with target_surfaces.
2837 VAStatus vaDeassociateSubpicture (
2839 VASubpictureID subpicture,
2840 VASurfaceID *target_surfaces,
2845 * Display attributes
2846 * Display attributes are used to control things such as contrast, hue, saturation,
2847 * brightness etc. in the rendering process. The application can query what
2848 * attributes are supported by the driver, and then set the appropriate attributes
2849 * before calling vaPutSurface()
2851 /* PowerVR IEP Lite attributes */
2854 VADISPLAYATTRIB_BLE_OFF = 0x00,
2855 VADISPLAYATTRIB_BLE_LOW,
2856 VADISPLAYATTRIB_BLE_MEDIUM,
2857 VADISPLAYATTRIB_BLE_HIGH,
2858 VADISPLAYATTRIB_BLE_NONE,
2859 } VADisplayAttribBLEMode;
2861 /** attribute value for VADisplayAttribRotation */
2862 #define VA_ROTATION_NONE 0x00000000
2863 #define VA_ROTATION_90 0x00000001
2864 #define VA_ROTATION_180 0x00000002
2865 #define VA_ROTATION_270 0x00000003
2867 /** attribute value for VADisplayAttribOutOfLoopDeblock */
2868 #define VA_OOL_DEBLOCKING_FALSE 0x00000000
2869 #define VA_OOL_DEBLOCKING_TRUE 0x00000001
2872 #define VA_RENDER_MODE_UNDEFINED 0
2873 #define VA_RENDER_MODE_LOCAL_OVERLAY 1
2874 #define VA_RENDER_MODE_LOCAL_GPU 2
2875 #define VA_RENDER_MODE_EXTERNAL_OVERLAY 4
2876 #define VA_RENDER_MODE_EXTERNAL_GPU 8
2878 /** Render device */
2879 #define VA_RENDER_DEVICE_UNDEFINED 0
2880 #define VA_RENDER_DEVICE_LOCAL 1
2881 #define VA_RENDER_DEVICE_EXTERNAL 2
2883 /** Currently defined display attribute types */
2886 VADisplayAttribBrightness = 0,
2887 VADisplayAttribContrast = 1,
2888 VADisplayAttribHue = 2,
2889 VADisplayAttribSaturation = 3,
2890 /* client can specifiy a background color for the target window
2891 * the new feature of video conference,
2892 * the uncovered area of the surface is filled by this color
2893 * also it will blend with the decoded video color
2895 VADisplayAttribBackgroundColor = 4,
2897 * this is a gettable only attribute. For some implementations that use the
2898 * hardware overlay, after PutSurface is called, the surface can not be
2899 * re-used until after the subsequent PutSurface call. If this is the case
2900 * then the value for this attribute will be set to 1 so that the client
2901 * will not attempt to re-use the surface right after returning from a call
2904 * Don't use it, use flag VASurfaceDisplaying of vaQuerySurfaceStatus since
2905 * driver may use overlay or GPU alternatively
2907 VADisplayAttribDirectSurface = 5,
2908 VADisplayAttribRotation = 6,
2909 VADisplayAttribOutofLoopDeblock = 7,
2911 /* PowerVR IEP Lite specific attributes */
2912 VADisplayAttribBLEBlackMode = 8,
2913 VADisplayAttribBLEWhiteMode = 9,
2914 VADisplayAttribBlueStretch = 10,
2915 VADisplayAttribSkinColorCorrection = 11,
2917 * For type VADisplayAttribCSCMatrix, "value" field is a pointer to the color
2918 * conversion matrix. Each element in the matrix is float-point
2920 VADisplayAttribCSCMatrix = 12,
2921 /* specify the constant color used to blend with video surface
2922 * Cd = Cv*Cc*Ac + Cb *(1 - Ac) C means the constant RGB
2923 * d: the final color to overwrite into the frame buffer
2924 * v: decoded video after color conversion,
2925 * c: video color specified by VADisplayAttribBlendColor
2926 * b: background color of the drawable
2928 VADisplayAttribBlendColor = 13,
2930 * Indicate driver to skip painting color key or not.
2931 * only applicable if the render is overlay
2933 VADisplayAttribOverlayAutoPaintColorKey = 14,
2935 * customized overlay color key, the format is RGB888
2936 * [23:16] = Red, [15:08] = Green, [07:00] = Blue.
2938 VADisplayAttribOverlayColorKey = 15,
2940 * The hint for the implementation of vaPutSurface
2941 * normally, the driver could use an overlay or GPU to render the surface on the screen
2942 * this flag provides APP the flexibity to switch the render dynamically
2944 VADisplayAttribRenderMode = 16,
2946 * specify if vaPutSurface needs to render into specified monitors
2947 * one example is that one external monitor (e.g. HDMI) is enabled,
2948 * but the window manager is not aware of it, and there is no associated drawable
2950 VADisplayAttribRenderDevice = 17,
2952 * specify vaPutSurface render area if there is no drawable on the monitor
2954 VADisplayAttribRenderRect = 18,
2955 } VADisplayAttribType;
2957 /* flags for VADisplayAttribute */
2958 #define VA_DISPLAY_ATTRIB_NOT_SUPPORTED 0x0000
2959 #define VA_DISPLAY_ATTRIB_GETTABLE 0x0001
2960 #define VA_DISPLAY_ATTRIB_SETTABLE 0x0002
2962 typedef struct _VADisplayAttribute
2964 VADisplayAttribType type;
2967 int value; /* used by the set/get attribute functions */
2968 /* flags can be VA_DISPLAY_ATTRIB_GETTABLE or VA_DISPLAY_ATTRIB_SETTABLE or OR'd together */
2970 } VADisplayAttribute;
2972 /** Get maximum number of display attributs supported by the implementation */
2973 int vaMaxNumDisplayAttributes (
2978 * Query display attributes
2979 * The caller must provide a "attr_list" array that can hold at
2980 * least vaMaxNumDisplayAttributes() entries. The actual number of attributes
2981 * returned in "attr_list" is returned in "num_attributes".
2983 VAStatus vaQueryDisplayAttributes (
2985 VADisplayAttribute *attr_list, /* out */
2986 int *num_attributes /* out */
2990 * Get display attributes
2991 * This function returns the current attribute values in "attr_list".
2992 * Only attributes returned with VA_DISPLAY_ATTRIB_GETTABLE set in the "flags" field
2993 * from vaQueryDisplayAttributes() can have their values retrieved.
2995 VAStatus vaGetDisplayAttributes (
2997 VADisplayAttribute *attr_list, /* in/out */
3002 * Set display attributes
3003 * Only attributes returned with VA_DISPLAY_ATTRIB_SETTABLE set in the "flags" field
3004 * from vaQueryDisplayAttributes() can be set. If the attribute is not settable or
3005 * the value is out of range, the function returns VA_STATUS_ERROR_ATTR_NOT_SUPPORTED
3007 VAStatus vaSetDisplayAttributes (
3009 VADisplayAttribute *attr_list,
3013 /****************************
3014 * HEVC data structures
3015 ****************************/
3017 * \brief Description of picture properties of those in DPB surfaces.
3019 * If only progressive scan is supported, each surface contains one whole
3021 * Otherwise, each surface contains two fields of whole picture.
3022 * In this case, two entries of ReferenceFrames[] may share same picture_id
3025 typedef struct _VAPictureHEVC
3027 /** \brief reconstructed picture buffer surface index
3028 * invalid when taking value VA_INVALID_SURFACE.
3030 VASurfaceID picture_id;
3031 /** \brief picture order count.
3032 * in HEVC, POCs for top and bottom fields of same picture should
3033 * take different values.
3035 int32_t pic_order_cnt;
3036 /* described below */
3040 /* flags in VAPictureHEVC could be OR of the following */
3041 #define VA_PICTURE_HEVC_INVALID 0x00000001
3042 /** \brief indication of interlace scan picture.
3043 * should take same value for all the pictures in sequence.
3045 #define VA_PICTURE_HEVC_FIELD_PIC 0x00000002
3046 /** \brief polarity of the field picture.
3047 * top field takes even lines of buffer surface.
3048 * bottom field takes odd lines of buffer surface.
3050 #define VA_PICTURE_HEVC_BOTTOM_FIELD 0x00000004
3051 /** \brief Long term reference picture */
3052 #define VA_PICTURE_HEVC_LONG_TERM_REFERENCE 0x00000008
3054 * VA_PICTURE_HEVC_RPS_ST_CURR_BEFORE, VA_PICTURE_HEVC_RPS_ST_CURR_AFTER
3055 * and VA_PICTURE_HEVC_RPS_LT_CURR of any picture in ReferenceFrames[] should
3056 * be exclusive. No more than one of them can be set for any picture.
3057 * Sum of NumPocStCurrBefore, NumPocStCurrAfter and NumPocLtCurr
3058 * equals NumPocTotalCurr, which should be equal to or smaller than 8.
3059 * Application should provide valid values for both short format and long format.
3060 * The pictures in DPB with any of these three flags turned on are referred by
3061 * the current picture.
3063 /** \brief RefPicSetStCurrBefore of HEVC spec variable
3064 * Number of ReferenceFrames[] entries with this bit set equals
3065 * NumPocStCurrBefore.
3067 #define VA_PICTURE_HEVC_RPS_ST_CURR_BEFORE 0x00000010
3068 /** \brief RefPicSetStCurrAfter of HEVC spec variable
3069 * Number of ReferenceFrames[] entries with this bit set equals
3070 * NumPocStCurrAfter.
3072 #define VA_PICTURE_HEVC_RPS_ST_CURR_AFTER 0x00000020
3073 /** \brief RefPicSetLtCurr of HEVC spec variable
3074 * Number of ReferenceFrames[] entries with this bit set equals
3077 #define VA_PICTURE_HEVC_RPS_LT_CURR 0x00000040
3079 #include <va/va_dec_hevc.h>
3080 #include <va/va_dec_jpeg.h>
3081 #include <va/va_dec_vp8.h>
3082 #include <va/va_dec_vp9.h>
3083 #include <va/va_enc_hevc.h>
3084 #include <va/va_enc_h264.h>
3085 #include <va/va_enc_jpeg.h>
3086 #include <va/va_enc_mpeg2.h>
3087 #include <va/va_enc_vp8.h>
3088 #include <va/va_enc_vp9.h>
3089 #include <va/va_vpp.h>