2 * gstvaapipostprocutil.h - VA-API video post processing utilities
4 * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
5 * Copyright (C) 2005-2012 David Schleef <ds@schleef.org>
6 * Copyright (C) 2016 Intel Corporation
7 * Author: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
8 * Author: Victor Jaquez <victorx.jaquez@intel.com>
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public License
12 * as published by the Free Software Foundation; either version 2.1
13 * of the License, or (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with this program; if not, write to the Free
22 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
23 * Boston, MA 02110-1301 USA
26 #include <gst/vaapi/gstvaapifilter.h>
28 #include "gstvaapipostprocutil.h"
29 #include "gstvaapipluginutil.h"
31 #define GST_CAT_DEFAULT (GST_VAAPI_PLUGIN_BASE (postproc)->debug_category)
33 /* if format property is set */
35 _transform_format (GstVaapiPostproc * postproc, GstCapsFeatures * features,
36 GstStructure * structure)
38 GValue value = G_VALUE_INIT;
40 if (postproc->format == DEFAULT_FORMAT)
43 if (!gst_caps_features_is_equal (features,
44 GST_CAPS_FEATURES_MEMORY_SYSTEM_MEMORY)
45 && !gst_caps_features_contains (features,
46 GST_CAPS_FEATURE_MEMORY_VAAPI_SURFACE))
49 if (!gst_vaapi_value_set_format (&value, postproc->format))
52 gst_structure_set_value (structure, "format", &value);
53 g_value_unset (&value);
57 _set_int (GValue * value, gint val)
59 g_value_init (value, G_TYPE_INT);
60 g_value_set_int (value, val);
64 _set_int_range (GValue * value)
66 g_value_init (value, GST_TYPE_INT_RANGE);
67 gst_value_set_int_range (value, 1, G_MAXINT);
71 _transform_frame_size (GstVaapiPostproc * postproc, GstStructure * structure)
73 GValue width = G_VALUE_INIT;
74 GValue height = G_VALUE_INIT;
76 if (postproc->width && postproc->height) {
77 _set_int (&width, postproc->width);
78 _set_int (&height, postproc->height);
79 } else if (postproc->width) {
80 _set_int (&width, postproc->width);
81 _set_int_range (&height);
82 } else if (postproc->height) {
83 _set_int_range (&width);
84 _set_int (&height, postproc->height);
86 _set_int_range (&width);
87 _set_int_range (&height);
90 gst_structure_set_value (structure, "width", &width);
91 gst_structure_set_value (structure, "height", &height);
95 * gst_vaapipostproc_transform_srccaps:
96 * @postproc: a #GstVaapiPostproc instance
98 * Early apply transformation of the src pad caps according to the set
101 * Returns: A new allocated #GstCaps
104 gst_vaapipostproc_transform_srccaps (GstVaapiPostproc * postproc)
107 GstStructure *structure;
108 GstCapsFeatures *features;
111 out_caps = gst_caps_new_empty ();
112 n = gst_caps_get_size (postproc->allowed_srcpad_caps);
114 for (i = 0; i < n; i++) {
115 structure = gst_caps_get_structure (postproc->allowed_srcpad_caps, i);
116 features = gst_caps_get_features (postproc->allowed_srcpad_caps, i);
119 structure = gst_structure_copy (structure);
121 if (postproc->keep_aspect)
122 gst_structure_set (structure, "pixel-aspect-ratio", GST_TYPE_FRACTION, 1,
125 _transform_format (postproc, features, structure);
126 _transform_frame_size (postproc, structure);
128 gst_caps_append_structure_full (out_caps, structure,
129 gst_caps_features_copy (features));
136 is_deinterlace_enabled (GstVaapiPostproc * postproc, GstVideoInfo * vip)
138 gboolean deinterlace;
140 switch (postproc->deinterlace_mode) {
141 case GST_VAAPI_DEINTERLACE_MODE_AUTO:
142 deinterlace = GST_VIDEO_INFO_IS_INTERLACED (vip);
144 case GST_VAAPI_DEINTERLACE_MODE_INTERLACED:
155 _fixate_frame_size (GstVaapiPostproc * postproc, GstVideoInfo * vinfo,
158 const GValue *to_par;
159 GValue tpar = G_VALUE_INIT;
163 to_par = gst_structure_get_value (outs, "pixel-aspect-ratio");
165 g_value_init (&tpar, GST_TYPE_FRACTION_RANGE);
166 gst_value_set_fraction_range_full (&tpar, 1, G_MAXINT, G_MAXINT, 1);
170 /* we have both PAR but they might not be fixated */
172 gint from_w, from_h, from_par_n, from_par_d, to_par_n, to_par_d;
174 gint from_dar_n, from_dar_d;
177 from_par_n = GST_VIDEO_INFO_PAR_N (vinfo);
178 from_par_d = GST_VIDEO_INFO_PAR_D (vinfo);
179 from_w = GST_VIDEO_INFO_WIDTH (vinfo);
180 from_h = GST_VIDEO_INFO_HEIGHT (vinfo);
182 if (postproc->has_vpp) {
183 /* adjust for crop settings */
184 from_w -= postproc->crop_left + postproc->crop_right;
185 from_h -= postproc->crop_top + postproc->crop_bottom;
187 /* compensate for rotation if needed */
188 switch (gst_vaapi_filter_get_video_direction (postproc->filter)) {
189 case GST_VIDEO_ORIENTATION_90R:
190 case GST_VIDEO_ORIENTATION_90L:
191 case GST_VIDEO_ORIENTATION_UL_LR:
192 case GST_VIDEO_ORIENTATION_UR_LL:
193 G_PRIMITIVE_SWAP (gint, from_w, from_h);
194 G_PRIMITIVE_SWAP (gint, from_par_n, from_par_d);
200 gst_structure_get_int (outs, "width", &w);
201 gst_structure_get_int (outs, "height", &h);
203 /* if both width and height are already fixed, we can't do anything
204 * about it anymore */
208 GST_DEBUG_OBJECT (postproc,
209 "dimensions already set to %dx%d, not fixating", w, h);
211 if (!gst_value_is_fixed (to_par)) {
212 if (gst_video_calculate_display_ratio (&n, &d, from_w, from_h,
213 from_par_n, from_par_d, w, h)) {
214 GST_DEBUG_OBJECT (postproc, "fixating to_par to %dx%d", n, d);
215 if (gst_structure_has_field (outs, "pixel-aspect-ratio"))
216 gst_structure_fixate_field_nearest_fraction (outs,
217 "pixel-aspect-ratio", n, d);
219 gst_structure_set (outs, "pixel-aspect-ratio", GST_TYPE_FRACTION,
227 /* Calculate input DAR */
228 if (!gst_util_fraction_multiply (from_w, from_h, from_par_n, from_par_d,
229 &from_dar_n, &from_dar_d))
232 GST_DEBUG_OBJECT (postproc, "Input DAR is %d/%d", from_dar_n, from_dar_d);
234 /* If either width or height are fixed there's not much we
235 * can do either except choosing a height or width and PAR
236 * that matches the DAR as good as possible
240 gint set_w, set_par_n, set_par_d;
242 GST_DEBUG_OBJECT (postproc, "height is fixed (%d)", h);
244 /* If the PAR is fixed too, there's not much to do
245 * except choosing the width that is nearest to the
246 * width with the same DAR */
247 if (gst_value_is_fixed (to_par)) {
248 to_par_n = gst_value_get_fraction_numerator (to_par);
249 to_par_d = gst_value_get_fraction_denominator (to_par);
251 GST_DEBUG_OBJECT (postproc, "PAR is fixed %d/%d", to_par_n, to_par_d);
253 if (!gst_util_fraction_multiply (from_dar_n, from_dar_d, to_par_d,
254 to_par_n, &num, &den))
257 w = (guint) gst_util_uint64_scale_int (h, num, den);
258 gst_structure_fixate_field_nearest_int (outs, "width", w);
263 /* The PAR is not fixed and it's quite likely that we can set
264 * an arbitrary PAR. */
266 /* Check if we can keep the input width */
267 tmp = gst_structure_copy (outs);
268 gst_structure_fixate_field_nearest_int (tmp, "width", from_w);
269 gst_structure_get_int (tmp, "width", &set_w);
271 /* Might have failed but try to keep the DAR nonetheless by
272 * adjusting the PAR */
273 if (!gst_util_fraction_multiply (from_dar_n, from_dar_d, h, set_w,
274 &to_par_n, &to_par_d)) {
275 gst_structure_free (tmp);
279 if (!gst_structure_has_field (tmp, "pixel-aspect-ratio"))
280 gst_structure_set_value (tmp, "pixel-aspect-ratio", to_par);
281 gst_structure_fixate_field_nearest_fraction (tmp, "pixel-aspect-ratio",
283 gst_structure_get_fraction (tmp, "pixel-aspect-ratio", &set_par_n,
285 gst_structure_free (tmp);
287 /* Check if the adjusted PAR is accepted */
288 if (set_par_n == to_par_n && set_par_d == to_par_d) {
289 if (gst_structure_has_field (outs, "pixel-aspect-ratio") ||
290 set_par_n != set_par_d)
291 gst_structure_set (outs, "width", G_TYPE_INT, set_w,
292 "pixel-aspect-ratio", GST_TYPE_FRACTION, set_par_n, set_par_d,
297 /* Otherwise scale the width to the new PAR and check if the
298 * adjusted with is accepted. If all that fails we can't keep
300 if (!gst_util_fraction_multiply (from_dar_n, from_dar_d, set_par_d,
301 set_par_n, &num, &den))
304 w = (guint) gst_util_uint64_scale_int (h, num, den);
305 gst_structure_fixate_field_nearest_int (outs, "width", w);
306 if (gst_structure_has_field (outs, "pixel-aspect-ratio") ||
307 set_par_n != set_par_d)
308 gst_structure_set (outs, "pixel-aspect-ratio", GST_TYPE_FRACTION,
309 set_par_n, set_par_d, NULL);
314 gint set_h, set_par_n, set_par_d;
316 GST_DEBUG_OBJECT (postproc, "width is fixed (%d)", w);
318 /* If the PAR is fixed too, there's not much to do
319 * except choosing the height that is nearest to the
320 * height with the same DAR */
321 if (gst_value_is_fixed (to_par)) {
322 to_par_n = gst_value_get_fraction_numerator (to_par);
323 to_par_d = gst_value_get_fraction_denominator (to_par);
325 GST_DEBUG_OBJECT (postproc, "PAR is fixed %d/%d", to_par_n, to_par_d);
327 if (!gst_util_fraction_multiply (from_dar_n, from_dar_d, to_par_d,
328 to_par_n, &num, &den))
331 h = (guint) gst_util_uint64_scale_int (w, den, num);
332 gst_structure_fixate_field_nearest_int (outs, "height", h);
337 /* The PAR is not fixed and it's quite likely that we can set
338 * an arbitrary PAR. */
340 /* Check if we can keep the input height */
341 tmp = gst_structure_copy (outs);
342 gst_structure_fixate_field_nearest_int (tmp, "height", from_h);
343 gst_structure_get_int (tmp, "height", &set_h);
345 /* Might have failed but try to keep the DAR nonetheless by
346 * adjusting the PAR */
347 if (!gst_util_fraction_multiply (from_dar_n, from_dar_d, set_h, w,
348 &to_par_n, &to_par_d)) {
349 gst_structure_free (tmp);
353 if (!gst_structure_has_field (tmp, "pixel-aspect-ratio"))
354 gst_structure_set_value (tmp, "pixel-aspect-ratio", to_par);
355 gst_structure_fixate_field_nearest_fraction (tmp, "pixel-aspect-ratio",
357 gst_structure_get_fraction (tmp, "pixel-aspect-ratio", &set_par_n,
359 gst_structure_free (tmp);
361 /* Check if the adjusted PAR is accepted */
362 if (set_par_n == to_par_n && set_par_d == to_par_d) {
363 if (gst_structure_has_field (outs, "pixel-aspect-ratio") ||
364 set_par_n != set_par_d)
365 gst_structure_set (outs, "height", G_TYPE_INT, set_h,
366 "pixel-aspect-ratio", GST_TYPE_FRACTION, set_par_n, set_par_d,
371 /* Otherwise scale the height to the new PAR and check if the
372 * adjusted with is accepted. If all that fails we can't keep
374 if (!gst_util_fraction_multiply (from_dar_n, from_dar_d, set_par_d,
375 set_par_n, &num, &den))
378 h = (guint) gst_util_uint64_scale_int (w, den, num);
379 gst_structure_fixate_field_nearest_int (outs, "height", h);
380 if (gst_structure_has_field (outs, "pixel-aspect-ratio") ||
381 set_par_n != set_par_d)
382 gst_structure_set (outs, "pixel-aspect-ratio", GST_TYPE_FRACTION,
383 set_par_n, set_par_d, NULL);
386 } else if (gst_value_is_fixed (to_par)) {
388 gint set_h, set_w, f_h, f_w;
390 to_par_n = gst_value_get_fraction_numerator (to_par);
391 to_par_d = gst_value_get_fraction_denominator (to_par);
393 /* Calculate scale factor for the PAR change */
394 if (!gst_util_fraction_multiply (from_dar_n, from_dar_d, to_par_n,
395 to_par_d, &num, &den))
398 /* Try to keep the input height (because of interlacing) */
399 tmp = gst_structure_copy (outs);
400 gst_structure_fixate_field_nearest_int (tmp, "height", from_h);
401 gst_structure_get_int (tmp, "height", &set_h);
403 /* This might have failed but try to scale the width
404 * to keep the DAR nonetheless */
405 w = (guint) gst_util_uint64_scale_int (set_h, num, den);
406 gst_structure_fixate_field_nearest_int (tmp, "width", w);
407 gst_structure_get_int (tmp, "width", &set_w);
408 gst_structure_free (tmp);
410 /* We kept the DAR and the height is nearest to the original height */
412 gst_structure_set (outs, "width", G_TYPE_INT, set_w, "height",
413 G_TYPE_INT, set_h, NULL);
420 /* If the former failed, try to keep the input width at least */
421 tmp = gst_structure_copy (outs);
422 gst_structure_fixate_field_nearest_int (tmp, "width", from_w);
423 gst_structure_get_int (tmp, "width", &set_w);
425 /* This might have failed but try to scale the width
426 * to keep the DAR nonetheless */
427 h = (guint) gst_util_uint64_scale_int (set_w, den, num);
428 gst_structure_fixate_field_nearest_int (tmp, "height", h);
429 gst_structure_get_int (tmp, "height", &set_h);
430 gst_structure_free (tmp);
432 /* We kept the DAR and the width is nearest to the original width */
434 gst_structure_set (outs, "width", G_TYPE_INT, set_w, "height",
435 G_TYPE_INT, set_h, NULL);
439 /* If all this failed, keep the height that was nearest to the orignal
440 * height and the nearest possible width. This changes the DAR but
441 * there's not much else to do here.
443 gst_structure_set (outs, "width", G_TYPE_INT, f_w, "height", G_TYPE_INT,
448 gint set_h, set_w, set_par_n, set_par_d, tmp2;
450 /* width, height and PAR are not fixed but passthrough is not possible */
452 /* First try to keep the height and width as good as possible
454 tmp = gst_structure_copy (outs);
455 gst_structure_fixate_field_nearest_int (tmp, "height", from_h);
456 gst_structure_get_int (tmp, "height", &set_h);
457 gst_structure_fixate_field_nearest_int (tmp, "width", from_w);
458 gst_structure_get_int (tmp, "width", &set_w);
460 if (!gst_util_fraction_multiply (from_dar_n, from_dar_d, set_h, set_w,
461 &to_par_n, &to_par_d)) {
462 gst_structure_free (tmp);
466 if (!gst_structure_has_field (tmp, "pixel-aspect-ratio"))
467 gst_structure_set_value (tmp, "pixel-aspect-ratio", to_par);
468 gst_structure_fixate_field_nearest_fraction (tmp, "pixel-aspect-ratio",
470 gst_structure_get_fraction (tmp, "pixel-aspect-ratio", &set_par_n,
472 gst_structure_free (tmp);
474 if (set_par_n == to_par_n && set_par_d == to_par_d) {
475 gst_structure_set (outs, "width", G_TYPE_INT, set_w, "height",
476 G_TYPE_INT, set_h, NULL);
478 if (gst_structure_has_field (outs, "pixel-aspect-ratio") ||
479 set_par_n != set_par_d)
480 gst_structure_set (outs, "pixel-aspect-ratio", GST_TYPE_FRACTION,
481 set_par_n, set_par_d, NULL);
485 /* Otherwise try to scale width to keep the DAR with the set
487 if (!gst_util_fraction_multiply (from_dar_n, from_dar_d, set_par_d,
488 set_par_n, &num, &den))
491 w = (guint) gst_util_uint64_scale_int (set_h, num, den);
492 tmp = gst_structure_copy (outs);
493 gst_structure_fixate_field_nearest_int (tmp, "width", w);
494 gst_structure_get_int (tmp, "width", &tmp2);
495 gst_structure_free (tmp);
498 gst_structure_set (outs, "width", G_TYPE_INT, tmp2, "height",
499 G_TYPE_INT, set_h, NULL);
500 if (gst_structure_has_field (outs, "pixel-aspect-ratio") ||
501 set_par_n != set_par_d)
502 gst_structure_set (outs, "pixel-aspect-ratio", GST_TYPE_FRACTION,
503 set_par_n, set_par_d, NULL);
507 /* ... or try the same with the height */
508 h = (guint) gst_util_uint64_scale_int (set_w, den, num);
509 tmp = gst_structure_copy (outs);
510 gst_structure_fixate_field_nearest_int (tmp, "height", h);
511 gst_structure_get_int (tmp, "height", &tmp2);
512 gst_structure_free (tmp);
515 gst_structure_set (outs, "width", G_TYPE_INT, set_w, "height",
516 G_TYPE_INT, tmp2, NULL);
517 if (gst_structure_has_field (outs, "pixel-aspect-ratio") ||
518 set_par_n != set_par_d)
519 gst_structure_set (outs, "pixel-aspect-ratio", GST_TYPE_FRACTION,
520 set_par_n, set_par_d, NULL);
524 /* If all fails we can't keep the DAR and take the nearest values
525 * for everything from the first try */
526 gst_structure_set (outs, "width", G_TYPE_INT, set_w, "height",
527 G_TYPE_INT, set_h, NULL);
528 if (gst_structure_has_field (outs, "pixel-aspect-ratio") ||
529 set_par_n != set_par_d)
530 gst_structure_set (outs, "pixel-aspect-ratio", GST_TYPE_FRACTION,
531 set_par_n, set_par_d, NULL);
537 g_value_unset (&tpar);
545 GST_ELEMENT_ERROR (postproc, CORE, NEGOTIATION, (NULL),
546 ("Error calculating the output scaled size - integer overflow"));
552 _fixate_frame_rate (GstVaapiPostproc * postproc, GstVideoInfo * vinfo,
557 fps_n = GST_VIDEO_INFO_FPS_N (vinfo);
558 fps_d = GST_VIDEO_INFO_FPS_D (vinfo);
559 if (is_deinterlace_enabled (postproc, vinfo)) {
560 if (!gst_util_fraction_multiply (fps_n, fps_d, 2, 1, &fps_n, &fps_d))
563 gst_structure_set (outs, "framerate", GST_TYPE_FRACTION, fps_n, fps_d, NULL);
569 GST_ELEMENT_ERROR (postproc, CORE, NEGOTIATION, (NULL),
570 ("Error calculating the output framerate - integer overflow"));
576 _set_multiview_mode (GstVaapiPostproc * postproc, GstVideoInfo * vinfo,
579 const gchar *caps_str;
582 gst_video_multiview_mode_to_caps_string (GST_VIDEO_INFO_MULTIVIEW_MODE
587 gst_structure_set (outs, "multiview-mode", G_TYPE_STRING, caps_str,
588 "multiview-flags", GST_TYPE_VIDEO_MULTIVIEW_FLAGSET,
589 GST_VIDEO_INFO_MULTIVIEW_FLAGS (vinfo), GST_FLAG_SET_MASK_EXACT, NULL);
591 if (GST_VIDEO_INFO_VIEWS (vinfo) > 1) {
592 gst_structure_set (outs, "views", G_TYPE_INT, GST_VIDEO_INFO_VIEWS (vinfo),
600 _set_colorimetry (GstVaapiPostproc * postproc, GstVideoInfo * sinkinfo,
601 GstVideoFormat format, GstStructure * outs)
604 GstVideoColorimetry colorimetry;
608 if (!gst_structure_get_int (outs, "width", &width)
609 || !gst_structure_get_int (outs, "height", &height))
612 /* Use the sink resolution and the src format to correctly determine the
613 * default src colorimetry. */
614 gst_video_info_set_format (&vinfo, format, GST_VIDEO_INFO_WIDTH (sinkinfo),
615 GST_VIDEO_INFO_HEIGHT (sinkinfo));
617 if (GST_VIDEO_INFO_CHROMA_SITE (&vinfo) != GST_VIDEO_CHROMA_SITE_UNKNOWN) {
618 gst_structure_set (outs, "chroma-site", G_TYPE_STRING,
619 gst_video_chroma_to_string (GST_VIDEO_INFO_CHROMA_SITE (&vinfo)), NULL);
622 /* if outs structure already specifies colorimetry, use it */
623 if (gst_structure_has_field (outs, "colorimetry"))
626 /* make sure we set the RGB matrix for RGB formats */
627 colorimetry = GST_VIDEO_INFO_COLORIMETRY (&vinfo);
628 if (GST_VIDEO_FORMAT_INFO_IS_RGB (vinfo.finfo) &&
629 colorimetry.matrix != GST_VIDEO_COLOR_MATRIX_RGB) {
630 GST_WARNING ("invalid matrix %d for RGB format, using RGB",
632 colorimetry.matrix = GST_VIDEO_COLOR_MATRIX_RGB;
635 if ((color = gst_video_colorimetry_to_string (&colorimetry))) {
636 gst_structure_set (outs, "colorimetry", G_TYPE_STRING, color, NULL);
644 _set_interlace_mode (GstVaapiPostproc * postproc, GstVideoInfo * vinfo,
647 const gchar *interlace_mode = NULL;
649 if (is_deinterlace_enabled (postproc, vinfo)) {
650 interlace_mode = "progressive";
653 gst_video_interlace_mode_to_string (GST_VIDEO_INFO_INTERLACE_MODE
660 gst_structure_set (outs, "interlace-mode", G_TYPE_STRING, interlace_mode,
666 _set_preferred_format (GstStructure * outs, GstVideoFormat format)
668 GValue value = G_VALUE_INIT;
670 if (format == GST_VIDEO_FORMAT_UNKNOWN || format == GST_VIDEO_FORMAT_ENCODED)
673 if (!gst_vaapi_value_set_format (&value, format))
675 gst_structure_set_value (outs, "format", &value);
676 g_value_unset (&value);
681 _get_preferred_caps (GstVaapiPostproc * postproc, GstVideoInfo * vinfo,
685 GstVideoFormat format;
686 GstVaapiCapsFeature f;
687 const gchar *feature;
688 GstStructure *structure;
689 GstCapsFeatures *features;
693 format = GST_VIDEO_FORMAT_UNKNOWN;
694 srcpad = GST_BASE_TRANSFORM_SRC_PAD (postproc);
695 f = gst_vaapi_find_preferred_caps_feature (srcpad, srccaps, &format);
696 if (f == GST_VAAPI_CAPS_FEATURE_NOT_NEGOTIATED)
699 feature = gst_vaapi_caps_feature_to_string (f);
701 feature = GST_CAPS_FEATURE_MEMORY_SYSTEM_MEMORY;
703 n = gst_caps_get_size (srccaps);
704 for (i = 0; i < n; i++) {
705 structure = gst_caps_get_structure (srccaps, i);
706 features = gst_caps_get_features (srccaps, i);
708 if (!gst_caps_features_is_any (features)
709 && gst_caps_features_contains (features, feature))
717 structure = gst_structure_copy (structure);
719 if (!_set_preferred_format (structure, format))
721 if (!_fixate_frame_size (postproc, vinfo, structure))
723 if (!_fixate_frame_rate (postproc, vinfo, structure))
725 _set_multiview_mode (postproc, vinfo, structure);
727 if (!_set_colorimetry (postproc, vinfo, format, structure))
730 if (!_set_interlace_mode (postproc, vinfo, structure))
731 goto interlace_mode_failed;
733 outcaps = gst_caps_new_empty ();
734 gst_caps_append_structure_full (outcaps, structure,
735 gst_caps_features_copy (features));
737 /* we don't need to do format conversion if GL_TEXTURE_UPLOAD_META
739 if (f == GST_VAAPI_CAPS_FEATURE_GL_TEXTURE_UPLOAD_META) {
740 postproc->format = DEFAULT_FORMAT;
741 } else if (postproc->format != format) {
742 postproc->format = format;
745 return gst_caps_fixate (outcaps);
750 GST_WARNING_OBJECT (postproc, "Could not fixate src caps");
751 gst_structure_free (structure);
756 GST_WARNING_OBJECT (postproc, "No valid src caps found");
759 interlace_mode_failed:
761 GST_WARNING_OBJECT (postproc, "Invalid sink caps interlace mode");
767 * gst_vaapipostproc_fixate_srccaps:
768 * @postproc: a #GstVaapiPostproc instance
769 * @sinkcaps: fixed #GstCaps from sink pad
770 * @srccaps: #GstCaps from src pad to fixate
772 * Given @srccaps and @sinkcaps returns a new allocated #GstCaps with
773 * the fixated caps for the src pad.
775 * Returns: A new allocated #GstCaps
778 gst_vaapipostproc_fixate_srccaps (GstVaapiPostproc * postproc,
779 GstCaps * sinkcaps, GstCaps * srccaps)
783 if (!gst_video_info_from_caps (&vi, sinkcaps))
785 return _get_preferred_caps (postproc, &vi, srccaps);