1 /*
2  *  gstmsdkvpputil.c - MediaSDK video post processing utilities
3  *
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  *  Copyright (C) 2018 Intel Corporation
8  *    Author: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
9  *    Author: Victor Jaquez <victorx.jaquez@intel.com>
10  *    Author: Sreerenj Balachandran <sreerenj.balachandran@intel.com>
11  *
12  *  This program is free software; you can redistribute it and/or
13  *  modify it under the terms of the GNU Lesser General Public License
14  *  as published by the Free Software Foundation; either version 2.1
15  *  of the License, or (at your option) any later version.
16  *
17  *  This program is distributed in the hope that it will be useful,
18  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
19  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20  *  Lesser General Public License for more details.
21  *
22  *  You should have received a copy of the GNU Lesser General Public
23  *  License along with this program; if not, write to the Free
24  *  Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
25  *  Boston, MA 02110-1301 USA
26  */
27 
28 #include "gstmsdkvpputil.h"
29 #include "msdk-enums.h"
30 
31 gboolean
gst_msdkvpp_is_deinterlace_enabled(GstMsdkVPP * msdkvpp,GstVideoInfo * vip)32 gst_msdkvpp_is_deinterlace_enabled (GstMsdkVPP * msdkvpp, GstVideoInfo * vip)
33 {
34   gboolean deinterlace;
35 
36   switch (msdkvpp->deinterlace_mode) {
37     case GST_MSDKVPP_DEINTERLACE_MODE_AUTO:
38       deinterlace = GST_VIDEO_INFO_IS_INTERLACED (vip);
39       break;
40     case GST_MSDKVPP_DEINTERLACE_MODE_INTERLACED:
41       deinterlace = TRUE;
42       break;
43     default:
44       deinterlace = FALSE;
45       break;
46   }
47   return deinterlace;
48 }
49 
50 static gboolean
fixate_output_frame_size(GstMsdkVPP * thiz,GstVideoInfo * vinfo,GstStructure * outs)51 fixate_output_frame_size (GstMsdkVPP * thiz, GstVideoInfo * vinfo,
52     GstStructure * outs)
53 {
54   const GValue *to_par;
55   GValue tpar = G_VALUE_INIT;
56   gboolean ret;
57 
58   ret = TRUE;
59   to_par = gst_structure_get_value (outs, "pixel-aspect-ratio");
60   if (!to_par) {
61     g_value_init (&tpar, GST_TYPE_FRACTION_RANGE);
62     gst_value_set_fraction_range_full (&tpar, 1, G_MAXINT, G_MAXINT, 1);
63     to_par = &tpar;
64   }
65 
66   /* we have both PAR but they might not be fixated */
67   {
68     gint from_w, from_h, from_par_n, from_par_d, to_par_n, to_par_d;
69     gint w = 0, h = 0;
70     gint from_dar_n, from_dar_d;
71     gint num, den;
72 
73     from_par_n = GST_VIDEO_INFO_PAR_N (vinfo);
74     from_par_d = GST_VIDEO_INFO_PAR_D (vinfo);
75     from_w = GST_VIDEO_INFO_WIDTH (vinfo);
76     from_h = GST_VIDEO_INFO_HEIGHT (vinfo);
77 
78     gst_structure_get_int (outs, "width", &w);
79     gst_structure_get_int (outs, "height", &h);
80 
81     /* if both width and height are already fixed, we can't do anything
82      * about it anymore */
83     if (w && h) {
84       guint n, d;
85 
86       GST_DEBUG_OBJECT (thiz,
87           "dimensions already set to %dx%d, not fixating", w, h);
88 
89       if (!gst_value_is_fixed (to_par)) {
90         if (gst_video_calculate_display_ratio (&n, &d, from_w, from_h,
91                 from_par_n, from_par_d, w, h)) {
92           GST_DEBUG_OBJECT (thiz, "fixating to_par to %dx%d", n, d);
93           if (gst_structure_has_field (outs, "pixel-aspect-ratio"))
94             gst_structure_fixate_field_nearest_fraction (outs,
95                 "pixel-aspect-ratio", n, d);
96           else if (n != d)
97             gst_structure_set (outs, "pixel-aspect-ratio", GST_TYPE_FRACTION,
98                 n, d, NULL);
99         }
100       }
101 
102       goto done;
103     }
104 
105     /* Calculate input DAR */
106     if (!gst_util_fraction_multiply (from_w, from_h, from_par_n, from_par_d,
107             &from_dar_n, &from_dar_d))
108       goto overflow_error;
109 
110     GST_DEBUG_OBJECT (thiz, "Input DAR is %d/%d", from_dar_n, from_dar_d);
111 
112     /* If either width or height are fixed there's not much we
113      * can do either except choosing a height or width and PAR
114      * that matches the DAR as good as possible
115      */
116     if (h) {
117       GstStructure *tmp;
118       gint set_w, set_par_n, set_par_d;
119 
120       GST_DEBUG_OBJECT (thiz, "height is fixed (%d)", h);
121 
122       /* If the PAR is fixed too, there's not much to do
123        * except choosing the width that is nearest to the
124        * width with the same DAR */
125       if (gst_value_is_fixed (to_par)) {
126         to_par_n = gst_value_get_fraction_numerator (to_par);
127         to_par_d = gst_value_get_fraction_denominator (to_par);
128 
129         GST_DEBUG_OBJECT (thiz, "PAR is fixed %d/%d", to_par_n, to_par_d);
130 
131         if (!gst_util_fraction_multiply (from_dar_n, from_dar_d, to_par_d,
132                 to_par_n, &num, &den))
133           goto overflow_error;
134 
135         w = (guint) gst_util_uint64_scale_int (h, num, den);
136         gst_structure_fixate_field_nearest_int (outs, "width", w);
137 
138         goto done;
139       }
140 
141       /* The PAR is not fixed and it's quite likely that we can set
142        * an arbitrary PAR. */
143 
144       /* Check if we can keep the input width */
145       tmp = gst_structure_copy (outs);
146       gst_structure_fixate_field_nearest_int (tmp, "width", from_w);
147       gst_structure_get_int (tmp, "width", &set_w);
148 
149       /* Might have failed but try to keep the DAR nonetheless by
150        * adjusting the PAR */
151       if (!gst_util_fraction_multiply (from_dar_n, from_dar_d, h, set_w,
152               &to_par_n, &to_par_d)) {
153         gst_structure_free (tmp);
154         goto overflow_error;
155       }
156 
157       if (!gst_structure_has_field (tmp, "pixel-aspect-ratio"))
158         gst_structure_set_value (tmp, "pixel-aspect-ratio", to_par);
159       gst_structure_fixate_field_nearest_fraction (tmp, "pixel-aspect-ratio",
160           to_par_n, to_par_d);
161       gst_structure_get_fraction (tmp, "pixel-aspect-ratio", &set_par_n,
162           &set_par_d);
163       gst_structure_free (tmp);
164 
165       /* Check if the adjusted PAR is accepted */
166       if (set_par_n == to_par_n && set_par_d == to_par_d) {
167         if (gst_structure_has_field (outs, "pixel-aspect-ratio") ||
168             set_par_n != set_par_d)
169           gst_structure_set (outs, "width", G_TYPE_INT, set_w,
170               "pixel-aspect-ratio", GST_TYPE_FRACTION, set_par_n, set_par_d,
171               NULL);
172         goto done;
173       }
174 
175       /* Otherwise scale the width to the new PAR and check if the
176        * adjusted with is accepted. If all that fails we can't keep
177        * the DAR */
178       if (!gst_util_fraction_multiply (from_dar_n, from_dar_d, set_par_d,
179               set_par_n, &num, &den))
180         goto overflow_error;
181 
182       w = (guint) gst_util_uint64_scale_int (h, num, den);
183       gst_structure_fixate_field_nearest_int (outs, "width", w);
184       if (gst_structure_has_field (outs, "pixel-aspect-ratio") ||
185           set_par_n != set_par_d)
186         gst_structure_set (outs, "pixel-aspect-ratio", GST_TYPE_FRACTION,
187             set_par_n, set_par_d, NULL);
188 
189       goto done;
190     } else if (w) {
191       GstStructure *tmp;
192       gint set_h, set_par_n, set_par_d;
193 
194       GST_DEBUG_OBJECT (thiz, "width is fixed (%d)", w);
195 
196       /* If the PAR is fixed too, there's not much to do
197        * except choosing the height that is nearest to the
198        * height with the same DAR */
199       if (gst_value_is_fixed (to_par)) {
200         to_par_n = gst_value_get_fraction_numerator (to_par);
201         to_par_d = gst_value_get_fraction_denominator (to_par);
202 
203         GST_DEBUG_OBJECT (thiz, "PAR is fixed %d/%d", to_par_n, to_par_d);
204 
205         if (!gst_util_fraction_multiply (from_dar_n, from_dar_d, to_par_d,
206                 to_par_n, &num, &den))
207           goto overflow_error;
208 
209         h = (guint) gst_util_uint64_scale_int (w, den, num);
210         gst_structure_fixate_field_nearest_int (outs, "height", h);
211 
212         goto done;
213       }
214 
215       /* The PAR is not fixed and it's quite likely that we can set
216        * an arbitrary PAR. */
217 
218       /* Check if we can keep the input height */
219       tmp = gst_structure_copy (outs);
220       gst_structure_fixate_field_nearest_int (tmp, "height", from_h);
221       gst_structure_get_int (tmp, "height", &set_h);
222 
223       /* Might have failed but try to keep the DAR nonetheless by
224        * adjusting the PAR */
225       if (!gst_util_fraction_multiply (from_dar_n, from_dar_d, set_h, w,
226               &to_par_n, &to_par_d)) {
227         gst_structure_free (tmp);
228         goto overflow_error;
229       }
230 
231       if (!gst_structure_has_field (tmp, "pixel-aspect-ratio"))
232         gst_structure_set_value (tmp, "pixel-aspect-ratio", to_par);
233       gst_structure_fixate_field_nearest_fraction (tmp, "pixel-aspect-ratio",
234           to_par_n, to_par_d);
235       gst_structure_get_fraction (tmp, "pixel-aspect-ratio", &set_par_n,
236           &set_par_d);
237       gst_structure_free (tmp);
238 
239       /* Check if the adjusted PAR is accepted */
240       if (set_par_n == to_par_n && set_par_d == to_par_d) {
241         if (gst_structure_has_field (outs, "pixel-aspect-ratio") ||
242             set_par_n != set_par_d)
243           gst_structure_set (outs, "height", G_TYPE_INT, set_h,
244               "pixel-aspect-ratio", GST_TYPE_FRACTION, set_par_n, set_par_d,
245               NULL);
246         goto done;
247       }
248 
249       /* Otherwise scale the height to the new PAR and check if the
250        * adjusted with is accepted. If all that fails we can't keep
251        * the DAR */
252       if (!gst_util_fraction_multiply (from_dar_n, from_dar_d, set_par_d,
253               set_par_n, &num, &den))
254         goto overflow_error;
255 
256       h = (guint) gst_util_uint64_scale_int (w, den, num);
257       gst_structure_fixate_field_nearest_int (outs, "height", h);
258       if (gst_structure_has_field (outs, "pixel-aspect-ratio") ||
259           set_par_n != set_par_d)
260         gst_structure_set (outs, "pixel-aspect-ratio", GST_TYPE_FRACTION,
261             set_par_n, set_par_d, NULL);
262 
263       goto done;
264     } else if (gst_value_is_fixed (to_par)) {
265       GstStructure *tmp;
266       gint set_h, set_w, f_h, f_w;
267 
268       to_par_n = gst_value_get_fraction_numerator (to_par);
269       to_par_d = gst_value_get_fraction_denominator (to_par);
270 
271       /* Calculate scale factor for the PAR change */
272       if (!gst_util_fraction_multiply (from_dar_n, from_dar_d, to_par_n,
273               to_par_d, &num, &den))
274         goto overflow_error;
275 
276       /* Try to keep the input height (because of interlacing) */
277       tmp = gst_structure_copy (outs);
278       gst_structure_fixate_field_nearest_int (tmp, "height", from_h);
279       gst_structure_get_int (tmp, "height", &set_h);
280 
281       /* This might have failed but try to scale the width
282        * to keep the DAR nonetheless */
283       w = (guint) gst_util_uint64_scale_int (set_h, num, den);
284       gst_structure_fixate_field_nearest_int (tmp, "width", w);
285       gst_structure_get_int (tmp, "width", &set_w);
286       gst_structure_free (tmp);
287 
288       /* We kept the DAR and the height is nearest to the original height */
289       if (set_w == w) {
290         gst_structure_set (outs, "width", G_TYPE_INT, set_w, "height",
291             G_TYPE_INT, set_h, NULL);
292         goto done;
293       }
294 
295       f_h = set_h;
296       f_w = set_w;
297 
298       /* If the former failed, try to keep the input width at least */
299       tmp = gst_structure_copy (outs);
300       gst_structure_fixate_field_nearest_int (tmp, "width", from_w);
301       gst_structure_get_int (tmp, "width", &set_w);
302 
303       /* This might have failed but try to scale the width
304        * to keep the DAR nonetheless */
305       h = (guint) gst_util_uint64_scale_int (set_w, den, num);
306       gst_structure_fixate_field_nearest_int (tmp, "height", h);
307       gst_structure_get_int (tmp, "height", &set_h);
308       gst_structure_free (tmp);
309 
310       /* We kept the DAR and the width is nearest to the original width */
311       if (set_h == h) {
312         gst_structure_set (outs, "width", G_TYPE_INT, set_w, "height",
313             G_TYPE_INT, set_h, NULL);
314         goto done;
315       }
316 
317       /* If all this failed, keep the height that was nearest to the orignal
318        * height and the nearest possible width. This changes the DAR but
319        * there's not much else to do here.
320        */
321       gst_structure_set (outs, "width", G_TYPE_INT, f_w, "height", G_TYPE_INT,
322           f_h, NULL);
323       goto done;
324     } else {
325       GstStructure *tmp;
326       gint set_h, set_w, set_par_n, set_par_d, tmp2;
327 
328       /* width, height and PAR are not fixed but passthrough is not possible */
329 
330       /* First try to keep the height and width as good as possible
331        * and scale PAR */
332       tmp = gst_structure_copy (outs);
333       gst_structure_fixate_field_nearest_int (tmp, "height", from_h);
334       gst_structure_get_int (tmp, "height", &set_h);
335       gst_structure_fixate_field_nearest_int (tmp, "width", from_w);
336       gst_structure_get_int (tmp, "width", &set_w);
337 
338       if (!gst_util_fraction_multiply (from_dar_n, from_dar_d, set_h, set_w,
339               &to_par_n, &to_par_d)) {
340         gst_structure_free (tmp);
341         goto overflow_error;
342       }
343 
344       if (!gst_structure_has_field (tmp, "pixel-aspect-ratio"))
345         gst_structure_set_value (tmp, "pixel-aspect-ratio", to_par);
346       gst_structure_fixate_field_nearest_fraction (tmp, "pixel-aspect-ratio",
347           to_par_n, to_par_d);
348       gst_structure_get_fraction (tmp, "pixel-aspect-ratio", &set_par_n,
349           &set_par_d);
350       gst_structure_free (tmp);
351 
352       if (set_par_n == to_par_n && set_par_d == to_par_d) {
353         gst_structure_set (outs, "width", G_TYPE_INT, set_w, "height",
354             G_TYPE_INT, set_h, NULL);
355 
356         if (gst_structure_has_field (outs, "pixel-aspect-ratio") ||
357             set_par_n != set_par_d)
358           gst_structure_set (outs, "pixel-aspect-ratio", GST_TYPE_FRACTION,
359               set_par_n, set_par_d, NULL);
360         goto done;
361       }
362 
363       /* Otherwise try to scale width to keep the DAR with the set
364        * PAR and height */
365       if (!gst_util_fraction_multiply (from_dar_n, from_dar_d, set_par_d,
366               set_par_n, &num, &den))
367         goto overflow_error;
368 
369       w = (guint) gst_util_uint64_scale_int (set_h, num, den);
370       tmp = gst_structure_copy (outs);
371       gst_structure_fixate_field_nearest_int (tmp, "width", w);
372       gst_structure_get_int (tmp, "width", &tmp2);
373       gst_structure_free (tmp);
374 
375       if (tmp2 == w) {
376         gst_structure_set (outs, "width", G_TYPE_INT, tmp2, "height",
377             G_TYPE_INT, set_h, NULL);
378         if (gst_structure_has_field (outs, "pixel-aspect-ratio") ||
379             set_par_n != set_par_d)
380           gst_structure_set (outs, "pixel-aspect-ratio", GST_TYPE_FRACTION,
381               set_par_n, set_par_d, NULL);
382         goto done;
383       }
384 
385       /* ... or try the same with the height */
386       h = (guint) gst_util_uint64_scale_int (set_w, den, num);
387       tmp = gst_structure_copy (outs);
388       gst_structure_fixate_field_nearest_int (tmp, "height", h);
389       gst_structure_get_int (tmp, "height", &tmp2);
390       gst_structure_free (tmp);
391 
392       if (tmp2 == h) {
393         gst_structure_set (outs, "width", G_TYPE_INT, set_w, "height",
394             G_TYPE_INT, tmp2, NULL);
395         if (gst_structure_has_field (outs, "pixel-aspect-ratio") ||
396             set_par_n != set_par_d)
397           gst_structure_set (outs, "pixel-aspect-ratio", GST_TYPE_FRACTION,
398               set_par_n, set_par_d, NULL);
399         goto done;
400       }
401 
402       /* If all fails we can't keep the DAR and take the nearest values
403        * for everything from the first try */
404       gst_structure_set (outs, "width", G_TYPE_INT, set_w, "height",
405           G_TYPE_INT, set_h, NULL);
406       if (gst_structure_has_field (outs, "pixel-aspect-ratio") ||
407           set_par_n != set_par_d)
408         gst_structure_set (outs, "pixel-aspect-ratio", GST_TYPE_FRACTION,
409             set_par_n, set_par_d, NULL);
410     }
411   }
412 
413 done:
414   if (to_par == &tpar)
415     g_value_unset (&tpar);
416 
417   return ret;
418 
419   /* ERRORS */
420 overflow_error:
421   {
422     ret = FALSE;
423     GST_ELEMENT_ERROR (thiz, CORE, NEGOTIATION, (NULL),
424         ("Error calculating the output scaled size - integer overflow"));
425     goto done;
426   }
427 }
428 
429 static gboolean
fixate_frame_rate(GstMsdkVPP * thiz,GstVideoInfo * vinfo,GstStructure * outs)430 fixate_frame_rate (GstMsdkVPP * thiz, GstVideoInfo * vinfo, GstStructure * outs)
431 {
432   gint fps_n = 0, fps_d;
433 
434   /* fixate the srcpad fps */
435   if (gst_structure_fixate_field (outs, "framerate"))
436     gst_structure_get (outs, "framerate", GST_TYPE_FRACTION, &fps_n, &fps_d,
437         NULL);
438 
439   /* if we don't have a fixed non-zero fps_n, use the sinkpad fps */
440   if (!fps_n) {
441     fps_n = GST_VIDEO_INFO_FPS_N (vinfo);
442     fps_d = GST_VIDEO_INFO_FPS_D (vinfo);
443   }
444 
445   if (gst_msdkvpp_is_deinterlace_enabled (thiz, vinfo)) {
446     /* Fixme: set double framerate?:
447      * msdk is not outputting double framerate for bob or adv deinterlace */
448     if (!gst_util_fraction_multiply (fps_n, fps_d, 1, 1, &fps_n, &fps_d))
449       goto overflow_error;
450   }
451   gst_structure_set (outs, "framerate", GST_TYPE_FRACTION, fps_n, fps_d, NULL);
452   return TRUE;
453 
454   /* ERRORS */
455 overflow_error:
456   {
457     GST_ELEMENT_ERROR (thiz, CORE, NEGOTIATION, (NULL),
458         ("Error calculating the output framerate - integer overflow"));
459     return FALSE;
460   }
461 }
462 
463 static gboolean
set_multiview_mode(GstMsdkVPP * thiz,GstVideoInfo * vinfo,GstStructure * outs)464 set_multiview_mode (GstMsdkVPP * thiz, GstVideoInfo * vinfo,
465     GstStructure * outs)
466 {
467   const gchar *caps_str;
468 
469   caps_str =
470       gst_video_multiview_mode_to_caps_string (GST_VIDEO_INFO_MULTIVIEW_MODE
471       (vinfo));
472   if (!caps_str)
473     return TRUE;
474 
475   gst_structure_set (outs, "multiview-mode", G_TYPE_STRING, caps_str,
476       "multiview-flags", GST_TYPE_VIDEO_MULTIVIEW_FLAGSET,
477       GST_VIDEO_INFO_MULTIVIEW_FLAGS (vinfo), GST_FLAG_SET_MASK_EXACT, NULL);
478 
479   if (GST_VIDEO_INFO_VIEWS (vinfo) > 1) {
480     gst_structure_set (outs, "views", G_TYPE_INT, GST_VIDEO_INFO_VIEWS (vinfo),
481         NULL);
482   }
483   return TRUE;
484 }
485 
486 static gboolean
set_interlace_mode(GstMsdkVPP * thiz,GstVideoInfo * vinfo,GstStructure * outs)487 set_interlace_mode (GstMsdkVPP * thiz, GstVideoInfo * vinfo,
488     GstStructure * outs)
489 {
490   const gchar *interlace_mode = NULL;
491 
492   if (gst_msdkvpp_is_deinterlace_enabled (thiz, vinfo)) {
493     interlace_mode = "progressive";
494   } else {
495     interlace_mode =
496         gst_video_interlace_mode_to_string (GST_VIDEO_INFO_INTERLACE_MODE
497         (vinfo));
498   }
499 
500   if (!interlace_mode)
501     return FALSE;
502 
503   gst_structure_set (outs, "interlace-mode", G_TYPE_STRING, interlace_mode,
504       NULL);
505   return TRUE;
506 }
507 
508 static GstCaps *
_get_preferred_src_caps(GstMsdkVPP * thiz,GstVideoInfo * vinfo,GstCaps * srccaps)509 _get_preferred_src_caps (GstMsdkVPP * thiz, GstVideoInfo * vinfo,
510     GstCaps * srccaps)
511 {
512   GstStructure *structure;
513   GstCaps *outcaps;
514 
515   structure = gst_caps_get_structure (srccaps, 0);
516 
517   /* make a copy */
518   structure = gst_structure_copy (structure);
519 
520   if (thiz->keep_aspect)
521     gst_structure_set (structure, "pixel-aspect-ratio", GST_TYPE_FRACTION, 1,
522         1, NULL);
523 
524   /* Fixate the format */
525   if (!gst_structure_fixate_field (structure, "format"))
526     goto fixate_failed;
527 
528   /* Fixate the frame size */
529   if (!fixate_output_frame_size (thiz, vinfo, structure))
530     goto fixate_failed;
531 
532   /* Fixate the framerate */
533   if (!fixate_frame_rate (thiz, vinfo, structure))
534     goto fixate_failed;
535 
536   /* set multiview mode based on input caps */
537   if (!set_multiview_mode (thiz, vinfo, structure))
538     goto fixate_failed;
539 
540   /*Fixme: Set colorimetry */
541 
542   /* set interlace mode */
543   if (!set_interlace_mode (thiz, vinfo, structure))
544     goto interlace_mode_failed;
545 
546   outcaps = gst_caps_new_empty ();
547   gst_caps_append_structure (outcaps, structure);
548 
549   return outcaps;
550 
551   /* ERRORS */
552 fixate_failed:
553   {
554     GST_WARNING_OBJECT (thiz, "Could not fixate src caps");
555     gst_structure_free (structure);
556     return NULL;
557   }
558 interlace_mode_failed:
559   {
560     GST_WARNING_OBJECT (thiz, "Invalid sink caps interlace mode");
561     return NULL;
562   }
563 }
564 
565 /**
566  * gst_msdkvpp_fixate_srccaps:
567  * @vpp: a #GstMsdkVPP instance
568  * @sinkcaps: fixed #GstCaps from sink pad
569  * @srccaps: #GstCaps from src pad to fixate
570  *
571  * Given @srccaps and @sinkcaps returns a new allocated #GstCaps with
572  * the fixated caps for the src pad.
573  *
574  * Returns: A new allocated #GstCaps
575  **/
576 GstCaps *
gst_msdkvpp_fixate_srccaps(GstMsdkVPP * msdkvpp,GstCaps * sinkcaps,GstCaps * srccaps)577 gst_msdkvpp_fixate_srccaps (GstMsdkVPP * msdkvpp,
578     GstCaps * sinkcaps, GstCaps * srccaps)
579 {
580   GstVideoInfo vi;
581   if (!gst_video_info_from_caps (&vi, sinkcaps))
582     return NULL;
583   return _get_preferred_src_caps (msdkvpp, &vi, srccaps);
584 }
585