OSDN Git Service

High Dynamic Range Tone Mapping: Add a new filter for input metadata and some comments.
[android-x86/hardware-intel-common-libva.git] / va / va_vpp.h
1 /*
2  * Copyright (c) 2007-2011 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 /**
26  * \file va_vpp.h
27  * \brief The video processing API
28  *
29  * This file contains the \ref api_vpp "Video processing API".
30  */
31
32 #ifndef VA_VPP_H
33 #define VA_VPP_H
34
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38
39 /**
40  * \defgroup api_vpp Video processing API
41  *
42  * @{
43  *
44  * The video processing API uses the same paradigm as for decoding:
45  * - Query for supported filters;
46  * - Set up a video processing pipeline;
47  * - Send video processing parameters through VA buffers.
48  *
49  * \section api_vpp_caps Query for supported filters
50  *
51  * Checking whether video processing is supported can be performed
52  * with vaQueryConfigEntrypoints() and the profile argument set to
53  * #VAProfileNone. If video processing is supported, then the list of
54  * returned entry-points will include #VAEntrypointVideoProc.
55  *
56  * \code
57  * VAEntrypoint *entrypoints;
58  * int i, num_entrypoints, supportsVideoProcessing = 0;
59  *
60  * num_entrypoints = vaMaxNumEntrypoints();
61  * entrypoints = malloc(num_entrypoints * sizeof(entrypoints[0]);
62  * vaQueryConfigEntrypoints(va_dpy, VAProfileNone,
63  *     entrypoints, &num_entrypoints);
64  *
65  * for (i = 0; !supportsVideoProcessing && i < num_entrypoints; i++) {
66  *     if (entrypoints[i] == VAEntrypointVideoProc)
67  *         supportsVideoProcessing = 1;
68  * }
69  * \endcode
70  *
71  * Then, the vaQueryVideoProcFilters() function is used to query the
72  * list of video processing filters.
73  *
74  * \code
75  * VAProcFilterType filters[VAProcFilterCount];
76  * unsigned int num_filters = VAProcFilterCount;
77  *
78  * // num_filters shall be initialized to the length of the array
79  * vaQueryVideoProcFilters(va_dpy, vpp_ctx, &filters, &num_filters);
80  * \endcode
81  *
82  * Finally, individual filter capabilities can be checked with
83  * vaQueryVideoProcFilterCaps().
84  *
85  * \code
86  * VAProcFilterCap denoise_caps;
87  * unsigned int num_denoise_caps = 1;
88  * vaQueryVideoProcFilterCaps(va_dpy, vpp_ctx,
89  *     VAProcFilterNoiseReduction,
90  *     &denoise_caps, &num_denoise_caps
91  * );
92  *
93  * VAProcFilterCapDeinterlacing deinterlacing_caps[VAProcDeinterlacingCount];
94  * unsigned int num_deinterlacing_caps = VAProcDeinterlacingCount;
95  * vaQueryVideoProcFilterCaps(va_dpy, vpp_ctx,
96  *     VAProcFilterDeinterlacing,
97  *     &deinterlacing_caps, &num_deinterlacing_caps
98  * );
99  * \endcode
100  *
101  * \section api_vpp_setup Set up a video processing pipeline
102  *
103  * A video processing pipeline buffer is created for each source
104  * surface we want to process. However, buffers holding filter
105  * parameters can be created once and for all. Rationale is to avoid
106  * multiple creation/destruction chains of filter buffers and also
107  * because filter parameters generally won't change frame after
108  * frame. e.g. this makes it possible to implement a checkerboard of
109  * videos where the same filters are applied to each video source.
110  *
111  * The general control flow is demonstrated by the following pseudo-code:
112  * \code
113  * // Create filters
114  * VABufferID denoise_filter, deint_filter;
115  * VABufferID filter_bufs[VAProcFilterCount];
116  * unsigned int num_filter_bufs;
117  *
118  * for (i = 0; i < num_filters; i++) {
119  *     switch (filters[i]) {
120  *     case VAProcFilterNoiseReduction: {       // Noise reduction filter
121  *         VAProcFilterParameterBuffer denoise;
122  *         denoise.type  = VAProcFilterNoiseReduction;
123  *         denoise.value = 0.5;
124  *         vaCreateBuffer(va_dpy, vpp_ctx,
125  *             VAProcFilterParameterBufferType, sizeof(denoise), 1,
126  *             &denoise, &denoise_filter
127  *         );
128  *         filter_bufs[num_filter_bufs++] = denoise_filter;
129  *         break;
130  *     }
131  *
132  *     case VAProcFilterDeinterlacing:          // Motion-adaptive deinterlacing
133  *         for (j = 0; j < num_deinterlacing_caps; j++) {
134  *             VAProcFilterCapDeinterlacing * const cap = &deinterlacing_caps[j];
135  *             if (cap->type != VAProcDeinterlacingMotionAdaptive)
136  *                 continue;
137  *
138  *             VAProcFilterParameterBufferDeinterlacing deint;
139  *             deint.type                   = VAProcFilterDeinterlacing;
140  *             deint.algorithm              = VAProcDeinterlacingMotionAdaptive;
141  *             vaCreateBuffer(va_dpy, vpp_ctx,
142  *                 VAProcFilterParameterBufferType, sizeof(deint), 1,
143  *                 &deint, &deint_filter
144  *             );
145  *             filter_bufs[num_filter_bufs++] = deint_filter;
146  *         }
147  *     }
148  * }
149  * \endcode
150  *
151  * Once the video processing pipeline is set up, the caller shall check the
152  * implied capabilities and requirements with vaQueryVideoProcPipelineCaps().
153  * This function can be used to validate the number of reference frames are
154  * needed by the specified deinterlacing algorithm, the supported color
155  * primaries, etc.
156  * \code
157  * // Create filters
158  * VAProcPipelineCaps pipeline_caps;
159  * VASurfaceID *forward_references;
160  * unsigned int num_forward_references;
161  * VASurfaceID *backward_references;
162  * unsigned int num_backward_references;
163  * VAProcColorStandardType in_color_standards[VAProcColorStandardCount];
164  * VAProcColorStandardType out_color_standards[VAProcColorStandardCount];
165  *
166  * pipeline_caps.input_color_standards      = NULL;
167  * pipeline_caps.num_input_color_standards  = ARRAY_ELEMS(in_color_standards);
168  * pipeline_caps.output_color_standards     = NULL;
169  * pipeline_caps.num_output_color_standards = ARRAY_ELEMS(out_color_standards);
170  * vaQueryVideoProcPipelineCaps(va_dpy, vpp_ctx,
171  *     filter_bufs, num_filter_bufs,
172  *     &pipeline_caps
173  * );
174  *
175  * num_forward_references  = pipeline_caps.num_forward_references;
176  * forward_references      =
177  *     malloc(num__forward_references * sizeof(VASurfaceID));
178  * num_backward_references = pipeline_caps.num_backward_references;
179  * backward_references     =
180  *     malloc(num_backward_references * sizeof(VASurfaceID));
181  * \endcode
182  *
183  * \section api_vpp_submit Send video processing parameters through VA buffers
184  *
185  * Video processing pipeline parameters are submitted for each source
186  * surface to process. Video filter parameters can also change, per-surface.
187  * e.g. the list of reference frames used for deinterlacing.
188  *
189  * \code
190  * foreach (iteration) {
191  *     vaBeginPicture(va_dpy, vpp_ctx, vpp_surface);
192  *     foreach (surface) {
193  *         VARectangle output_region;
194  *         VABufferID pipeline_buf;
195  *         VAProcPipelineParameterBuffer *pipeline_param;
196  *
197  *         vaCreateBuffer(va_dpy, vpp_ctx,
198  *             VAProcPipelineParameterBuffer, sizeof(*pipeline_param), 1,
199  *             NULL, &pipeline_buf
200  *         );
201  *
202  *         // Setup output region for this surface
203  *         // e.g. upper left corner for the first surface
204  *         output_region.x     = BORDER;
205  *         output_region.y     = BORDER;
206  *         output_region.width =
207  *             (vpp_surface_width - (Nx_surfaces + 1) * BORDER) / Nx_surfaces;
208  *         output_region.height =
209  *             (vpp_surface_height - (Ny_surfaces + 1) * BORDER) / Ny_surfaces;
210  *
211  *         vaMapBuffer(va_dpy, pipeline_buf, &pipeline_param);
212  *         pipeline_param->surface              = surface;
213  *         pipeline_param->surface_region       = NULL;
214  *         pipeline_param->output_region        = &output_region;
215  *         pipeline_param->output_background_color = 0;
216  *         if (first surface to render)
217  *             pipeline_param->output_background_color = 0xff000000; // black
218  *         pipeline_param->filter_flags         = VA_FILTER_SCALING_HQ;
219  *         pipeline_param->filters              = filter_bufs;
220  *         pipeline_param->num_filters          = num_filter_bufs;
221  *         vaUnmapBuffer(va_dpy, pipeline_buf);
222  *
223  *         // Update reference frames for deinterlacing, if necessary
224  *         pipeline_param->forward_references      = forward_references;
225  *         pipeline_param->num_forward_references  = num_forward_references_used;
226  *         pipeline_param->backward_references     = backward_references;
227  *         pipeline_param->num_backward_references = num_bacward_references_used;
228  *
229  *         // Apply filters
230  *         vaRenderPicture(va_dpy, vpp_ctx, &pipeline_buf, 1);
231  *     }
232  *     vaEndPicture(va_dpy, vpp_ctx);
233  * }
234  * \endcode
235  */
236
237 /** \brief Video filter types. */
238 typedef enum _VAProcFilterType {
239     VAProcFilterNone = 0,
240     /** \brief Noise reduction filter. */
241     VAProcFilterNoiseReduction,
242     /** \brief Deinterlacing filter. */
243     VAProcFilterDeinterlacing,
244     /** \brief Sharpening filter. */
245     VAProcFilterSharpening,
246     /** \brief Color balance parameters. */
247     VAProcFilterColorBalance,
248     /** \brief Skin Tone Enhancement. */
249     VAProcFilterSkinToneEnhancement,
250     /** \brief Total Color Correction. */
251     VAProcFilterTotalColorCorrection,
252     /** \brief Human Vision System(HVS) Noise reduction filter. */
253     VAProcFilterHVSNoiseReduction,
254     /** \brief High Dynamic Range Tone Mapping. */
255     VAProcFilterHighDynamicRangeToneMapping,
256     /** \brief Number of video filters. */
257     VAProcFilterCount
258 } VAProcFilterType;
259
260 /** \brief Deinterlacing types. */
261 typedef enum _VAProcDeinterlacingType {
262     VAProcDeinterlacingNone = 0,
263     /** \brief Bob deinterlacing algorithm. */
264     VAProcDeinterlacingBob,
265     /** \brief Weave deinterlacing algorithm. */
266     VAProcDeinterlacingWeave,
267     /** \brief Motion adaptive deinterlacing algorithm. */
268     VAProcDeinterlacingMotionAdaptive,
269     /** \brief Motion compensated deinterlacing algorithm. */
270     VAProcDeinterlacingMotionCompensated,
271     /** \brief Number of deinterlacing algorithms. */
272     VAProcDeinterlacingCount
273 } VAProcDeinterlacingType;
274
275 /** \brief Color balance types. */
276 typedef enum _VAProcColorBalanceType {
277     VAProcColorBalanceNone = 0,
278     /** \brief Hue. */
279     VAProcColorBalanceHue,
280     /** \brief Saturation. */
281     VAProcColorBalanceSaturation,
282     /** \brief Brightness. */
283     VAProcColorBalanceBrightness,
284     /** \brief Contrast. */
285     VAProcColorBalanceContrast,
286     /** \brief Automatically adjusted saturation. */
287     VAProcColorBalanceAutoSaturation,
288     /** \brief Automatically adjusted brightness. */
289     VAProcColorBalanceAutoBrightness,
290     /** \brief Automatically adjusted contrast. */
291     VAProcColorBalanceAutoContrast,
292     /** \brief Number of color balance attributes. */
293     VAProcColorBalanceCount
294 } VAProcColorBalanceType;
295
296 /** \brief Color standard types.
297  *
298  * These define a set of color properties corresponding to particular
299  * video standards.
300  *
301  * Where matrix_coefficients is specified, it applies only to YUV data -
302  * RGB data always use the identity matrix (matrix_coefficients = 0).
303  */
304 typedef enum _VAProcColorStandardType {
305     VAProcColorStandardNone = 0,
306     /** \brief ITU-R BT.601.
307      *
308      * It is unspecified whether this will use 525-line or 625-line values;
309      * specify the colour primaries and matrix coefficients explicitly if
310      * it is known which one is required.
311      *
312      * Equivalent to:
313      *   colour_primaries = 5 or 6
314      *   transfer_characteristics = 6
315      *   matrix_coefficients = 5 or 6
316      */
317     VAProcColorStandardBT601,
318     /** \brief ITU-R BT.709.
319      *
320      * Equivalent to:
321      *   colour_primaries = 1
322      *   transfer_characteristics = 1
323      *   matrix_coefficients = 1
324      */
325     VAProcColorStandardBT709,
326     /** \brief ITU-R BT.470-2 System M.
327      *
328      * Equivalent to:
329      *   colour_primaries = 4
330      *   transfer_characteristics = 4
331      *   matrix_coefficients = 4
332      */
333     VAProcColorStandardBT470M,
334     /** \brief ITU-R BT.470-2 System B, G.
335      *
336      * Equivalent to:
337      *   colour_primaries = 5
338      *   transfer_characteristics = 5
339      *   matrix_coefficients = 5
340      */
341     VAProcColorStandardBT470BG,
342     /** \brief SMPTE-170M.
343      *
344      * Equivalent to:
345      *   colour_primaries = 6
346      *   transfer_characteristics = 6
347      *   matrix_coefficients = 6
348      */
349     VAProcColorStandardSMPTE170M,
350     /** \brief SMPTE-240M.
351      *
352      * Equivalent to:
353      *   colour_primaries = 7
354      *   transfer_characteristics = 7
355      *   matrix_coefficients = 7
356      */
357     VAProcColorStandardSMPTE240M,
358     /** \brief Generic film.
359      *
360      * Equivalent to:
361      *   colour_primaries = 8
362      *   transfer_characteristics = 1
363      *   matrix_coefficients = 1
364      */
365     VAProcColorStandardGenericFilm,
366     /** \brief sRGB.
367      *
368      * Equivalent to:
369      *   colour_primaries = 1
370      *   transfer_characteristics = 13
371      *   matrix_coefficients = 0
372      */
373     VAProcColorStandardSRGB,
374     /** \brief stRGB.
375      *
376      * ???
377      */
378     VAProcColorStandardSTRGB,
379     /** \brief xvYCC601.
380      *
381      * Equivalent to:
382      *   colour_primaries = 1
383      *   transfer_characteristics = 11
384      *   matrix_coefficients = 5
385      */
386     VAProcColorStandardXVYCC601,
387     /** \brief xvYCC709.
388      *
389      * Equivalent to:
390      *   colour_primaries = 1
391      *   transfer_characteristics = 11
392      *   matrix_coefficients = 1
393      */
394     VAProcColorStandardXVYCC709,
395     /** \brief ITU-R BT.2020.
396      *
397      * Equivalent to:
398      *   colour_primaries = 9
399      *   transfer_characteristics = 14
400      *   matrix_coefficients = 9
401      */
402     VAProcColorStandardBT2020,
403     /** \brief Explicitly specified color properties.
404      *
405      * Use corresponding color properties section.
406      * For example, HDR10 content:
407      *   colour_primaries = 9 (BT2020)
408      *   transfer_characteristics = 16 (SMPTE ST2084)
409      *   matrix_coefficients = 9
410      */
411     VAProcColorStandardExplicit,
412     /** \brief Number of color standards. */
413     VAProcColorStandardCount
414 } VAProcColorStandardType;
415
416 /** \brief Total color correction types. */
417 typedef enum _VAProcTotalColorCorrectionType {
418     VAProcTotalColorCorrectionNone = 0,
419     /** \brief Red Saturation. */
420     VAProcTotalColorCorrectionRed,
421     /** \brief Green Saturation. */
422     VAProcTotalColorCorrectionGreen,
423     /** \brief Blue Saturation. */
424     VAProcTotalColorCorrectionBlue,
425     /** \brief Cyan Saturation. */
426     VAProcTotalColorCorrectionCyan,
427     /** \brief Magenta Saturation. */
428     VAProcTotalColorCorrectionMagenta,
429     /** \brief Yellow Saturation. */
430     VAProcTotalColorCorrectionYellow,
431     /** \brief Number of color correction attributes. */
432     VAProcTotalColorCorrectionCount
433 } VAProcTotalColorCorrectionType;
434
435 /** \brief High Dynamic Range Metadata types. */
436 typedef enum _VAProcHighDynamicRangeMetadataType {
437     VAProcHighDynamicRangeMetadataNone = 0,
438     /** \brief Metadata type for HDR10. */
439     VAProcHighDynamicRangeMetadataHDR10,
440     /** \brief Number of Metadata type. */
441     VAProcHighDynamicRangeMetadataTypeCount
442 } VAProcHighDynamicRangeMetadataType;
443
444 /** \brief Video Processing Mode. */
445 typedef enum _VAProcMode {
446     /**
447      * \brief Default Mode.
448      * In this mode, pipeline is decided in driver to the appropriate mode.
449      * e.g. a mode that's a balance between power and performance.
450      */
451     VAProcDefaultMode = 0,
452     /**
453      * \brief Power Saving Mode.
454      * In this mode, pipeline is optimized for power saving.
455      */
456     VAProcPowerSavingMode,
457     /**
458      * \brief Performance Mode.
459      * In this mode, pipeline is optimized for performance.
460      */
461     VAProcPerformanceMode
462 } VAProcMode;
463
464 /** @name Video blending flags */
465 /**@{*/
466 /** \brief Global alpha blending. */
467 #define VA_BLEND_GLOBAL_ALPHA           0x0001
468 /** \brief Premultiplied alpha blending (RGBA surfaces only). */
469 #define VA_BLEND_PREMULTIPLIED_ALPHA    0x0002
470 /** \brief Luma color key (YUV surfaces only). */
471 #define VA_BLEND_LUMA_KEY               0x0010
472 /**@}*/
473
474 /** \brief Video blending state definition. */
475 typedef struct _VABlendState {
476     /** \brief Video blending flags. */
477     unsigned int        flags;
478     /**
479      * \brief Global alpha value.
480      *
481      * Valid if \flags has VA_BLEND_GLOBAL_ALPHA.
482      * Valid range is 0.0 to 1.0 inclusive.
483      */
484     float               global_alpha;
485     /**
486      * \brief Minimum luma value.
487      *
488      * Valid if \flags has VA_BLEND_LUMA_KEY.
489      * Valid range is 0.0 to 1.0 inclusive.
490      * \ref min_luma shall be set to a sensible value lower than \ref max_luma.
491      */
492     float               min_luma;
493     /**
494      * \brief Maximum luma value.
495      *
496      * Valid if \flags has VA_BLEND_LUMA_KEY.
497      * Valid range is 0.0 to 1.0 inclusive.
498      * \ref max_luma shall be set to a sensible value larger than \ref min_luma.
499      */
500     float               max_luma;
501 } VABlendState;
502
503 /** @name Video pipeline flags */
504 /**@{*/
505 /** \brief Specifies whether to apply subpictures when processing a surface. */
506 #define VA_PROC_PIPELINE_SUBPICTURES    0x00000001
507 /**
508  * \brief Specifies whether to apply power or performance
509  * optimizations to a pipeline.
510  *
511  * When processing several surfaces, it may be necessary to prioritize
512  * more certain pipelines than others. This flag is only a hint to the
513  * video processor so that it can omit certain filters to save power
514  * for example. Typically, this flag could be used with video surfaces
515  * decoded from a secondary bitstream.
516  */
517 #define VA_PROC_PIPELINE_FAST           0x00000002
518 /**@}*/
519
520 /** @name Video filter flags */
521 /**@{*/
522 /** \brief Specifies whether the filter shall be present in the pipeline. */
523 #define VA_PROC_FILTER_MANDATORY        0x00000001
524 /**@}*/
525
526 /** @name Pipeline end flags */
527 /**@{*/
528 /** \brief Specifies the pipeline is the last. */
529 #define VA_PIPELINE_FLAG_END            0x00000004
530 /**@}*/
531
532 /** @name Chroma Siting flag */
533 /**@{*/
534 /** vertical chroma sitting take bit 0-1, horizontal chroma sitting take bit 2-3
535  * vertical chromma siting | horizontal chroma sitting to be chroma sitting */
536 #define VA_CHROMA_SITING_UNKNOWN              0x00
537 /** \brief Chroma samples are co-sited vertically on the top with the luma samples. */
538 #define VA_CHROMA_SITING_VERTICAL_TOP         0x01
539 /** \brief Chroma samples are not co-sited vertically with the luma samples. */
540 #define VA_CHROMA_SITING_VERTICAL_CENTER      0x02
541 /** \brief Chroma samples are co-sited vertically on the bottom with the luma samples. */
542 #define VA_CHROMA_SITING_VERTICAL_BOTTOM      0x03
543 /** \brief Chroma samples are co-sited horizontally on the left with the luma samples. */
544 #define VA_CHROMA_SITING_HORIZONTAL_LEFT      0x04
545 /** \brief Chroma samples are not co-sited horizontally with the luma samples. */
546 #define VA_CHROMA_SITING_HORIZONTAL_CENTER    0x08
547 /**@}*/
548
549 /**
550  * This is to indicate that the color-space conversion uses full range or reduced range.
551  * VA_SOURCE_RANGE_FULL(Full range): Y/Cb/Cr is in [0, 255]. It is mainly used
552  *      for JPEG/JFIF formats. The combination with the BT601 flag means that
553  *      JPEG/JFIF color-space conversion matrix is used.
554  * VA_SOURCE_RANGE_REDUCED(Reduced range): Y is in [16, 235] and Cb/Cr is in [16, 240].
555  *      It is mainly used for the YUV->RGB color-space conversion in SDTV/HDTV/UHDTV.
556  */
557 #define VA_SOURCE_RANGE_UNKNOWN         0
558 #define VA_SOURCE_RANGE_REDUCED         1
559 #define VA_SOURCE_RANGE_FULL            2
560
561 /** @name Tone Mapping flags multiple HDR mode*/
562 /**@{*/
563 /** \brief Tone Mapping from HDR content to HDR display. */
564 #define VA_TONE_MAPPING_HDR_TO_HDR      0x0001
565 /** \brief Tone Mapping from HDR content to SDR display. */
566 #define VA_TONE_MAPPING_HDR_TO_SDR      0x0002
567 /** \brief Tone Mapping from HDR content to EDR display. */
568 #define VA_TONE_MAPPING_HDR_TO_EDR      0x0004
569 /** \brief Tone Mapping from SDR content to HDR display. */
570 #define VA_TONE_MAPPING_SDR_TO_HDR      0x0008
571 /**@}*/
572
573 /** \brief Video processing pipeline capabilities. */
574 typedef struct _VAProcPipelineCaps {
575     /** \brief Pipeline flags. See VAProcPipelineParameterBuffer::pipeline_flags. */
576     uint32_t        pipeline_flags;
577     /** \brief Extra filter flags. See VAProcPipelineParameterBuffer::filter_flags. */
578     uint32_t        filter_flags;
579     /** \brief Number of forward reference frames that are needed. */
580     uint32_t        num_forward_references;
581     /** \brief Number of backward reference frames that are needed. */
582     uint32_t        num_backward_references;
583     /** \brief List of color standards supported on input. */
584     VAProcColorStandardType *input_color_standards;
585     /** \brief Number of elements in \ref input_color_standards array. */
586     uint32_t        num_input_color_standards;
587     /** \brief List of color standards supported on output. */
588     VAProcColorStandardType *output_color_standards;
589     /** \brief Number of elements in \ref output_color_standards array. */
590     uint32_t        num_output_color_standards;
591
592     /**
593      * \brief Rotation flags.
594      *
595      * For each rotation angle supported by the underlying hardware,
596      * the corresponding bit is set in \ref rotation_flags. See
597      * "Rotation angles" for a description of rotation angles.
598      *
599      * A value of 0 means the underlying hardware does not support any
600      * rotation. Otherwise, a check for a specific rotation angle can be
601      * performed as follows:
602      *
603      * \code
604      * VAProcPipelineCaps pipeline_caps;
605      * ...
606      * vaQueryVideoProcPipelineCaps(va_dpy, vpp_ctx,
607      *     filter_bufs, num_filter_bufs,
608      *     &pipeline_caps
609      * );
610      * ...
611      * if (pipeline_caps.rotation_flags & (1 << VA_ROTATION_xxx)) {
612      *     // Clockwise rotation by xxx degrees is supported
613      *     ...
614      * }
615      * \endcode
616      */
617     uint32_t        rotation_flags;
618     /** \brief Blend flags. See "Video blending flags". */
619     uint32_t        blend_flags;
620     /**
621      * \brief Mirroring flags.
622      *
623      * For each mirroring direction supported by the underlying hardware,
624      * the corresponding bit is set in \ref mirror_flags. See
625      * "Mirroring directions" for a description of mirroring directions.
626      *
627      */
628     uint32_t        mirror_flags;
629     /** \brief Number of additional output surfaces supported by the pipeline  */
630     uint32_t        num_additional_outputs;
631
632     /** \brief Number of elements in \ref input_pixel_format array. */
633     uint32_t        num_input_pixel_formats;
634     /** \brief List of input pixel formats in fourcc. */
635     uint32_t        *input_pixel_format;
636     /** \brief Number of elements in \ref output_pixel_format array. */
637     uint32_t        num_output_pixel_formats;
638     /** \brief List of output pixel formats in fourcc. */
639     uint32_t        *output_pixel_format;
640
641     /** \brief Max supported input width in pixels. */
642     uint32_t        max_input_width;
643     /** \brief Max supported input height in pixels. */
644     uint32_t        max_input_height;
645     /** \brief Min supported input width in pixels. */
646     uint32_t        min_input_width;
647     /** \brief Min supported input height in pixels. */
648     uint32_t        min_input_height;
649
650     /** \brief Max supported output width in pixels. */
651     uint32_t        max_output_width;
652     /** \brief Max supported output height in pixels. */
653     uint32_t        max_output_height;
654     /** \brief Min supported output width in pixels. */
655     uint32_t        min_output_width;
656     /** \brief Min supported output height in pixels. */
657     uint32_t        min_output_height;
658     /** \brief Reserved bytes for future use, must be zero */
659     #if defined(__AMD64__) || defined(__x86_64__) || defined(__amd64__) || defined(__LP64__)
660     uint32_t        va_reserved[VA_PADDING_HIGH - 2];
661     #else
662     uint32_t        va_reserved[VA_PADDING_HIGH];
663     #endif
664 } VAProcPipelineCaps;
665
666 /** \brief Specification of values supported by the filter. */
667 typedef struct _VAProcFilterValueRange {
668     /** \brief Minimum value supported, inclusive. */
669     float               min_value;
670     /** \brief Maximum value supported, inclusive. */
671     float               max_value;
672     /** \brief Default value. */
673     float               default_value;
674     /** \brief Step value that alters the filter behaviour in a sensible way. */
675     float               step;
676
677     /** \brief Reserved bytes for future use, must be zero */
678     uint32_t            va_reserved[VA_PADDING_LOW];
679 } VAProcFilterValueRange;
680
681 typedef struct _VAProcColorProperties {
682     /** Chroma sample location.\c VA_CHROMA_SITING_VERTICAL_XXX | VA_CHROMA_SITING_HORIZONTAL_XXX */
683     uint8_t chroma_sample_location;
684     /** Chroma sample location. \c VA_SOURCE_RANGE_XXX*/
685     uint8_t color_range;
686     /** Colour primaries.
687      *
688      * See ISO/IEC 23001-8 or ITU H.273, section 8.1 and table 2.
689      * Only used if the color standard in use is \c VAColorStandardExplicit.
690      */
691     uint8_t colour_primaries;
692     /** Transfer characteristics.
693      *
694      * See ISO/IEC 23001-8 or ITU H.273, section 8.2 and table 3.
695      * Only used if the color standard in use is \c VAColorStandardExplicit.
696      */
697     uint8_t transfer_characteristics;
698     /** Matrix coefficients.
699      *
700      * See ISO/IEC 23001-8 or ITU H.273, section 8.3 and table 4.
701      * Only used if the color standard in use is \c VAColorStandardExplicit.
702      */
703     uint8_t matrix_coefficients;
704     /** Reserved bytes for future use, must be zero. */
705     uint8_t reserved[3];
706 } VAProcColorProperties;
707
708 /** \berief Describes High Dynamic Range Meta Data for HDR10.
709  *
710  *  Specifies the colour volume(the colour primaries, white point and luminance range) of
711  *  a display considered to be the mastering display for the associated video content -e.g.,
712  *  the colour volume of a display that was used for viewing while authoring the video content.
713  *  See ITU-T H.265 D.3.27 Mastering display colour volume SEI message semantics.
714  *
715  *  Specifies upper bounds for the nominal light level of the content. See ITU-T H.265 D.3.35
716  *  Content light level information SEI message semantics.
717  *
718  *  This structure can be used to indicate the HDR10 metadata for 1) the content which was authored;
719  *  2) the display on which the content will be presented. If it is for display, max_content_light_level
720  *  and max_pic_average_light_level are ignored.
721  */
722 typedef struct _VAHdrMetaDataHDR10
723 {
724     /**
725      * \brief X chromaticity coordinate of the mastering display.
726      *
727      * Index value c equal to 0 should correspond to the green primary.
728      * Index value c equal to 1 should correspond to the blue primary.
729      * Index value c equal to 2 should correspond to the red primary.
730      * The value for display_primaries_x shall be in the range of 0 to 50000 inclusive.
731      */
732     uint16_t    display_primaries_x[3];
733     /**
734      * \brief Y chromaticity coordinate of the mastering display.
735      *
736      * Index value c equal to 0 should correspond to the green primary.
737      * Index value c equal to 1 should correspond to the blue primary.
738      * Index value c equal to 2 should correspond to the red primary.
739      * The value for display_primaries_y shall be in the range of 0 to 50000 inclusive.
740      */
741     uint16_t    display_primaries_y[3];
742     /**
743      * \brief X chromaticity coordinate of the white point of the mastering display.
744      *
745      * The value for white_point_x shall be in the range of 0 to 50000 inclusive.
746      */
747     uint16_t    white_point_x;
748     /**
749      * \brief Y chromaticity coordinate of the white point of the mastering display.
750      *
751      * The value for white_point_y shall be in the range of 0 to 50000 inclusive.
752      */
753     uint16_t    white_point_y;
754     /**
755      * \brief The maximum display luminance of the mastering display.
756      *
757      * The value is in units of 0.0001 candelas per square metre.
758      */
759     uint32_t    max_display_mastering_luminance;
760     /**
761      * \brief The minumum display luminance of the mastering display.
762      *
763      * The value is in units of 0.0001 candelas per square metre.
764      */
765     uint32_t    min_display_mastering_luminance;
766     /**
767      * \brief The maximum content light level.
768      *
769      * The value is in units of 0.0001 candelas per square metre.
770      */
771     uint16_t    max_content_light_level;
772     /**
773      * \brief The maximum picture average light level.
774      *
775      * The value is in units of 0.0001 candelas per square metre.
776      */
777     uint16_t    max_pic_average_light_level;
778     /** Resevered */
779     uint16_t    reserved[VA_PADDING_HIGH];
780 } VAHdrMetaDataHDR10;
781
782 /** \brief Capabilities specification for the High Dynamic Range filter. */
783 typedef struct _VAProcFilterCapHighDynamicRange {
784     /** \brief high dynamic range type. */
785     VAProcHighDynamicRangeMetadataType     metadata_type;
786     /**
787      * \brief flag for high dynamic range tone mapping
788      *
789      * The flag is the combination of VA_TONE_MAPPING_XXX_TO_XXX.
790      * It could be VA_TONE_MAPPING_HDR_TO_HDR | VA_TONE_MAPPING_HDR_TO_SDR.
791      * SDR content to SDR display is always supported by default since it is legacy path.
792      */
793     uint16_t                               caps_flag;
794     /** \brief Reserved bytes for future use, must be zero */
795     uint16_t                               va_reserved[VA_PADDING_HIGH];
796 } VAProcFilterCapHighDynamicRange;
797
798 /** \brief High Dynamic Range Meta Data. */
799 typedef struct _VAHdrMetaData
800 {
801     /** \brief high dynamic range metadata type, HDR10 etc. */
802     VAProcHighDynamicRangeMetadataType       metadata_type;
803     /**
804      *  \brief Pointer to high dynamic range metadata.
805      *
806      *  The pointer could point to VAHdrMetaDataHDR10 or other HDR meta data.
807      */
808     void*                                    metadata;
809     /**
810      *  \brief Size of high dynamic range metadata.
811      */
812     uint32_t                                 metadata_size;
813     /** \brief Reserved bytes for future use, must be zero */
814     uint32_t                                 reserved[VA_PADDING_LOW];
815 } VAHdrMetaData;
816
817 /**
818  * \brief Video processing pipeline configuration.
819  *
820  * This buffer defines a video processing pipeline. The actual filters to
821  * be applied are provided in the \c filters field, they can be re-used
822  * in other processing pipelines.
823  *
824  * The target surface is specified by the \c render_target argument of
825  * \c vaBeginPicture(). The general usage model is described as follows:
826  * - \c vaBeginPicture(): specify the target surface that receives the
827  *   processed output;
828  * - \c vaRenderPicture(): specify a surface to be processed and composed
829  *   into the \c render_target. Use as many \c vaRenderPicture() calls as
830  *   necessary surfaces to compose ;
831  * - \c vaEndPicture(): tell the driver to start processing the surfaces
832  *   with the requested filters.
833  *
834  * If a filter (e.g. noise reduction) needs to be applied with different
835  * values for multiple surfaces, the application needs to create as many
836  * filter parameter buffers as necessary. i.e. the filter parameters shall
837  * not change between two calls to \c vaRenderPicture().
838  *
839  * For composition usage models, the first surface to process will generally
840  * use an opaque background color, i.e. \c output_background_color set with
841  * the most significant byte set to \c 0xff. For instance, \c 0xff000000 for
842  * a black background. Then, subsequent surfaces would use a transparent
843  * background color.
844  */
845 typedef struct _VAProcPipelineParameterBuffer {
846     /**
847      * \brief Source surface ID.
848      *
849      * ID of the source surface to process. If subpictures are associated
850      * with the video surfaces then they shall be rendered to the target
851      * surface, if the #VA_PROC_PIPELINE_SUBPICTURES pipeline flag is set.
852      */
853     VASurfaceID         surface;
854     /**
855      * \brief Region within the source surface to be processed.
856      *
857      * Pointer to a #VARectangle defining the region within the source
858      * surface to be processed. If NULL, \c surface_region implies the
859      * whole surface.
860      */
861     const VARectangle  *surface_region;
862     /**
863      * \brief Requested input color standard.
864      *
865      * Color properties are implicitly converted throughout the processing
866      * pipeline. The video processor chooses the best moment to apply
867      * this conversion. The set of supported color standards for input shall
868      * be queried with vaQueryVideoProcPipelineCaps().
869      *
870      * If this is set to VAProcColorStandardExplicit, the color properties
871      * are specified explicitly in surface_color_properties instead.
872      */
873     VAProcColorStandardType surface_color_standard;
874     /**
875      * \brief Region within the output surface.
876      *
877      * Pointer to a #VARectangle defining the region within the output
878      * surface that receives the processed pixels. If NULL, \c output_region
879      * implies the whole surface.
880      *
881      * Note that any pixels residing outside the specified region will
882      * be filled in with the \ref output_background_color.
883      */
884     const VARectangle  *output_region;
885     /**
886      * \brief Background color.
887      *
888      * Background color used to fill in pixels that reside outside of the
889      * specified \ref output_region. The color is specified in ARGB format:
890      * [31:24] alpha, [23:16] red, [15:8] green, [7:0] blue.
891      *
892      * Unless the alpha value is zero or the \ref output_region represents
893      * the whole target surface size, implementations shall not render the
894      * source surface to the target surface directly. Rather, in order to
895      * maintain the exact semantics of \ref output_background_color, the
896      * driver shall use a temporary surface and fill it in with the
897      * appropriate background color. Next, the driver will blend this
898      * temporary surface into the target surface.
899      */
900     uint32_t        output_background_color;
901     /**
902      * \brief Requested output color standard.
903      *
904      * If this is set to VAProcColorStandardExplicit, the color properties
905      * are specified explicitly in output_color_properties instead.
906      */
907     VAProcColorStandardType output_color_standard;
908     /**
909      * \brief Pipeline filters. See video pipeline flags.
910      *
911      * Flags to control the pipeline, like whether to apply subpictures
912      * or not, notify the driver that it can opt for power optimizations,
913      * should this be needed.
914      */
915     uint32_t        pipeline_flags;
916     /**
917      * \brief Extra filter flags. See vaPutSurface() flags.
918      *
919      * Filter flags are used as a fast path, wherever possible, to use
920      * vaPutSurface() flags instead of explicit filter parameter buffers.
921      *
922      * Allowed filter flags API-wise. Use vaQueryVideoProcPipelineCaps()
923      * to check for implementation details:
924      * - Bob-deinterlacing: \c VA_FRAME_PICTURE, \c VA_TOP_FIELD,
925      *   \c VA_BOTTOM_FIELD. Note that any deinterlacing filter
926      *   (#VAProcFilterDeinterlacing) will override those flags.
927      * - Color space conversion: \c VA_SRC_BT601, \c VA_SRC_BT709,
928      *   \c VA_SRC_SMPTE_240.
929      * - Scaling: \c VA_FILTER_SCALING_DEFAULT, \c VA_FILTER_SCALING_FAST,
930      *   \c VA_FILTER_SCALING_HQ, \c VA_FILTER_SCALING_NL_ANAMORPHIC.
931      */
932     uint32_t        filter_flags;
933     /**
934      * \brief Array of filters to apply to the surface.
935      *
936      * The list of filters shall be ordered in the same way the driver expects
937      * them. i.e. as was returned from vaQueryVideoProcFilters().
938      * Otherwise, a #VA_STATUS_ERROR_INVALID_FILTER_CHAIN is returned
939      * from vaRenderPicture() with this buffer.
940      *
941      * #VA_STATUS_ERROR_UNSUPPORTED_FILTER is returned if the list
942      * contains an unsupported filter.
943      *
944      */
945     VABufferID         *filters;
946     /** \brief Actual number of filters. */
947     uint32_t           num_filters;
948     /** \brief Array of forward reference frames. */
949     VASurfaceID        *forward_references;
950     /** \brief Number of forward reference frames that were supplied. */
951     uint32_t           num_forward_references;
952     /** \brief Array of backward reference frames. */
953     VASurfaceID        *backward_references;
954     /** \brief Number of backward reference frames that were supplied. */
955     uint32_t           num_backward_references;
956     /**
957      * \brief Rotation state. See rotation angles.
958      *
959      * The rotation angle is clockwise. There is no specific rotation
960      * center for this operation. Rather, The source \ref surface is
961      * first rotated by the specified angle and then scaled to fit the
962      * \ref output_region.
963      *
964      * This means that the top-left hand corner (0,0) of the output
965      * (rotated) surface is expressed as follows:
966      * - \ref VA_ROTATION_NONE: (0,0) is the top left corner of the
967      *   source surface -- no rotation is performed ;
968      * - \ref VA_ROTATION_90: (0,0) is the bottom-left corner of the
969      *   source surface ;
970      * - \ref VA_ROTATION_180: (0,0) is the bottom-right corner of the
971      *   source surface -- the surface is flipped around the X axis ;
972      * - \ref VA_ROTATION_270: (0,0) is the top-right corner of the
973      *   source surface.
974      *
975      * Check VAProcPipelineCaps::rotation_flags first prior to
976      * defining a specific rotation angle. Otherwise, the hardware can
977      * perfectly ignore this variable if it does not support any
978      * rotation.
979      */
980     uint32_t        rotation_state;
981     /**
982      * \brief blending state. See "Video blending state definition".
983      *
984      * If \ref blend_state is NULL, then default operation mode depends
985      * on the source \ref surface format:
986      * - RGB: per-pixel alpha blending ;
987      * - YUV: no blending, i.e override the underlying pixels.
988      *
989      * Otherwise, \ref blend_state is a pointer to a #VABlendState
990      * structure that shall be live until vaEndPicture().
991      *
992      * Implementation note: the driver is responsible for checking the
993      * blend state flags against the actual source \ref surface format.
994      * e.g. premultiplied alpha blending is only applicable to RGB
995      * surfaces, and luma keying is only applicable to YUV surfaces.
996      * If a mismatch occurs, then #VA_STATUS_ERROR_INVALID_BLEND_STATE
997      * is returned.
998      */
999     const VABlendState *blend_state;
1000     /**
1001      * \bried mirroring state. See "Mirroring directions".
1002      *
1003      * Mirroring of an image can be performed either along the
1004      * horizontal or vertical axis. It is assumed that the rotation
1005      * operation is always performed before the mirroring operation.
1006      */
1007     uint32_t      mirror_state;
1008     /** \brief Array of additional output surfaces. */
1009     VASurfaceID        *additional_outputs;
1010     /** \brief Number of additional output surfaces. */
1011     uint32_t        num_additional_outputs;
1012     /**
1013      * \brief Flag to indicate the input surface flag
1014      *
1015      * bit0: 0 non-protected 1: protected
1016      * bit 1~31 for future
1017      */
1018     uint32_t        input_surface_flag;
1019     /**
1020      * \brief Flag to indicate the output surface flag
1021      *
1022      * bit0: 0 non-protected  1: protected
1023      * bit 1~31 for future
1024      */
1025     uint32_t        output_surface_flag;
1026     /**
1027      * \brief Input Color Properties. See "VAProcColorProperties".
1028      */
1029     VAProcColorProperties  input_color_properties;
1030     /**
1031      * \brief Output Color Properties. See "VAProcColorProperties".
1032      */
1033     VAProcColorProperties  output_color_properties;
1034     /**
1035      * \brief Processing mode. See "VAProcMode".
1036      */
1037     VAProcMode             processing_mode;
1038     /**
1039      * \brief Output High Dynamic Metadata.
1040      *
1041      * If output_metadata is NULL, then output default to SDR.
1042      */
1043     VAHdrMetaData          *output_hdr_metadata;
1044
1045     /** \brief Reserved bytes for future use, must be zero */
1046     #if defined(__AMD64__) || defined(__x86_64__) || defined(__amd64__)|| defined(__LP64__)
1047     uint32_t                va_reserved[VA_PADDING_LARGE - 16];
1048     #else
1049     uint32_t                va_reserved[VA_PADDING_LARGE - 13];
1050     #endif
1051 } VAProcPipelineParameterBuffer;
1052
1053 /**
1054  * \brief Filter parameter buffer base.
1055  *
1056  * This is a helper structure used by driver implementations only.
1057  * Users are not supposed to allocate filter parameter buffers of this
1058  * type.
1059  */
1060 typedef struct _VAProcFilterParameterBufferBase {
1061     /** \brief Filter type. */
1062     VAProcFilterType    type;
1063 } VAProcFilterParameterBufferBase;
1064
1065 /**
1066  * \brief Default filter parametrization.
1067  *
1068  * Unless there is a filter-specific parameter buffer,
1069  * #VAProcFilterParameterBuffer is the default type to use.
1070  */
1071 typedef struct _VAProcFilterParameterBuffer {
1072     /** \brief Filter type. */
1073     VAProcFilterType    type;
1074     /** \brief Value. */
1075     float               value;
1076
1077     /** \brief Reserved bytes for future use, must be zero */
1078     uint32_t                va_reserved[VA_PADDING_LOW];
1079 } VAProcFilterParameterBuffer;
1080
1081 /** @name De-interlacing flags */
1082 /**@{*/
1083 /** 
1084  * \brief Bottom field first in the input frame. 
1085  * if this is not set then assumes top field first.
1086  */
1087 #define VA_DEINTERLACING_BOTTOM_FIELD_FIRST     0x0001
1088 /** 
1089  * \brief Bottom field used in deinterlacing. 
1090  * if this is not set then assumes top field is used.
1091  */
1092 #define VA_DEINTERLACING_BOTTOM_FIELD           0x0002
1093 /** 
1094  * \brief A single field is stored in the input frame. 
1095  * if this is not set then assumes the frame contains two interleaved fields.
1096  */
1097 #define VA_DEINTERLACING_ONE_FIELD              0x0004
1098 /**
1099  * \brief Film Mode Detection is enabled. If enabled, driver performs inverse
1100  * of various pulldowns, such as 3:2 pulldown.
1101  * if this is not set then assumes FMD is disabled.
1102  */
1103 #define VA_DEINTERLACING_FMD_ENABLE             0x0008
1104
1105 //Scene change parameter for ADI on Linux, if enabled, driver use spatial DI(Bob), instead of ADI. if not, use old behavior for ADI
1106 //Input stream is TFF(set flags = 0), SRC0,1,2,3 are interlaced frame (top +bottom fields), DSTs are progressive frames
1107 //30i->30p
1108 //SRC0 -> BOBDI,  no reference, set flag = 0, output DST0
1109 //SRC1 -> ADI, reference frame=SRC0, set flags = 0, call VP, output DST1
1110 //SRC2 -> ADI, reference frame=SRC1, set flags = 0x0010(decimal 16), call VP, output DST2(T4)
1111 //SRC3 -> ADI, reference frame=SRC2, set flags = 0, call VP, output DST3
1112 //30i->60p
1113 //SRC0 -> BOBDI, no reference, set flag = 0, output DST0
1114 //SRC0 -> BOBDI, no reference, set flag =0x0002, output DST1
1115
1116 //SRC1 -> ADI, reference frame =SRC0, set flags = 0, call VP, output DST2
1117 //SRC1 -> ADI, reference frame =SRC0, set flags = 0x0012(decimal18), call VP, output DST3(B3)
1118
1119 //SRC2 -> ADI, reference frame =SRC1, set flags =  0x0010(decimal 16), call VP, output DST4(T4)
1120 //SRC2 -> ADI, reference frame =SRC1, set flags =  0x0002, call VP, output DST5
1121
1122 //SRC3 -> ADI, reference frame =SRC2, set flags =  0, call VP, output DST6
1123 //SRC3 -> ADI, reference frame =SRC1, set flags = 0x0002, call VP, output DST7
1124
1125 #define VA_DEINTERLACING_SCD_ENABLE     0x0010
1126
1127 /**@}*/
1128
1129 /** \brief Deinterlacing filter parametrization. */
1130 typedef struct _VAProcFilterParameterBufferDeinterlacing {
1131     /** \brief Filter type. Shall be set to #VAProcFilterDeinterlacing. */
1132     VAProcFilterType            type;
1133     /** \brief Deinterlacing algorithm. */
1134     VAProcDeinterlacingType     algorithm;
1135     /** \brief Deinterlacing flags. */
1136     uint32_t                    flags;
1137
1138     /** \brief Reserved bytes for future use, must be zero */
1139     uint32_t                va_reserved[VA_PADDING_LOW];
1140 } VAProcFilterParameterBufferDeinterlacing;
1141
1142 /**
1143  * \brief Color balance filter parametrization.
1144  *
1145  * This buffer defines color balance attributes. A VA buffer can hold
1146  * several color balance attributes by creating a VA buffer of desired
1147  * number of elements. This can be achieved by the following pseudo-code:
1148  *
1149  * \code
1150  * enum { kHue, kSaturation, kBrightness, kContrast };
1151  *
1152  * // Initial color balance parameters
1153  * static const VAProcFilterParameterBufferColorBalance colorBalanceParams[4] =
1154  * {
1155  *     [kHue] =
1156  *         { VAProcFilterColorBalance, VAProcColorBalanceHue, 0.5 },
1157  *     [kSaturation] =
1158  *         { VAProcFilterColorBalance, VAProcColorBalanceSaturation, 0.5 },
1159  *     [kBrightness] =
1160  *         { VAProcFilterColorBalance, VAProcColorBalanceBrightness, 0.5 },
1161  *     [kSaturation] =
1162  *         { VAProcFilterColorBalance, VAProcColorBalanceSaturation, 0.5 }
1163  * };
1164  *
1165  * // Create buffer
1166  * VABufferID colorBalanceBuffer;
1167  * vaCreateBuffer(va_dpy, vpp_ctx,
1168  *     VAProcFilterParameterBufferType, sizeof(*pColorBalanceParam), 4,
1169  *     colorBalanceParams,
1170  *     &colorBalanceBuffer
1171  * );
1172  *
1173  * VAProcFilterParameterBufferColorBalance *pColorBalanceParam;
1174  * vaMapBuffer(va_dpy, colorBalanceBuffer, &pColorBalanceParam);
1175  * {
1176  *     // Change brightness only
1177  *     pColorBalanceBuffer[kBrightness].value = 0.75;
1178  * }
1179  * vaUnmapBuffer(va_dpy, colorBalanceBuffer);
1180  * \endcode
1181  */
1182 typedef struct _VAProcFilterParameterBufferColorBalance {
1183     /** \brief Filter type. Shall be set to #VAProcFilterColorBalance. */
1184     VAProcFilterType            type;
1185     /** \brief Color balance attribute. */
1186     VAProcColorBalanceType      attrib;
1187     /**
1188      * \brief Color balance value.
1189      *
1190      * Special case for automatically adjusted attributes. e.g. 
1191      * #VAProcColorBalanceAutoSaturation,
1192      * #VAProcColorBalanceAutoBrightness,
1193      * #VAProcColorBalanceAutoContrast.
1194      * - If \ref value is \c 1.0 +/- \c FLT_EPSILON, the attribute is
1195      *   automatically adjusted and overrides any other attribute of
1196      *   the same type that would have been set explicitly;
1197      * - If \ref value is \c 0.0 +/- \c FLT_EPSILON, the attribute is
1198      *   disabled and other attribute of the same type is used instead.
1199      */
1200     float                       value;
1201
1202     /** \brief Reserved bytes for future use, must be zero */
1203     uint32_t                va_reserved[VA_PADDING_LOW];
1204 } VAProcFilterParameterBufferColorBalance;
1205
1206 /** \brief Total color correction filter parametrization. */
1207 typedef struct _VAProcFilterParameterBufferTotalColorCorrection {
1208     /** \brief Filter type. Shall be set to #VAProcFilterTotalColorCorrection. */
1209     VAProcFilterType                  type;
1210     /** \brief Color to correct. */
1211     VAProcTotalColorCorrectionType    attrib;
1212     /** \brief Color correction value. */
1213     float                             value;
1214 } VAProcFilterParameterBufferTotalColorCorrection;
1215
1216 /** \brief Human Vision System(HVS) Noise reduction filter parametrization. */
1217 typedef struct _VAProcFilterParameterBufferHVSNoiseReduction {
1218     /** \brief Filter type. Shall be set to #VAProcFilterHVSNoiseReduction. */
1219     VAProcFilterType    type;
1220     /** \brief QP for encoding, used for HVS Denoise */
1221     uint16_t            qp;
1222     /**
1223      *  \brief QP to Noise Reduction Strength Mode, used for Human Vision System Based Noise Reduction.
1224      *  Controls Noise Reduction strength of conservative and aggressive mode.
1225      *  It is an integer from [0-16].
1226      *  Value 0 means completely turn off Noise Reduction;
1227      *  Value 16 means the most aggressive mode of Noise Reduction;
1228      *  Value 10 is the default value.
1229      */
1230     uint16_t            strength;
1231     /** \brief Reserved bytes for future use, must be zero */
1232     uint16_t            va_reserved[VA_PADDING_HIGH];
1233 } VAProcFilterParameterBufferHVSNoiseReduction;
1234
1235 /** \brief High Dynamic Range(HDR) Tone Mapping filter parametrization. */
1236 typedef struct _VAProcFilterParameterBufferHDRToneMapping {
1237     /** \brief Filter type. Shall be set to #VAProcFilterHighDynamicRangeToneMapping.*/
1238     VAProcFilterType    type;
1239     /**
1240      *  \brief High Dynamic Range metadata, could be HDR10 etc.
1241      *
1242      *  This metadata is mainly for the input surface. Given that dynamic metadata is changing
1243      *  on frame-by-frame or scene-by-scene basis for HDR10 plus, differentiate the metadata
1244      *  for the input and output.
1245      */
1246     VAHdrMetaData       data;
1247     /** \brief Reserved bytes for future use, must be zero */
1248     uint32_t            va_reserved[VA_PADDING_HIGH];
1249 } VAProcFilterParameterBufferHDRToneMapping;
1250
1251 /**
1252  * \brief Default filter cap specification (single range value).
1253  *
1254  * Unless there is a filter-specific cap structure, #VAProcFilterCap is the
1255  * default type to use for output caps from vaQueryVideoProcFilterCaps().
1256  */
1257 typedef struct _VAProcFilterCap {
1258     /** \brief Range of supported values for the filter. */
1259     VAProcFilterValueRange      range;
1260
1261     /** \brief Reserved bytes for future use, must be zero */
1262     uint32_t                va_reserved[VA_PADDING_LOW];
1263 } VAProcFilterCap;
1264
1265 /** \brief Capabilities specification for the deinterlacing filter. */
1266 typedef struct _VAProcFilterCapDeinterlacing {
1267     /** \brief Deinterlacing algorithm. */
1268     VAProcDeinterlacingType     type;
1269
1270     /** \brief Reserved bytes for future use, must be zero */
1271     uint32_t                va_reserved[VA_PADDING_LOW];
1272 } VAProcFilterCapDeinterlacing;
1273
1274 /** \brief Capabilities specification for the color balance filter. */
1275 typedef struct _VAProcFilterCapColorBalance {
1276     /** \brief Color balance operation. */
1277     VAProcColorBalanceType      type;
1278     /** \brief Range of supported values for the specified operation. */
1279     VAProcFilterValueRange      range;
1280
1281     /** \brief Reserved bytes for future use, must be zero */
1282     uint32_t                va_reserved[VA_PADDING_LOW];
1283 } VAProcFilterCapColorBalance;
1284
1285 /** \brief Capabilities specification for the Total Color Correction filter. */
1286 typedef struct _VAProcFilterCapTotalColorCorrection {
1287     /** \brief Color to correct. */
1288     VAProcTotalColorCorrectionType    type;
1289     /** \brief Range of supported values for the specified color. */
1290     VAProcFilterValueRange            range;
1291 } VAProcFilterCapTotalColorCorrection;
1292
1293 /**
1294  * \brief Queries video processing filters.
1295  *
1296  * This function returns the list of video processing filters supported
1297  * by the driver. The \c filters array is allocated by the user and
1298  * \c num_filters shall be initialized to the number of allocated
1299  * elements in that array. Upon successful return, the actual number
1300  * of filters will be overwritten into \c num_filters. Otherwise,
1301  * \c VA_STATUS_ERROR_MAX_NUM_EXCEEDED is returned and \c num_filters
1302  * is adjusted to the number of elements that would be returned if enough
1303  * space was available.
1304  *
1305  * The list of video processing filters supported by the driver shall
1306  * be ordered in the way they can be iteratively applied. This is needed
1307  * for both correctness, i.e. some filters would not mean anything if
1308  * applied at the beginning of the pipeline; but also for performance
1309  * since some filters can be applied in a single pass (e.g. noise
1310  * reduction + deinterlacing).
1311  *
1312  * @param[in] dpy               the VA display
1313  * @param[in] context           the video processing context
1314  * @param[out] filters          the output array of #VAProcFilterType elements
1315  * @param[in,out] num_filters the number of elements allocated on input,
1316  *      the number of elements actually filled in on output
1317  */
1318 VAStatus
1319 vaQueryVideoProcFilters(
1320     VADisplay           dpy,
1321     VAContextID         context,
1322     VAProcFilterType   *filters,
1323     unsigned int       *num_filters
1324 );
1325
1326 /**
1327  * \brief Queries video filter capabilities.
1328  *
1329  * This function returns the list of capabilities supported by the driver
1330  * for a specific video filter. The \c filter_caps array is allocated by
1331  * the user and \c num_filter_caps shall be initialized to the number
1332  * of allocated elements in that array. Upon successful return, the
1333  * actual number of filters will be overwritten into \c num_filter_caps.
1334  * Otherwise, \c VA_STATUS_ERROR_MAX_NUM_EXCEEDED is returned and
1335  * \c num_filter_caps is adjusted to the number of elements that would be
1336  * returned if enough space was available.
1337  *
1338  * @param[in] dpy               the VA display
1339  * @param[in] context           the video processing context
1340  * @param[in] type              the video filter type
1341  * @param[out] filter_caps      the output array of #VAProcFilterCap elements
1342  * @param[in,out] num_filter_caps the number of elements allocated on input,
1343  *      the number of elements actually filled in output
1344  */
1345 VAStatus
1346 vaQueryVideoProcFilterCaps(
1347     VADisplay           dpy,
1348     VAContextID         context,
1349     VAProcFilterType    type,
1350     void               *filter_caps,
1351     unsigned int       *num_filter_caps
1352 );
1353
1354 /**
1355  * \brief Queries video processing pipeline capabilities.
1356  *
1357  * This function returns the video processing pipeline capabilities. The
1358  * \c filters array defines the video processing pipeline and is an array
1359  * of buffers holding filter parameters.
1360  *
1361  * Note: the #VAProcPipelineCaps structure contains user-provided arrays.
1362  * If non-NULL, the corresponding \c num_* fields shall be filled in on
1363  * input with the number of elements allocated. Upon successful return,
1364  * the actual number of elements will be overwritten into the \c num_*
1365  * fields. Otherwise, \c VA_STATUS_ERROR_MAX_NUM_EXCEEDED is returned
1366  * and \c num_* fields are adjusted to the number of elements that would
1367  * be returned if enough space was available.
1368  *
1369  * @param[in] dpy               the VA display
1370  * @param[in] context           the video processing context
1371  * @param[in] filters           the array of VA buffers defining the video
1372  *      processing pipeline
1373  * @param[in] num_filters       the number of elements in filters
1374  * @param[in,out] pipeline_caps the video processing pipeline capabilities
1375  */
1376 VAStatus
1377 vaQueryVideoProcPipelineCaps(
1378     VADisplay           dpy,
1379     VAContextID         context,
1380     VABufferID         *filters,
1381     unsigned int        num_filters,
1382     VAProcPipelineCaps *pipeline_caps
1383 );
1384
1385 /**@}*/
1386
1387 #ifdef __cplusplus
1388 }
1389 #endif
1390
1391 #endif /* VA_VPP_H */