2 * Copyright (c) 2007-2011 Intel Corporation. All Rights Reserved.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the
6 * "Software"), to deal in the Software without restriction, including
7 * without limitation the rights to use, copy, modify, merge, publish,
8 * distribute, sub license, and/or sell copies of the Software, and to
9 * permit persons to whom the Software is furnished to do so, subject to
10 * the following conditions:
12 * The above copyright notice and this permission notice (including the
13 * next paragraph) shall be included in all copies or substantial portions
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
19 * IN NO EVENT SHALL INTEL AND/OR ITS SUPPLIERS BE LIABLE FOR
20 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 * \brief The video processing API
29 * This file contains the \ref api_vpp "Video processing API".
40 * \defgroup api_vpp Video processing API
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.
49 * \section api_vpp_caps Query for supported filters
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.
57 * VAEntrypoint *entrypoints;
58 * int i, num_entrypoints, supportsVideoProcessing = 0;
60 * num_entrypoints = vaMaxNumEntrypoints();
61 * entrypoints = malloc(num_entrypoints * sizeof(entrypoints[0]);
62 * vaQueryConfigEntrypoints(va_dpy, VAProfileNone,
63 * entrypoints, &num_entrypoints);
65 * for (i = 0; !supportsVideoProcessing && i < num_entrypoints; i++) {
66 * if (entrypoints[i] == VAEntrypointVideoProc)
67 * supportsVideoProcessing = 1;
71 * Then, the vaQueryVideoProcFilters() function is used to query the
72 * list of video processing filters.
75 * VAProcFilterType filters[VAProcFilterCount];
76 * unsigned int num_filters = VAProcFilterCount;
78 * // num_filters shall be initialized to the length of the array
79 * vaQueryVideoProcFilters(va_dpy, vpp_ctx, &filters, &num_filters);
82 * Finally, individual filter capabilities can be checked with
83 * vaQueryVideoProcFilterCaps().
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
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
101 * \section api_vpp_setup Set up a video processing pipeline
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.
111 * The general control flow is demonstrated by the following pseudo-code:
114 * VABufferID denoise_filter, deint_filter;
115 * VABufferID filter_bufs[VAProcFilterCount];
116 * unsigned int num_filter_bufs;
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
128 * filter_bufs[num_filter_bufs++] = denoise_filter;
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)
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
145 * filter_bufs[num_filter_bufs++] = deint_filter;
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
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];
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,
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));
183 * \section api_vpp_submit Send video processing parameters through VA buffers
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.
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;
197 * vaCreateBuffer(va_dpy, vpp_ctx,
198 * VAProcPipelineParameterBuffer, sizeof(*pipeline_param), 1,
199 * NULL, &pipeline_buf
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;
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);
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;
230 * vaRenderPicture(va_dpy, vpp_ctx, &pipeline_buf, 1);
232 * vaEndPicture(va_dpy, vpp_ctx);
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 Number of video filters. */
258 /** \brief Deinterlacing types. */
259 typedef enum _VAProcDeinterlacingType {
260 VAProcDeinterlacingNone = 0,
261 /** \brief Bob deinterlacing algorithm. */
262 VAProcDeinterlacingBob,
263 /** \brief Weave deinterlacing algorithm. */
264 VAProcDeinterlacingWeave,
265 /** \brief Motion adaptive deinterlacing algorithm. */
266 VAProcDeinterlacingMotionAdaptive,
267 /** \brief Motion compensated deinterlacing algorithm. */
268 VAProcDeinterlacingMotionCompensated,
269 /** \brief Number of deinterlacing algorithms. */
270 VAProcDeinterlacingCount
271 } VAProcDeinterlacingType;
273 /** \brief Color balance types. */
274 typedef enum _VAProcColorBalanceType {
275 VAProcColorBalanceNone = 0,
277 VAProcColorBalanceHue,
278 /** \brief Saturation. */
279 VAProcColorBalanceSaturation,
280 /** \brief Brightness. */
281 VAProcColorBalanceBrightness,
282 /** \brief Contrast. */
283 VAProcColorBalanceContrast,
284 /** \brief Automatically adjusted saturation. */
285 VAProcColorBalanceAutoSaturation,
286 /** \brief Automatically adjusted brightness. */
287 VAProcColorBalanceAutoBrightness,
288 /** \brief Automatically adjusted contrast. */
289 VAProcColorBalanceAutoContrast,
290 /** \brief Number of color balance attributes. */
291 VAProcColorBalanceCount
292 } VAProcColorBalanceType;
294 /** \brief Color standard types.
296 * These define a set of color properties corresponding to particular
299 * Where matrix_coefficients is specified, it applies only to YUV data -
300 * RGB data always use the identity matrix (matrix_coefficients = 0).
302 typedef enum _VAProcColorStandardType {
303 VAProcColorStandardNone = 0,
304 /** \brief ITU-R BT.601.
306 * It is unspecified whether this will use 525-line or 625-line values;
307 * specify the colour primaries and matrix coefficients explicitly if
308 * it is known which one is required.
311 * colour_primaries = 5 or 6
312 * transfer_characteristics = 6
313 * matrix_coefficients = 5 or 6
315 VAProcColorStandardBT601,
316 /** \brief ITU-R BT.709.
319 * colour_primaries = 1
320 * transfer_characteristics = 1
321 * matrix_coefficients = 1
323 VAProcColorStandardBT709,
324 /** \brief ITU-R BT.470-2 System M.
327 * colour_primaries = 4
328 * transfer_characteristics = 4
329 * matrix_coefficients = 4
331 VAProcColorStandardBT470M,
332 /** \brief ITU-R BT.470-2 System B, G.
335 * colour_primaries = 5
336 * transfer_characteristics = 5
337 * matrix_coefficients = 5
339 VAProcColorStandardBT470BG,
340 /** \brief SMPTE-170M.
343 * colour_primaries = 6
344 * transfer_characteristics = 6
345 * matrix_coefficients = 6
347 VAProcColorStandardSMPTE170M,
348 /** \brief SMPTE-240M.
351 * colour_primaries = 7
352 * transfer_characteristics = 7
353 * matrix_coefficients = 7
355 VAProcColorStandardSMPTE240M,
356 /** \brief Generic film.
359 * colour_primaries = 8
360 * transfer_characteristics = 1
361 * matrix_coefficients = 1
363 VAProcColorStandardGenericFilm,
367 * colour_primaries = 1
368 * transfer_characteristics = 13
369 * matrix_coefficients = 0
371 VAProcColorStandardSRGB,
376 VAProcColorStandardSTRGB,
380 * colour_primaries = 1
381 * transfer_characteristics = 11
382 * matrix_coefficients = 5
384 VAProcColorStandardXVYCC601,
388 * colour_primaries = 1
389 * transfer_characteristics = 11
390 * matrix_coefficients = 1
392 VAProcColorStandardXVYCC709,
393 /** \brief ITU-R BT.2020.
396 * colour_primaries = 9
397 * transfer_characteristics = 14
398 * matrix_coefficients = 9
400 VAProcColorStandardBT2020,
401 /** \brief Explicitly specified color properties.
403 * Use corresponding color properties section.
405 VAProcColorStandardExplicit,
406 /** \brief Number of color standards. */
407 VAProcColorStandardCount
408 } VAProcColorStandardType;
410 /** \brief Total color correction types. */
411 typedef enum _VAProcTotalColorCorrectionType {
412 VAProcTotalColorCorrectionNone = 0,
413 /** \brief Red Saturation. */
414 VAProcTotalColorCorrectionRed,
415 /** \brief Green Saturation. */
416 VAProcTotalColorCorrectionGreen,
417 /** \brief Blue Saturation. */
418 VAProcTotalColorCorrectionBlue,
419 /** \brief Cyan Saturation. */
420 VAProcTotalColorCorrectionCyan,
421 /** \brief Magenta Saturation. */
422 VAProcTotalColorCorrectionMagenta,
423 /** \brief Yellow Saturation. */
424 VAProcTotalColorCorrectionYellow,
425 /** \brief Number of color correction attributes. */
426 VAProcTotalColorCorrectionCount
427 } VAProcTotalColorCorrectionType;
428 /** @name Video blending flags */
430 /** \brief Global alpha blending. */
431 #define VA_BLEND_GLOBAL_ALPHA 0x0001
432 /** \brief Premultiplied alpha blending (RGBA surfaces only). */
433 #define VA_BLEND_PREMULTIPLIED_ALPHA 0x0002
434 /** \brief Luma color key (YUV surfaces only). */
435 #define VA_BLEND_LUMA_KEY 0x0010
438 /** \brief Video blending state definition. */
439 typedef struct _VABlendState {
440 /** \brief Video blending flags. */
443 * \brief Global alpha value.
445 * Valid if \flags has VA_BLEND_GLOBAL_ALPHA.
446 * Valid range is 0.0 to 1.0 inclusive.
450 * \brief Minimum luma value.
452 * Valid if \flags has VA_BLEND_LUMA_KEY.
453 * Valid range is 0.0 to 1.0 inclusive.
454 * \ref min_luma shall be set to a sensible value lower than \ref max_luma.
458 * \brief Maximum luma value.
460 * Valid if \flags has VA_BLEND_LUMA_KEY.
461 * Valid range is 0.0 to 1.0 inclusive.
462 * \ref max_luma shall be set to a sensible value larger than \ref min_luma.
467 /** @name Video pipeline flags */
469 /** \brief Specifies whether to apply subpictures when processing a surface. */
470 #define VA_PROC_PIPELINE_SUBPICTURES 0x00000001
472 * \brief Specifies whether to apply power or performance
473 * optimizations to a pipeline.
475 * When processing several surfaces, it may be necessary to prioritize
476 * more certain pipelines than others. This flag is only a hint to the
477 * video processor so that it can omit certain filters to save power
478 * for example. Typically, this flag could be used with video surfaces
479 * decoded from a secondary bitstream.
481 #define VA_PROC_PIPELINE_FAST 0x00000002
484 /** @name Video filter flags */
486 /** \brief Specifies whether the filter shall be present in the pipeline. */
487 #define VA_PROC_FILTER_MANDATORY 0x00000001
490 /** @name Pipeline end flags */
492 /** \brief Specifies the pipeline is the last. */
493 #define VA_PIPELINE_FLAG_END 0x00000004
496 /** @name Chroma Siting flag */
498 /** vertical chroma sitting take bit 0-1, horizontal chroma sitting take bit 2-3
499 * vertical chromma siting | horizontal chroma sitting to be chroma sitting */
500 #define VA_CHROMA_SITING_UNKNOWN 0x00
501 /** \brief Chroma samples are co-sited vertically on the top with the luma samples. */
502 #define VA_CHROMA_SITING_VERTICAL_TOP 0x01
503 /** \brief Chroma samples are not co-sited vertically with the luma samples. */
504 #define VA_CHROMA_SITING_VERTICAL_CENTER 0x02
505 /** \brief Chroma samples are co-sited vertically on the bottom with the luma samples. */
506 #define VA_CHROMA_SITING_VERTICAL_BOTTOM 0x03
507 /** \brief Chroma samples are co-sited horizontally on the left with the luma samples. */
508 #define VA_CHROMA_SITING_HORIZONTAL_LEFT 0x04
509 /** \brief Chroma samples are not co-sited horizontally with the luma samples. */
510 #define VA_CHROMA_SITING_HORIZONTAL_CENTER 0x08
514 * This is to indicate that the color-space conversion uses full range or reduced range.
515 * VA_SOURCE_RANGE_FULL(Full range): Y/Cb/Cr is in [0, 255]. It is mainly used
516 * for JPEG/JFIF formats. The combination with the BT601 flag means that
517 * JPEG/JFIF color-space conversion matrix is used.
518 * VA_SOURCE_RANGE_REDUCED(Reduced range): Y is in [16, 235] and Cb/Cr is in [16, 240].
519 * It is mainly used for the YUV->RGB color-space conversion in SDTV/HDTV/UHDTV.
521 #define VA_SOURCE_RANGE_UNKNOWN 0
522 #define VA_SOURCE_RANGE_REDUCED 1
523 #define VA_SOURCE_RANGE_FULL 2
525 /** \brief Video processing pipeline capabilities. */
526 typedef struct _VAProcPipelineCaps {
527 /** \brief Pipeline flags. See VAProcPipelineParameterBuffer::pipeline_flags. */
528 uint32_t pipeline_flags;
529 /** \brief Extra filter flags. See VAProcPipelineParameterBuffer::filter_flags. */
530 uint32_t filter_flags;
531 /** \brief Number of forward reference frames that are needed. */
532 uint32_t num_forward_references;
533 /** \brief Number of backward reference frames that are needed. */
534 uint32_t num_backward_references;
535 /** \brief List of color standards supported on input. */
536 VAProcColorStandardType *input_color_standards;
537 /** \brief Number of elements in \ref input_color_standards array. */
538 uint32_t num_input_color_standards;
539 /** \brief List of color standards supported on output. */
540 VAProcColorStandardType *output_color_standards;
541 /** \brief Number of elements in \ref output_color_standards array. */
542 uint32_t num_output_color_standards;
545 * \brief Rotation flags.
547 * For each rotation angle supported by the underlying hardware,
548 * the corresponding bit is set in \ref rotation_flags. See
549 * "Rotation angles" for a description of rotation angles.
551 * A value of 0 means the underlying hardware does not support any
552 * rotation. Otherwise, a check for a specific rotation angle can be
553 * performed as follows:
556 * VAProcPipelineCaps pipeline_caps;
558 * vaQueryVideoProcPipelineCaps(va_dpy, vpp_ctx,
559 * filter_bufs, num_filter_bufs,
563 * if (pipeline_caps.rotation_flags & (1 << VA_ROTATION_xxx)) {
564 * // Clockwise rotation by xxx degrees is supported
569 uint32_t rotation_flags;
570 /** \brief Blend flags. See "Video blending flags". */
571 uint32_t blend_flags;
573 * \brief Mirroring flags.
575 * For each mirroring direction supported by the underlying hardware,
576 * the corresponding bit is set in \ref mirror_flags. See
577 * "Mirroring directions" for a description of mirroring directions.
580 uint32_t mirror_flags;
581 /** \brief Number of additional output surfaces supported by the pipeline */
582 uint32_t num_additional_outputs;
584 /** \brief Number of elements in \ref input_pixel_format array. */
585 uint32_t num_input_pixel_formats;
586 /** \brief List of input pixel formats in fourcc. */
587 uint32_t *input_pixel_format;
588 /** \brief Number of elements in \ref output_pixel_format array. */
589 uint32_t num_output_pixel_formats;
590 /** \brief List of output pixel formats in fourcc. */
591 uint32_t *output_pixel_format;
593 /** \brief Max supported input width in pixels. */
594 uint32_t max_input_width;
595 /** \brief Max supported input height in pixels. */
596 uint32_t max_input_height;
597 /** \brief Min supported input width in pixels. */
598 uint32_t min_input_width;
599 /** \brief Min supported input height in pixels. */
600 uint32_t min_input_height;
602 /** \brief Max supported output width in pixels. */
603 uint32_t max_output_width;
604 /** \brief Max supported output height in pixels. */
605 uint32_t max_output_height;
606 /** \brief Min supported output width in pixels. */
607 uint32_t min_output_width;
608 /** \brief Min supported output height in pixels. */
609 uint32_t min_output_height;
610 /** \brief Reserved bytes for future use, must be zero */
611 #if defined(__AMD64__) || defined(__x86_64__) || defined(__amd64__) || defined(__LP64__)
612 uint32_t va_reserved[VA_PADDING_HIGH - 2];
614 uint32_t va_reserved[VA_PADDING_HIGH];
616 } VAProcPipelineCaps;
618 /** \brief Specification of values supported by the filter. */
619 typedef struct _VAProcFilterValueRange {
620 /** \brief Minimum value supported, inclusive. */
622 /** \brief Maximum value supported, inclusive. */
624 /** \brief Default value. */
626 /** \brief Step value that alters the filter behaviour in a sensible way. */
629 /** \brief Reserved bytes for future use, must be zero */
630 uint32_t va_reserved[VA_PADDING_LOW];
631 } VAProcFilterValueRange;
633 typedef struct _VAProcColorProperties {
634 /** Chroma sample location.\c VA_CHROMA_SITING_VERTICAL_XXX | VA_CHROMA_SITING_HORIZONTAL_XXX */
635 uint8_t chroma_sample_location;
636 /** Chroma sample location. \c VA_SOURCE_RANGE_XXX*/
638 /** Colour primaries.
640 * See ISO/IEC 23001-8 or ITU H.273, section 8.1 and table 2.
641 * Only used if the color standard in use is \c VAColorStandardExplicit.
643 uint8_t colour_primaries;
644 /** Transfer characteristics.
646 * See ISO/IEC 23001-8 or ITU H.273, section 8.2 and table 3.
647 * Only used if the color standard in use is \c VAColorStandardExplicit.
649 uint8_t transfer_characteristics;
650 /** Matrix coefficients.
652 * See ISO/IEC 23001-8 or ITU H.273, section 8.3 and table 4.
653 * Only used if the color standard in use is \c VAColorStandardExplicit.
655 uint8_t matrix_coefficients;
656 /** Reserved bytes for future use, must be zero. */
658 } VAProcColorProperties;
661 * \brief Video processing pipeline configuration.
663 * This buffer defines a video processing pipeline. The actual filters to
664 * be applied are provided in the \c filters field, they can be re-used
665 * in other processing pipelines.
667 * The target surface is specified by the \c render_target argument of
668 * \c vaBeginPicture(). The general usage model is described as follows:
669 * - \c vaBeginPicture(): specify the target surface that receives the
671 * - \c vaRenderPicture(): specify a surface to be processed and composed
672 * into the \c render_target. Use as many \c vaRenderPicture() calls as
673 * necessary surfaces to compose ;
674 * - \c vaEndPicture(): tell the driver to start processing the surfaces
675 * with the requested filters.
677 * If a filter (e.g. noise reduction) needs to be applied with different
678 * values for multiple surfaces, the application needs to create as many
679 * filter parameter buffers as necessary. i.e. the filter parameters shall
680 * not change between two calls to \c vaRenderPicture().
682 * For composition usage models, the first surface to process will generally
683 * use an opaque background color, i.e. \c output_background_color set with
684 * the most significant byte set to \c 0xff. For instance, \c 0xff000000 for
685 * a black background. Then, subsequent surfaces would use a transparent
688 typedef struct _VAProcPipelineParameterBuffer {
690 * \brief Source surface ID.
692 * ID of the source surface to process. If subpictures are associated
693 * with the video surfaces then they shall be rendered to the target
694 * surface, if the #VA_PROC_PIPELINE_SUBPICTURES pipeline flag is set.
698 * \brief Region within the source surface to be processed.
700 * Pointer to a #VARectangle defining the region within the source
701 * surface to be processed. If NULL, \c surface_region implies the
704 const VARectangle *surface_region;
706 * \brief Requested input color standard.
708 * Color properties are implicitly converted throughout the processing
709 * pipeline. The video processor chooses the best moment to apply
710 * this conversion. The set of supported color standards for input shall
711 * be queried with vaQueryVideoProcPipelineCaps().
713 * If this is set to VAProcColorStandardExplicit, the color properties
714 * are specified explicitly in surface_color_properties instead.
716 VAProcColorStandardType surface_color_standard;
718 * \brief Region within the output surface.
720 * Pointer to a #VARectangle defining the region within the output
721 * surface that receives the processed pixels. If NULL, \c output_region
722 * implies the whole surface.
724 * Note that any pixels residing outside the specified region will
725 * be filled in with the \ref output_background_color.
727 const VARectangle *output_region;
729 * \brief Background color.
731 * Background color used to fill in pixels that reside outside of the
732 * specified \ref output_region. The color is specified in ARGB format:
733 * [31:24] alpha, [23:16] red, [15:8] green, [7:0] blue.
735 * Unless the alpha value is zero or the \ref output_region represents
736 * the whole target surface size, implementations shall not render the
737 * source surface to the target surface directly. Rather, in order to
738 * maintain the exact semantics of \ref output_background_color, the
739 * driver shall use a temporary surface and fill it in with the
740 * appropriate background color. Next, the driver will blend this
741 * temporary surface into the target surface.
743 uint32_t output_background_color;
745 * \brief Requested output color standard.
747 * If this is set to VAProcColorStandardExplicit, the color properties
748 * are specified explicitly in output_color_properties instead.
750 VAProcColorStandardType output_color_standard;
752 * \brief Pipeline filters. See video pipeline flags.
754 * Flags to control the pipeline, like whether to apply subpictures
755 * or not, notify the driver that it can opt for power optimizations,
756 * should this be needed.
758 uint32_t pipeline_flags;
760 * \brief Extra filter flags. See vaPutSurface() flags.
762 * Filter flags are used as a fast path, wherever possible, to use
763 * vaPutSurface() flags instead of explicit filter parameter buffers.
765 * Allowed filter flags API-wise. Use vaQueryVideoProcPipelineCaps()
766 * to check for implementation details:
767 * - Bob-deinterlacing: \c VA_FRAME_PICTURE, \c VA_TOP_FIELD,
768 * \c VA_BOTTOM_FIELD. Note that any deinterlacing filter
769 * (#VAProcFilterDeinterlacing) will override those flags.
770 * - Color space conversion: \c VA_SRC_BT601, \c VA_SRC_BT709,
771 * \c VA_SRC_SMPTE_240.
772 * - Scaling: \c VA_FILTER_SCALING_DEFAULT, \c VA_FILTER_SCALING_FAST,
773 * \c VA_FILTER_SCALING_HQ, \c VA_FILTER_SCALING_NL_ANAMORPHIC.
775 uint32_t filter_flags;
777 * \brief Array of filters to apply to the surface.
779 * The list of filters shall be ordered in the same way the driver expects
780 * them. i.e. as was returned from vaQueryVideoProcFilters().
781 * Otherwise, a #VA_STATUS_ERROR_INVALID_FILTER_CHAIN is returned
782 * from vaRenderPicture() with this buffer.
784 * #VA_STATUS_ERROR_UNSUPPORTED_FILTER is returned if the list
785 * contains an unsupported filter.
789 /** \brief Actual number of filters. */
790 uint32_t num_filters;
791 /** \brief Array of forward reference frames. */
792 VASurfaceID *forward_references;
793 /** \brief Number of forward reference frames that were supplied. */
794 uint32_t num_forward_references;
795 /** \brief Array of backward reference frames. */
796 VASurfaceID *backward_references;
797 /** \brief Number of backward reference frames that were supplied. */
798 uint32_t num_backward_references;
800 * \brief Rotation state. See rotation angles.
802 * The rotation angle is clockwise. There is no specific rotation
803 * center for this operation. Rather, The source \ref surface is
804 * first rotated by the specified angle and then scaled to fit the
805 * \ref output_region.
807 * This means that the top-left hand corner (0,0) of the output
808 * (rotated) surface is expressed as follows:
809 * - \ref VA_ROTATION_NONE: (0,0) is the top left corner of the
810 * source surface -- no rotation is performed ;
811 * - \ref VA_ROTATION_90: (0,0) is the bottom-left corner of the
813 * - \ref VA_ROTATION_180: (0,0) is the bottom-right corner of the
814 * source surface -- the surface is flipped around the X axis ;
815 * - \ref VA_ROTATION_270: (0,0) is the top-right corner of the
818 * Check VAProcPipelineCaps::rotation_flags first prior to
819 * defining a specific rotation angle. Otherwise, the hardware can
820 * perfectly ignore this variable if it does not support any
823 uint32_t rotation_state;
825 * \brief blending state. See "Video blending state definition".
827 * If \ref blend_state is NULL, then default operation mode depends
828 * on the source \ref surface format:
829 * - RGB: per-pixel alpha blending ;
830 * - YUV: no blending, i.e override the underlying pixels.
832 * Otherwise, \ref blend_state is a pointer to a #VABlendState
833 * structure that shall be live until vaEndPicture().
835 * Implementation note: the driver is responsible for checking the
836 * blend state flags against the actual source \ref surface format.
837 * e.g. premultiplied alpha blending is only applicable to RGB
838 * surfaces, and luma keying is only applicable to YUV surfaces.
839 * If a mismatch occurs, then #VA_STATUS_ERROR_INVALID_BLEND_STATE
842 const VABlendState *blend_state;
844 * \bried mirroring state. See "Mirroring directions".
846 * Mirroring of an image can be performed either along the
847 * horizontal or vertical axis. It is assumed that the rotation
848 * operation is always performed before the mirroring operation.
850 uint32_t mirror_state;
851 /** \brief Array of additional output surfaces. */
852 VASurfaceID *additional_outputs;
853 /** \brief Number of additional output surfaces. */
854 uint32_t num_additional_outputs;
856 * \brief Flag to indicate the input surface flag
858 * bit0: 0 non-protected 1: protected
859 * bit 1~31 for future
861 uint32_t input_surface_flag;
863 * \brief Flag to indicate the output surface flag
865 * bit0: 0 non-protected 1: protected
866 * bit 1~31 for future
868 uint32_t output_surface_flag;
870 VAProcColorProperties input_color_properties;
872 VAProcColorProperties output_color_properties;
874 /** \brief Reserved bytes for future use, must be zero */
875 #if defined(__AMD64__) || defined(__x86_64__) || defined(__amd64__)|| defined(__LP64__)
876 uint32_t va_reserved[VA_PADDING_LARGE - 13];
878 uint32_t va_reserved[VA_PADDING_LARGE - 11];
880 } VAProcPipelineParameterBuffer;
883 * \brief Filter parameter buffer base.
885 * This is a helper structure used by driver implementations only.
886 * Users are not supposed to allocate filter parameter buffers of this
889 typedef struct _VAProcFilterParameterBufferBase {
890 /** \brief Filter type. */
891 VAProcFilterType type;
892 } VAProcFilterParameterBufferBase;
895 * \brief Default filter parametrization.
897 * Unless there is a filter-specific parameter buffer,
898 * #VAProcFilterParameterBuffer is the default type to use.
900 typedef struct _VAProcFilterParameterBuffer {
901 /** \brief Filter type. */
902 VAProcFilterType type;
906 /** \brief Reserved bytes for future use, must be zero */
907 uint32_t va_reserved[VA_PADDING_LOW];
908 } VAProcFilterParameterBuffer;
910 /** @name De-interlacing flags */
913 * \brief Bottom field first in the input frame.
914 * if this is not set then assumes top field first.
916 #define VA_DEINTERLACING_BOTTOM_FIELD_FIRST 0x0001
918 * \brief Bottom field used in deinterlacing.
919 * if this is not set then assumes top field is used.
921 #define VA_DEINTERLACING_BOTTOM_FIELD 0x0002
923 * \brief A single field is stored in the input frame.
924 * if this is not set then assumes the frame contains two interleaved fields.
926 #define VA_DEINTERLACING_ONE_FIELD 0x0004
928 * \brief Film Mode Detection is enabled. If enabled, driver performs inverse
929 * of various pulldowns, such as 3:2 pulldown.
930 * if this is not set then assumes FMD is disabled.
932 #define VA_DEINTERLACING_FMD_ENABLE 0x0008
934 //Scene change parameter for ADI on Linux, if enabled, driver use spatial DI(Bob), instead of ADI. if not, use old behavior for ADI
935 //Input stream is TFF(set flags = 0), SRC0,1,2,3 are interlaced frame (top +bottom fields), DSTs are progressive frames
937 //SRC0 -> BOBDI, no reference, set flag = 0, output DST0
938 //SRC1 -> ADI, reference frame=SRC0, set flags = 0, call VP, output DST1
939 //SRC2 -> ADI, reference frame=SRC1, set flags = 0x0010(decimal 16), call VP, output DST2(T4)
940 //SRC3 -> ADI, reference frame=SRC2, set flags = 0, call VP, output DST3
942 //SRC0 -> BOBDI, no reference, set flag = 0, output DST0
943 //SRC0 -> BOBDI, no reference, set flag =0x0002, output DST1
945 //SRC1 -> ADI, reference frame =SRC0, set flags = 0, call VP, output DST2
946 //SRC1 -> ADI, reference frame =SRC0, set flags = 0x0012(decimal18), call VP, output DST3(B3)
948 //SRC2 -> ADI, reference frame =SRC1, set flags = 0x0010(decimal 16), call VP, output DST4(T4)
949 //SRC2 -> ADI, reference frame =SRC1, set flags = 0x0002, call VP, output DST5
951 //SRC3 -> ADI, reference frame =SRC2, set flags = 0, call VP, output DST6
952 //SRC3 -> ADI, reference frame =SRC1, set flags = 0x0002, call VP, output DST7
954 #define VA_DEINTERLACING_SCD_ENABLE 0x0010
958 /** \brief Deinterlacing filter parametrization. */
959 typedef struct _VAProcFilterParameterBufferDeinterlacing {
960 /** \brief Filter type. Shall be set to #VAProcFilterDeinterlacing. */
961 VAProcFilterType type;
962 /** \brief Deinterlacing algorithm. */
963 VAProcDeinterlacingType algorithm;
964 /** \brief Deinterlacing flags. */
967 /** \brief Reserved bytes for future use, must be zero */
968 uint32_t va_reserved[VA_PADDING_LOW];
969 } VAProcFilterParameterBufferDeinterlacing;
972 * \brief Color balance filter parametrization.
974 * This buffer defines color balance attributes. A VA buffer can hold
975 * several color balance attributes by creating a VA buffer of desired
976 * number of elements. This can be achieved by the following pseudo-code:
979 * enum { kHue, kSaturation, kBrightness, kContrast };
981 * // Initial color balance parameters
982 * static const VAProcFilterParameterBufferColorBalance colorBalanceParams[4] =
985 * { VAProcFilterColorBalance, VAProcColorBalanceHue, 0.5 },
987 * { VAProcFilterColorBalance, VAProcColorBalanceSaturation, 0.5 },
989 * { VAProcFilterColorBalance, VAProcColorBalanceBrightness, 0.5 },
991 * { VAProcFilterColorBalance, VAProcColorBalanceSaturation, 0.5 }
995 * VABufferID colorBalanceBuffer;
996 * vaCreateBuffer(va_dpy, vpp_ctx,
997 * VAProcFilterParameterBufferType, sizeof(*pColorBalanceParam), 4,
998 * colorBalanceParams,
999 * &colorBalanceBuffer
1002 * VAProcFilterParameterBufferColorBalance *pColorBalanceParam;
1003 * vaMapBuffer(va_dpy, colorBalanceBuffer, &pColorBalanceParam);
1005 * // Change brightness only
1006 * pColorBalanceBuffer[kBrightness].value = 0.75;
1008 * vaUnmapBuffer(va_dpy, colorBalanceBuffer);
1011 typedef struct _VAProcFilterParameterBufferColorBalance {
1012 /** \brief Filter type. Shall be set to #VAProcFilterColorBalance. */
1013 VAProcFilterType type;
1014 /** \brief Color balance attribute. */
1015 VAProcColorBalanceType attrib;
1017 * \brief Color balance value.
1019 * Special case for automatically adjusted attributes. e.g.
1020 * #VAProcColorBalanceAutoSaturation,
1021 * #VAProcColorBalanceAutoBrightness,
1022 * #VAProcColorBalanceAutoContrast.
1023 * - If \ref value is \c 1.0 +/- \c FLT_EPSILON, the attribute is
1024 * automatically adjusted and overrides any other attribute of
1025 * the same type that would have been set explicitly;
1026 * - If \ref value is \c 0.0 +/- \c FLT_EPSILON, the attribute is
1027 * disabled and other attribute of the same type is used instead.
1031 /** \brief Reserved bytes for future use, must be zero */
1032 uint32_t va_reserved[VA_PADDING_LOW];
1033 } VAProcFilterParameterBufferColorBalance;
1035 /** \brief Total color correction filter parametrization. */
1036 typedef struct _VAProcFilterParameterBufferTotalColorCorrection {
1037 /** \brief Filter type. Shall be set to #VAProcFilterTotalColorCorrection. */
1038 VAProcFilterType type;
1039 /** \brief Color to correct. */
1040 VAProcTotalColorCorrectionType attrib;
1041 /** \brief Color correction value. */
1043 } VAProcFilterParameterBufferTotalColorCorrection;
1045 /** \brief Human Vision System(HVS) Noise reduction filter parametrization. */
1046 typedef struct _VAProcFilterParameterBufferHVSNoiseReduction {
1047 /** \brief Filter type. Shall be set to #VAProcFilterHVSNoiseReduction. */
1048 VAProcFilterType type;
1049 /** \brief QP for encoding, used for HVS Denoise */
1052 * \brief QP to Noise Reduction Strength Mode, used for Human Vision System Based Noise Reduction.
1053 * Controls Noise Reduction strength of conservative and aggressive mode.
1054 * It is an integer from [0-16].
1055 * Value 0 means completely turn off Noise Reduction;
1056 * Value 16 means the most aggressive mode of Noise Reduction;
1057 * Value 10 is the default value.
1060 /** \brief Reserved bytes for future use, must be zero */
1061 uint16_t va_reserved[VA_PADDING_HIGH];
1062 } VAProcFilterParameterBufferHVSNoiseReduction;
1065 * \brief Default filter cap specification (single range value).
1067 * Unless there is a filter-specific cap structure, #VAProcFilterCap is the
1068 * default type to use for output caps from vaQueryVideoProcFilterCaps().
1070 typedef struct _VAProcFilterCap {
1071 /** \brief Range of supported values for the filter. */
1072 VAProcFilterValueRange range;
1074 /** \brief Reserved bytes for future use, must be zero */
1075 uint32_t va_reserved[VA_PADDING_LOW];
1078 /** \brief Capabilities specification for the deinterlacing filter. */
1079 typedef struct _VAProcFilterCapDeinterlacing {
1080 /** \brief Deinterlacing algorithm. */
1081 VAProcDeinterlacingType type;
1083 /** \brief Reserved bytes for future use, must be zero */
1084 uint32_t va_reserved[VA_PADDING_LOW];
1085 } VAProcFilterCapDeinterlacing;
1087 /** \brief Capabilities specification for the color balance filter. */
1088 typedef struct _VAProcFilterCapColorBalance {
1089 /** \brief Color balance operation. */
1090 VAProcColorBalanceType type;
1091 /** \brief Range of supported values for the specified operation. */
1092 VAProcFilterValueRange range;
1094 /** \brief Reserved bytes for future use, must be zero */
1095 uint32_t va_reserved[VA_PADDING_LOW];
1096 } VAProcFilterCapColorBalance;
1098 /** \brief Capabilities specification for the Total Color Correction filter. */
1099 typedef struct _VAProcFilterCapTotalColorCorrection {
1100 /** \brief Color to correct. */
1101 VAProcTotalColorCorrectionType type;
1102 /** \brief Range of supported values for the specified color. */
1103 VAProcFilterValueRange range;
1104 } VAProcFilterCapTotalColorCorrection;
1107 * \brief Queries video processing filters.
1109 * This function returns the list of video processing filters supported
1110 * by the driver. The \c filters array is allocated by the user and
1111 * \c num_filters shall be initialized to the number of allocated
1112 * elements in that array. Upon successful return, the actual number
1113 * of filters will be overwritten into \c num_filters. Otherwise,
1114 * \c VA_STATUS_ERROR_MAX_NUM_EXCEEDED is returned and \c num_filters
1115 * is adjusted to the number of elements that would be returned if enough
1116 * space was available.
1118 * The list of video processing filters supported by the driver shall
1119 * be ordered in the way they can be iteratively applied. This is needed
1120 * for both correctness, i.e. some filters would not mean anything if
1121 * applied at the beginning of the pipeline; but also for performance
1122 * since some filters can be applied in a single pass (e.g. noise
1123 * reduction + deinterlacing).
1125 * @param[in] dpy the VA display
1126 * @param[in] context the video processing context
1127 * @param[out] filters the output array of #VAProcFilterType elements
1128 * @param[in,out] num_filters the number of elements allocated on input,
1129 * the number of elements actually filled in on output
1132 vaQueryVideoProcFilters(
1134 VAContextID context,
1135 VAProcFilterType *filters,
1136 unsigned int *num_filters
1140 * \brief Queries video filter capabilities.
1142 * This function returns the list of capabilities supported by the driver
1143 * for a specific video filter. The \c filter_caps array is allocated by
1144 * the user and \c num_filter_caps shall be initialized to the number
1145 * of allocated elements in that array. Upon successful return, the
1146 * actual number of filters will be overwritten into \c num_filter_caps.
1147 * Otherwise, \c VA_STATUS_ERROR_MAX_NUM_EXCEEDED is returned and
1148 * \c num_filter_caps is adjusted to the number of elements that would be
1149 * returned if enough space was available.
1151 * @param[in] dpy the VA display
1152 * @param[in] context the video processing context
1153 * @param[in] type the video filter type
1154 * @param[out] filter_caps the output array of #VAProcFilterCap elements
1155 * @param[in,out] num_filter_caps the number of elements allocated on input,
1156 * the number of elements actually filled in output
1159 vaQueryVideoProcFilterCaps(
1161 VAContextID context,
1162 VAProcFilterType type,
1164 unsigned int *num_filter_caps
1168 * \brief Queries video processing pipeline capabilities.
1170 * This function returns the video processing pipeline capabilities. The
1171 * \c filters array defines the video processing pipeline and is an array
1172 * of buffers holding filter parameters.
1174 * Note: the #VAProcPipelineCaps structure contains user-provided arrays.
1175 * If non-NULL, the corresponding \c num_* fields shall be filled in on
1176 * input with the number of elements allocated. Upon successful return,
1177 * the actual number of elements will be overwritten into the \c num_*
1178 * fields. Otherwise, \c VA_STATUS_ERROR_MAX_NUM_EXCEEDED is returned
1179 * and \c num_* fields are adjusted to the number of elements that would
1180 * be returned if enough space was available.
1182 * @param[in] dpy the VA display
1183 * @param[in] context the video processing context
1184 * @param[in] filters the array of VA buffers defining the video
1185 * processing pipeline
1186 * @param[in] num_filters the number of elements in filters
1187 * @param[in,out] pipeline_caps the video processing pipeline capabilities
1190 vaQueryVideoProcPipelineCaps(
1192 VAContextID context,
1193 VABufferID *filters,
1194 unsigned int num_filters,
1195 VAProcPipelineCaps *pipeline_caps
1204 #endif /* VA_VPP_H */