• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 Deblocking filter. */
249     VAProcFilterDeblocking,
250     /** \brief Frame rate conversion. */
251     VAProcFilterFrameRateConversion,
252     /** \brief Skin Tone Enhancement. */
253     VAProcFilterSkinToneEnhancement,
254     /** \brief Total Color Correction. */
255     VAProcFilterTotalColorCorrection,
256     /** \brief Non-Linear Anamorphic Scaling. */
257     VAProcFilterNonLinearAnamorphicScaling,
258     /** \brief Image Stabilization. */
259     VAProcFilterImageStabilization,
260     /** \brief Number of video filters. */
261     VAProcFilterCount
262 } VAProcFilterType;
263 
264 /** \brief Deinterlacing types. */
265 typedef enum _VAProcDeinterlacingType {
266     VAProcDeinterlacingNone = 0,
267     /** \brief Bob deinterlacing algorithm. */
268     VAProcDeinterlacingBob,
269     /** \brief Weave deinterlacing algorithm. */
270     VAProcDeinterlacingWeave,
271     /** \brief Motion adaptive deinterlacing algorithm. */
272     VAProcDeinterlacingMotionAdaptive,
273     /** \brief Motion compensated deinterlacing algorithm. */
274     VAProcDeinterlacingMotionCompensated,
275     /** \brief Number of deinterlacing algorithms. */
276     VAProcDeinterlacingCount
277 } VAProcDeinterlacingType;
278 
279 /** \brief Color balance types. */
280 typedef enum _VAProcColorBalanceType {
281     VAProcColorBalanceNone = 0,
282     /** \brief Hue. */
283     VAProcColorBalanceHue,
284     /** \brief Saturation. */
285     VAProcColorBalanceSaturation,
286     /** \brief Brightness. */
287     VAProcColorBalanceBrightness,
288     /** \brief Contrast. */
289     VAProcColorBalanceContrast,
290     /** \brief Automatically adjusted saturation. */
291     VAProcColorBalanceAutoSaturation,
292     /** \brief Automatically adjusted brightness. */
293     VAProcColorBalanceAutoBrightness,
294     /** \brief Automatically adjusted contrast. */
295     VAProcColorBalanceAutoContrast,
296     /** \brief Number of color balance attributes. */
297     VAProcColorBalanceCount
298 } VAProcColorBalanceType;
299 
300 /** \brief Color standard types. */
301 typedef enum _VAProcColorStandardType {
302     VAProcColorStandardNone = 0,
303     /** \brief ITU-R BT.601. */
304     VAProcColorStandardBT601,
305     /** \brief ITU-R BT.709. */
306     VAProcColorStandardBT709,
307     /** \brief ITU-R BT.470-2 System M. */
308     VAProcColorStandardBT470M,
309     /** \brief ITU-R BT.470-2 System B, G. */
310     VAProcColorStandardBT470BG,
311     /** \brief SMPTE-170M. */
312     VAProcColorStandardSMPTE170M,
313     /** \brief SMPTE-240M. */
314     VAProcColorStandardSMPTE240M,
315     /** \brief Generic film. */
316     VAProcColorStandardGenericFilm,
317     /** \brief sRGB. */
318     VAProcColorStandardSRGB,
319     /** \brief stRGB. */
320     VAProcColorStandardSTRGB,
321     /** \brief xvYCC601. */
322     VAProcColorStandardXVYCC601,
323     /** \brief xvYCC709. */
324     VAProcColorStandardXVYCC709,
325     /** \brief ITU-R BT.2020. */
326     VAProcColorStandardBT2020,
327     /** \brief Number of color standards. */
328     VAProcColorStandardCount
329 } VAProcColorStandardType;
330 
331 /** \brief Total color correction types. */
332 typedef enum _VAProcTotalColorCorrectionType {
333     VAProcTotalColorCorrectionNone = 0,
334     /** \brief Red Saturation. */
335     VAProcTotalColorCorrectionRed,
336     /** \brief Green Saturation. */
337     VAProcTotalColorCorrectionGreen,
338     /** \brief Blue Saturation. */
339     VAProcTotalColorCorrectionBlue,
340     /** \brief Cyan Saturation. */
341     VAProcTotalColorCorrectionCyan,
342     /** \brief Magenta Saturation. */
343     VAProcTotalColorCorrectionMagenta,
344     /** \brief Yellow Saturation. */
345     VAProcTotalColorCorrectionYellow,
346     /** \brief Number of color correction attributes. */
347     VAProcTotalColorCorrectionCount
348 } VAProcTotalColorCorrectionType;
349 
350 /** \brief ImageStabilization Types. */
351 typedef enum _VAProcImageStabilizationType {
352     VAProcImageStabilizationTypeNone = 0,
353     /** \brief Mode Crop - crops the frame by the app provided percentage. */
354     VAProcImageStabilizationTypeCrop,
355     /** \brief Mode Crop Min Zoom - crops and then upscales the frame to half the black boundary. */
356     VAProcImageStabilizationTypeMinZoom,
357     /** \brief Mode Crop Full Zoom - crops and upscales the frame to original size. */
358     VAProcImageStabilizationTypeFullZoom,
359     /** \brief Number of Image Stabilization Type. */
360     VAProcImageStabilizationTypeCount
361 } VAProcImageStabilizationType;
362 
363 /** @name Video blending flags */
364 /**@{*/
365 /** \brief Global alpha blending. */
366 #define VA_BLEND_GLOBAL_ALPHA           0x0002
367 /** \brief Premultiplied alpha blending (RGBA surfaces only). */
368 #define VA_BLEND_PREMULTIPLIED_ALPHA    0x0008
369 /** \brief Luma color key (YUV surfaces only). */
370 #define VA_BLEND_LUMA_KEY               0x0010
371 /**@}*/
372 
373 /** \brief Video blending state definition. */
374 typedef struct _VABlendState {
375     /** \brief Video blending flags. */
376     unsigned int        flags;
377     /**
378      * \brief Global alpha value.
379      *
380      * Valid if \flags has VA_BLEND_GLOBAL_ALPHA.
381      * Valid range is 0.0 to 1.0 inclusive.
382      */
383     float               global_alpha;
384     /**
385      * \brief Minimum luma value.
386      *
387      * Valid if \flags has VA_BLEND_LUMA_KEY.
388      * Valid range is 0.0 to 1.0 inclusive.
389      * \ref min_luma shall be set to a sensible value lower than \ref max_luma.
390      */
391     float               min_luma;
392     /**
393      * \brief Maximum luma value.
394      *
395      * Valid if \flags has VA_BLEND_LUMA_KEY.
396      * Valid range is 0.0 to 1.0 inclusive.
397      * \ref max_luma shall be set to a sensible value larger than \ref min_luma.
398      */
399     float               max_luma;
400 } VABlendState;
401 
402 /** @name Video pipeline flags */
403 /**@{*/
404 /** \brief Specifies whether to apply subpictures when processing a surface. */
405 #define VA_PROC_PIPELINE_SUBPICTURES    0x00000001
406 /**
407  * \brief Specifies whether to apply power or performance
408  * optimizations to a pipeline.
409  *
410  * When processing several surfaces, it may be necessary to prioritize
411  * more certain pipelines than others. This flag is only a hint to the
412  * video processor so that it can omit certain filters to save power
413  * for example. Typically, this flag could be used with video surfaces
414  * decoded from a secondary bitstream.
415  */
416 #define VA_PROC_PIPELINE_FAST           0x00000002
417 /**@}*/
418 
419 /** @name Video filter flags */
420 /**@{*/
421 /** \brief Specifies whether the filter shall be present in the pipeline. */
422 #define VA_PROC_FILTER_MANDATORY        0x00000001
423 /**@}*/
424 
425 /** @name Pipeline end flags */
426 /**@{*/
427 /** \brief Specifies the pipeline is the last. */
428 #define VA_PIPELINE_FLAG_END		0x00000004
429 /**@}*/
430 
431 /** @name Chroma Siting flag */
432 /**@{*/
433 #define VA_CHROMA_SITING_UNKNOWN              0x00000000
434 /** \brief Chroma samples are co-sited vertically on the top with the luma samples. */
435 #define VA_CHROMA_SITING_VERTICAL_TOP         0x00000001
436 /** \brief Chroma samples are not co-sited vertically with the luma samples. */
437 #define VA_CHROMA_SITING_VERTICAL_CENTER      0x00000002
438 /** \brief Chroma samples are co-sited vertically on the bottom with the luma samples. */
439 #define VA_CHROMA_SITING_VERTICAL_BOTTOM      0x00000003
440 /** \brief Chroma samples are co-sited horizontally on the left with the luma samples. */
441 #define VA_CHROMA_SITING_HORIZONTAL_LEFT      0x00000004
442 /** \brief Chroma samples are not co-sited horizontally with the luma samples. */
443 #define VA_CHROMA_SITING_HORIZONTAL_CENTER    0x00000008
444 /**@}*/
445 
446 /** \brief Video processing pipeline capabilities. */
447 typedef struct _VAProcPipelineCaps {
448     /** \brief Pipeline flags. See VAProcPipelineParameterBuffer::pipeline_flags. */
449     unsigned int        pipeline_flags;
450     /** \brief Extra filter flags. See VAProcPipelineParameterBuffer::filter_flags. */
451     unsigned int        filter_flags;
452     /** \brief Number of forward reference frames that are needed. */
453     unsigned int        num_forward_references;
454     /** \brief Number of backward reference frames that are needed. */
455     unsigned int        num_backward_references;
456     /** \brief List of color standards supported on input. */
457     VAProcColorStandardType *input_color_standards;
458     /** \brief Number of elements in \ref input_color_standards array. */
459     unsigned int        num_input_color_standards;
460     /** \brief List of color standards supported on output. */
461     VAProcColorStandardType *output_color_standards;
462     /** \brief Number of elements in \ref output_color_standards array. */
463     unsigned int        num_output_color_standards;
464     /**
465      * \brief Rotation flags.
466      *
467      * For each rotation angle supported by the underlying hardware,
468      * the corresponding bit is set in \ref rotation_flags. See
469      * "Rotation angles" for a description of rotation angles.
470      *
471      * A value of 0 means the underlying hardware does not support any
472      * rotation. Otherwise, a check for a specific rotation angle can be
473      * performed as follows:
474      *
475      * \code
476      * VAProcPipelineCaps pipeline_caps;
477      * ...
478      * vaQueryVideoProcPipelineCaps(va_dpy, vpp_ctx,
479      *     filter_bufs, num_filter_bufs,
480      *     &pipeline_caps
481      * );
482      * ...
483      * if (pipeline_caps.rotation_flags & (1 << VA_ROTATION_xxx)) {
484      *     // Clockwise rotation by xxx degrees is supported
485      *     ...
486      * }
487      * \endcode
488      */
489     unsigned int        rotation_flags;
490     /** \brief Blend flags. See "Video blending flags". */
491     unsigned int        blend_flags;
492     /**
493      * \brief Mirroring flags.
494      *
495      * For each mirroring direction supported by the underlying hardware,
496      * the corresponding bit is set in \ref mirror_flags. See
497      * "Mirroring directions" for a description of mirroring directions.
498      *
499      */
500     unsigned int        mirror_flags;
501     /** \brief Number of additional output surfaces supported by the pipeline  */
502     unsigned int        num_additional_outputs;
503 } VAProcPipelineCaps;
504 
505 /** \brief Specification of values supported by the filter. */
506 typedef struct _VAProcFilterValueRange {
507     /** \brief Minimum value supported, inclusive. */
508     float               min_value;
509     /** \brief Maximum value supported, inclusive. */
510     float               max_value;
511     /** \brief Default value. */
512     float               default_value;
513     /** \brief Step value that alters the filter behaviour in a sensible way. */
514     float               step;
515 } VAProcFilterValueRange;
516 
517 /**
518  * \brief Video processing pipeline configuration.
519  *
520  * This buffer defines a video processing pipeline. As for any buffer
521  * passed to \c vaRenderPicture(), this is a one-time usage model.
522  * However, the actual filters to be applied are provided in the
523  * \c filters field, so they can be re-used in other processing
524  * pipelines.
525  *
526  * The target surface is specified by the \c render_target argument of
527  * \c vaBeginPicture(). The general usage model is described as follows:
528  * - \c vaBeginPicture(): specify the target surface that receives the
529  *   processed output;
530  * - \c vaRenderPicture(): specify a surface to be processed and composed
531  *   into the \c render_target. Use as many \c vaRenderPicture() calls as
532  *   necessary surfaces to compose ;
533  * - \c vaEndPicture(): tell the driver to start processing the surfaces
534  *   with the requested filters.
535  *
536  * If a filter (e.g. noise reduction) needs to be applied with different
537  * values for multiple surfaces, the application needs to create as many
538  * filter parameter buffers as necessary. i.e. the filter parameters shall
539  * not change between two calls to \c vaRenderPicture().
540  *
541  * For composition usage models, the first surface to process will generally
542  * use an opaque background color, i.e. \c output_background_color set with
543  * the most significant byte set to \c 0xff. For instance, \c 0xff000000 for
544  * a black background. Then, subsequent surfaces would use a transparent
545  * background color.
546  */
547 typedef struct _VAProcPipelineParameterBuffer {
548     /**
549      * \brief Source surface ID.
550      *
551      * ID of the source surface to process. If subpictures are associated
552      * with the video surfaces then they shall be rendered to the target
553      * surface, if the #VA_PROC_PIPELINE_SUBPICTURES pipeline flag is set.
554      */
555     VASurfaceID         surface;
556     /**
557      * \brief Region within the source surface to be processed.
558      *
559      * Pointer to a #VARectangle defining the region within the source
560      * surface to be processed. If NULL, \c surface_region implies the
561      * whole surface.
562      */
563     const VARectangle  *surface_region;
564     /**
565      * \brief Requested input color primaries.
566      *
567      * Color primaries are implicitly converted throughout the processing
568      * pipeline. The video processor chooses the best moment to apply
569      * this conversion. The set of supported color primaries primaries
570      * for input shall be queried with vaQueryVideoProcPipelineCaps().
571      */
572     VAProcColorStandardType surface_color_standard;
573     /**
574      * \brief Region within the output surface.
575      *
576      * Pointer to a #VARectangle defining the region within the output
577      * surface that receives the processed pixels. If NULL, \c output_region
578      * implies the whole surface.
579      *
580      * Note that any pixels residing outside the specified region will
581      * be filled in with the \ref output_background_color.
582      */
583     const VARectangle  *output_region;
584     /**
585      * \brief Background color.
586      *
587      * Background color used to fill in pixels that reside outside of the
588      * specified \ref output_region. The color is specified in ARGB format:
589      * [31:24] alpha, [23:16] red, [15:8] green, [7:0] blue.
590      *
591      * Unless the alpha value is zero or the \ref output_region represents
592      * the whole target surface size, implementations shall not render the
593      * source surface to the target surface directly. Rather, in order to
594      * maintain the exact semantics of \ref output_background_color, the
595      * driver shall use a temporary surface and fill it in with the
596      * appropriate background color. Next, the driver will blend this
597      * temporary surface into the target surface.
598      */
599     unsigned int        output_background_color;
600     /**
601      * \brief Requested output color primaries.
602      */
603     VAProcColorStandardType output_color_standard;
604     /**
605      * \brief Pipeline filters. See video pipeline flags.
606      *
607      * Flags to control the pipeline, like whether to apply subpictures
608      * or not, notify the driver that it can opt for power optimizations,
609      * should this be needed.
610      */
611     unsigned int        pipeline_flags;
612     /**
613      * \brief Extra filter flags. See vaPutSurface() flags.
614      *
615      * Filter flags are used as a fast path, wherever possible, to use
616      * vaPutSurface() flags instead of explicit filter parameter buffers.
617      *
618      * Allowed filter flags API-wise. Use vaQueryVideoProcPipelineCaps()
619      * to check for implementation details:
620      * - Bob-deinterlacing: \c VA_FRAME_PICTURE, \c VA_TOP_FIELD,
621      *   \c VA_BOTTOM_FIELD. Note that any deinterlacing filter
622      *   (#VAProcFilterDeinterlacing) will override those flags.
623      * - Color space conversion: \c VA_SRC_BT601, \c VA_SRC_BT709,
624      *   \c VA_SRC_SMPTE_240.
625      * - Scaling: \c VA_FILTER_SCALING_DEFAULT, \c VA_FILTER_SCALING_FAST,
626      *   \c VA_FILTER_SCALING_HQ, \c VA_FILTER_SCALING_NL_ANAMORPHIC.
627      * - Enable auto noise reduction: \c VA_FILTER_NOISEREDUCTION_AUTO.
628      */
629     unsigned int        filter_flags;
630     /**
631      * \brief Array of filters to apply to the surface.
632      *
633      * The list of filters shall be ordered in the same way the driver expects
634      * them. i.e. as was returned from vaQueryVideoProcFilters().
635      * Otherwise, a #VA_STATUS_ERROR_INVALID_FILTER_CHAIN is returned
636      * from vaRenderPicture() with this buffer.
637      *
638      * #VA_STATUS_ERROR_UNSUPPORTED_FILTER is returned if the list
639      * contains an unsupported filter.
640      *
641      * Note: no filter buffer is destroyed after a call to vaRenderPicture(),
642      * only this pipeline buffer will be destroyed as per the core API
643      * specification. This allows for flexibility in re-using the filter for
644      * other surfaces to be processed.
645      */
646     VABufferID         *filters;
647     /** \brief Actual number of filters. */
648     unsigned int        num_filters;
649     /** \brief Array of forward reference frames. */
650     VASurfaceID        *forward_references;
651     /** \brief Number of forward reference frames that were supplied. */
652     unsigned int        num_forward_references;
653     /** \brief Array of backward reference frames. */
654     VASurfaceID        *backward_references;
655     /** \brief Number of backward reference frames that were supplied. */
656     unsigned int        num_backward_references;
657     /**
658      * \brief Rotation state. See rotation angles.
659      *
660      * The rotation angle is clockwise. There is no specific rotation
661      * center for this operation. Rather, The source \ref surface is
662      * first rotated by the specified angle and then scaled to fit the
663      * \ref output_region.
664      *
665      * This means that the top-left hand corner (0,0) of the output
666      * (rotated) surface is expressed as follows:
667      * - \ref VA_ROTATION_NONE: (0,0) is the top left corner of the
668      *   source surface -- no rotation is performed ;
669      * - \ref VA_ROTATION_90: (0,0) is the bottom-left corner of the
670      *   source surface ;
671      * - \ref VA_ROTATION_180: (0,0) is the bottom-right corner of the
672      *   source surface -- the surface is flipped around the X axis ;
673      * - \ref VA_ROTATION_270: (0,0) is the top-right corner of the
674      *   source surface.
675      *
676      * Check VAProcPipelineCaps::rotation_flags first prior to
677      * defining a specific rotation angle. Otherwise, the hardware can
678      * perfectly ignore this variable if it does not support any
679      * rotation.
680      */
681     unsigned int        rotation_state;
682     /**
683      * \brief blending state. See "Video blending state definition".
684      *
685      * If \ref blend_state is NULL, then default operation mode depends
686      * on the source \ref surface format:
687      * - RGB: per-pixel alpha blending ;
688      * - YUV: no blending, i.e override the underlying pixels.
689      *
690      * Otherwise, \ref blend_state is a pointer to a #VABlendState
691      * structure that shall be live until vaEndPicture().
692      *
693      * Implementation note: the driver is responsible for checking the
694      * blend state flags against the actual source \ref surface format.
695      * e.g. premultiplied alpha blending is only applicable to RGB
696      * surfaces, and luma keying is only applicable to YUV surfaces.
697      * If a mismatch occurs, then #VA_STATUS_ERROR_INVALID_BLEND_STATE
698      * is returned.
699      */
700     const VABlendState *blend_state;
701     /**
702      * \bried mirroring state. See "Mirroring directions".
703      *
704      * Mirroring of an image can be performed either along the
705      * horizontal or vertical axis. It is assumed that the rotation
706      * operation is always performed before the mirroring operation.
707      */
708     unsigned int      mirror_state;
709     /** \brief Array of additional output surfaces. */
710     VASurfaceID        *additional_outputs;
711     /** \brief Number of additional output surfaces. */
712     unsigned int        num_additional_outputs;
713     /**
714      * \brief Flag to indicate the input surface flag such as chroma-siting,
715      * range flag and so on.
716      *
717      * The lower 4 bits are still used as chroma-siting flag
718      * The range_flag bit is used to indicate that the range flag of color-space conversion.
719      * -\ref VA_SOURCE_RANGE_FULL(Full range): Y/Cb/Cr is in [0, 255].It is
720      *   mainly used for JPEG/JFIF formats. The combination with the BT601 flag
721      *   means that JPEG/JFIF color-space conversion matrix is used.
722      * -\ref VA_SOURCE_RANGE_FULL(Reduced range): Y is in [16, 235] and Cb/Cr
723      *   is in [16, 240]. It is mainly used for the YUV<->RGB color-space
724      *   conversion in SDTV/HDTV/UHDTV.
725      */
726     unsigned int        input_surface_flag;
727 } VAProcPipelineParameterBuffer;
728 
729 /**
730  * \brief Filter parameter buffer base.
731  *
732  * This is a helper structure used by driver implementations only.
733  * Users are not supposed to allocate filter parameter buffers of this
734  * type.
735  */
736 typedef struct _VAProcFilterParameterBufferBase {
737     /** \brief Filter type. */
738     VAProcFilterType    type;
739 } VAProcFilterParameterBufferBase;
740 
741 /**
742  * \brief Default filter parametrization.
743  *
744  * Unless there is a filter-specific parameter buffer,
745  * #VAProcFilterParameterBuffer is the default type to use.
746  */
747 typedef struct _VAProcFilterParameterBuffer {
748     /** \brief Filter type. */
749     VAProcFilterType    type;
750     /** \brief Value. */
751     float               value;
752 } VAProcFilterParameterBuffer;
753 
754 /** @name De-interlacing flags */
755 /**@{*/
756 /**
757  * \brief Bottom field first in the input frame.
758  * if this is not set then assumes top field first.
759  */
760 #define VA_DEINTERLACING_BOTTOM_FIELD_FIRST	0x0001
761 /**
762  * \brief Bottom field used in deinterlacing.
763  * if this is not set then assumes top field is used.
764  */
765 #define VA_DEINTERLACING_BOTTOM_FIELD		0x0002
766 /**
767  * \brief A single field is stored in the input frame.
768  * if this is not set then assumes the frame contains two interleaved fields.
769  */
770 #define VA_DEINTERLACING_ONE_FIELD		0x0004
771 /**
772  * \brief Film Mode Detection is enabled. If enabled, driver performs inverse
773  * of various pulldowns, such as 3:2 pulldown.
774  * if this is not set then assumes FMD is disabled.
775  */
776 #define VA_DEINTERLACING_FMD_ENABLE		0x0008
777 /**@}*/
778 
779 /** \brief Deinterlacing filter parametrization. */
780 typedef struct _VAProcFilterParameterBufferDeinterlacing {
781     /** \brief Filter type. Shall be set to #VAProcFilterDeinterlacing. */
782     VAProcFilterType            type;
783     /** \brief Deinterlacing algorithm. */
784     VAProcDeinterlacingType     algorithm;
785     /** \brief Deinterlacing flags. */
786     unsigned int     		flags;
787 } VAProcFilterParameterBufferDeinterlacing;
788 
789 /**
790  * \brief Color balance filter parametrization.
791  *
792  * This buffer defines color balance attributes. A VA buffer can hold
793  * several color balance attributes by creating a VA buffer of desired
794  * number of elements. This can be achieved by the following pseudo-code:
795  *
796  * \code
797  * enum { kHue, kSaturation, kBrightness, kContrast };
798  *
799  * // Initial color balance parameters
800  * static const VAProcFilterParameterBufferColorBalance colorBalanceParams[4] =
801  * {
802  *     [kHue] =
803  *         { VAProcFilterColorBalance, VAProcColorBalanceHue, 0.5 },
804  *     [kSaturation] =
805  *         { VAProcFilterColorBalance, VAProcColorBalanceSaturation, 0.5 },
806  *     [kBrightness] =
807  *         { VAProcFilterColorBalance, VAProcColorBalanceBrightness, 0.5 },
808  *     [kSaturation] =
809  *         { VAProcFilterColorBalance, VAProcColorBalanceSaturation, 0.5 }
810  * };
811  *
812  * // Create buffer
813  * VABufferID colorBalanceBuffer;
814  * vaCreateBuffer(va_dpy, vpp_ctx,
815  *     VAProcFilterParameterBufferType, sizeof(*pColorBalanceParam), 4,
816  *     colorBalanceParams,
817  *     &colorBalanceBuffer
818  * );
819  *
820  * VAProcFilterParameterBufferColorBalance *pColorBalanceParam;
821  * vaMapBuffer(va_dpy, colorBalanceBuffer, &pColorBalanceParam);
822  * {
823  *     // Change brightness only
824  *     pColorBalanceBuffer[kBrightness].value = 0.75;
825  * }
826  * vaUnmapBuffer(va_dpy, colorBalanceBuffer);
827  * \endcode
828  */
829 typedef struct _VAProcFilterParameterBufferColorBalance {
830     /** \brief Filter type. Shall be set to #VAProcFilterColorBalance. */
831     VAProcFilterType            type;
832     /** \brief Color balance attribute. */
833     VAProcColorBalanceType      attrib;
834     /**
835      * \brief Color balance value.
836      *
837      * Special case for automatically adjusted attributes. e.g.
838      * #VAProcColorBalanceAutoSaturation,
839      * #VAProcColorBalanceAutoBrightness,
840      * #VAProcColorBalanceAutoContrast.
841      * - If \ref value is \c 1.0 +/- \c FLT_EPSILON, the attribute is
842      *   automatically adjusted and overrides any other attribute of
843      *   the same type that would have been set explicitly;
844      * - If \ref value is \c 0.0 +/- \c FLT_EPSILON, the attribute is
845      *   disabled and other attribute of the same type is used instead.
846      */
847     float                       value;
848 } VAProcFilterParameterBufferColorBalance;
849 
850 /** @name FRC Custom Rate types. */
851 /**@{*/
852 /** \brief 24p to 60p. */
853 #define VA_FRAME_RATE_CONVERSION_24p_60p    0x0001
854 /** \brief 30p to 60p. */
855 #define VA_FRAME_RATE_CONVERSION_30p_60p    0x0002
856 /**@}*/
857 
858 /** \brief Frame rate conversion filter parametrization. */
859 typedef struct _VAProcFilterParamterBufferFrameRateConversion {
860     /** \brief filter type. Shall be set to #VAProcFilterFrameRateConversion. */
861     VAProcFilterType                    type;
862     /** \brief FPS of input sequence. */
863     unsigned int                        input_fps;
864     /** \brief FPS of output sequence. */
865     unsigned int                        output_fps;
866     /** \brief Number of output frames in addition to the first output frame.
867         \brief If num_output_frames returned from pipeline query is 0,
868         \brief vaRenderPicture() will only produce one output frame with each call*/
869     unsigned int                        num_output_frames;
870     /**
871      * \brief Array to store output frames in addition to the first one.
872      * \brief The first output frame is stored in the render target from vaBeginPicture(). */
873     VASurfaceID*                        output_frames;
874     /** \brief if frame repeat or not. 1: repeat 0: do not repeat */
875     unsigned int                        repeat_frame;
876     /** \brief Counter within one complete FRC Cycle.
877         \brief The counter would run from 0 to 4 for 24to60p in each cycle.
878         \brief The counter would run from 0 to 1 for 30to60p in each cycle. */
879     unsigned int                        cyclic_counter;
880 } VAProcFilterParameterBufferFrameRateConversion;
881 
882 /** \brief Total color correction filter parametrization. */
883 typedef struct _VAProcFilterParameterBufferTotalColorCorrection {
884     /** \brief Filter type. Shall be set to #VAProcFilterTotalColorCorrection. */
885     VAProcFilterType                  type;
886     /** \brief Color to correct. */
887     VAProcTotalColorCorrectionType    attrib;
888     /** \brief Color correction value. */
889     float                             value;
890 } VAProcFilterParameterBufferTotalColorCorrection;
891 
892 /** @name ImageStabilization Perf Types. */
893 /**@{*/
894 /** \brief Fast Mode. */
895 #define VA_IMAGE_STABILIZATION_PERF_TYPE_FAST       0x0001
896  /** \brief Quality Mode. */
897 #define VA_IMAGE_STABILIZATION_PERF_TYPE_QUALITY    0x0002
898 /**@}*/
899 
900 /** \brief Image Stabilization filter parametrization. */
901 typedef struct _VAProcFilterParameterBufferImageStabilization {
902     /** \brief Filter type. Shall be set to #VAProcFilterImageStabilization. */
903     VAProcFilterType                  type;
904     /** \brief Image Stabilization Mode. */
905     VAProcImageStabilizationType      mode;
906     /** \brief Image Stabilization Crop percentage. */
907     float                             crop;
908     /** \brief Image Stabilization Perf type. */
909     unsigned int                      perf_type;
910 } VAProcFilterParameterBufferImageStabilization;
911 
912 /** \brief Non-Linear Anamorphic Scaling filter parametrization. */
913 typedef struct _VAProcFilterParameterBufferNonLinearAnamorphicScaling {
914     /** \brief filter type. Shall be set to #VAProcFilterNonLinearAnamorphicScaling. */
915     VAProcFilterType    type;
916     /** \brief Vertical crop. */
917     float               vertical_crop;
918     /** \brief HLinear region. */
919     float               horizontal_linear_region;
920     /** \brief Non-linear crop. */
921     float               nonlinear_crop;
922 } VAProcFilterParameterBufferNonLinearAnamorphicScaling;
923 
924 /**
925  * \brief Default filter cap specification (single range value).
926  *
927  * Unless there is a filter-specific cap structure, #VAProcFilterCap is the
928  * default type to use for output caps from vaQueryVideoProcFilterCaps().
929  */
930 typedef struct _VAProcFilterCap {
931     /** \brief Range of supported values for the filter. */
932     VAProcFilterValueRange      range;
933 } VAProcFilterCap;
934 
935 /** \brief Capabilities specification for the deinterlacing filter. */
936 typedef struct _VAProcFilterCapDeinterlacing {
937     /** \brief Deinterlacing algorithm. */
938     VAProcDeinterlacingType     type;
939 } VAProcFilterCapDeinterlacing;
940 
941 /** \brief Capabilities specification for the color balance filter. */
942 typedef struct _VAProcFilterCapColorBalance {
943     /** \brief Color balance operation. */
944     VAProcColorBalanceType      type;
945     /** \brief Range of supported values for the specified operation. */
946     VAProcFilterValueRange      range;
947 } VAProcFilterCapColorBalance;
948 
949 /** \brief Capabilities specification for the Total Color Correction filter. */
950 typedef struct _VAProcFilterCapTotalColorCorrection {
951     /** \brief Color to correct. */
952     VAProcTotalColorCorrectionType    type;
953     /** \brief Range of supported values for the specified color. */
954     VAProcFilterValueRange            range;
955 } VAProcFilterCapTotalColorCorrection;
956 
957 /** \brief Capabilities specification for the Image Stabilization filter. */
958 typedef struct _VAProcFilterCapImageStabilization {
959     /** \brief IS modes supported. */
960     VAProcImageStabilizationType       type[VAProcImageStabilizationTypeCount];
961     /** \brief Range of supported values for crop ratio. */
962     VAProcFilterValueRange             crop_range;
963     /** \brief Maximum number of forward reference frames supported. */
964     unsigned int                       max_forward_reference;
965     /** \brief Maximum number of IS perf modes supported. */
966     unsigned int                       perf_type;
967 } VAProcFilterCapImageStabilization;
968 
969 /** \brief Capabilities specification for the Non-Linear Anamorphic Scaling filter. */
970 typedef struct _VAProcFilterCapNonLinearAnamorphicScaling {
971     /** \brief Range of supported values for the vertical crop. */
972     VAProcFilterValueRange      vertical_crop_range;
973     /** \brief Range of supported values for the horizontal linear region. */
974     VAProcFilterValueRange      horizontal_linear_region_range;
975     /** \brief Range of supported values for the non-linear crop. */
976     VAProcFilterValueRange      nonlinear_crop_range;
977 } VAProcFilterCapNonLinearAnamorphicScaling;
978 
979 /** \brief Capabilities specification for the Frame Rate Conversion filter. */
980 typedef struct _VAProcFilterCapFrameRateConversion {
981     /** \brief Should be set to 1 if only supported rates are requested.
982         \brief Set to 0 to get the rest of the caps for the particular custom rate */
983     unsigned int                        bget_custom_rates;
984     /** \brief FRC custom rates supported by the pipeline in the first query
985         \brief App request caps for a custom rate in the second query */
986     unsigned int                        frc_custom_rates;
987     /** \brief FPS of input sequence. */
988     unsigned int                        input_fps;
989     /** \brief FPS of output sequence. */
990     unsigned int                        output_fps;
991     /** \brief Number of input frames. */
992     unsigned int                        input_frames;
993     /** \brief Number of output frames. */
994     unsigned int                        output_frames;
995    /** \brief Set to 1 if interlaced input is supoorted. */
996     unsigned int                        input_interlaced;
997 } VAProcFilterCapFrameRateConversion;
998 
999 /**
1000  * \brief Queries video processing filters.
1001  *
1002  * This function returns the list of video processing filters supported
1003  * by the driver. The \c filters array is allocated by the user and
1004  * \c num_filters shall be initialized to the number of allocated
1005  * elements in that array. Upon successful return, the actual number
1006  * of filters will be overwritten into \c num_filters. Otherwise,
1007  * \c VA_STATUS_ERROR_MAX_NUM_EXCEEDED is returned and \c num_filters
1008  * is adjusted to the number of elements that would be returned if enough
1009  * space was available.
1010  *
1011  * The list of video processing filters supported by the driver shall
1012  * be ordered in the way they can be iteratively applied. This is needed
1013  * for both correctness, i.e. some filters would not mean anything if
1014  * applied at the beginning of the pipeline; but also for performance
1015  * since some filters can be applied in a single pass (e.g. noise
1016  * reduction + deinterlacing).
1017  *
1018  * @param[in] dpy               the VA display
1019  * @param[in] context           the video processing context
1020  * @param[out] filters          the output array of #VAProcFilterType elements
1021  * @param[in,out] num_filters the number of elements allocated on input,
1022  *      the number of elements actually filled in on output
1023  */
1024 VAStatus
1025 vaQueryVideoProcFilters(
1026     VADisplay           dpy,
1027     VAContextID         context,
1028     VAProcFilterType   *filters,
1029     unsigned int       *num_filters
1030 );
1031 
1032 /**
1033  * \brief Queries video filter capabilities.
1034  *
1035  * This function returns the list of capabilities supported by the driver
1036  * for a specific video filter. The \c filter_caps array is allocated by
1037  * the user and \c num_filter_caps shall be initialized to the number
1038  * of allocated elements in that array. Upon successful return, the
1039  * actual number of filters will be overwritten into \c num_filter_caps.
1040  * Otherwise, \c VA_STATUS_ERROR_MAX_NUM_EXCEEDED is returned and
1041  * \c num_filter_caps is adjusted to the number of elements that would be
1042  * returned if enough space was available.
1043  *
1044  * @param[in] dpy               the VA display
1045  * @param[in] context           the video processing context
1046  * @param[in] type              the video filter type
1047  * @param[out] filter_caps      the output array of #VAProcFilterCap elements
1048  * @param[in,out] num_filter_caps the number of elements allocated on input,
1049  *      the number of elements actually filled in output
1050  */
1051 VAStatus
1052 vaQueryVideoProcFilterCaps(
1053     VADisplay           dpy,
1054     VAContextID         context,
1055     VAProcFilterType    type,
1056     void               *filter_caps,
1057     unsigned int       *num_filter_caps
1058 );
1059 
1060 /**
1061  * \brief Queries video processing pipeline capabilities.
1062  *
1063  * This function returns the video processing pipeline capabilities. The
1064  * \c filters array defines the video processing pipeline and is an array
1065  * of buffers holding filter parameters.
1066  *
1067  * Note: the #VAProcPipelineCaps structure contains user-provided arrays.
1068  * If non-NULL, the corresponding \c num_* fields shall be filled in on
1069  * input with the number of elements allocated. Upon successful return,
1070  * the actual number of elements will be overwritten into the \c num_*
1071  * fields. Otherwise, \c VA_STATUS_ERROR_MAX_NUM_EXCEEDED is returned
1072  * and \c num_* fields are adjusted to the number of elements that would
1073  * be returned if enough space was available.
1074  *
1075  * @param[in] dpy               the VA display
1076  * @param[in] context           the video processing context
1077  * @param[in] filters           the array of VA buffers defining the video
1078  *      processing pipeline
1079  * @param[in] num_filters       the number of elements in filters
1080  * @param[in,out] pipeline_caps the video processing pipeline capabilities
1081  */
1082 VAStatus
1083 vaQueryVideoProcPipelineCaps(
1084     VADisplay           dpy,
1085     VAContextID         context,
1086     VABufferID         *filters,
1087     unsigned int        num_filters,
1088     VAProcPipelineCaps *pipeline_caps
1089 );
1090 
1091 /**@}*/
1092 
1093 #ifdef __cplusplus
1094 }
1095 #endif
1096 
1097 #endif /* VA_VPP_H */
1098