doc/encode: link modules from the main page.
[platform/upstream/libva.git] / va / va.h
1 /*
2  * Copyright (c) 2007-2009 Intel Corporation. All Rights Reserved.
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the
6  * "Software"), to deal in the Software without restriction, including
7  * without limitation the rights to use, copy, modify, merge, publish,
8  * distribute, sub license, and/or sell copies of the Software, and to
9  * permit persons to whom the Software is furnished to do so, subject to
10  * the following conditions:
11  * 
12  * The above copyright notice and this permission notice (including the
13  * next paragraph) shall be included in all copies or substantial portions
14  * of the Software.
15  * 
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
19  * IN NO EVENT SHALL INTEL AND/OR ITS SUPPLIERS BE LIABLE FOR
20  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23  */
24 /*
25  * Video Acceleration (VA) API Specification
26  *
27  * Rev. 0.30
28  * <jonathan.bian@intel.com>
29  *
30  * Revision History:
31  * rev 0.10 (12/10/2006 Jonathan Bian) - Initial draft
32  * rev 0.11 (12/15/2006 Jonathan Bian) - Fixed some errors
33  * rev 0.12 (02/05/2007 Jonathan Bian) - Added VC-1 data structures for slice level decode
34  * rev 0.13 (02/28/2007 Jonathan Bian) - Added GetDisplay()
35  * rev 0.14 (04/13/2007 Jonathan Bian) - Fixed MPEG-2 PictureParameter structure, cleaned up a few funcs.
36  * rev 0.15 (04/20/2007 Jonathan Bian) - Overhauled buffer management
37  * rev 0.16 (05/02/2007 Jonathan Bian) - Added error codes and fixed some issues with configuration
38  * rev 0.17 (05/07/2007 Jonathan Bian) - Added H.264/AVC data structures for slice level decode.
39  * rev 0.18 (05/14/2007 Jonathan Bian) - Added data structures for MPEG-4 slice level decode 
40  *                                       and MPEG-2 motion compensation.
41  * rev 0.19 (08/06/2007 Jonathan Bian) - Removed extra type for bitplane data.
42  * rev 0.20 (08/08/2007 Jonathan Bian) - Added missing fields to VC-1 PictureParameter structure.
43  * rev 0.21 (08/20/2007 Jonathan Bian) - Added image and subpicture support.
44  * rev 0.22 (08/27/2007 Jonathan Bian) - Added support for chroma-keying and global alpha.
45  * rev 0.23 (09/11/2007 Jonathan Bian) - Fixed some issues with images and subpictures.
46  * rev 0.24 (09/18/2007 Jonathan Bian) - Added display attributes.
47  * rev 0.25 (10/18/2007 Jonathan Bian) - Changed to use IDs only for some types.
48  * rev 0.26 (11/07/2007 Waldo Bastian) - Change vaCreateBuffer semantics
49  * rev 0.27 (11/19/2007 Matt Sottek)   - Added DeriveImage
50  * rev 0.28 (12/06/2007 Jonathan Bian) - Added new versions of PutImage and AssociateSubpicture 
51  *                                       to enable scaling
52  * rev 0.29 (02/07/2008 Jonathan Bian) - VC1 parameter fixes,
53  *                                       added VA_STATUS_ERROR_RESOLUTION_NOT_SUPPORTED
54  * rev 0.30 (03/01/2009 Jonathan Bian) - Added encoding support for H.264 BP and MPEG-4 SP and fixes
55  *                                       for ISO C conformance.
56  * rev 0.31 (09/02/2009 Gwenole Beauchesne) - VC-1/H264 fields change for VDPAU and XvBA backend
57  *                                       Application needs to relink with the new library.
58  *
59  * rev 0.31.1 (03/29/2009)              - Data structure for JPEG encode
60  * rev 0.31.2 (01/13/2011 Anthony Pabon)- Added a flag to indicate Subpicture coordinates are screen
61  *                                        screen relative rather than source video relative.
62  * rev 0.32.0 (01/13/2011 Xiang Haihao) - Add profile into VAPictureParameterBufferVC1
63  *                                        update VAAPI to 0.32.0
64  *
65  * Acknowledgements:
66  *  Some concepts borrowed from XvMC and XvImage.
67  *  Waldo Bastian (Intel), Matt Sottek (Intel),  Austin Yuan (Intel), and Gwenole Beauchesne (SDS)
68  *  contributed to various aspects of the API.
69  */
70
71 /**
72  * \file va.h
73  * \brief The Core API
74  *
75  * This file contains the \ref api_core "Core API".
76  */
77
78 #ifndef _VA_H_
79 #define _VA_H_
80
81 #include <va/va_version.h>
82
83 #ifdef __cplusplus
84 extern "C" {
85 #endif
86
87 /**
88  * \mainpage Video Acceleration (VA) API
89  *
90  * \section intro Introduction
91  *
92  * The main motivation for VA-API (Video Acceleration API) is to
93  * enable hardware accelerated video decode and encode at various
94  * entry-points (VLD, IDCT, Motion Compensation etc.) for the
95  * prevailing coding standards today (MPEG-2, MPEG-4 ASP/H.263, MPEG-4
96  * AVC/H.264, VC-1/VMW3, and JPEG).
97  *
98  * VA-API is split into several modules:
99  * - \ref api_core
100  * - \ref api_enc_core
101  * - \ref api_enc_h264
102  */
103
104 /**
105  * \defgroup api_core Core API
106  *
107  * @{
108  */
109
110 /* 
111 Overview 
112
113 The VA API is intended to provide an interface between a video decode/encode/display
114 application (client) and a hardware accelerator (server), to off-load 
115 video decode/encode/display operations from the host to the hardware accelerator at various 
116 entry-points.
117
118 The basic operation steps are:
119
120 - Negotiate a mutually acceptable configuration with the server to lock
121   down profile, entrypoints, and other attributes that will not change on 
122   a frame-by-frame basis.
123 - Create a decode context which represents a "virtualized" hardware decode 
124   device
125 - Get and fill decode buffers with picture level, slice level and macroblock 
126   level data (depending on entrypoints)
127 - Pass the decode buffers to the server to decode the current frame
128
129 Initialization & Configuration Management 
130
131 - Find out supported profiles
132 - Find out entrypoints for a given profile
133 - Find out configuration attributes for a given profile/entrypoint pair
134 - Create a configuration for use by the decoder
135
136 */
137
138 typedef void* VADisplay;        /* window system dependent */
139
140 typedef int VAStatus;   /* Return status type from functions */
141 /* Values for the return status */
142 #define VA_STATUS_SUCCESS                       0x00000000
143 #define VA_STATUS_ERROR_OPERATION_FAILED        0x00000001
144 #define VA_STATUS_ERROR_ALLOCATION_FAILED       0x00000002
145 #define VA_STATUS_ERROR_INVALID_DISPLAY         0x00000003
146 #define VA_STATUS_ERROR_INVALID_CONFIG          0x00000004
147 #define VA_STATUS_ERROR_INVALID_CONTEXT         0x00000005
148 #define VA_STATUS_ERROR_INVALID_SURFACE         0x00000006
149 #define VA_STATUS_ERROR_INVALID_BUFFER          0x00000007
150 #define VA_STATUS_ERROR_INVALID_IMAGE           0x00000008
151 #define VA_STATUS_ERROR_INVALID_SUBPICTURE      0x00000009
152 #define VA_STATUS_ERROR_ATTR_NOT_SUPPORTED      0x0000000a
153 #define VA_STATUS_ERROR_MAX_NUM_EXCEEDED        0x0000000b
154 #define VA_STATUS_ERROR_UNSUPPORTED_PROFILE     0x0000000c
155 #define VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT  0x0000000d
156 #define VA_STATUS_ERROR_UNSUPPORTED_RT_FORMAT   0x0000000e
157 #define VA_STATUS_ERROR_UNSUPPORTED_BUFFERTYPE  0x0000000f
158 #define VA_STATUS_ERROR_SURFACE_BUSY            0x00000010
159 #define VA_STATUS_ERROR_FLAG_NOT_SUPPORTED      0x00000011
160 #define VA_STATUS_ERROR_INVALID_PARAMETER       0x00000012
161 #define VA_STATUS_ERROR_RESOLUTION_NOT_SUPPORTED 0x00000013
162 #define VA_STATUS_ERROR_UNIMPLEMENTED           0x00000014
163 #define VA_STATUS_ERROR_SURFACE_IN_DISPLAYING   0x00000015
164 #define VA_STATUS_ERROR_INVALID_IMAGE_FORMAT    0x00000016
165 #define VA_STATUS_ERROR_DECODING_ERROR          0x00000017
166 #define VA_STATUS_ERROR_ENCODING_ERROR          0x00000018
167 /**
168  * \brief An invalid/unsupported value was supplied.
169  *
170  * This is a catch-all error code for invalid or unsupported values.
171  * e.g. value exceeding the valid range, invalid type in the context
172  * of generic attribute values.
173  */
174 #define VA_STATUS_ERROR_INVALID_VALUE           0x00000019
175 /** \brief An unsupported filter was supplied. */
176 #define VA_STATUS_ERROR_UNSUPPORTED_FILTER      0x00000020
177 /** \brief An invalid filter chain was supplied. */
178 #define VA_STATUS_ERROR_INVALID_FILTER_CHAIN    0x00000021
179 /** \brief Indicate HW busy (e.g. run multiple encoding simultaneously). */
180 #define VA_STATUS_ERROR_HW_BUSY                 0x00000022
181 #define VA_STATUS_ERROR_UNKNOWN                 0xFFFFFFFF
182
183 /* De-interlacing flags for vaPutSurface() */
184 #define VA_FRAME_PICTURE        0x00000000 
185 #define VA_TOP_FIELD            0x00000001
186 #define VA_BOTTOM_FIELD         0x00000002
187
188 /*
189  * Enabled the positioning/cropping/blending feature:
190  * 1, specify the video playback position in the isurface
191  * 2, specify the cropping info for video playback
192  * 3, encoded video will blend with background color
193  */
194 #define VA_ENABLE_BLEND         0x00000004 /* video area blend with the constant color */ 
195     
196 /*
197  * Clears the drawable with background color.
198  * for hardware overlay based implementation this flag
199  * can be used to turn off the overlay
200  */
201 #define VA_CLEAR_DRAWABLE       0x00000008
202
203 /* Color space conversion flags for vaPutSurface() */
204 #define VA_SRC_BT601            0x00000010
205 #define VA_SRC_BT709            0x00000020
206 #define VA_SRC_SMPTE_240        0x00000040
207
208 /* Scaling flags for vaPutSurface() */
209 #define VA_FILTER_SCALING_DEFAULT       0x00000000
210 #define VA_FILTER_SCALING_FAST          0x00000100
211 #define VA_FILTER_SCALING_HQ            0x00000200
212 #define VA_FILTER_SCALING_NL_ANAMORPHIC 0x00000300
213 #define VA_FILTER_SCALING_MASK          0x00000f00
214
215 /*
216  * Returns a short english description of error_status
217  */
218 const char *vaErrorStr(VAStatus error_status);
219
220 /*
221  * Initialization:
222  * A display must be obtained by calling vaGetDisplay() before calling
223  * vaInitialize() and other functions. This connects the API to the 
224  * native window system.
225  * For X Windows, native_dpy would be from XOpenDisplay()
226  */
227 typedef void* VANativeDisplay;  /* window system dependent */
228
229 int vaDisplayIsValid(VADisplay dpy);
230     
231 /*
232  * Initialize the library 
233  */
234 VAStatus vaInitialize (
235     VADisplay dpy,
236     int *major_version,  /* out */
237     int *minor_version   /* out */
238 );
239
240 /*
241  * After this call, all library internal resources will be cleaned up
242  */ 
243 VAStatus vaTerminate (
244     VADisplay dpy
245 );
246
247 /*
248  * vaQueryVendorString returns a pointer to a zero-terminated string
249  * describing some aspects of the VA implemenation on a specific    
250  * hardware accelerator. The format of the returned string is vendor
251  * specific and at the discretion of the implementer.
252  * e.g. for the Intel GMA500 implementation, an example would be:
253  * "Intel GMA500 - 2.0.0.32L.0005"
254  */
255 const char *vaQueryVendorString (
256     VADisplay dpy
257 );
258
259 typedef int (*VAPrivFunc)();
260
261 /*
262  * Return a function pointer given a function name in the library.
263  * This allows private interfaces into the library
264  */ 
265 VAPrivFunc vaGetLibFunc (
266     VADisplay dpy,
267     const char *func
268 );
269
270 /* Currently defined profiles */
271 typedef enum
272 {
273     /** \brief Profile ID used for video processing. */
274     VAProfileNone                       = -1,
275     VAProfileMPEG2Simple                = 0,
276     VAProfileMPEG2Main                  = 1,
277     VAProfileMPEG4Simple                = 2,
278     VAProfileMPEG4AdvancedSimple        = 3,
279     VAProfileMPEG4Main                  = 4,
280     VAProfileH264Baseline               = 5,
281     VAProfileH264Main                   = 6,
282     VAProfileH264High                   = 7,
283     VAProfileVC1Simple                  = 8,
284     VAProfileVC1Main                    = 9,
285     VAProfileVC1Advanced                = 10,
286     VAProfileH263Baseline               = 11,
287     VAProfileJPEGBaseline               = 12,
288     VAProfileH264ConstrainedBaseline = 13
289 } VAProfile;
290
291 /* 
292  *  Currently defined entrypoints 
293  */
294 typedef enum
295 {
296     VAEntrypointVLD             = 1,
297     VAEntrypointIZZ             = 2,
298     VAEntrypointIDCT            = 3,
299     VAEntrypointMoComp          = 4,
300     VAEntrypointDeblocking      = 5,
301     VAEntrypointEncSlice        = 6,    /* slice level encode */
302     VAEntrypointEncPicture      = 7,    /* pictuer encode, JPEG, etc */
303     VAEntrypointVideoProc       = 10,   /**< Video pre/post-processing. */
304     VAEntrypointMax
305 } VAEntrypoint;
306
307 /* Currently defined configuration attribute types */
308 typedef enum
309 {
310     VAConfigAttribRTFormat              = 0,
311     VAConfigAttribSpatialResidual       = 1,
312     VAConfigAttribSpatialClipping       = 2,
313     VAConfigAttribIntraResidual         = 3,
314     VAConfigAttribEncryption            = 4,
315     VAConfigAttribRateControl           = 5,
316
317     /** @name Attributes for encoding */
318     /**@{*/
319     /**
320      * \brief Packed headers mode. Read/write.
321      *
322      * This attribute determines what packed headers the driver supports,
323      * through vaGetConfigAttributes(); and what packed headers the user
324      * will be providing to the driver, through vaCreateConfig(), if the
325      * driver supports those.
326      *
327      * See \c VA_ENC_PACKED_HEADER_xxx for the list of packed headers.
328      */
329     VAConfigAttribEncPackedHeaders      = 10,
330     /**
331      * \brief Interlaced mode. Read/write.
332      *
333      * This attribute determines what kind of interlaced encoding mode
334      * the driver supports.
335      *
336      * See \c VA_ENC_INTERLACED_xxx for the list of interlaced modes.
337      */
338     VAConfigAttribEncInterlaced         = 11,
339     /**
340      * \brief Maximum number of reference frames. Read-only.
341      *
342      * This attribute determines the maximum number of reference
343      * frames supported for encoding.
344      *
345      * Note: for H.264 encoding, the value represents the maximum number
346      * of reference frames for both the reference picture list 0 (bottom
347      * 16 bits) and the reference picture list 1 (top 16 bits).
348      */
349     VAConfigAttribEncMaxRefFrames       = 13,
350     /**
351      * \brief Maximum number of slices per frame. Read-only.
352      *
353      * This attribute determines the maximum number of slices the
354      * driver can support to encode a single frame.
355      */
356     VAConfigAttribEncMaxSlices          = 14,
357     /**
358      * \brief Slice structure. Read-only.
359      *
360      * This attribute determines slice structures supported by the
361      * driver for encoding. This attribute is a hint to the user so
362      * that he can choose a suitable surface size and how to arrange
363      * the encoding process of multiple slices per frame.
364      *
365      * More specifically, for H.264 encoding, this attribute
366      * determines the range of accepted values to
367      * VAEncSliceParameterBufferH264::macroblock_address and
368      * VAEncSliceParameterBufferH264::num_macroblocks.
369      *
370      * See \c VA_ENC_SLICE_STRUCTURE_xxx for the supported slice
371      * structure types.
372      */
373     VAConfigAttribEncSliceStructure     = 15,
374     /**
375      * \brief Macroblock information. Read-only.
376      *
377      * This attribute determines whether the driver supports extra
378      * encoding information per-macroblock. e.g. QP.
379      *
380      * More specifically, for H.264 encoding, if the driver returns a non-zero
381      * value for this attribute, this means the application can create
382      * additional #VAEncMacroblockParameterBufferH264 buffers referenced
383      * through VAEncSliceParameterBufferH264::macroblock_info.
384      */
385     VAConfigAttribEncMacroblockInfo     = 16,
386     /**@}*/
387     VAConfigAttribTypeMax
388 } VAConfigAttribType;
389
390 /*
391  * Configuration attributes
392  * If there is more than one value for an attribute, a default
393  * value will be assigned to the attribute if the client does not
394  * specify the attribute when creating a configuration
395  */
396 typedef struct _VAConfigAttrib {
397     VAConfigAttribType type;
398     unsigned int value; /* OR'd flags (bits) for this attribute */
399 } VAConfigAttrib;
400
401 /* attribute value for VAConfigAttribRTFormat */
402 #define VA_RT_FORMAT_YUV420     0x00000001      
403 #define VA_RT_FORMAT_YUV422     0x00000002
404 #define VA_RT_FORMAT_YUV444     0x00000004
405 #define VA_RT_FORMAT_PROTECTED  0x80000000
406
407 /** @name Attribute values for VAConfigAttribRateControl */
408 /**@{*/
409 /** \brief Driver does not support any form of rate control. */
410 #define VA_RC_NONE                      0x00000001
411 /** \brief Constant bitrate. */
412 #define VA_RC_CBR                       0x00000002
413 /** \brief Variable bitrate. */
414 #define VA_RC_VBR                       0x00000004
415 /** \brief Video conference mode. */
416 #define VA_RC_VCM                       0x00000008
417 /** \brief Constant QP. */
418 #define VA_RC_CQP                       0x00000010
419 /** \brief Variable bitrate with peak rate higher than average bitrate. */
420 #define VA_RC_VBR_CONSTRAINED           0x00000020
421 /**@}*/
422
423 /** @name Attribute values for VAConfigAttribEncPackedHeaders */
424 /**@{*/
425 /** \brief Driver does not support any packed headers mode. */
426 #define VA_ENC_PACKED_HEADER_NONE       0x00000000
427 /** \brief Driver supports packed sequence headers. e.g. SPS for H.264. */
428 #define VA_ENC_PACKED_HEADER_SEQUENCE   0x00000001
429 /** \brief Driver supports packed picture headers. e.g. PPS for H.264. */
430 #define VA_ENC_PACKED_HEADER_PICTURE    0x00000002
431 /** \brief Driver supports packed slice headers. e.g. \c slice_header() for H.264. */
432 #define VA_ENC_PACKED_HEADER_SLICE      0x00000004
433 /** \brief Driver supports misc packed headers. e.g. SEI for H.264. */
434 #define VA_ENC_PACKED_HEADER_MISC       0x00000008
435 /** \brief Driver supports raw packed header, see VAEncPackedHeaderRawData */
436 #define VA_ENC_PACKED_HEADER_RAW_DATA   0x0000000C
437 /**@}*/
438
439 /** @name Attribute values for VAConfigAttribEncInterlaced */
440 /**@{*/
441 /** \brief Driver does not support interlaced coding. */
442 #define VA_ENC_INTERLACED_NONE          0x00000000
443 /** \brief Driver supports interlaced frame coding. */
444 #define VA_ENC_INTERLACED_FRAME         0x00000001
445 /** \brief Driver supports interlaced field coding. */
446 #define VA_ENC_INTERLACED_FIELD         0x00000002
447 /** \brief Driver supports macroblock adaptive frame field coding. */
448 #define VA_ENC_INTERLACED_MBAFF         0x00000004
449 /** \brief Driver supports picture adaptive frame field coding. */
450 #define VA_ENC_INTERLACED_PAFF          0x00000008
451 /**@}*/
452
453 /** @name Attribute values for VAConfigAttribEncSliceStructure */
454 /**@{*/
455 /** \brief Driver supports an arbitrary number of rows per slice. */
456 #define VA_ENC_SLICE_STRUCTURE_ARBITRARY_ROWS           0x00000000
457 /** \brief Driver supports a power-of-two number of rows per slice. */
458 #define VA_ENC_SLICE_STRUCTURE_POWER_OF_TWO_ROWS        0x00000001
459 /** \brief Driver supports an arbitrary number of rows per slice. */
460 #define VA_ENC_SLICE_STRUCTURE_ARBITRARY_MACROBLOCKS    0x00000002
461 /**@}*/
462
463 /*
464  * if an attribute is not applicable for a given
465  * profile/entrypoint pair, then set the value to the following 
466  */
467 #define VA_ATTRIB_NOT_SUPPORTED 0x80000000
468
469 /* Get maximum number of profiles supported by the implementation */
470 int vaMaxNumProfiles (
471     VADisplay dpy
472 );
473
474 /* Get maximum number of entrypoints supported by the implementation */
475 int vaMaxNumEntrypoints (
476     VADisplay dpy
477 );
478
479 /* Get maximum number of attributs supported by the implementation */
480 int vaMaxNumConfigAttributes (
481     VADisplay dpy
482 );
483
484 /* 
485  * Query supported profiles 
486  * The caller must provide a "profile_list" array that can hold at
487  * least vaMaxNumProfile() entries. The actual number of profiles
488  * returned in "profile_list" is returned in "num_profile".
489  */
490 VAStatus vaQueryConfigProfiles (
491     VADisplay dpy,
492     VAProfile *profile_list,    /* out */
493     int *num_profiles           /* out */
494 );
495
496 /* 
497  * Query supported entrypoints for a given profile 
498  * The caller must provide an "entrypoint_list" array that can hold at
499  * least vaMaxNumEntrypoints() entries. The actual number of entrypoints 
500  * returned in "entrypoint_list" is returned in "num_entrypoints".
501  */
502 VAStatus vaQueryConfigEntrypoints (
503     VADisplay dpy,
504     VAProfile profile,
505     VAEntrypoint *entrypoint_list,      /* out */
506     int *num_entrypoints                /* out */
507 );
508
509 /* 
510  * Get attributes for a given profile/entrypoint pair 
511  * The caller must provide an "attrib_list" with all attributes to be 
512  * retrieved.  Upon return, the attributes in "attrib_list" have been 
513  * updated with their value.  Unknown attributes or attributes that are 
514  * not supported for the given profile/entrypoint pair will have their 
515  * value set to VA_ATTRIB_NOT_SUPPORTED
516  */
517 VAStatus vaGetConfigAttributes (
518     VADisplay dpy,
519     VAProfile profile,
520     VAEntrypoint entrypoint,
521     VAConfigAttrib *attrib_list, /* in/out */
522     int num_attribs
523 );
524
525 /* Generic ID type, can be re-typed for specific implementation */
526 typedef unsigned int VAGenericID;
527
528 typedef VAGenericID VAConfigID;
529
530 /* 
531  * Create a configuration for the decode pipeline 
532  * it passes in the attribute list that specifies the attributes it cares 
533  * about, with the rest taking default values.  
534  */
535 VAStatus vaCreateConfig (
536     VADisplay dpy,
537     VAProfile profile, 
538     VAEntrypoint entrypoint, 
539     VAConfigAttrib *attrib_list,
540     int num_attribs,
541     VAConfigID *config_id /* out */
542 );
543
544 /* 
545  * Free resources associdated with a given config 
546  */
547 VAStatus vaDestroyConfig (
548     VADisplay dpy,
549     VAConfigID config_id
550 );
551
552 /* 
553  * Query all attributes for a given configuration 
554  * The profile of the configuration is returned in "profile"
555  * The entrypoint of the configuration is returned in "entrypoint"
556  * The caller must provide an "attrib_list" array that can hold at least 
557  * vaMaxNumConfigAttributes() entries. The actual number of attributes 
558  * returned in "attrib_list" is returned in "num_attribs"
559  */
560 VAStatus vaQueryConfigAttributes (
561     VADisplay dpy,
562     VAConfigID config_id, 
563     VAProfile *profile,         /* out */
564     VAEntrypoint *entrypoint,   /* out */
565     VAConfigAttrib *attrib_list,/* out */
566     int *num_attribs            /* out */
567 );
568
569
570 /*
571  * Contexts and Surfaces
572  *
573  * Context represents a "virtual" video decode pipeline. Surfaces are render 
574  * targets for a given context. The data in the surfaces are not accessible  
575  * to the client and the internal data format of the surface is implementatin 
576  * specific. 
577  *
578  * Surfaces will be bound to a context when the context is created. Once
579  * a surface is bound to a given context, it can not be used to create  
580  * another context. The association is removed when the context is destroyed
581  * 
582  * Both contexts and surfaces are identified by unique IDs and its
583  * implementation specific internals are kept opaque to the clients
584  */
585
586 typedef VAGenericID VAContextID;
587
588 typedef VAGenericID VASurfaceID;
589
590 #define VA_INVALID_ID           0xffffffff
591 #define VA_INVALID_SURFACE      VA_INVALID_ID
592
593 /** \brief Generic value types. */
594 typedef enum  {
595     VAGenericValueTypeInteger = 1,      /**< 32-bit signed integer. */
596     VAGenericValueTypeFloat,            /**< 32-bit floating-point value. */
597     VAGenericValueTypePointer,          /**< Generic pointer type */
598     VAGenericValueTypeFunc              /**< Pointer to function */
599 } VAGenericValueType;
600
601 /** \brief Generic function type. */
602 typedef void (*VAGenericFunc)(void);
603
604 /** \brief Generic value. */
605 typedef struct _VAGenericValue {
606     /** \brief Value type. See #VAGenericValueType. */
607     VAGenericValueType  type;
608     /** \brief Value holder. */
609     union {
610         /** \brief 32-bit signed integer. */
611         int             i;
612         /** \brief 32-bit float. */
613         float           f;
614         /** \brief Generic pointer. */
615         void           *p;
616         /** \brief Pointer to function. */
617         VAGenericFunc   fn;
618     }                   value;
619 } VAGenericValue;
620
621 /* 
622  * vaCreateSurfaces - Create an array of surfaces used for decode and display  
623  *  dpy: display
624  *  width: surface width
625  *  height: surface height
626  *  format: VA_RT_FORMAT_YUV420, VA_RT_FORMAT_YUV422 or VA_RT_FORMAT_YUV444
627  *  num_surfaces: number of surfaces to be created
628  *  surfaces: array of surfaces created upon return
629  */
630 VAStatus vaCreateSurfaces (
631     VADisplay dpy,
632     int width,
633     int height,
634     int format,
635     int num_surfaces,
636     VASurfaceID *surfaces       /* out */
637 );
638
639     
640 /*
641  * vaDestroySurfaces - Destroy resources associated with surfaces. 
642  *  Surfaces can only be destroyed after the context associated has been 
643  *  destroyed.  
644  *  dpy: display
645  *  surfaces: array of surfaces to destroy
646  *  num_surfaces: number of surfaces in the array to be destroyed.
647  */
648 VAStatus vaDestroySurfaces (
649     VADisplay dpy,
650     VASurfaceID *surfaces,
651     int num_surfaces
652 );
653
654 #define VA_PROGRESSIVE 0x1
655 /*
656  * vaCreateContext - Create a context
657  *  dpy: display
658  *  config_id: configuration for the context
659  *  picture_width: coded picture width
660  *  picture_height: coded picture height
661  *  flag: any combination of the following:
662  *    VA_PROGRESSIVE (only progressive frame pictures in the sequence when set)
663  *  render_targets: render targets (surfaces) tied to the context
664  *  num_render_targets: number of render targets in the above array
665  *  context: created context id upon return
666  */
667 VAStatus vaCreateContext (
668     VADisplay dpy,
669     VAConfigID config_id,
670     int picture_width,
671     int picture_height,
672     int flag,
673     VASurfaceID *render_targets,
674     int num_render_targets,
675     VAContextID *context                /* out */
676 );
677
678 /*
679  * vaDestroyContext - Destroy a context 
680  *  dpy: display
681  *  context: context to be destroyed
682  */
683 VAStatus vaDestroyContext (
684     VADisplay dpy,
685     VAContextID context
686 );
687
688 /*
689  * Buffers 
690  * Buffers are used to pass various types of data from the
691  * client to the server. The server maintains a data store
692  * for each buffer created, and the client idenfies a buffer
693  * through a unique buffer id assigned by the server.
694  */
695
696 typedef VAGenericID VABufferID;
697
698 typedef enum
699 {
700     VAPictureParameterBufferType        = 0,
701     VAIQMatrixBufferType                = 1,
702     VABitPlaneBufferType                = 2,
703     VASliceGroupMapBufferType           = 3,
704     VASliceParameterBufferType          = 4,
705     VASliceDataBufferType               = 5,
706     VAMacroblockParameterBufferType     = 6,
707     VAResidualDataBufferType            = 7,
708     VADeblockingParameterBufferType     = 8,
709     VAImageBufferType                   = 9,
710     VAProtectedSliceDataBufferType      = 10,
711     VAQMatrixBufferType                 = 11,
712     VAHuffmanTableBufferType            = 12,
713
714 /* Following are encode buffer types */
715     VAEncCodedBufferType                = 21,
716     VAEncSequenceParameterBufferType    = 22,
717     VAEncPictureParameterBufferType     = 23,
718     VAEncSliceParameterBufferType       = 24,
719     VAEncPackedHeaderParameterBufferType = 25,
720     VAEncPackedHeaderDataBufferType     = 26,
721     VAEncMiscParameterBufferType        = 27,
722     VAEncMacroblockParameterBufferType  = 28,
723 /* Following are video processing buffer types */
724     /**
725      * \brief Video processing pipeline parameter buffer.
726      *
727      * This buffer describes the video processing pipeline. See
728      * #VAProcPipelineParameterBuffer for details.
729      */
730     VAProcPipelineParameterBufferType   = 41,
731     /**
732      * \brief Video filter parameter buffer.
733      *
734      * This buffer describes the video filter parameters. All buffers
735      * inherit from #VAProcFilterParameterBufferBase, thus including
736      * a unique filter buffer type.
737      *
738      * The default buffer used by most filters is #VAProcFilterParameterBuffer.
739      * Filters requiring advanced parameters include, but are not limited to,
740      * deinterlacing (#VAProcFilterParameterBufferDeinterlacing),
741      * color balance (#VAProcFilterParameterBufferColorBalance), etc.
742      */
743     VAProcFilterParameterBufferType     = 42,
744     VABufferTypeMax
745 } VABufferType;
746
747 typedef enum
748 {
749     VAEncMiscParameterTypeFrameRate     = 0,
750     VAEncMiscParameterTypeRateControl   = 1,
751     VAEncMiscParameterTypeMaxSliceSize  = 2,
752     VAEncMiscParameterTypeAIR           = 3,
753     /** \brief Buffer type used to express a maximum frame size (in bits). */
754     VAEncMiscParameterTypeMaxFrameSize  = 4,
755     /** \brief Buffer type used for HRD parameters. */
756     VAEncMiscParameterTypeHRD           = 5,
757 } VAEncMiscParameterType;
758
759 /** \brief Packed header type. */
760 typedef enum {
761     /** \brief Packed sequence header. */
762     VAEncPackedHeaderSequence   = 1,
763     /** \brief Packed picture header. */
764     VAEncPackedHeaderPicture    = 2,
765     /** \brief Packed slice header. */
766     VAEncPackedHeaderSlice      = 3,
767     /** 
768      * \brief Packed raw header. 
769      * 
770      * Packed raw data header can be used by the client to insert a header  
771      * into the bitstream data buffer at the point it is passed, the driver 
772      * will handle the raw packed header based on "has_emulation_bytes" field
773      * in the packed header parameter structure.
774      */
775     VAEncPackedHeaderRawData    = 4,
776     /** \brief Misc packed header. See codec-specific definitions. */
777     VAEncPackedHeaderMiscMask   = 0x80000000,
778 } VAEncPackedHeaderType;
779
780 /** \brief Packed header parameter. */
781 typedef struct _VAEncPackedHeaderParameterBuffer {
782     /** Type of the packed header buffer. See #VAEncPackedHeaderType. */
783     unsigned int                type;
784     /** \brief Size of the #VAEncPackedHeaderDataBuffer in bits. */
785     unsigned int                bit_length;
786     /** \brief Flag: buffer contains start code emulation prevention bytes? */
787     unsigned char               has_emulation_bytes;
788 } VAEncPackedHeaderParameterBuffer;
789
790 /*
791  *  For application, e.g. set a new bitrate
792  *    VABufferID buf_id;
793  *    VAEncMiscParameterBuffer *misc_param;
794  *    VAEncMiscParameterRateControl *misc_rate_ctrl;
795  * 
796  *    vaCreateBuffer(dpy, context, VAEncMiscParameterBufferType,
797  *              sizeof(VAEncMiscParameterBuffer) + sizeof(VAEncMiscParameterRateControl),
798  *              1, NULL, &buf_id);
799  *
800  *    vaMapBuffer(dpy,buf_id,(void **)&misc_param);
801  *    misc_param->type = VAEncMiscParameterTypeRateControl;
802  *    misc_rate_ctrl= (VAEncMiscParameterRateControl *)misc_param->data;
803  *    misc_rate_ctrl->bits_per_second = 6400000;
804  *    vaUnmapBuffer(dpy, buf_id);
805  *    vaRenderPicture(dpy, context, &buf_id, 1);
806  */
807 typedef struct _VAEncMiscParameterBuffer
808 {
809     VAEncMiscParameterType type;
810     unsigned int data[0];
811 } VAEncMiscParameterBuffer;
812
813
814 /** \brief Rate control parameters */
815 typedef struct _VAEncMiscParameterRateControl
816 {
817     /* this is the maximum bit-rate to be constrained by the rate control implementation */
818     unsigned int bits_per_second;
819     /* this is the bit-rate the rate control is targeting, as a percentage of the maximum
820      * bit-rate for example if target_percentage is 95 then the rate control will target
821      * a bit-rate that is 95% of the maximum bit-rate
822      */
823     unsigned int target_percentage;
824     /* windows size in milliseconds. For example if this is set to 500,
825      * then the rate control will guarantee the target bit-rate over a 500 ms window
826      */
827     unsigned int window_size;
828     /* initial QP at I frames */
829     unsigned int initial_qp;
830     unsigned int min_qp;
831     unsigned int basic_unit_size;
832     union
833     {
834         struct
835         {
836             unsigned int reset : 1;
837             unsigned int disable_frame_skip : 1; /* Disable frame skip in rate control mode */
838             unsigned int disable_bit_stuffing : 1; /* Disable bit stuffing in rate control mode */
839         } bits;
840         unsigned int value;
841     } rc_flags;
842 } VAEncMiscParameterRateControl;
843
844 typedef struct _VAEncMiscParameterFrameRate
845 {
846     unsigned int framerate;
847 } VAEncMiscParameterFrameRate;
848
849 /*
850  * Allow a maximum slice size to be specified (in bits).
851  * The encoder will attempt to make sure that individual slices do not exceed this size
852  * Or to signal applicate if the slice size exceed this size, see "status" of VACodedBufferSegment
853  */
854 typedef struct _VAEncMiscParameterMaxSliceSize
855 {
856     unsigned int max_slice_size;
857 } VAEncMiscParameterMaxSliceSize;
858
859 typedef struct _VAEncMiscParameterAIR
860 {
861     unsigned int air_num_mbs;
862     unsigned int air_threshold;
863     unsigned int air_auto; /* if set to 1 then hardware auto-tune the AIR threshold */
864 } VAEncMiscParameterAIR;
865
866 typedef struct _VAEncMiscParameterHRD
867 {
868     unsigned int initial_buffer_fullness;       /* in bits */
869     unsigned int buffer_size;                   /* in bits */
870 } VAEncMiscParameterHRD;
871
872 /**
873  * \brief Defines a maximum frame size (in bits).
874  *
875  * This misc parameter buffer defines the maximum size of a frame (in
876  * bits). The encoder will try to make sure that each frame does not
877  * exceed this size. Otherwise, if the frame size exceeds this size,
878  * the \c status flag of #VACodedBufferSegment will contain
879  * #VA_CODED_BUF_STATUS_FRAME_SIZE_OVERFLOW.
880  */
881 typedef struct _VAEncMiscParameterBufferMaxFrameSize {
882     /** \brief Type. Shall be set to #VAEncMiscParameterTypeMaxFrameSize. */
883     VAEncMiscParameterType      type;
884     /** \brief Maximum size of a frame (in bits). */
885     unsigned int                max_frame_size;
886 } VAEncMiscParameterBufferMaxFrameSize;
887
888 /* 
889  * There will be cases where the bitstream buffer will not have enough room to hold
890  * the data for the entire slice, and the following flags will be used in the slice
891  * parameter to signal to the server for the possible cases.
892  * If a slice parameter buffer and slice data buffer pair is sent to the server with 
893  * the slice data partially in the slice data buffer (BEGIN and MIDDLE cases below), 
894  * then a slice parameter and data buffer needs to be sent again to complete this slice. 
895  */
896 #define VA_SLICE_DATA_FLAG_ALL          0x00    /* whole slice is in the buffer */
897 #define VA_SLICE_DATA_FLAG_BEGIN        0x01    /* The beginning of the slice is in the buffer but the end if not */
898 #define VA_SLICE_DATA_FLAG_MIDDLE       0x02    /* Neither beginning nor end of the slice is in the buffer */
899 #define VA_SLICE_DATA_FLAG_END          0x04    /* end of the slice is in the buffer */
900
901 /* Codec-independent Slice Parameter Buffer base */
902 typedef struct _VASliceParameterBufferBase
903 {
904     unsigned int slice_data_size;       /* number of bytes in the slice data buffer for this slice */
905     unsigned int slice_data_offset;     /* the offset to the first byte of slice data */
906     unsigned int slice_data_flag;       /* see VA_SLICE_DATA_FLAG_XXX definitions */
907 } VASliceParameterBufferBase;
908
909
910 /****************************
911  * JEPG data structure
912  ***************************/
913 typedef struct _VAQMatrixBufferJPEG
914 {
915     int load_lum_quantiser_matrix;
916     int load_chroma_quantiser_matrix;
917     unsigned char lum_quantiser_matrix[64];
918     unsigned char chroma_quantiser_matrix[64];
919 } VAQMatrixBufferJPEG;
920
921 typedef struct _VAEncPictureParameterBufferJPEG
922 {
923     VASurfaceID reconstructed_picture;
924     unsigned short picture_width;
925     unsigned short picture_height;
926     VABufferID coded_buf;
927 } VAEncPictureParameterBufferJPEG;
928
929 #include <va/va_dec_jpeg.h>
930
931 /****************************
932  * MPEG-2 data structures
933  ****************************/
934  
935 /* MPEG-2 Picture Parameter Buffer */
936 /* 
937  * For each frame or field, and before any slice data, a single
938  * picture parameter buffer must be send.
939  */
940 typedef struct _VAPictureParameterBufferMPEG2
941 {
942     unsigned short horizontal_size;
943     unsigned short vertical_size;
944     VASurfaceID forward_reference_picture;
945     VASurfaceID backward_reference_picture;
946     /* meanings of the following fields are the same as in the standard */
947     int picture_coding_type;
948     int f_code; /* pack all four fcode into this */
949     union {
950         struct {
951             unsigned int intra_dc_precision             : 2; 
952             unsigned int picture_structure              : 2; 
953             unsigned int top_field_first                : 1; 
954             unsigned int frame_pred_frame_dct           : 1; 
955             unsigned int concealment_motion_vectors     : 1;
956             unsigned int q_scale_type                   : 1;
957             unsigned int intra_vlc_format               : 1;
958             unsigned int alternate_scan                 : 1;
959             unsigned int repeat_first_field             : 1;
960             unsigned int progressive_frame              : 1;
961             unsigned int is_first_field                 : 1; /* indicate whether the current field
962                                                               * is the first field for field picture
963                                                               */
964         } bits;
965         unsigned int value;
966     } picture_coding_extension;
967 } VAPictureParameterBufferMPEG2;
968
969 /* MPEG-2 Inverse Quantization Matrix Buffer */
970 typedef struct _VAIQMatrixBufferMPEG2
971 {
972     int load_intra_quantiser_matrix;
973     int load_non_intra_quantiser_matrix;
974     int load_chroma_intra_quantiser_matrix;
975     int load_chroma_non_intra_quantiser_matrix;
976     unsigned char intra_quantiser_matrix[64];
977     unsigned char non_intra_quantiser_matrix[64];
978     unsigned char chroma_intra_quantiser_matrix[64];
979     unsigned char chroma_non_intra_quantiser_matrix[64];
980 } VAIQMatrixBufferMPEG2;
981
982 /* MPEG-2 Slice Parameter Buffer */
983 typedef struct _VASliceParameterBufferMPEG2
984 {
985     unsigned int slice_data_size;/* number of bytes in the slice data buffer for this slice */
986     unsigned int slice_data_offset;/* the offset to the first byte of slice data */
987     unsigned int slice_data_flag; /* see VA_SLICE_DATA_FLAG_XXX defintions */
988     unsigned int macroblock_offset;/* the offset to the first bit of MB from the first byte of slice data */
989     unsigned int slice_horizontal_position;
990     unsigned int slice_vertical_position;
991     int quantiser_scale_code;
992     int intra_slice_flag;
993 } VASliceParameterBufferMPEG2;
994
995 /* MPEG-2 Macroblock Parameter Buffer */
996 typedef struct _VAMacroblockParameterBufferMPEG2
997 {
998     unsigned short macroblock_address;
999     /* 
1000      * macroblock_address (in raster scan order)
1001      * top-left: 0
1002      * bottom-right: picture-height-in-mb*picture-width-in-mb - 1
1003      */
1004     unsigned char macroblock_type;  /* see definition below */
1005     union {
1006         struct {
1007             unsigned int frame_motion_type              : 2; 
1008             unsigned int field_motion_type              : 2; 
1009             unsigned int dct_type                       : 1; 
1010         } bits;
1011         unsigned int value;
1012     } macroblock_modes;
1013     unsigned char motion_vertical_field_select; 
1014     /* 
1015      * motion_vertical_field_select:
1016      * see section 6.3.17.2 in the spec
1017      * only the lower 4 bits are used
1018      * bit 0: first vector forward
1019      * bit 1: first vector backward
1020      * bit 2: second vector forward
1021      * bit 3: second vector backward
1022      */
1023     short PMV[2][2][2]; /* see Table 7-7 in the spec */
1024     unsigned short coded_block_pattern;
1025     /* 
1026      * The bitplanes for coded_block_pattern are described 
1027      * in Figure 6.10-12 in the spec
1028      */
1029      
1030     /* Number of skipped macroblocks after this macroblock */
1031     unsigned short num_skipped_macroblocks;
1032 } VAMacroblockParameterBufferMPEG2;
1033
1034 /* 
1035  * OR'd flags for macroblock_type (section 6.3.17.1 in the spec)
1036  */
1037 #define VA_MB_TYPE_MOTION_FORWARD       0x02
1038 #define VA_MB_TYPE_MOTION_BACKWARD      0x04
1039 #define VA_MB_TYPE_MOTION_PATTERN       0x08
1040 #define VA_MB_TYPE_MOTION_INTRA         0x10
1041
1042 /* 
1043  * MPEG-2 Residual Data Buffer 
1044  * For each macroblock, there wil be 64 shorts (16-bit) in the 
1045  * residual data buffer
1046  */
1047
1048 /****************************
1049  * MPEG-4 Part 2 data structures
1050  ****************************/
1051  
1052 /* MPEG-4 Picture Parameter Buffer */
1053 /* 
1054  * For each frame or field, and before any slice data, a single
1055  * picture parameter buffer must be send.
1056  */
1057 typedef struct _VAPictureParameterBufferMPEG4
1058 {
1059     unsigned short vop_width;
1060     unsigned short vop_height;
1061     VASurfaceID forward_reference_picture;
1062     VASurfaceID backward_reference_picture;
1063     union {
1064         struct {
1065             unsigned int short_video_header             : 1; 
1066             unsigned int chroma_format                  : 2; 
1067             unsigned int interlaced                     : 1; 
1068             unsigned int obmc_disable                   : 1; 
1069             unsigned int sprite_enable                  : 2; 
1070             unsigned int sprite_warping_accuracy        : 2; 
1071             unsigned int quant_type                     : 1; 
1072             unsigned int quarter_sample                 : 1; 
1073             unsigned int data_partitioned               : 1; 
1074             unsigned int reversible_vlc                 : 1; 
1075             unsigned int resync_marker_disable          : 1; 
1076         } bits;
1077         unsigned int value;
1078     } vol_fields;
1079     unsigned char no_of_sprite_warping_points;
1080     short sprite_trajectory_du[3];
1081     short sprite_trajectory_dv[3];
1082     unsigned char quant_precision;
1083     union {
1084         struct {
1085             unsigned int vop_coding_type                : 2; 
1086             unsigned int backward_reference_vop_coding_type     : 2; 
1087             unsigned int vop_rounding_type              : 1; 
1088             unsigned int intra_dc_vlc_thr               : 3; 
1089             unsigned int top_field_first                : 1; 
1090             unsigned int alternate_vertical_scan_flag   : 1; 
1091         } bits;
1092         unsigned int value;
1093     } vop_fields;
1094     unsigned char vop_fcode_forward;
1095     unsigned char vop_fcode_backward;
1096     unsigned short vop_time_increment_resolution;
1097     /* short header related */
1098     unsigned char num_gobs_in_vop;
1099     unsigned char num_macroblocks_in_gob;
1100     /* for direct mode prediction */
1101     short TRB;
1102     short TRD;
1103 } VAPictureParameterBufferMPEG4;
1104
1105 /* MPEG-4 Inverse Quantization Matrix Buffer */
1106 typedef struct _VAIQMatrixBufferMPEG4
1107 {
1108     int load_intra_quant_mat;
1109     int load_non_intra_quant_mat;
1110     unsigned char intra_quant_mat[64];
1111     unsigned char non_intra_quant_mat[64];
1112 } VAIQMatrixBufferMPEG4;
1113
1114 /* MPEG-4 Slice Parameter Buffer */
1115 typedef struct _VASliceParameterBufferMPEG4
1116 {
1117     unsigned int slice_data_size;/* number of bytes in the slice data buffer for this slice */
1118     unsigned int slice_data_offset;/* the offset to the first byte of slice data */
1119     unsigned int slice_data_flag; /* see VA_SLICE_DATA_FLAG_XXX defintions */
1120     unsigned int macroblock_offset;/* the offset to the first bit of MB from the first byte of slice data */
1121     unsigned int macroblock_number;
1122     int quant_scale;
1123 } VASliceParameterBufferMPEG4;
1124
1125 /*
1126  VC-1 data structures
1127 */
1128
1129 typedef enum   /* see 7.1.1.32 */
1130 {
1131     VAMvMode1Mv                        = 0,
1132     VAMvMode1MvHalfPel                 = 1,
1133     VAMvMode1MvHalfPelBilinear         = 2,
1134     VAMvModeMixedMv                    = 3,
1135     VAMvModeIntensityCompensation      = 4 
1136 } VAMvModeVC1;
1137
1138 /* VC-1 Picture Parameter Buffer */
1139 /* 
1140  * For each picture, and before any slice data, a picture parameter
1141  * buffer must be send. Multiple picture parameter buffers may be
1142  * sent for a single picture. In that case picture parameters will
1143  * apply to all slice data that follow it until a new picture
1144  * parameter buffer is sent.
1145  *
1146  * Notes:
1147  *   pic_quantizer_type should be set to the applicable quantizer
1148  *   type as defined by QUANTIZER (J.1.19) and either
1149  *   PQUANTIZER (7.1.1.8) or PQINDEX (7.1.1.6)
1150  */
1151 typedef struct _VAPictureParameterBufferVC1
1152 {
1153     VASurfaceID forward_reference_picture;
1154     VASurfaceID backward_reference_picture;
1155     /* if out-of-loop post-processing is done on the render
1156        target, then we need to keep the in-loop decoded 
1157        picture as a reference picture */
1158     VASurfaceID inloop_decoded_picture;
1159
1160     /* sequence layer for AP or meta data for SP and MP */
1161     union {
1162         struct {
1163             unsigned int pulldown       : 1; /* SEQUENCE_LAYER::PULLDOWN */
1164             unsigned int interlace      : 1; /* SEQUENCE_LAYER::INTERLACE */
1165             unsigned int tfcntrflag     : 1; /* SEQUENCE_LAYER::TFCNTRFLAG */
1166             unsigned int finterpflag    : 1; /* SEQUENCE_LAYER::FINTERPFLAG */
1167             unsigned int psf            : 1; /* SEQUENCE_LAYER::PSF */
1168             unsigned int multires       : 1; /* METADATA::MULTIRES */
1169             unsigned int overlap        : 1; /* METADATA::OVERLAP */
1170             unsigned int syncmarker     : 1; /* METADATA::SYNCMARKER */
1171             unsigned int rangered       : 1; /* METADATA::RANGERED */
1172             unsigned int max_b_frames   : 3; /* METADATA::MAXBFRAMES */
1173             unsigned int profile        : 2; /* SEQUENCE_LAYER::PROFILE or The MSB of METADATA::PROFILE */
1174         } bits;
1175         unsigned int value;
1176     } sequence_fields;
1177
1178     unsigned short coded_width;         /* ENTRY_POINT_LAYER::CODED_WIDTH */
1179     unsigned short coded_height;        /* ENTRY_POINT_LAYER::CODED_HEIGHT */
1180     union {
1181         struct {
1182             unsigned int broken_link    : 1; /* ENTRY_POINT_LAYER::BROKEN_LINK */
1183             unsigned int closed_entry   : 1; /* ENTRY_POINT_LAYER::CLOSED_ENTRY */
1184             unsigned int panscan_flag   : 1; /* ENTRY_POINT_LAYER::PANSCAN_FLAG */
1185             unsigned int loopfilter     : 1; /* ENTRY_POINT_LAYER::LOOPFILTER */
1186         } bits;
1187         unsigned int value;
1188     } entrypoint_fields;
1189     unsigned char conditional_overlap_flag; /* ENTRY_POINT_LAYER::CONDOVER */
1190     unsigned char fast_uvmc_flag;       /* ENTRY_POINT_LAYER::FASTUVMC */
1191     union {
1192         struct {
1193             unsigned int luma_flag      : 1; /* ENTRY_POINT_LAYER::RANGE_MAPY_FLAG */
1194             unsigned int luma           : 3; /* ENTRY_POINT_LAYER::RANGE_MAPY */
1195             unsigned int chroma_flag    : 1; /* ENTRY_POINT_LAYER::RANGE_MAPUV_FLAG */
1196             unsigned int chroma         : 3; /* ENTRY_POINT_LAYER::RANGE_MAPUV */
1197         } bits;
1198         unsigned int value;
1199     } range_mapping_fields;
1200
1201     unsigned char b_picture_fraction;   /* PICTURE_LAYER::BFRACTION */
1202     unsigned char cbp_table;            /* PICTURE_LAYER::CBPTAB/ICBPTAB */
1203     unsigned char mb_mode_table;        /* PICTURE_LAYER::MBMODETAB */
1204     unsigned char range_reduction_frame;/* PICTURE_LAYER::RANGEREDFRM */
1205     unsigned char rounding_control;     /* PICTURE_LAYER::RNDCTRL */
1206     unsigned char post_processing;      /* PICTURE_LAYER::POSTPROC */
1207     unsigned char picture_resolution_index;     /* PICTURE_LAYER::RESPIC */
1208     unsigned char luma_scale;           /* PICTURE_LAYER::LUMSCALE */
1209     unsigned char luma_shift;           /* PICTURE_LAYER::LUMSHIFT */
1210     union {
1211         struct {
1212             unsigned int picture_type           : 3; /* PICTURE_LAYER::PTYPE */
1213             unsigned int frame_coding_mode      : 3; /* PICTURE_LAYER::FCM */
1214             unsigned int top_field_first        : 1; /* PICTURE_LAYER::TFF */
1215             unsigned int is_first_field         : 1; /* set to 1 if it is the first field */
1216             unsigned int intensity_compensation : 1; /* PICTURE_LAYER::INTCOMP */
1217         } bits;
1218         unsigned int value;
1219     } picture_fields;
1220     union {
1221         struct {
1222             unsigned int mv_type_mb     : 1;    /* PICTURE::MVTYPEMB */
1223             unsigned int direct_mb      : 1;    /* PICTURE::DIRECTMB */
1224             unsigned int skip_mb        : 1;    /* PICTURE::SKIPMB */
1225             unsigned int field_tx       : 1;    /* PICTURE::FIELDTX */
1226             unsigned int forward_mb     : 1;    /* PICTURE::FORWARDMB */
1227             unsigned int ac_pred        : 1;    /* PICTURE::ACPRED */
1228             unsigned int overflags      : 1;    /* PICTURE::OVERFLAGS */
1229         } flags;
1230         unsigned int value;
1231     } raw_coding;
1232     union {
1233         struct {
1234             unsigned int bp_mv_type_mb   : 1;    /* PICTURE::MVTYPEMB */
1235             unsigned int bp_direct_mb    : 1;    /* PICTURE::DIRECTMB */
1236             unsigned int bp_skip_mb      : 1;    /* PICTURE::SKIPMB */  
1237             unsigned int bp_field_tx     : 1;    /* PICTURE::FIELDTX */ 
1238             unsigned int bp_forward_mb   : 1;    /* PICTURE::FORWARDMB */
1239             unsigned int bp_ac_pred      : 1;    /* PICTURE::ACPRED */   
1240             unsigned int bp_overflags    : 1;    /* PICTURE::OVERFLAGS */
1241         } flags;
1242         unsigned int value;
1243     } bitplane_present; /* signal what bitplane is being passed via the bitplane buffer */
1244     union {
1245         struct {
1246             unsigned int reference_distance_flag : 1;/* PICTURE_LAYER::REFDIST_FLAG */
1247             unsigned int reference_distance     : 5;/* PICTURE_LAYER::REFDIST */
1248             unsigned int num_reference_pictures: 1;/* PICTURE_LAYER::NUMREF */
1249             unsigned int reference_field_pic_indicator  : 1;/* PICTURE_LAYER::REFFIELD */
1250         } bits;
1251         unsigned int value;
1252     } reference_fields;
1253     union {
1254         struct {
1255             unsigned int mv_mode                : 3; /* PICTURE_LAYER::MVMODE */
1256             unsigned int mv_mode2               : 3; /* PICTURE_LAYER::MVMODE2 */
1257             unsigned int mv_table               : 3; /* PICTURE_LAYER::MVTAB/IMVTAB */
1258             unsigned int two_mv_block_pattern_table: 2; /* PICTURE_LAYER::2MVBPTAB */
1259             unsigned int four_mv_switch         : 1; /* PICTURE_LAYER::4MVSWITCH */
1260             unsigned int four_mv_block_pattern_table : 2; /* PICTURE_LAYER::4MVBPTAB */
1261             unsigned int extended_mv_flag       : 1; /* ENTRY_POINT_LAYER::EXTENDED_MV */
1262             unsigned int extended_mv_range      : 2; /* PICTURE_LAYER::MVRANGE */
1263             unsigned int extended_dmv_flag      : 1; /* ENTRY_POINT_LAYER::EXTENDED_DMV */
1264             unsigned int extended_dmv_range     : 2; /* PICTURE_LAYER::DMVRANGE */
1265         } bits;
1266         unsigned int value;
1267     } mv_fields;
1268     union {
1269         struct {
1270             unsigned int dquant : 2;    /* ENTRY_POINT_LAYER::DQUANT */
1271             unsigned int quantizer     : 2;     /* ENTRY_POINT_LAYER::QUANTIZER */
1272             unsigned int half_qp        : 1;    /* PICTURE_LAYER::HALFQP */
1273             unsigned int pic_quantizer_scale : 5;/* PICTURE_LAYER::PQUANT */
1274             unsigned int pic_quantizer_type : 1;/* PICTURE_LAYER::PQUANTIZER */
1275             unsigned int dq_frame       : 1;    /* VOPDQUANT::DQUANTFRM */
1276             unsigned int dq_profile     : 2;    /* VOPDQUANT::DQPROFILE */
1277             unsigned int dq_sb_edge     : 2;    /* VOPDQUANT::DQSBEDGE */
1278             unsigned int dq_db_edge     : 2;    /* VOPDQUANT::DQDBEDGE */
1279             unsigned int dq_binary_level : 1;   /* VOPDQUANT::DQBILEVEL */
1280             unsigned int alt_pic_quantizer : 5;/* VOPDQUANT::ALTPQUANT */
1281         } bits;
1282         unsigned int value;
1283     } pic_quantizer_fields;
1284     union {
1285         struct {
1286             unsigned int variable_sized_transform_flag  : 1;/* ENTRY_POINT_LAYER::VSTRANSFORM */
1287             unsigned int mb_level_transform_type_flag   : 1;/* PICTURE_LAYER::TTMBF */
1288             unsigned int frame_level_transform_type     : 2;/* PICTURE_LAYER::TTFRM */
1289             unsigned int transform_ac_codingset_idx1    : 2;/* PICTURE_LAYER::TRANSACFRM */
1290             unsigned int transform_ac_codingset_idx2    : 2;/* PICTURE_LAYER::TRANSACFRM2 */
1291             unsigned int intra_transform_dc_table       : 1;/* PICTURE_LAYER::TRANSDCTAB */
1292         } bits;
1293         unsigned int value;
1294     } transform_fields;
1295 } VAPictureParameterBufferVC1;
1296
1297 /* VC-1 Bitplane Buffer 
1298 There will be at most three bitplanes coded in any picture header. To send 
1299 the bitplane data more efficiently, each byte is divided in two nibbles, with
1300 each nibble carrying three bitplanes for one macroblock.  The following table
1301 shows the bitplane data arrangement within each nibble based on the picture
1302 type.
1303
1304 Picture Type    Bit3            Bit2            Bit1            Bit0
1305 I or BI                         OVERFLAGS       ACPRED          FIELDTX
1306 P                               MYTYPEMB        SKIPMB          DIRECTMB
1307 B                               FORWARDMB       SKIPMB          DIRECTMB
1308
1309 Within each byte, the lower nibble is for the first MB and the upper nibble is 
1310 for the second MB.  E.g. the lower nibble of the first byte in the bitplane
1311 buffer is for Macroblock #1 and the upper nibble of the first byte is for 
1312 Macroblock #2 in the first row.
1313 */
1314
1315 /* VC-1 Slice Parameter Buffer */
1316 typedef struct _VASliceParameterBufferVC1
1317 {
1318     unsigned int slice_data_size;/* number of bytes in the slice data buffer for this slice */
1319     unsigned int slice_data_offset;/* the offset to the first byte of slice data */
1320     unsigned int slice_data_flag; /* see VA_SLICE_DATA_FLAG_XXX defintions */
1321     unsigned int macroblock_offset;/* the offset to the first bit of MB from the first byte of slice data */
1322     unsigned int slice_vertical_position;
1323 } VASliceParameterBufferVC1;
1324
1325 /* VC-1 Slice Data Buffer */
1326 /* 
1327 This is simplely a buffer containing raw bit-stream bytes 
1328 */
1329
1330 /****************************
1331  * H.264/AVC data structures
1332  ****************************/
1333
1334 typedef struct _VAPictureH264
1335 {
1336     VASurfaceID picture_id;
1337     unsigned int frame_idx;
1338     unsigned int flags;
1339     signed int TopFieldOrderCnt;
1340     signed int BottomFieldOrderCnt;
1341 } VAPictureH264;
1342 /* flags in VAPictureH264 could be OR of the following */
1343 #define VA_PICTURE_H264_INVALID                 0x00000001
1344 #define VA_PICTURE_H264_TOP_FIELD               0x00000002
1345 #define VA_PICTURE_H264_BOTTOM_FIELD            0x00000004
1346 #define VA_PICTURE_H264_SHORT_TERM_REFERENCE    0x00000008
1347 #define VA_PICTURE_H264_LONG_TERM_REFERENCE     0x00000010
1348
1349 /* H.264 Picture Parameter Buffer */
1350 /* 
1351  * For each picture, and before any slice data, a single
1352  * picture parameter buffer must be send.
1353  */
1354 typedef struct _VAPictureParameterBufferH264
1355 {
1356     VAPictureH264 CurrPic;
1357     VAPictureH264 ReferenceFrames[16];  /* in DPB */
1358     unsigned short picture_width_in_mbs_minus1;
1359     unsigned short picture_height_in_mbs_minus1;
1360     unsigned char bit_depth_luma_minus8;
1361     unsigned char bit_depth_chroma_minus8;
1362     unsigned char num_ref_frames;
1363     union {
1364         struct {
1365             unsigned int chroma_format_idc                      : 2; 
1366             unsigned int residual_colour_transform_flag         : 1; 
1367             unsigned int gaps_in_frame_num_value_allowed_flag   : 1; 
1368             unsigned int frame_mbs_only_flag                    : 1; 
1369             unsigned int mb_adaptive_frame_field_flag           : 1; 
1370             unsigned int direct_8x8_inference_flag              : 1; 
1371             unsigned int MinLumaBiPredSize8x8                   : 1; /* see A.3.3.2 */
1372             unsigned int log2_max_frame_num_minus4              : 4;
1373             unsigned int pic_order_cnt_type                     : 2;
1374             unsigned int log2_max_pic_order_cnt_lsb_minus4      : 4;
1375             unsigned int delta_pic_order_always_zero_flag       : 1;
1376         } bits;
1377         unsigned int value;
1378     } seq_fields;
1379     unsigned char num_slice_groups_minus1;
1380     unsigned char slice_group_map_type;
1381     unsigned short slice_group_change_rate_minus1;
1382     signed char pic_init_qp_minus26;
1383     signed char pic_init_qs_minus26;
1384     signed char chroma_qp_index_offset;
1385     signed char second_chroma_qp_index_offset;
1386     union {
1387         struct {
1388             unsigned int entropy_coding_mode_flag       : 1;
1389             unsigned int weighted_pred_flag             : 1;
1390             unsigned int weighted_bipred_idc            : 2;
1391             unsigned int transform_8x8_mode_flag        : 1;
1392             unsigned int field_pic_flag                 : 1;
1393             unsigned int constrained_intra_pred_flag    : 1;
1394             unsigned int pic_order_present_flag                 : 1;
1395             unsigned int deblocking_filter_control_present_flag : 1;
1396             unsigned int redundant_pic_cnt_present_flag         : 1;
1397             unsigned int reference_pic_flag                     : 1; /* nal_ref_idc != 0 */
1398         } bits;
1399         unsigned int value;
1400     } pic_fields;
1401     unsigned short frame_num;
1402 } VAPictureParameterBufferH264;
1403
1404 /* H.264 Inverse Quantization Matrix Buffer */
1405 typedef struct _VAIQMatrixBufferH264
1406 {
1407     unsigned char ScalingList4x4[6][16];
1408     unsigned char ScalingList8x8[2][64];
1409 } VAIQMatrixBufferH264;
1410
1411 /* 
1412  * H.264 Slice Group Map Buffer 
1413  * When VAPictureParameterBufferH264::num_slice_group_minus1 is not equal to 0,
1414  * A slice group map buffer should be sent for each picture if required. The buffer
1415  * is sent only when there is a change in the mapping values.
1416  * The slice group map buffer map "map units" to slice groups as specified in 
1417  * section 8.2.2 of the H.264 spec. The buffer will contain one byte for each macroblock 
1418  * in raster scan order
1419  */ 
1420
1421 /* H.264 Slice Parameter Buffer */
1422 typedef struct _VASliceParameterBufferH264
1423 {
1424     unsigned int slice_data_size;/* number of bytes in the slice data buffer for this slice */
1425     /** \brief Byte offset to the NAL Header Unit for this slice. */
1426     unsigned int slice_data_offset;
1427     unsigned int slice_data_flag; /* see VA_SLICE_DATA_FLAG_XXX defintions */
1428     /**
1429      * \brief Bit offset from NAL Header Unit to the begining of slice_data().
1430      *
1431      * This bit offset is relative to and includes the NAL unit byte
1432      * and represents the number of bits parsed in the slice_header()
1433      * after the removal of any emulation prevention bytes in
1434      * there. However, the slice data buffer passed to the hardware is
1435      * the original bitstream, thus including any emulation prevention
1436      * bytes.
1437      */
1438     unsigned short slice_data_bit_offset;
1439     unsigned short first_mb_in_slice;
1440     unsigned char slice_type;
1441     unsigned char direct_spatial_mv_pred_flag;
1442     unsigned char num_ref_idx_l0_active_minus1;
1443     unsigned char num_ref_idx_l1_active_minus1;
1444     unsigned char cabac_init_idc;
1445     char slice_qp_delta;
1446     unsigned char disable_deblocking_filter_idc;
1447     char slice_alpha_c0_offset_div2;
1448     char slice_beta_offset_div2;
1449     VAPictureH264 RefPicList0[32];      /* See 8.2.4.2 */
1450     VAPictureH264 RefPicList1[32];      /* See 8.2.4.2 */
1451     unsigned char luma_log2_weight_denom;
1452     unsigned char chroma_log2_weight_denom;
1453     unsigned char luma_weight_l0_flag;
1454     short luma_weight_l0[32];
1455     short luma_offset_l0[32];
1456     unsigned char chroma_weight_l0_flag;
1457     short chroma_weight_l0[32][2];
1458     short chroma_offset_l0[32][2];
1459     unsigned char luma_weight_l1_flag;
1460     short luma_weight_l1[32];
1461     short luma_offset_l1[32];
1462     unsigned char chroma_weight_l1_flag;
1463     short chroma_weight_l1[32][2];
1464     short chroma_offset_l1[32][2];
1465 } VASliceParameterBufferH264;
1466
1467 /****************************
1468  * Common encode data structures 
1469  ****************************/
1470 typedef enum
1471 {
1472     VAEncPictureTypeIntra               = 0,
1473     VAEncPictureTypePredictive          = 1,
1474     VAEncPictureTypeBidirectional       = 2,
1475 } VAEncPictureType;
1476
1477 /* Encode Slice Parameter Buffer */
1478 typedef struct _VAEncSliceParameterBuffer
1479 {
1480     unsigned int start_row_number;      /* starting MB row number for this slice */
1481     unsigned int slice_height;  /* slice height measured in MB */
1482     union {
1483         struct {
1484             unsigned int is_intra       : 1;
1485             unsigned int disable_deblocking_filter_idc : 2;
1486             unsigned int uses_long_term_ref             :1;
1487             unsigned int is_long_term_ref               :1;
1488         } bits;
1489         unsigned int value;
1490     } slice_flags;
1491 } VAEncSliceParameterBuffer;
1492
1493
1494 /****************************
1495  * H.263 specific encode data structures
1496  ****************************/
1497
1498 typedef struct _VAEncSequenceParameterBufferH263
1499 {
1500     unsigned int intra_period;
1501     unsigned int bits_per_second;
1502     unsigned int frame_rate;
1503     unsigned int initial_qp;
1504     unsigned int min_qp;
1505 } VAEncSequenceParameterBufferH263;
1506
1507 typedef struct _VAEncPictureParameterBufferH263
1508 {
1509     VASurfaceID reference_picture;
1510     VASurfaceID reconstructed_picture;
1511     VABufferID coded_buf;
1512     unsigned short picture_width;
1513     unsigned short picture_height;
1514     VAEncPictureType picture_type;
1515 } VAEncPictureParameterBufferH263;
1516
1517 /****************************
1518  * MPEG-4 specific encode data structures
1519  ****************************/
1520
1521 typedef struct _VAEncSequenceParameterBufferMPEG4
1522 {
1523     unsigned char profile_and_level_indication;
1524     unsigned int intra_period;
1525     unsigned int video_object_layer_width;
1526     unsigned int video_object_layer_height;
1527     unsigned int vop_time_increment_resolution;
1528     unsigned int fixed_vop_rate;
1529     unsigned int fixed_vop_time_increment;
1530     unsigned int bits_per_second;
1531     unsigned int frame_rate;
1532     unsigned int initial_qp;
1533     unsigned int min_qp;
1534 } VAEncSequenceParameterBufferMPEG4;
1535
1536 typedef struct _VAEncPictureParameterBufferMPEG4
1537 {
1538     VASurfaceID reference_picture;
1539     VASurfaceID reconstructed_picture;
1540     VABufferID coded_buf;
1541     unsigned short picture_width;
1542     unsigned short picture_height;
1543     unsigned int modulo_time_base; /* number of 1s */
1544     unsigned int vop_time_increment;
1545     VAEncPictureType picture_type;
1546 } VAEncPictureParameterBufferMPEG4;
1547
1548
1549
1550 /* Buffer functions */
1551
1552 /*
1553  * Creates a buffer for "num_elements" elements of "size" bytes and 
1554  * initalize with "data".
1555  * if "data" is null, then the contents of the buffer data store
1556  * are undefined.
1557  * Basically there are two ways to get buffer data to the server side. One is 
1558  * to call vaCreateBuffer() with a non-null "data", which results the data being
1559  * copied to the data store on the server side.  A different method that 
1560  * eliminates this copy is to pass null as "data" when calling vaCreateBuffer(),
1561  * and then use vaMapBuffer() to map the data store from the server side to the
1562  * client address space for access.
1563  *  Note: image buffers are created by the library, not the client. Please see 
1564  *        vaCreateImage on how image buffers are managed.
1565  */
1566 VAStatus vaCreateBuffer (
1567     VADisplay dpy,
1568     VAContextID context,
1569     VABufferType type,  /* in */
1570     unsigned int size,  /* in */
1571     unsigned int num_elements, /* in */
1572     void *data,         /* in */
1573     VABufferID *buf_id  /* out */
1574 );
1575
1576 /*
1577  * Convey to the server how many valid elements are in the buffer. 
1578  * e.g. if multiple slice parameters are being held in a single buffer,
1579  * this will communicate to the server the number of slice parameters
1580  * that are valid in the buffer.
1581  */
1582 VAStatus vaBufferSetNumElements (
1583     VADisplay dpy,
1584     VABufferID buf_id,  /* in */
1585     unsigned int num_elements /* in */
1586 );
1587
1588
1589 /*
1590  * device independent data structure for codedbuffer
1591  */
1592
1593 /* 
1594  * FICTURE_AVE_QP(bit7-0): The average Qp value used during this frame
1595  * LARGE_SLICE(bit8):At least one slice in the current frame was large
1596  *              enough for the encoder to attempt to limit its size.
1597  * SLICE_OVERFLOW(bit9): At least one slice in the current frame has
1598  *              exceeded the maximum slice size specified.
1599  * BITRATE_OVERFLOW(bit10): The peak bitrate was exceeded for this frame.
1600  * BITRATE_HIGH(bit11): The frame size got within the safety margin of the maximum size (VCM only)
1601  * AIR_MB_OVER_THRESHOLD: the number of MBs adapted to Intra MB
1602  */
1603 #define VA_CODED_BUF_STATUS_PICTURE_AVE_QP_MASK         0xff
1604 #define VA_CODED_BUF_STATUS_LARGE_SLICE_MASK            0x100
1605 #define VA_CODED_BUF_STATUS_SLICE_OVERFLOW_MASK         0x200
1606 #define VA_CODED_BUF_STATUS_BITRATE_OVERFLOW            0x400
1607 #define VA_CODED_BUF_STATUS_BITRATE_HIGH                0x800
1608 /**
1609  * \brief The frame has exceeded the maximum requested size.
1610  *
1611  * This flag indicates that the encoded frame size exceeds the value
1612  * specified through a misc parameter buffer of type
1613  * #VAEncMiscParameterTypeMaxFrameSize.
1614  */
1615 #define VA_CODED_BUF_STATUS_FRAME_SIZE_OVERFLOW         0x1000
1616 #define VA_CODED_BUF_STATUS_AIR_MB_OVER_THRESHOLD       0xff0000
1617
1618 /**
1619  * \brief The coded buffer segment contains a single NAL unit. 
1620  *
1621  * This flag indicates that the coded buffer segment contains a
1622  * single NAL unit. This flag might be useful to the user for 
1623  * processing the coded buffer.
1624  */
1625 #define VA_CODED_BUF_STATUS_SINGLE_NALU                 0x10000000      
1626
1627 /**
1628  * \brief Coded buffer segment.
1629  *
1630  * #VACodedBufferSegment is an element of a linked list describing
1631  * some information on the coded buffer. The coded buffer segment
1632  * could contain either a single NAL unit, or more than one NAL unit. 
1633  * It is recommended (but not required) to return a single NAL unit 
1634  * in a coded buffer segment, and the implementation should set the 
1635  * VA_CODED_BUF_STATUS_SINGLE_NALU status flag if that is the case.
1636  */
1637 typedef  struct _VACodedBufferSegment  {
1638     /**
1639      * \brief Size of the data buffer in this segment (in bytes).
1640      */
1641     unsigned int        size;
1642     /** \brief Bit offset into the data buffer where the video data starts. */
1643     unsigned int        bit_offset;
1644     /** \brief Status set by the driver. See \c VA_CODED_BUF_STATUS_*. */
1645     unsigned int        status;
1646     /** \brief Reserved for future use. */
1647     unsigned int        reserved;
1648     /** \brief Pointer to the start of the data buffer. */
1649     void               *buf;
1650     /**
1651      * \brief Pointer to the next #VACodedBufferSegment element,
1652      * or \c NULL if there is none.
1653      */
1654     void               *next;
1655 } VACodedBufferSegment;
1656      
1657 /*
1658  * Map data store of the buffer into the client's address space
1659  * vaCreateBuffer() needs to be called with "data" set to NULL before
1660  * calling vaMapBuffer()
1661  *
1662  * if buffer type is VAEncCodedBufferType, pbuf points to link-list of
1663  * VACodedBufferSegment, and the list is terminated if "next" is NULL
1664  */
1665 VAStatus vaMapBuffer (
1666     VADisplay dpy,
1667     VABufferID buf_id,  /* in */
1668     void **pbuf         /* out */
1669 );
1670
1671 /*
1672  * After client making changes to a mapped data store, it needs to
1673  * "Unmap" it to let the server know that the data is ready to be
1674  * consumed by the server
1675  */
1676 VAStatus vaUnmapBuffer (
1677     VADisplay dpy,
1678     VABufferID buf_id   /* in */
1679 );
1680
1681 /*
1682  * After this call, the buffer is deleted and this buffer_id is no longer valid
1683  * Only call this if the buffer is not going to be passed to vaRenderBuffer
1684  */
1685 VAStatus vaDestroyBuffer (
1686     VADisplay dpy,
1687     VABufferID buffer_id
1688 );
1689
1690 /*
1691 Render (Decode) Pictures
1692
1693 A picture represents either a frame or a field.
1694
1695 The Begin/Render/End sequence sends the decode buffers to the server
1696 */
1697
1698 /*
1699  * Get ready to decode a picture to a target surface
1700  */
1701 VAStatus vaBeginPicture (
1702     VADisplay dpy,
1703     VAContextID context,
1704     VASurfaceID render_target
1705 );
1706
1707 /* 
1708  * Send decode buffers to the server.
1709  * Buffers are automatically destroyed afterwards
1710  */
1711 VAStatus vaRenderPicture (
1712     VADisplay dpy,
1713     VAContextID context,
1714     VABufferID *buffers,
1715     int num_buffers
1716 );
1717
1718 /* 
1719  * Make the end of rendering for a picture. 
1720  * The server should start processing all pending operations for this 
1721  * surface. This call is non-blocking. The client can start another 
1722  * Begin/Render/End sequence on a different render target.
1723  */
1724 VAStatus vaEndPicture (
1725     VADisplay dpy,
1726     VAContextID context
1727 );
1728
1729 /*
1730
1731 Synchronization 
1732
1733 */
1734
1735 /* 
1736  * This function blocks until all pending operations on the render target
1737  * have been completed.  Upon return it is safe to use the render target for a 
1738  * different picture. 
1739  */
1740 VAStatus vaSyncSurface (
1741     VADisplay dpy,
1742     VASurfaceID render_target
1743 );
1744
1745 typedef enum
1746 {
1747     VASurfaceRendering  = 1, /* Rendering in progress */ 
1748     VASurfaceDisplaying = 2, /* Displaying in progress (not safe to render into it) */ 
1749                              /* this status is useful if surface is used as the source */
1750                              /* of an overlay */
1751     VASurfaceReady      = 4, /* not being rendered or displayed */
1752     VASurfaceSkipped    = 8  /* Indicate a skipped frame during encode */
1753 } VASurfaceStatus;
1754
1755 /*
1756  * Find out any pending ops on the render target 
1757  */
1758 VAStatus vaQuerySurfaceStatus (
1759     VADisplay dpy,
1760     VASurfaceID render_target,
1761     VASurfaceStatus *status     /* out */
1762 );
1763
1764 typedef enum
1765 {
1766     VADecodeSliceMissing            = 0,
1767     VADecodeMBError                 = 1,
1768 } VADecodeErrorType;
1769
1770 /*
1771  * Client calls vaQuerySurfaceError with VA_STATUS_ERROR_DECODING_ERROR, server side returns
1772  * an array of structure VASurfaceDecodeMBErrors, and the array is terminated by setting status=-1
1773 */
1774 typedef struct _VASurfaceDecodeMBErrors
1775 {
1776     int status; /* 1 if hardware has returned detailed info below, -1 means this record is invalid */
1777     unsigned int start_mb; /* start mb address with errors */
1778     unsigned int end_mb;  /* end mb address with errors */
1779     VADecodeErrorType decode_error_type;
1780 } VASurfaceDecodeMBErrors;
1781
1782 /*
1783  * After the application gets VA_STATUS_ERROR_DECODING_ERROR after calling vaSyncSurface(),
1784  * it can call vaQuerySurfaceError to find out further details on the particular error.
1785  * VA_STATUS_ERROR_DECODING_ERROR should be passed in as "error_status",
1786  * upon the return, error_info will point to an array of _VASurfaceDecodeMBErrors structure,
1787  * which is allocated and filled by libVA with detailed information on the missing or error macroblocks.
1788  * The array is terminated if "status==-1" is detected.
1789  */
1790 VAStatus vaQuerySurfaceError(
1791     VADisplay dpy,
1792     VASurfaceID surface,
1793     VAStatus error_status,
1794     void **error_info
1795 );
1796
1797 /*
1798  * Images and Subpictures
1799  * VAImage is used to either get the surface data to client memory, or 
1800  * to copy image data in client memory to a surface. 
1801  * Both images, subpictures and surfaces follow the same 2D coordinate system where origin 
1802  * is at the upper left corner with positive X to the right and positive Y down
1803  */
1804 #define VA_FOURCC(ch0, ch1, ch2, ch3) \
1805     ((unsigned long)(unsigned char) (ch0) | ((unsigned long)(unsigned char) (ch1) << 8) | \
1806     ((unsigned long)(unsigned char) (ch2) << 16) | ((unsigned long)(unsigned char) (ch3) << 24 ))
1807
1808 /* a few common FourCCs */
1809 #define VA_FOURCC_NV12          0x3231564E
1810 #define VA_FOURCC_AI44          0x34344149
1811 #define VA_FOURCC_RGBA          0x41424752
1812 #define VA_FOURCC_BGRA          0x41524742
1813 #define VA_FOURCC_UYVY          0x59565955
1814 #define VA_FOURCC_YUY2          0x32595559
1815 #define VA_FOURCC_AYUV          0x56555941
1816 #define VA_FOURCC_NV11          0x3131564e
1817 #define VA_FOURCC_YV12          0x32315659
1818 #define VA_FOURCC_P208          0x38303250
1819 #define VA_FOURCC_IYUV          0x56555949
1820
1821 /* byte order */
1822 #define VA_LSB_FIRST            1
1823 #define VA_MSB_FIRST            2
1824
1825 typedef struct _VAImageFormat
1826 {
1827     unsigned int        fourcc;
1828     unsigned int        byte_order; /* VA_LSB_FIRST, VA_MSB_FIRST */
1829     unsigned int        bits_per_pixel;
1830     /* for RGB formats */
1831     unsigned int        depth; /* significant bits per pixel */
1832     unsigned int        red_mask;
1833     unsigned int        green_mask;
1834     unsigned int        blue_mask;
1835     unsigned int        alpha_mask;
1836 } VAImageFormat;
1837
1838 typedef VAGenericID VAImageID;
1839
1840 typedef struct _VAImage
1841 {
1842     VAImageID           image_id; /* uniquely identify this image */
1843     VAImageFormat       format;
1844     VABufferID          buf;    /* image data buffer */
1845     /*
1846      * Image data will be stored in a buffer of type VAImageBufferType to facilitate
1847      * data store on the server side for optimal performance. The buffer will be 
1848      * created by the CreateImage function, and proper storage allocated based on the image
1849      * size and format. This buffer is managed by the library implementation, and 
1850      * accessed by the client through the buffer Map/Unmap functions.
1851      */
1852     unsigned short      width; 
1853     unsigned short      height;
1854     unsigned int        data_size;
1855     unsigned int        num_planes;     /* can not be greater than 3 */
1856     /* 
1857      * An array indicating the scanline pitch in bytes for each plane.
1858      * Each plane may have a different pitch. Maximum 3 planes for planar formats
1859      */
1860     unsigned int        pitches[3];
1861     /* 
1862      * An array indicating the byte offset from the beginning of the image data 
1863      * to the start of each plane.
1864      */
1865     unsigned int        offsets[3];
1866
1867     /* The following fields are only needed for paletted formats */
1868     int num_palette_entries;   /* set to zero for non-palette images */
1869     /* 
1870      * Each component is one byte and entry_bytes indicates the number of components in 
1871      * each entry (eg. 3 for YUV palette entries). set to zero for non-palette images   
1872      */
1873     int entry_bytes; 
1874     /*
1875      * An array of ascii characters describing the order of the components within the bytes.
1876      * Only entry_bytes characters of the string are used.
1877      */
1878     char component_order[4];
1879 } VAImage;
1880
1881 /* Get maximum number of image formats supported by the implementation */
1882 int vaMaxNumImageFormats (
1883     VADisplay dpy
1884 );
1885
1886 /* 
1887  * Query supported image formats 
1888  * The caller must provide a "format_list" array that can hold at
1889  * least vaMaxNumImageFormats() entries. The actual number of formats
1890  * returned in "format_list" is returned in "num_formats".
1891  */
1892 VAStatus vaQueryImageFormats (
1893     VADisplay dpy,
1894     VAImageFormat *format_list, /* out */
1895     int *num_formats            /* out */
1896 );
1897
1898 /* 
1899  * Create a VAImage structure
1900  * The width and height fields returned in the VAImage structure may get 
1901  * enlarged for some YUV formats. Upon return from this function, 
1902  * image->buf has been created and proper storage allocated by the library. 
1903  * The client can access the image through the Map/Unmap calls.
1904  */
1905 VAStatus vaCreateImage (
1906     VADisplay dpy,
1907     VAImageFormat *format,
1908     int width,
1909     int height,
1910     VAImage *image      /* out */
1911 );
1912
1913 /*
1914  * Should call DestroyImage before destroying the surface it is bound to
1915  */
1916 VAStatus vaDestroyImage (
1917     VADisplay dpy,
1918     VAImageID image
1919 );
1920
1921 VAStatus vaSetImagePalette (
1922     VADisplay dpy,
1923     VAImageID image,
1924     /* 
1925      * pointer to an array holding the palette data.  The size of the array is 
1926      * num_palette_entries * entry_bytes in size.  The order of the components 
1927      * in the palette is described by the component_order in VAImage struct    
1928      */
1929     unsigned char *palette 
1930 );
1931
1932 /*
1933  * Retrive surface data into a VAImage
1934  * Image must be in a format supported by the implementation
1935  */
1936 VAStatus vaGetImage (
1937     VADisplay dpy,
1938     VASurfaceID surface,
1939     int x,      /* coordinates of the upper left source pixel */
1940     int y,
1941     unsigned int width, /* width and height of the region */
1942     unsigned int height,
1943     VAImageID image
1944 );
1945
1946 /*
1947  * Copy data from a VAImage to a surface
1948  * Image must be in a format supported by the implementation
1949  * Returns a VA_STATUS_ERROR_SURFACE_BUSY if the surface
1950  * shouldn't be rendered into when this is called
1951  */
1952 VAStatus vaPutImage (
1953     VADisplay dpy,
1954     VASurfaceID surface,
1955     VAImageID image,
1956     int src_x,
1957     int src_y,
1958     unsigned int src_width,
1959     unsigned int src_height,
1960     int dest_x,
1961     int dest_y,
1962     unsigned int dest_width,
1963     unsigned int dest_height
1964 );
1965
1966 /*
1967  * Derive an VAImage from an existing surface.
1968  * This interface will derive a VAImage and corresponding image buffer from
1969  * an existing VA Surface. The image buffer can then be mapped/unmapped for
1970  * direct CPU access. This operation is only possible on implementations with
1971  * direct rendering capabilities and internal surface formats that can be
1972  * represented with a VAImage. When the operation is not possible this interface
1973  * will return VA_STATUS_ERROR_OPERATION_FAILED. Clients should then fall back
1974  * to using vaCreateImage + vaPutImage to accomplish the same task in an
1975  * indirect manner.
1976  *
1977  * Implementations should only return success when the resulting image buffer
1978  * would be useable with vaMap/Unmap.
1979  *
1980  * When directly accessing a surface special care must be taken to insure
1981  * proper synchronization with the graphics hardware. Clients should call
1982  * vaQuerySurfaceStatus to insure that a surface is not the target of concurrent
1983  * rendering or currently being displayed by an overlay.
1984  *
1985  * Additionally nothing about the contents of a surface should be assumed
1986  * following a vaPutSurface. Implementations are free to modify the surface for
1987  * scaling or subpicture blending within a call to vaPutImage.
1988  *
1989  * Calls to vaPutImage or vaGetImage using the same surface from which the image
1990  * has been derived will return VA_STATUS_ERROR_SURFACE_BUSY. vaPutImage or
1991  * vaGetImage with other surfaces is supported.
1992  *
1993  * An image created with vaDeriveImage should be freed with vaDestroyImage. The
1994  * image and image buffer structures will be destroyed; however, the underlying
1995  * surface will remain unchanged until freed with vaDestroySurfaces.
1996  */
1997 VAStatus vaDeriveImage (
1998     VADisplay dpy,
1999     VASurfaceID surface,
2000     VAImage *image      /* out */
2001 );
2002
2003 /*
2004  * Subpictures 
2005  * Subpicture is a special type of image that can be blended 
2006  * with a surface during vaPutSurface(). Subpicture can be used to render
2007  * DVD sub-titles or closed captioning text etc.  
2008  */
2009
2010 typedef VAGenericID VASubpictureID;
2011
2012 /* Get maximum number of subpicture formats supported by the implementation */
2013 int vaMaxNumSubpictureFormats (
2014     VADisplay dpy
2015 );
2016
2017 /* flags for subpictures */
2018 #define VA_SUBPICTURE_CHROMA_KEYING                     0x0001
2019 #define VA_SUBPICTURE_GLOBAL_ALPHA                      0x0002
2020 #define VA_SUBPICTURE_DESTINATION_IS_SCREEN_COORD       0x0004
2021 /* 
2022  * Query supported subpicture formats 
2023  * The caller must provide a "format_list" array that can hold at
2024  * least vaMaxNumSubpictureFormats() entries. The flags arrary holds the flag 
2025  * for each format to indicate additional capabilities for that format. The actual 
2026  * number of formats returned in "format_list" is returned in "num_formats".
2027  *  flags: returned value to indicate addtional capabilities
2028  *         VA_SUBPICTURE_CHROMA_KEYING - supports chroma-keying
2029  *         VA_SUBPICTURE_GLOBAL_ALPHA - supports global alpha
2030  *         VA_SUBPICTURE_DESTINATION_IS_SCREEN_COORD - supports unscaled screen relative subpictures for On Screen Display
2031  */
2032
2033 VAStatus vaQuerySubpictureFormats (
2034     VADisplay dpy,
2035     VAImageFormat *format_list, /* out */
2036     unsigned int *flags,        /* out */
2037     unsigned int *num_formats   /* out */
2038 );
2039
2040 /* 
2041  * Subpictures are created with an image associated. 
2042  */
2043 VAStatus vaCreateSubpicture (
2044     VADisplay dpy,
2045     VAImageID image,
2046     VASubpictureID *subpicture  /* out */
2047 );
2048
2049 /*
2050  * Destroy the subpicture before destroying the image it is assocated to
2051  */
2052 VAStatus vaDestroySubpicture (
2053     VADisplay dpy,
2054     VASubpictureID subpicture
2055 );
2056
2057 /* 
2058  * Bind an image to the subpicture. This image will now be associated with 
2059  * the subpicture instead of the one at creation.
2060  */
2061 VAStatus vaSetSubpictureImage (
2062     VADisplay dpy,
2063     VASubpictureID subpicture,
2064     VAImageID image
2065 );
2066
2067 /*
2068  * If chromakey is enabled, then the area where the source value falls within
2069  * the chromakey [min, max] range is transparent
2070  * The chromakey component format is the following:
2071  *  For RGB: [0:7] Red [8:15] Blue [16:23] Green   
2072  *  For YUV: [0:7] V [8:15] U [16:23] Y
2073  * The chromakey mask can be used to mask out certain components for chromakey
2074  * comparision
2075  */
2076 VAStatus vaSetSubpictureChromakey (
2077     VADisplay dpy,
2078     VASubpictureID subpicture,
2079     unsigned int chromakey_min,
2080     unsigned int chromakey_max,
2081     unsigned int chromakey_mask
2082 );
2083
2084 /*
2085  * Global alpha value is between 0 and 1. A value of 1 means fully opaque and 
2086  * a value of 0 means fully transparent. If per-pixel alpha is also specified then
2087  * the overall alpha is per-pixel alpha multiplied by the global alpha
2088  */
2089 VAStatus vaSetSubpictureGlobalAlpha (
2090     VADisplay dpy,
2091     VASubpictureID subpicture,
2092     float global_alpha 
2093 );
2094
2095 /*
2096  * vaAssociateSubpicture associates the subpicture with target_surfaces.
2097  * It defines the region mapping between the subpicture and the target  
2098  * surfaces through source and destination rectangles (with the same width and height).
2099  * Both will be displayed at the next call to vaPutSurface.  Additional
2100  * associations before the call to vaPutSurface simply overrides the association.
2101  */
2102 VAStatus vaAssociateSubpicture (
2103     VADisplay dpy,
2104     VASubpictureID subpicture,
2105     VASurfaceID *target_surfaces,
2106     int num_surfaces,
2107     short src_x, /* upper left offset in subpicture */
2108     short src_y,
2109     unsigned short src_width,
2110     unsigned short src_height,
2111     short dest_x, /* upper left offset in surface */
2112     short dest_y,
2113     unsigned short dest_width,
2114     unsigned short dest_height,
2115     /*
2116      * whether to enable chroma-keying, global-alpha, or screen relative mode
2117      * see VA_SUBPICTURE_XXX values
2118      */
2119     unsigned int flags
2120 );
2121
2122 /*
2123  * vaDeassociateSubpicture removes the association of the subpicture with target_surfaces.
2124  */
2125 VAStatus vaDeassociateSubpicture (
2126     VADisplay dpy,
2127     VASubpictureID subpicture,
2128     VASurfaceID *target_surfaces,
2129     int num_surfaces
2130 );
2131
2132 typedef struct _VARectangle
2133 {
2134     short x;
2135     short y;
2136     unsigned short width;
2137     unsigned short height;
2138 } VARectangle;
2139
2140 /*
2141  * Display attributes
2142  * Display attributes are used to control things such as contrast, hue, saturation,
2143  * brightness etc. in the rendering process.  The application can query what
2144  * attributes are supported by the driver, and then set the appropriate attributes
2145  * before calling vaPutSurface()
2146  */
2147 /* PowerVR IEP Lite attributes */
2148 typedef enum
2149 {
2150     VADISPLAYATTRIB_BLE_OFF              = 0x00,
2151     VADISPLAYATTRIB_BLE_LOW,
2152     VADISPLAYATTRIB_BLE_MEDIUM,
2153     VADISPLAYATTRIB_BLE_HIGH,
2154     VADISPLAYATTRIB_BLE_NONE,
2155 } VADisplayAttribBLEMode;
2156
2157 /* attribute value for VADisplayAttribRotation   */
2158 #define VA_ROTATION_NONE        0x00000000
2159 #define VA_ROTATION_90          0x00000001
2160 #define VA_ROTATION_180         0x00000002
2161 #define VA_ROTATION_270         0x00000003
2162
2163 /* attribute value for VADisplayAttribOutOfLoopDeblock */
2164 #define VA_OOL_DEBLOCKING_FALSE 0x00000000
2165 #define VA_OOL_DEBLOCKING_TRUE  0x00000001
2166
2167 /* Render mode */
2168 #define VA_RENDER_MODE_UNDEFINED           0
2169 #define VA_RENDER_MODE_LOCAL_OVERLAY       1
2170 #define VA_RENDER_MODE_LOCAL_GPU           2
2171 #define VA_RENDER_MODE_EXTERNAL_OVERLAY    4
2172 #define VA_RENDER_MODE_EXTERNAL_GPU        8
2173
2174 /* Render device */
2175 #define VA_RENDER_DEVICE_UNDEFINED  0
2176 #define VA_RENDER_DEVICE_LOCAL      1
2177 #define VA_RENDER_DEVICE_EXTERNAL   2
2178
2179 /* Currently defined display attribute types */
2180 typedef enum
2181 {
2182     VADisplayAttribBrightness           = 0,
2183     VADisplayAttribContrast             = 1,
2184     VADisplayAttribHue                  = 2,
2185     VADisplayAttribSaturation           = 3,
2186     /* client can specifiy a background color for the target window
2187      * the new feature of video conference,
2188      * the uncovered area of the surface is filled by this color
2189      * also it will blend with the decoded video color
2190      */
2191     VADisplayAttribBackgroundColor      = 4,
2192     /*
2193      * this is a gettable only attribute. For some implementations that use the
2194      * hardware overlay, after PutSurface is called, the surface can not be    
2195      * re-used until after the subsequent PutSurface call. If this is the case 
2196      * then the value for this attribute will be set to 1 so that the client   
2197      * will not attempt to re-use the surface right after returning from a call
2198      * to PutSurface.
2199      *
2200      * Don't use it, use flag VASurfaceDisplaying of vaQuerySurfaceStatus since
2201      * driver may use overlay or GPU alternatively
2202      */
2203     VADisplayAttribDirectSurface       = 5,
2204     VADisplayAttribRotation            = 6,     
2205     VADisplayAttribOutofLoopDeblock    = 7,
2206
2207     /* PowerVR IEP Lite specific attributes */
2208     VADisplayAttribBLEBlackMode        = 8,
2209     VADisplayAttribBLEWhiteMode        = 9,
2210     VADisplayAttribBlueStretch         = 10,
2211     VADisplayAttribSkinColorCorrection = 11,
2212     /*
2213      * For type VADisplayAttribCSCMatrix, "value" field is a pointer to the color
2214      * conversion matrix. Each element in the matrix is float-point
2215      */
2216     VADisplayAttribCSCMatrix           = 12,
2217     /* specify the constant color used to blend with video surface
2218      * Cd = Cv*Cc*Ac + Cb *(1 - Ac) C means the constant RGB
2219      *      d: the final color to overwrite into the frame buffer 
2220      *      v: decoded video after color conversion, 
2221      *      c: video color specified by VADisplayAttribBlendColor
2222      *      b: background color of the drawable
2223      */
2224     VADisplayAttribBlendColor          = 13,
2225     /*
2226      * Indicate driver to skip painting color key or not.
2227      * only applicable if the render is overlay
2228      */
2229     VADisplayAttribOverlayAutoPaintColorKey   = 14,
2230     /*
2231      * customized overlay color key, the format is RGB888
2232      * [23:16] = Red, [15:08] = Green, [07:00] = Blue.
2233      */
2234     VADisplayAttribOverlayColorKey      = 15,
2235     /*
2236      * The hint for the implementation of vaPutSurface
2237      * normally, the driver could use an overlay or GPU to render the surface on the screen
2238      * this flag provides APP the flexibity to switch the render dynamically
2239      */
2240     VADisplayAttribRenderMode           = 16,
2241     /*
2242      * specify if vaPutSurface needs to render into specified monitors
2243      * one example is that one external monitor (e.g. HDMI) is enabled, 
2244      * but the window manager is not aware of it, and there is no associated drawable
2245      */
2246     VADisplayAttribRenderDevice        = 17,
2247     /*
2248      * specify vaPutSurface render area if there is no drawable on the monitor
2249      */
2250     VADisplayAttribRenderRect          = 18,
2251 } VADisplayAttribType;
2252
2253 /* flags for VADisplayAttribute */
2254 #define VA_DISPLAY_ATTRIB_NOT_SUPPORTED 0x0000
2255 #define VA_DISPLAY_ATTRIB_GETTABLE      0x0001
2256 #define VA_DISPLAY_ATTRIB_SETTABLE      0x0002
2257
2258 typedef struct _VADisplayAttribute
2259 {
2260     VADisplayAttribType type;
2261     int min_value;
2262     int max_value;
2263     int value;  /* used by the set/get attribute functions */
2264 /* flags can be VA_DISPLAY_ATTRIB_GETTABLE or VA_DISPLAY_ATTRIB_SETTABLE or OR'd together */
2265     unsigned int flags;
2266 } VADisplayAttribute;
2267
2268 /* Get maximum number of display attributs supported by the implementation */
2269 int vaMaxNumDisplayAttributes (
2270     VADisplay dpy
2271 );
2272
2273 /* 
2274  * Query display attributes 
2275  * The caller must provide a "attr_list" array that can hold at
2276  * least vaMaxNumDisplayAttributes() entries. The actual number of attributes
2277  * returned in "attr_list" is returned in "num_attributes".
2278  */
2279 VAStatus vaQueryDisplayAttributes (
2280     VADisplay dpy,
2281     VADisplayAttribute *attr_list,      /* out */
2282     int *num_attributes                 /* out */
2283 );
2284
2285 /* 
2286  * Get display attributes 
2287  * This function returns the current attribute values in "attr_list".
2288  * Only attributes returned with VA_DISPLAY_ATTRIB_GETTABLE set in the "flags" field
2289  * from vaQueryDisplayAttributes() can have their values retrieved.  
2290  */
2291 VAStatus vaGetDisplayAttributes (
2292     VADisplay dpy,
2293     VADisplayAttribute *attr_list,      /* in/out */
2294     int num_attributes
2295 );
2296
2297 /* 
2298  * Set display attributes 
2299  * Only attributes returned with VA_DISPLAY_ATTRIB_SETTABLE set in the "flags" field
2300  * from vaQueryDisplayAttributes() can be set.  If the attribute is not settable or 
2301  * the value is out of range, the function returns VA_STATUS_ERROR_ATTR_NOT_SUPPORTED
2302  */
2303 VAStatus vaSetDisplayAttributes (
2304     VADisplay dpy,
2305     VADisplayAttribute *attr_list,
2306     int num_attributes
2307 );
2308
2309 /**@}*/
2310
2311 #ifdef __cplusplus
2312 }
2313 #endif
2314
2315 #endif /* _VA_H_ */