OSDN Git Service

Add maximum type number define, and one addition VPP flag
[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 Color standard conversion. */
249     VAProcFilterColorStandard,
250     /** \brief Number of video filters. */
251     VAProcFilterCount
252 } VAProcFilterType;
253
254 /** \brief Deinterlacing types. */
255 typedef enum _VAProcDeinterlacingType {
256     VAProcDeinterlacingNone = 0,
257     /** \brief Bob deinterlacing algorithm. */
258     VAProcDeinterlacingBob,
259     /** \brief Weave deinterlacing algorithm. */
260     VAProcDeinterlacingWeave,
261     /** \brief Motion adaptive deinterlacing algorithm. */
262     VAProcDeinterlacingMotionAdaptive,
263     /** \brief Motion compensated deinterlacing algorithm. */
264     VAProcDeinterlacingMotionCompensated,
265     /** \brief Number of deinterlacing algorithms. */
266     VAProcDeinterlacingCount
267 } VAProcDeinterlacingType;
268
269 /** \brief Color balance types. */
270 typedef enum _VAProcColorBalanceType {
271     VAProcColorBalanceNone = 0,
272     /** \brief Hue. */
273     VAProcColorBalanceHue,
274     /** \brief Saturation. */
275     VAProcColorBalanceSaturation,
276     /** \brief Brightness. */
277     VAProcColorBalanceBrightness,
278     /** \brief Contrast. */
279     VAProcColorBalanceContrast,
280     /** \brief Automatically adjusted saturation. */
281     VAProcColorBalanceAutoSaturation,
282     /** \brief Automatically adjusted brightness. */
283     VAProcColorBalanceAutoBrightness,
284     /** \brief Automatically adjusted contrast. */
285     VAProcColorBalanceAutoContrast,
286     /** \brief Number of color balance attributes. */
287     VAProcColorBalanceCount
288 } VAProcColorBalanceType;
289
290 /** \brief Color standard types. */
291 typedef enum _VAProcColorStandardType {
292     VAProcColorStandardNone = 0,
293     /** \brief ITU-R BT.601. */
294     VAProcColorStandardBT601,
295     /** \brief ITU-R BT.709. */
296     VAProcColorStandardBT709,
297     /** \brief ITU-R BT.470-2 System M. */
298     VAProcColorStandardBT470M,
299     /** \brief ITU-R BT.470-2 System B, G. */
300     VAProcColorStandardBT470BG,
301     /** \brief SMPTE-170M. */
302     VAProcColorStandardSMPTE170M,
303     /** \brief SMPTE-240M. */
304     VAProcColorStandardSMPTE240M,
305     /** \brief Generic film. */
306     VAProcColorStandardGenericFilm,
307     /** \brief Number of color standards. */
308     VAProcColorStandardCount
309 } VAProcColorStandardType;
310
311 /** @name Video pipeline flags */
312 /**@{*/
313 /** \brief Specifies whether to apply subpictures when processing a surface. */
314 #define VA_PROC_PIPELINE_SUBPICTURES    0x00000001
315 /**
316  * \brief Specifies whether to apply power or performance
317  * optimizations to a pipeline.
318  *
319  * When processing several surfaces, it may be necessary to prioritize
320  * more certain pipelines than others. This flag is only a hint to the
321  * video processor so that it can omit certain filters to save power
322  * for example. Typically, this flag could be used with video surfaces
323  * decoded from a secondary bitstream.
324  */
325 #define VA_PROC_PIPELINE_FAST           0x00000002
326 /**@}*/
327
328 /** @name Video filter flags */
329 /**@{*/
330 /** \brief Specifies whether the filter shall be present in the pipeline. */
331 #define VA_PROC_FILTER_MANDATORY        0x00000001
332 /**@}*/
333
334 /** @name Pipeline end flags */
335 /**@{*/
336 /** \brief Specifies the pipeline is the last. */
337 #define VA_PIPELINE_FLAG_END            0x00000004
338 /**@}*/
339
340 /** \brief Video processing pipeline capabilities. */
341 typedef struct _VAProcPipelineCaps {
342     /** \brief Pipeline flags. See VAProcPipelineParameterBuffer::pipeline_flags. */
343     unsigned int        pipeline_flags;
344     /** \brief Extra filter flags. See VAProcPipelineParameterBuffer::filter_flags. */
345     unsigned int        filter_flags;
346     /** \brief Number of forward reference frames that are needed. */
347     unsigned int        num_forward_references;
348     /** \brief Number of backward reference frames that are needed. */
349     unsigned int        num_backward_references;
350     /** \brief List of color standards supported on input. */
351     VAProcColorStandardType *input_color_standards;
352     /** \brief Number of elements in \ref input_color_standards array. */
353     unsigned int        num_input_color_standards;
354     /** \brief List of color standards supported on output. */
355     VAProcColorStandardType *output_color_standards;
356     /** \brief Number of elements in \ref output_color_standards array. */
357     unsigned int        num_output_color_standards;
358 } VAProcPipelineCaps;
359
360 /** \brief Specification of values supported by the filter. */
361 typedef struct _VAProcFilterValueRange {
362     /** \brief Minimum value supported, inclusive. */
363     float               min_value;
364     /** \brief Maximum value supported, inclusive. */
365     float               max_value;
366     /** \brief Default value. */
367     float               default_value;
368     /** \brief Step value that alters the filter behaviour in a sensible way. */
369     float               step;
370 } VAProcFilterValueRange;
371
372 /**
373  * \brief Video processing pipeline configuration.
374  *
375  * This buffer defines a video processing pipeline. As for any buffer
376  * passed to \c vaRenderPicture(), this is a one-time usage model.
377  * However, the actual filters to be applied are provided in the
378  * \c filters field, so they can be re-used in other processing
379  * pipelines.
380  *
381  * The target surface is specified by the \c render_target argument of
382  * \c vaBeginPicture(). The general usage model is described as follows:
383  * - \c vaBeginPicture(): specify the target surface that receives the
384  *   processed output;
385  * - \c vaRenderPicture(): specify a surface to be processed and composed
386  *   into the \c render_target. Use as many \c vaRenderPicture() calls as
387  *   necessary surfaces to compose ;
388  * - \c vaEndPicture(): tell the driver to start processing the surfaces
389  *   with the requested filters.
390  *
391  * If a filter (e.g. noise reduction) needs to be applied with different
392  * values for multiple surfaces, the application needs to create as many
393  * filter parameter buffers as necessary. i.e. the filter parameters shall
394  * not change between two calls to \c vaRenderPicture().
395  *
396  * For composition usage models, the first surface to process will generally
397  * use an opaque background color, i.e. \c output_background_color set with
398  * the most significant byte set to \c 0xff. For instance, \c 0xff000000 for
399  * a black background. Then, subsequent surfaces would use a transparent
400  * background color.
401  */
402 typedef struct _VAProcPipelineParameterBuffer {
403     /**
404      * \brief Source surface ID.
405      *
406      * ID of the source surface to process. If subpictures are associated
407      * with the video surfaces then they shall be rendered to the target
408      * surface, if the #VA_PROC_PIPELINE_SUBPICTURES pipeline flag is set.
409      */
410     VASurfaceID         surface;
411     /**
412      * \brief Region within the source surface to be processed.
413      *
414      * Pointer to a #VARectangle defining the region within the source
415      * surface to be processed. If NULL, \c surface_region implies the
416      * whole surface.
417      */
418     const VARectangle  *surface_region;
419     /**
420      * \brief Requested input color primaries.
421      *
422      * Color primaries are implicitly converted throughout the processing
423      * pipeline. The video processor chooses the best moment to apply
424      * this conversion. The set of supported color primaries primaries
425      * for input shall be queried with vaQueryVideoProcPipelineCaps().
426      */
427     VAProcColorStandardType surface_color_standard;
428     /**
429      * \brief Region within the output surface.
430      *
431      * Pointer to a #VARectangle defining the region within the output
432      * surface that receives the processed pixels. If NULL, \c output_region
433      * implies the whole surface. 
434      *
435      * Note that any pixels residing outside the specified region will
436      * be filled in with the \ref output_background_color.
437      */
438     const VARectangle  *output_region;
439     /**
440      * \brief Background color.
441      *
442      * Background color used to fill in pixels that reside outside of the
443      * specified \ref output_region. The color is specified in ARGB format:
444      * [31:24] alpha, [23:16] red, [15:8] green, [7:0] blue.
445      *
446      * Unless the alpha value is zero or the \ref output_region represents
447      * the whole target surface size, implementations shall not render the
448      * source surface to the target surface directly. Rather, in order to
449      * maintain the exact semantics of \ref output_background_color, the
450      * driver shall use a temporary surface and fill it in with the
451      * appropriate background color. Next, the driver will blend this
452      * temporary surface into the target surface.
453      */
454     unsigned int        output_background_color;
455     /**
456      * \brief Requested output color primaries.
457      */
458     VAProcColorStandardType output_color_standard;
459     /**
460      * \brief Pipeline filters. See video pipeline flags.
461      *
462      * Flags to control the pipeline, like whether to apply subpictures
463      * or not, notify the driver that it can opt for power optimizations,
464      * should this be needed.
465      */
466     unsigned int        pipeline_flags;
467     /**
468      * \brief Extra filter flags. See vaPutSurface() flags.
469      *
470      * Filter flags are used as a fast path, wherever possible, to use
471      * vaPutSurface() flags instead of explicit filter parameter buffers.
472      *
473      * Allowed filter flags API-wise. Use vaQueryVideoProcPipelineCaps()
474      * to check for implementation details:
475      * - Bob-deinterlacing: \c VA_FRAME_PICTURE, \c VA_TOP_FIELD,
476      *   \c VA_BOTTOM_FIELD. Note that any deinterlacing filter
477      *   (#VAProcFilterDeinterlacing) will override those flags.
478      * - Color space conversion: \c VA_SRC_BT601, \c VA_SRC_BT709,
479      *   \c VA_SRC_SMPTE_240. Note that any color standard filter
480      *   (#VAProcFilterColorStandard) will override those flags.
481      * - Scaling: \c VA_FILTER_SCALING_DEFAULT, \c VA_FILTER_SCALING_FAST,
482      *   \c VA_FILTER_SCALING_HQ, \c VA_FILTER_SCALING_NL_ANAMORPHIC.
483      */
484     unsigned int        filter_flags;
485     /**
486      * \brief Array of filters to apply to the surface.
487      *
488      * The list of filters shall be ordered in the same way the driver expects
489      * them. i.e. as was returned from vaQueryVideoProcFilters().
490      * Otherwise, a #VA_STATUS_ERROR_INVALID_FILTER_CHAIN is returned
491      * from vaRenderPicture() with this buffer.
492      *
493      * #VA_STATUS_ERROR_UNSUPPORTED_FILTER is returned if the list
494      * contains an unsupported filter.
495      *
496      * Note: no filter buffer is destroyed after a call to vaRenderPicture(),
497      * only this pipeline buffer will be destroyed as per the core API
498      * specification. This allows for flexibility in re-using the filter for
499      * other surfaces to be processed.
500      */
501     VABufferID         *filters;
502     /** \brief Actual number of filters. */
503     unsigned int        num_filters;
504     /** \brief Array of forward reference frames. */
505     VASurfaceID        *forward_references;
506     /** \brief Number of forward reference frames that were supplied. */
507     unsigned int        num_forward_references;
508     /** \brief Array of backward reference frames. */
509     VASurfaceID        *backward_references;
510     /** \brief Number of backward reference frames that were supplied. */
511     unsigned int        num_backward_references;
512 } VAProcPipelineParameterBuffer;
513
514 /**
515  * \brief Filter parameter buffer base.
516  *
517  * This is a helper structure used by driver implementations only.
518  * Users are not supposed to allocate filter parameter buffers of this
519  * type.
520  */
521 typedef struct _VAProcFilterParameterBufferBase {
522     /** \brief Filter type. */
523     VAProcFilterType    type;
524 } VAProcFilterParameterBufferBase;
525
526 /**
527  * \brief Default filter parametrization.
528  *
529  * Unless there is a filter-specific parameter buffer,
530  * #VAProcFilterParameterBuffer is the default type to use.
531  */
532 typedef struct _VAProcFilterParameterBuffer {
533     /** \brief Filter type. */
534     VAProcFilterType    type;
535     /** \brief Value. */
536     float               value;
537 } VAProcFilterParameterBuffer;
538
539 /** \brief Deinterlacing filter parametrization. */
540 typedef struct _VAProcFilterParameterBufferDeinterlacing {
541     /** \brief Filter type. Shall be set to #VAProcFilterDeinterlacing. */
542     VAProcFilterType            type;
543     /** \brief Deinterlacing algorithm. */
544     VAProcDeinterlacingType     algorithm;
545 } VAProcFilterParameterBufferDeinterlacing;
546
547 /**
548  * \brief Color balance filter parametrization.
549  *
550  * This buffer defines color balance attributes. A VA buffer can hold
551  * several color balance attributes by creating a VA buffer of desired
552  * number of elements. This can be achieved by the following pseudo-code:
553  *
554  * \code
555  * enum { kHue, kSaturation, kBrightness, kContrast };
556  *
557  * // Initial color balance parameters
558  * static const VAProcFilterParameterBufferColorBalance colorBalanceParams[4] =
559  * {
560  *     [kHue] =
561  *         { VAProcFilterColorBalance, VAProcColorBalanceHue, 0.5 },
562  *     [kSaturation] =
563  *         { VAProcFilterColorBalance, VAProcColorBalanceSaturation, 0.5 },
564  *     [kBrightness] =
565  *         { VAProcFilterColorBalance, VAProcColorBalanceBrightness, 0.5 },
566  *     [kSaturation] =
567  *         { VAProcFilterColorBalance, VAProcColorBalanceSaturation, 0.5 }
568  * };
569  *
570  * // Create buffer
571  * VABufferID colorBalanceBuffer;
572  * vaCreateBuffer(va_dpy, vpp_ctx,
573  *     VAProcFilterParameterBufferType, sizeof(*pColorBalanceParam), 4,
574  *     colorBalanceParams,
575  *     &colorBalanceBuffer
576  * );
577  *
578  * VAProcFilterParameterBufferColorBalance *pColorBalanceParam;
579  * vaMapBuffer(va_dpy, colorBalanceBuffer, &pColorBalanceParam);
580  * {
581  *     // Change brightness only
582  *     pColorBalanceBuffer[kBrightness].value = 0.75;
583  * }
584  * vaUnmapBuffer(va_dpy, colorBalanceBuffer);
585  * \endcode
586  */
587 typedef struct _VAProcFilterParameterBufferColorBalance {
588     /** \brief Filter type. Shall be set to #VAProcFilterColorBalance. */
589     VAProcFilterType            type;
590     /** \brief Color balance attribute. */
591     VAProcColorBalanceType      attrib;
592     /**
593      * \brief Color balance value.
594      *
595      * Special case for automatically adjusted attributes. e.g. 
596      * #VAProcColorBalanceAutoSaturation,
597      * #VAProcColorBalanceAutoBrightness,
598      * #VAProcColorBalanceAutoContrast.
599      * - If \ref value is \c 1.0 +/- \c FLT_EPSILON, the attribute is
600      *   automatically adjusted and overrides any other attribute of
601      *   the same type that would have been set explicitly;
602      * - If \ref value is \c 0.0 +/- \c FLT_EPSILON, the attribute is
603      *   disabled and other attribute of the same type is used instead.
604      */
605     float                       value;
606 } VAProcFilterParameterBufferColorBalance;
607
608 /** \brief Color standard filter parametrization. */
609 typedef struct _VAProcFilterParameterBufferColorStandard {
610     /** \brief Filter type. Shall be set to #VAProcFilterColorStandard. */
611     VAProcFilterType            type;
612     /** \brief Color standard to use. */
613     VAProcColorStandardType     standard;
614 } VAProcFilterParameterBufferColorStandard;
615
616 /**
617  * \brief Default filter cap specification (single range value).
618  *
619  * Unless there is a filter-specific cap structure, #VAProcFilterCap is the
620  * default type to use for output caps from vaQueryVideoProcFilterCaps().
621  */
622 typedef struct _VAProcFilterCap {
623     /** \brief Range of supported values for the filter. */
624     VAProcFilterValueRange      range;
625 } VAProcFilterCap;
626
627 /** \brief Capabilities specification for the deinterlacing filter. */
628 typedef struct _VAProcFilterCapDeinterlacing {
629     /** \brief Deinterlacing algorithm. */
630     VAProcDeinterlacingType     type;
631 } VAProcFilterCapDeinterlacing;
632
633 /** \brief Capabilities specification for the color balance filter. */
634 typedef struct _VAProcFilterCapColorBalance {
635     /** \brief Color balance operation. */
636     VAProcColorBalanceType      type;
637     /** \brief Range of supported values for the specified operation. */
638     VAProcFilterValueRange      range;
639 } VAProcFilterCapColorBalance;
640
641 /** \brief Capabilities specification for the color standard filter. */
642 typedef struct _VAProcFilterCapColorStandard {
643     /** \brief Color standard type. */
644     VAProcColorStandardType     type;
645 } VAProcFilterCapColorStandard;
646
647 /**
648  * \brief Queries video processing filters.
649  *
650  * This function returns the list of video processing filters supported
651  * by the driver. The \c filters array is allocated by the user and
652  * \c num_filters shall be initialized to the number of allocated
653  * elements in that array. Upon successful return, the actual number
654  * of filters will be overwritten into \c num_filters. Otherwise,
655  * \c VA_STATUS_ERROR_MAX_NUM_EXCEEDED is returned and \c num_filters
656  * is adjusted to the number of elements that would be returned if enough
657  * space was available.
658  *
659  * The list of video processing filters supported by the driver shall
660  * be ordered in the way they can be iteratively applied. This is needed
661  * for both correctness, i.e. some filters would not mean anything if
662  * applied at the beginning of the pipeline; but also for performance
663  * since some filters can be applied in a single pass (e.g. noise
664  * reduction + deinterlacing).
665  *
666  * @param[in] dpy               the VA display
667  * @param[in] context           the video processing context
668  * @param[out] filters          the output array of #VAProcFilterType elements
669  * @param[in,out] num_filters the number of elements allocated on input,
670  *      the number of elements actually filled in on output
671  */
672 VAStatus
673 vaQueryVideoProcFilters(
674     VADisplay           dpy,
675     VAContextID         context,
676     VAProcFilterType   *filters,
677     unsigned int       *num_filters
678 );
679
680 /**
681  * \brief Queries video filter capabilities.
682  *
683  * This function returns the list of capabilities supported by the driver
684  * for a specific video filter. The \c filter_caps array is allocated by
685  * the user and \c num_filter_caps shall be initialized to the number
686  * of allocated elements in that array. Upon successful return, the
687  * actual number of filters will be overwritten into \c num_filter_caps.
688  * Otherwise, \c VA_STATUS_ERROR_MAX_NUM_EXCEEDED is returned and
689  * \c num_filter_caps is adjusted to the number of elements that would be
690  * returned if enough space was available.
691  *
692  * @param[in] dpy               the VA display
693  * @param[in] context           the video processing context
694  * @param[in] type              the video filter type
695  * @param[out] filter_caps      the output array of #VAProcFilterCap elements
696  * @param[in,out] num_filter_caps the number of elements allocated on input,
697  *      the number of elements actually filled in output
698  */
699 VAStatus
700 vaQueryVideoProcFilterCaps(
701     VADisplay           dpy,
702     VAContextID         context,
703     VAProcFilterType    type,
704     void               *filter_caps,
705     unsigned int       *num_filter_caps
706 );
707
708 /**
709  * \brief Queries video processing pipeline capabilities.
710  *
711  * This function returns the video processing pipeline capabilities. The
712  * \c filters array defines the video processing pipeline and is an array
713  * of buffers holding filter parameters.
714  *
715  * Note: the #VAProcPipelineCaps structure contains user-provided arrays.
716  * If non-NULL, the corresponding \c num_* fields shall be filled in on
717  * input with the number of elements allocated. Upon successful return,
718  * the actual number of elements will be overwritten into the \c num_*
719  * fields. Otherwise, \c VA_STATUS_ERROR_MAX_NUM_EXCEEDED is returned
720  * and \c num_* fields are adjusted to the number of elements that would
721  * be returned if enough space was available.
722  *
723  * @param[in] dpy               the VA display
724  * @param[in] context           the video processing context
725  * @param[in] filters           the array of VA buffers defining the video
726  *      processing pipeline
727  * @param[in] num_filters       the number of elements in filters
728  * @param[in,out] pipeline_caps the video processing pipeline capabilities
729  */
730 VAStatus
731 vaQueryVideoProcPipelineCaps(
732     VADisplay           dpy,
733     VAContextID         context,
734     VABufferID         *filters,
735     unsigned int        num_filters,
736     VAProcPipelineCaps *pipeline_caps
737 );
738
739 /**@}*/
740
741 #ifdef __cplusplus
742 }
743 #endif
744
745 #endif /* VA_VPP_H */