2 * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
3 * Library <2002> Ronald Bultje <rbultje@ronald.bitfreak.net>
4 * Copyright (C) 2007 David A. Schleef <ds@schleef.org>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
30 * @short_description: Support library for video operations
34 * This library contains some helper functions and includes the
35 * videosink and videofilter base classes.
40 static GstVideoFormat gst_video_format_from_rgb32_masks (int red_mask,
41 int green_mask, int blue_mask);
42 static GstVideoFormat gst_video_format_from_rgba32_masks (int red_mask,
43 int green_mask, int blue_mask, int alpha_mask);
44 static GstVideoFormat gst_video_format_from_rgb24_masks (int red_mask,
45 int green_mask, int blue_mask);
46 static GstVideoFormat gst_video_format_from_rgb16_masks (int red_mask,
47 int green_mask, int blue_mask);
51 * gst_video_frame_rate:
52 * @pad: pointer to a #GstPad
54 * A convenience function to retrieve a GValue holding the framerate
55 * from the caps on a pad.
57 * The pad needs to have negotiated caps containing a framerate property.
59 * Returns: NULL if the pad has no configured caps or the configured caps
60 * do not contain a framerate.
64 gst_video_frame_rate (GstPad * pad)
69 const GstCaps *caps = NULL;
70 GstStructure *structure;
73 caps = GST_PAD_CAPS (pad);
75 g_warning ("gstvideo: failed to get caps of pad %s:%s",
76 GST_DEBUG_PAD_NAME (pad));
80 structure = gst_caps_get_structure (caps, 0);
81 if ((fps = gst_structure_get_value (structure, "framerate")) == NULL) {
82 g_warning ("gstvideo: failed to get framerate property of pad %s:%s",
83 GST_DEBUG_PAD_NAME (pad));
86 if (!GST_VALUE_HOLDS_FRACTION (fps)) {
88 ("gstvideo: framerate property of pad %s:%s is not of type Fraction",
89 GST_DEBUG_PAD_NAME (pad));
93 fps_string = gst_value_serialize (fps);
94 GST_DEBUG ("Framerate request on pad %s:%s: %s",
95 GST_DEBUG_PAD_NAME (pad), fps_string);
102 * gst_video_get_size:
103 * @pad: pointer to a #GstPad
104 * @width: pointer to integer to hold pixel width of the video frames (output)
105 * @height: pointer to integer to hold pixel height of the video frames (output)
107 * Inspect the caps of the provided pad and retrieve the width and height of
108 * the video frames it is configured for.
110 * The pad needs to have negotiated caps containing width and height properties.
112 * Returns: TRUE if the width and height could be retrieved.
116 gst_video_get_size (GstPad * pad, gint * width, gint * height)
118 const GstCaps *caps = NULL;
119 GstStructure *structure;
122 g_return_val_if_fail (pad != NULL, FALSE);
123 g_return_val_if_fail (width != NULL, FALSE);
124 g_return_val_if_fail (height != NULL, FALSE);
126 caps = GST_PAD_CAPS (pad);
129 g_warning ("gstvideo: failed to get caps of pad %s:%s",
130 GST_DEBUG_PAD_NAME (pad));
134 structure = gst_caps_get_structure (caps, 0);
135 ret = gst_structure_get_int (structure, "width", width);
136 ret &= gst_structure_get_int (structure, "height", height);
139 g_warning ("gstvideo: failed to get size properties on pad %s:%s",
140 GST_DEBUG_PAD_NAME (pad));
144 GST_DEBUG ("size request on pad %s:%s: %dx%d",
145 GST_DEBUG_PAD_NAME (pad), width ? *width : -1, height ? *height : -1);
151 * gst_video_calculate_display_ratio:
152 * @dar_n: Numerator of the calculated display_ratio
153 * @dar_d: Denominator of the calculated display_ratio
154 * @video_width: Width of the video frame in pixels
155 * @video_height: Height of the video frame in pixels
156 * @video_par_n: Numerator of the pixel aspect ratio of the input video.
157 * @video_par_d: Denominator of the pixel aspect ratio of the input video.
158 * @display_par_n: Numerator of the pixel aspect ratio of the display device
159 * @display_par_d: Denominator of the pixel aspect ratio of the display device
161 * Given the Pixel Aspect Ratio and size of an input video frame, and the
162 * pixel aspect ratio of the intended display device, calculates the actual
163 * display ratio the video will be rendered with.
165 * Returns: A boolean indicating success and a calculated Display Ratio in the
166 * dar_n and dar_d parameters.
167 * The return value is FALSE in the case of integer overflow or other error.
172 gst_video_calculate_display_ratio (guint * dar_n, guint * dar_d,
173 guint video_width, guint video_height,
174 guint video_par_n, guint video_par_d,
175 guint display_par_n, guint display_par_d)
180 g_return_val_if_fail (dar_n != NULL, FALSE);
181 g_return_val_if_fail (dar_d != NULL, FALSE);
183 /* Calculate (video_width * video_par_n * display_par_d) /
184 * (video_height * video_par_d * display_par_n) */
185 if (!gst_util_fraction_multiply (video_width, video_height, video_par_n,
186 video_par_d, &tmp_n, &tmp_d))
189 if (!gst_util_fraction_multiply (tmp_n, tmp_d, display_par_d, display_par_n,
193 g_return_val_if_fail (num > 0, FALSE);
194 g_return_val_if_fail (den > 0, FALSE);
205 * gst_video_format_parse_caps_interlaced:
206 * @caps: the fixed #GstCaps to parse
207 * @interlaced: whether @caps represents interlaced video or not, may be NULL (output)
209 * Extracts whether the caps represents interlaced content or not and places it
214 * Returns: TRUE if @caps was parsed correctly.
217 gst_video_format_parse_caps_interlaced (GstCaps * caps, gboolean * interlaced)
219 GstStructure *structure;
221 if (!gst_caps_is_fixed (caps))
224 structure = gst_caps_get_structure (caps, 0);
227 if (!gst_structure_get_boolean (structure, "interlaced", interlaced))
235 * gst_video_parse_caps_color_matrix:
236 * @caps: the fixed #GstCaps to parse
238 * Extracts the color matrix used by the caps. Possible values are
239 * "sdtv" for the standard definition color matrix (as specified in
240 * Rec. ITU-R BT.470-6) or "hdtv" for the high definition color
241 * matrix (as specified in Rec. ITU-R BT.709)
245 * Returns: a color matrix string, or NULL if no color matrix could be
249 gst_video_parse_caps_color_matrix (GstCaps * caps)
251 GstStructure *structure;
254 if (!gst_caps_is_fixed (caps))
257 structure = gst_caps_get_structure (caps, 0);
259 s = gst_structure_get_string (structure, "color-matrix");
263 if (gst_structure_has_name (structure, "video/x-raw-yuv")) {
271 * gst_video_parse_caps_chroma_site:
272 * @caps: the fixed #GstCaps to parse
274 * Extracts the chroma site used by the caps. Possible values are
275 * "mpeg2" for MPEG-2 style chroma siting (co-sited horizontally,
276 * halfway-sited vertically), "jpeg" for JPEG and Theora style
277 * chroma siting (halfway-sited both horizontally and vertically).
278 * Other chroma site values are possible, but uncommon.
280 * When no chroma site is specified in the caps, it should be assumed
285 * Returns: a chroma site string, or NULL if no chroma site could be
289 gst_video_parse_caps_chroma_site (GstCaps * caps)
291 GstStructure *structure;
294 if (!gst_caps_is_fixed (caps))
297 structure = gst_caps_get_structure (caps, 0);
299 s = gst_structure_get_string (structure, "chroma-site");
303 if (gst_structure_has_name (structure, "video/x-raw-yuv")) {
311 * gst_video_format_parse_caps:
312 * @caps: the #GstCaps to parse
313 * @format: the #GstVideoFormat of the video represented by @caps (output)
314 * @width: the width of the video represented by @caps, may be NULL (output)
315 * @height: the height of the video represented by @caps, may be NULL (output)
317 * Determines the #GstVideoFormat of @caps and places it in the location
318 * pointed to by @format. Extracts the size of the video and places it
319 * in the location pointed to by @width and @height. If @caps does not
320 * represent one of the raw video formats listed in #GstVideoFormat, the
321 * function will fail and return FALSE.
325 * Returns: TRUE if @caps was parsed correctly.
328 gst_video_format_parse_caps (GstCaps * caps, GstVideoFormat * format,
329 int *width, int *height)
331 GstStructure *structure;
334 if (!gst_caps_is_fixed (caps))
337 structure = gst_caps_get_structure (caps, 0);
340 if (gst_structure_has_name (structure, "video/x-raw-yuv")) {
343 ok &= gst_structure_get_fourcc (structure, "format", &fourcc);
345 *format = gst_video_format_from_fourcc (fourcc);
346 if (*format == GST_VIDEO_FORMAT_UNKNOWN) {
349 } else if (gst_structure_has_name (structure, "video/x-raw-rgb")) {
359 ok &= gst_structure_get_int (structure, "depth", &depth);
360 ok &= gst_structure_get_int (structure, "bpp", &bpp);
363 ok &= gst_structure_get_int (structure, "endianness", &endianness);
364 ok &= gst_structure_get_int (structure, "red_mask", &red_mask);
365 ok &= gst_structure_get_int (structure, "green_mask", &green_mask);
366 ok &= gst_structure_get_int (structure, "blue_mask", &blue_mask);
368 have_alpha = gst_structure_get_int (structure, "alpha_mask", &alpha_mask);
370 if (depth == 30 && bpp == 32 && endianness == G_BIG_ENDIAN) {
371 *format = GST_VIDEO_FORMAT_r210;
372 } else if (depth == 24 && bpp == 32 && endianness == G_BIG_ENDIAN) {
373 *format = gst_video_format_from_rgb32_masks (red_mask, green_mask,
375 if (*format == GST_VIDEO_FORMAT_UNKNOWN) {
378 } else if (depth == 32 && bpp == 32 && endianness == G_BIG_ENDIAN &&
380 *format = gst_video_format_from_rgba32_masks (red_mask, green_mask,
381 blue_mask, alpha_mask);
382 if (*format == GST_VIDEO_FORMAT_UNKNOWN) {
385 } else if (depth == 24 && bpp == 24 && endianness == G_BIG_ENDIAN) {
386 *format = gst_video_format_from_rgb24_masks (red_mask, green_mask,
388 if (*format == GST_VIDEO_FORMAT_UNKNOWN) {
391 } else if ((depth == 15 || depth == 16) && bpp == 16 &&
392 endianness == G_BYTE_ORDER) {
393 *format = gst_video_format_from_rgb16_masks (red_mask, green_mask,
395 if (*format == GST_VIDEO_FORMAT_UNKNOWN) {
398 } else if (depth == 8 && bpp == 8) {
399 *format = GST_VIDEO_FORMAT_RGB8_PALETTED;
400 } else if (depth == 64 && bpp == 64) {
401 *format = gst_video_format_from_rgba32_masks (red_mask, green_mask,
402 blue_mask, alpha_mask);
403 if (*format == GST_VIDEO_FORMAT_ARGB) {
404 *format = GST_VIDEO_FORMAT_ARGB64;
406 *format = GST_VIDEO_FORMAT_UNKNOWN;
412 } else if (gst_structure_has_name (structure, "video/x-raw-gray")) {
417 ok &= gst_structure_get_int (structure, "depth", &depth);
418 ok &= gst_structure_get_int (structure, "bpp", &bpp);
421 ok &= gst_structure_get_int (structure, "endianness", &endianness);
423 if (depth == 8 && bpp == 8) {
424 *format = GST_VIDEO_FORMAT_GRAY8;
425 } else if (depth == 16 && bpp == 16 && endianness == G_BIG_ENDIAN) {
426 *format = GST_VIDEO_FORMAT_GRAY16_BE;
427 } else if (depth == 16 && bpp == 16 && endianness == G_LITTLE_ENDIAN) {
428 *format = GST_VIDEO_FORMAT_GRAY16_LE;
438 ok &= gst_structure_get_int (structure, "width", width);
442 ok &= gst_structure_get_int (structure, "height", height);
450 * gst_video_parse_caps_framerate:
451 * @caps: pointer to a #GstCaps instance
452 * @fps_n: pointer to integer to hold numerator of frame rate (output)
453 * @fps_d: pointer to integer to hold denominator of frame rate (output)
455 * Extracts the frame rate from @caps and places the values in the locations
456 * pointed to by @fps_n and @fps_d. Returns TRUE if the values could be
457 * parsed correctly, FALSE if not.
459 * This function can be used with #GstCaps that have any media type; it
460 * is not limited to formats handled by #GstVideoFormat.
464 * Returns: TRUE if @caps was parsed correctly.
467 gst_video_parse_caps_framerate (GstCaps * caps, int *fps_n, int *fps_d)
469 GstStructure *structure;
471 if (!gst_caps_is_fixed (caps))
474 structure = gst_caps_get_structure (caps, 0);
476 return gst_structure_get_fraction (structure, "framerate", fps_n, fps_d);
480 * gst_video_parse_caps_pixel_aspect_ratio:
481 * @caps: pointer to a #GstCaps instance
482 * @par_n: pointer to numerator of pixel aspect ratio (output)
483 * @par_d: pointer to denominator of pixel aspect ratio (output)
485 * Extracts the pixel aspect ratio from @caps and places the values in
486 * the locations pointed to by @par_n and @par_d. Returns TRUE if the
487 * values could be parsed correctly, FALSE if not.
489 * This function can be used with #GstCaps that have any media type; it
490 * is not limited to formats handled by #GstVideoFormat.
494 * Returns: TRUE if @caps was parsed correctly.
497 gst_video_parse_caps_pixel_aspect_ratio (GstCaps * caps, int *par_n, int *par_d)
499 GstStructure *structure;
501 if (!gst_caps_is_fixed (caps))
504 structure = gst_caps_get_structure (caps, 0);
506 if (!gst_structure_get_fraction (structure, "pixel-aspect-ratio",
515 * gst_video_format_new_caps_interlaced:
516 * @format: the #GstVideoFormat describing the raw video format
517 * @width: width of video
518 * @height: height of video
519 * @framerate_n: numerator of frame rate
520 * @framerate_d: denominator of frame rate
521 * @par_n: numerator of pixel aspect ratio
522 * @par_d: denominator of pixel aspect ratio
523 * @interlaced: #TRUE if the format is interlaced
525 * Creates a new #GstCaps object based on the parameters provided.
529 * Returns: a new #GstCaps object, or NULL if there was an error
532 gst_video_format_new_caps_interlaced (GstVideoFormat format,
533 int width, int height, int framerate_n, int framerate_d, int par_n,
534 int par_d, gboolean interlaced)
539 gst_video_format_new_caps (format, width, height, framerate_n,
540 framerate_d, par_n, par_d);
541 if (interlaced && (res != NULL))
542 gst_caps_set_simple (res, "interlaced", G_TYPE_BOOLEAN, TRUE, NULL);
548 gst_video_format_new_caps_raw (GstVideoFormat format)
550 g_return_val_if_fail (format != GST_VIDEO_FORMAT_UNKNOWN, NULL);
552 if (gst_video_format_is_yuv (format)) {
553 return gst_caps_new_simple ("video/x-raw-yuv",
554 "format", GST_TYPE_FOURCC, gst_video_format_to_fourcc (format), NULL);
556 if (gst_video_format_is_rgb (format)) {
565 unsigned int mask = 0;
568 case GST_VIDEO_FORMAT_RGBx:
569 case GST_VIDEO_FORMAT_BGRx:
570 case GST_VIDEO_FORMAT_xRGB:
571 case GST_VIDEO_FORMAT_xBGR:
576 case GST_VIDEO_FORMAT_RGBA:
577 case GST_VIDEO_FORMAT_BGRA:
578 case GST_VIDEO_FORMAT_ARGB:
579 case GST_VIDEO_FORMAT_ABGR:
584 case GST_VIDEO_FORMAT_RGB:
585 case GST_VIDEO_FORMAT_BGR:
590 case GST_VIDEO_FORMAT_RGB16:
591 case GST_VIDEO_FORMAT_BGR16:
596 case GST_VIDEO_FORMAT_RGB15:
597 case GST_VIDEO_FORMAT_BGR15:
602 case GST_VIDEO_FORMAT_RGB8_PALETTED:
607 case GST_VIDEO_FORMAT_ARGB64:
612 case GST_VIDEO_FORMAT_r210:
620 if (bpp == 32 && depth == 30) {
621 red_mask = 0x3ff00000;
622 green_mask = 0x000ffc00;
623 blue_mask = 0x000003ff;
625 } else if (bpp == 32 || bpp == 24 || bpp == 64) {
632 mask >> (8 * gst_video_format_get_component_offset (format, 0, 0, 0));
634 mask >> (8 * gst_video_format_get_component_offset (format, 1, 0, 0));
636 mask >> (8 * gst_video_format_get_component_offset (format, 2, 0, 0));
637 } else if (bpp == 16) {
639 case GST_VIDEO_FORMAT_RGB16:
640 red_mask = GST_VIDEO_COMP1_MASK_16_INT;
641 green_mask = GST_VIDEO_COMP2_MASK_16_INT;
642 blue_mask = GST_VIDEO_COMP3_MASK_16_INT;
644 case GST_VIDEO_FORMAT_BGR16:
645 red_mask = GST_VIDEO_COMP3_MASK_16_INT;
646 green_mask = GST_VIDEO_COMP2_MASK_16_INT;
647 blue_mask = GST_VIDEO_COMP1_MASK_16_INT;
650 case GST_VIDEO_FORMAT_RGB15:
651 red_mask = GST_VIDEO_COMP1_MASK_15_INT;
652 green_mask = GST_VIDEO_COMP2_MASK_15_INT;
653 blue_mask = GST_VIDEO_COMP3_MASK_15_INT;
655 case GST_VIDEO_FORMAT_BGR15:
656 red_mask = GST_VIDEO_COMP3_MASK_15_INT;
657 green_mask = GST_VIDEO_COMP2_MASK_15_INT;
658 blue_mask = GST_VIDEO_COMP1_MASK_15_INT;
663 } else if (bpp != 8) {
667 caps = gst_caps_new_simple ("video/x-raw-rgb",
668 "bpp", G_TYPE_INT, bpp, "depth", G_TYPE_INT, depth, NULL);
671 gst_caps_set_simple (caps,
672 "endianness", G_TYPE_INT, G_BIG_ENDIAN,
673 "red_mask", G_TYPE_INT, red_mask,
674 "green_mask", G_TYPE_INT, green_mask,
675 "blue_mask", G_TYPE_INT, blue_mask, NULL);
680 mask >> (8 * gst_video_format_get_component_offset (format, 3, 0, 0));
681 gst_caps_set_simple (caps, "alpha_mask", G_TYPE_INT, alpha_mask, NULL);
686 if (gst_video_format_is_gray (format)) {
693 case GST_VIDEO_FORMAT_GRAY8:
695 endianness = G_BIG_ENDIAN;
697 case GST_VIDEO_FORMAT_GRAY16_BE:
699 endianness = G_BIG_ENDIAN;
701 case GST_VIDEO_FORMAT_GRAY16_LE:
703 endianness = G_LITTLE_ENDIAN;
711 caps = gst_caps_new_simple ("video/x-raw-gray",
712 "bpp", G_TYPE_INT, bpp, "depth", G_TYPE_INT, depth, NULL);
714 caps = gst_caps_new_simple ("video/x-raw-gray",
715 "bpp", G_TYPE_INT, bpp,
716 "depth", G_TYPE_INT, depth,
717 "endianness", G_TYPE_INT, endianness, NULL);
727 * gst_video_format_new_template_caps:
728 * @format: the #GstVideoFormat describing the raw video format
730 * Creates a new #GstCaps object based on the parameters provided.
731 * Size, frame rate, and pixel aspect ratio are set to the full
736 * Returns: a new #GstCaps object, or NULL if there was an error
739 gst_video_format_new_template_caps (GstVideoFormat format)
742 GstStructure *structure;
744 g_return_val_if_fail (format != GST_VIDEO_FORMAT_UNKNOWN, NULL);
746 caps = gst_video_format_new_caps_raw (format);
748 GValue value = { 0 };
751 structure = gst_caps_get_structure (caps, 0);
753 gst_structure_set (structure,
754 "width", GST_TYPE_INT_RANGE, 1, G_MAXINT,
755 "height", GST_TYPE_INT_RANGE, 1, G_MAXINT,
756 "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1,
757 "pixel-aspect-ratio", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1, NULL);
759 g_value_init (&value, GST_TYPE_LIST);
760 g_value_init (&v, G_TYPE_BOOLEAN);
761 g_value_set_boolean (&v, TRUE);
762 gst_value_list_append_value (&value, &v);
763 g_value_set_boolean (&v, FALSE);
764 gst_value_list_append_value (&value, &v);
766 gst_structure_set_value (structure, "interlaced", &value);
768 g_value_reset (&value);
776 * gst_video_format_new_caps:
777 * @format: the #GstVideoFormat describing the raw video format
778 * @width: width of video
779 * @height: height of video
780 * @framerate_n: numerator of frame rate
781 * @framerate_d: denominator of frame rate
782 * @par_n: numerator of pixel aspect ratio
783 * @par_d: denominator of pixel aspect ratio
785 * Creates a new #GstCaps object based on the parameters provided.
789 * Returns: a new #GstCaps object, or NULL if there was an error
792 gst_video_format_new_caps (GstVideoFormat format, int width,
793 int height, int framerate_n, int framerate_d, int par_n, int par_d)
796 GstStructure *structure;
798 g_return_val_if_fail (format != GST_VIDEO_FORMAT_UNKNOWN, NULL);
799 g_return_val_if_fail (width > 0 && height > 0, NULL);
801 caps = gst_video_format_new_caps_raw (format);
803 structure = gst_caps_get_structure (caps, 0);
805 gst_structure_set (structure,
806 "width", G_TYPE_INT, width,
807 "height", G_TYPE_INT, height,
808 "framerate", GST_TYPE_FRACTION, framerate_n, framerate_d,
809 "pixel-aspect-ratio", GST_TYPE_FRACTION, par_n, par_d, NULL);
817 * gst_video_format_from_fourcc:
818 * @fourcc: a FOURCC value representing raw YUV video
820 * Converts a FOURCC value into the corresponding #GstVideoFormat.
821 * If the FOURCC cannot be represented by #GstVideoFormat,
822 * #GST_VIDEO_FORMAT_UNKNOWN is returned.
826 * Returns: the #GstVideoFormat describing the FOURCC value
829 gst_video_format_from_fourcc (guint32 fourcc)
832 case GST_MAKE_FOURCC ('I', '4', '2', '0'):
833 return GST_VIDEO_FORMAT_I420;
834 case GST_MAKE_FOURCC ('Y', 'V', '1', '2'):
835 return GST_VIDEO_FORMAT_YV12;
836 case GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'):
837 return GST_VIDEO_FORMAT_YUY2;
838 case GST_MAKE_FOURCC ('Y', 'V', 'Y', 'U'):
839 return GST_VIDEO_FORMAT_YVYU;
840 case GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y'):
841 return GST_VIDEO_FORMAT_UYVY;
842 case GST_MAKE_FOURCC ('A', 'Y', 'U', 'V'):
843 return GST_VIDEO_FORMAT_AYUV;
844 case GST_MAKE_FOURCC ('Y', '4', '1', 'B'):
845 return GST_VIDEO_FORMAT_Y41B;
846 case GST_MAKE_FOURCC ('Y', '4', '2', 'B'):
847 return GST_VIDEO_FORMAT_Y42B;
848 case GST_MAKE_FOURCC ('Y', '4', '4', '4'):
849 return GST_VIDEO_FORMAT_Y444;
850 case GST_MAKE_FOURCC ('v', '2', '1', '0'):
851 return GST_VIDEO_FORMAT_v210;
852 case GST_MAKE_FOURCC ('v', '2', '1', '6'):
853 return GST_VIDEO_FORMAT_v216;
854 case GST_MAKE_FOURCC ('N', 'V', '1', '2'):
855 return GST_VIDEO_FORMAT_NV12;
856 case GST_MAKE_FOURCC ('N', 'V', '2', '1'):
857 return GST_VIDEO_FORMAT_NV21;
858 case GST_MAKE_FOURCC ('v', '3', '0', '8'):
859 return GST_VIDEO_FORMAT_v308;
860 case GST_MAKE_FOURCC ('Y', '8', '0', '0'):
861 case GST_MAKE_FOURCC ('Y', '8', ' ', ' '):
862 case GST_MAKE_FOURCC ('G', 'R', 'E', 'Y'):
863 return GST_VIDEO_FORMAT_Y800;
864 case GST_MAKE_FOURCC ('Y', '1', '6', ' '):
865 return GST_VIDEO_FORMAT_Y16;
866 case GST_MAKE_FOURCC ('U', 'Y', 'V', 'P'):
867 return GST_VIDEO_FORMAT_UYVP;
868 case GST_MAKE_FOURCC ('A', '4', '2', '0'):
869 return GST_VIDEO_FORMAT_A420;
870 case GST_MAKE_FOURCC ('Y', 'U', 'V', '9'):
871 return GST_VIDEO_FORMAT_YUV9;
872 case GST_MAKE_FOURCC ('Y', 'V', 'U', '9'):
873 return GST_VIDEO_FORMAT_YVU9;
874 case GST_MAKE_FOURCC ('I', 'Y', 'U', '1'):
875 return GST_VIDEO_FORMAT_IYU1;
876 case GST_MAKE_FOURCC ('A', 'Y', '6', '4'):
877 return GST_VIDEO_FORMAT_AYUV64;
879 return GST_VIDEO_FORMAT_UNKNOWN;
884 * gst_video_format_to_fourcc:
885 * @format: a #GstVideoFormat video format
887 * Converts a #GstVideoFormat value into the corresponding FOURCC. Only
888 * a few YUV formats have corresponding FOURCC values. If @format has
889 * no corresponding FOURCC value, 0 is returned.
893 * Returns: the FOURCC corresponding to @format
896 gst_video_format_to_fourcc (GstVideoFormat format)
898 g_return_val_if_fail (format != GST_VIDEO_FORMAT_UNKNOWN, 0);
901 case GST_VIDEO_FORMAT_I420:
902 return GST_MAKE_FOURCC ('I', '4', '2', '0');
903 case GST_VIDEO_FORMAT_YV12:
904 return GST_MAKE_FOURCC ('Y', 'V', '1', '2');
905 case GST_VIDEO_FORMAT_YUY2:
906 return GST_MAKE_FOURCC ('Y', 'U', 'Y', '2');
907 case GST_VIDEO_FORMAT_YVYU:
908 return GST_MAKE_FOURCC ('Y', 'V', 'Y', 'U');
909 case GST_VIDEO_FORMAT_UYVY:
910 return GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y');
911 case GST_VIDEO_FORMAT_AYUV:
912 return GST_MAKE_FOURCC ('A', 'Y', 'U', 'V');
913 case GST_VIDEO_FORMAT_Y41B:
914 return GST_MAKE_FOURCC ('Y', '4', '1', 'B');
915 case GST_VIDEO_FORMAT_Y42B:
916 return GST_MAKE_FOURCC ('Y', '4', '2', 'B');
917 case GST_VIDEO_FORMAT_Y444:
918 return GST_MAKE_FOURCC ('Y', '4', '4', '4');
919 case GST_VIDEO_FORMAT_v210:
920 return GST_MAKE_FOURCC ('v', '2', '1', '0');
921 case GST_VIDEO_FORMAT_v216:
922 return GST_MAKE_FOURCC ('v', '2', '1', '6');
923 case GST_VIDEO_FORMAT_NV12:
924 return GST_MAKE_FOURCC ('N', 'V', '1', '2');
925 case GST_VIDEO_FORMAT_NV21:
926 return GST_MAKE_FOURCC ('N', 'V', '2', '1');
927 case GST_VIDEO_FORMAT_v308:
928 return GST_MAKE_FOURCC ('v', '3', '0', '8');
929 case GST_VIDEO_FORMAT_Y800:
930 return GST_MAKE_FOURCC ('Y', '8', '0', '0');
931 case GST_VIDEO_FORMAT_Y16:
932 return GST_MAKE_FOURCC ('Y', '1', '6', ' ');
933 case GST_VIDEO_FORMAT_UYVP:
934 return GST_MAKE_FOURCC ('U', 'Y', 'V', 'P');
935 case GST_VIDEO_FORMAT_A420:
936 return GST_MAKE_FOURCC ('A', '4', '2', '0');
937 case GST_VIDEO_FORMAT_YUV9:
938 return GST_MAKE_FOURCC ('Y', 'U', 'V', '9');
939 case GST_VIDEO_FORMAT_YVU9:
940 return GST_MAKE_FOURCC ('Y', 'V', 'U', '9');
941 case GST_VIDEO_FORMAT_IYU1:
942 return GST_MAKE_FOURCC ('I', 'Y', 'U', '1');
943 case GST_VIDEO_FORMAT_AYUV64:
944 return GST_MAKE_FOURCC ('A', 'Y', '6', '4');
951 * gst_video_format_from_rgb32_masks:
952 * @red_mask: red bit mask
953 * @green_mask: green bit mask
954 * @blue_mask: blue bit mask
956 * Converts red, green, blue bit masks into the corresponding
961 * Returns: the #GstVideoFormat corresponding to the bit masks
963 static GstVideoFormat
964 gst_video_format_from_rgb32_masks (int red_mask, int green_mask, int blue_mask)
966 if (red_mask == 0xff000000 && green_mask == 0x00ff0000 &&
967 blue_mask == 0x0000ff00) {
968 return GST_VIDEO_FORMAT_RGBx;
970 if (red_mask == 0x0000ff00 && green_mask == 0x00ff0000 &&
971 blue_mask == 0xff000000) {
972 return GST_VIDEO_FORMAT_BGRx;
974 if (red_mask == 0x00ff0000 && green_mask == 0x0000ff00 &&
975 blue_mask == 0x000000ff) {
976 return GST_VIDEO_FORMAT_xRGB;
978 if (red_mask == 0x000000ff && green_mask == 0x0000ff00 &&
979 blue_mask == 0x00ff0000) {
980 return GST_VIDEO_FORMAT_xBGR;
983 return GST_VIDEO_FORMAT_UNKNOWN;
986 static GstVideoFormat
987 gst_video_format_from_rgba32_masks (int red_mask, int green_mask,
988 int blue_mask, int alpha_mask)
990 if (red_mask == 0xff000000 && green_mask == 0x00ff0000 &&
991 blue_mask == 0x0000ff00 && alpha_mask == 0x000000ff) {
992 return GST_VIDEO_FORMAT_RGBA;
994 if (red_mask == 0x0000ff00 && green_mask == 0x00ff0000 &&
995 blue_mask == 0xff000000 && alpha_mask == 0x000000ff) {
996 return GST_VIDEO_FORMAT_BGRA;
998 if (red_mask == 0x00ff0000 && green_mask == 0x0000ff00 &&
999 blue_mask == 0x000000ff && alpha_mask == 0xff000000) {
1000 return GST_VIDEO_FORMAT_ARGB;
1002 if (red_mask == 0x000000ff && green_mask == 0x0000ff00 &&
1003 blue_mask == 0x00ff0000 && alpha_mask == 0xff000000) {
1004 return GST_VIDEO_FORMAT_ABGR;
1007 return GST_VIDEO_FORMAT_UNKNOWN;
1010 static GstVideoFormat
1011 gst_video_format_from_rgb24_masks (int red_mask, int green_mask, int blue_mask)
1013 if (red_mask == 0xff0000 && green_mask == 0x00ff00 && blue_mask == 0x0000ff) {
1014 return GST_VIDEO_FORMAT_RGB;
1016 if (red_mask == 0x0000ff && green_mask == 0x00ff00 && blue_mask == 0xff0000) {
1017 return GST_VIDEO_FORMAT_BGR;
1020 return GST_VIDEO_FORMAT_UNKNOWN;
1023 static GstVideoFormat
1024 gst_video_format_from_rgb16_masks (int red_mask, int green_mask, int blue_mask)
1026 if (red_mask == GST_VIDEO_COMP1_MASK_16_INT
1027 && green_mask == GST_VIDEO_COMP2_MASK_16_INT
1028 && blue_mask == GST_VIDEO_COMP3_MASK_16_INT) {
1029 return GST_VIDEO_FORMAT_RGB16;
1031 if (red_mask == GST_VIDEO_COMP3_MASK_16_INT
1032 && green_mask == GST_VIDEO_COMP2_MASK_16_INT
1033 && blue_mask == GST_VIDEO_COMP1_MASK_16_INT) {
1034 return GST_VIDEO_FORMAT_BGR16;
1036 if (red_mask == GST_VIDEO_COMP1_MASK_15_INT
1037 && green_mask == GST_VIDEO_COMP2_MASK_15_INT
1038 && blue_mask == GST_VIDEO_COMP3_MASK_15_INT) {
1039 return GST_VIDEO_FORMAT_RGB15;
1041 if (red_mask == GST_VIDEO_COMP3_MASK_15_INT
1042 && green_mask == GST_VIDEO_COMP2_MASK_15_INT
1043 && blue_mask == GST_VIDEO_COMP1_MASK_15_INT) {
1044 return GST_VIDEO_FORMAT_BGR15;
1047 return GST_VIDEO_FORMAT_UNKNOWN;
1051 * gst_video_format_is_rgb:
1052 * @format: a #GstVideoFormat
1054 * Determine whether the video format is an RGB format.
1058 * Returns: TRUE if @format represents RGB video
1061 gst_video_format_is_rgb (GstVideoFormat format)
1064 case GST_VIDEO_FORMAT_RGBx:
1065 case GST_VIDEO_FORMAT_BGRx:
1066 case GST_VIDEO_FORMAT_xRGB:
1067 case GST_VIDEO_FORMAT_xBGR:
1068 case GST_VIDEO_FORMAT_RGBA:
1069 case GST_VIDEO_FORMAT_BGRA:
1070 case GST_VIDEO_FORMAT_ARGB:
1071 case GST_VIDEO_FORMAT_ABGR:
1072 case GST_VIDEO_FORMAT_RGB:
1073 case GST_VIDEO_FORMAT_BGR:
1074 case GST_VIDEO_FORMAT_RGB16:
1075 case GST_VIDEO_FORMAT_BGR16:
1076 case GST_VIDEO_FORMAT_RGB15:
1077 case GST_VIDEO_FORMAT_BGR15:
1078 case GST_VIDEO_FORMAT_RGB8_PALETTED:
1079 case GST_VIDEO_FORMAT_ARGB64:
1080 case GST_VIDEO_FORMAT_r210:
1088 * gst_video_format_is_yuv:
1089 * @format: a #GstVideoFormat
1091 * Determine whether the video format is a YUV format.
1095 * Returns: TRUE if @format represents YUV video
1098 gst_video_format_is_yuv (GstVideoFormat format)
1101 case GST_VIDEO_FORMAT_I420:
1102 case GST_VIDEO_FORMAT_YV12:
1103 case GST_VIDEO_FORMAT_YUY2:
1104 case GST_VIDEO_FORMAT_YVYU:
1105 case GST_VIDEO_FORMAT_UYVY:
1106 case GST_VIDEO_FORMAT_AYUV:
1107 case GST_VIDEO_FORMAT_Y41B:
1108 case GST_VIDEO_FORMAT_Y42B:
1109 case GST_VIDEO_FORMAT_Y444:
1110 case GST_VIDEO_FORMAT_v210:
1111 case GST_VIDEO_FORMAT_v216:
1112 case GST_VIDEO_FORMAT_NV12:
1113 case GST_VIDEO_FORMAT_NV21:
1114 case GST_VIDEO_FORMAT_v308:
1115 case GST_VIDEO_FORMAT_Y800:
1116 case GST_VIDEO_FORMAT_Y16:
1117 case GST_VIDEO_FORMAT_UYVP:
1118 case GST_VIDEO_FORMAT_A420:
1119 case GST_VIDEO_FORMAT_YUV9:
1120 case GST_VIDEO_FORMAT_YVU9:
1121 case GST_VIDEO_FORMAT_IYU1:
1122 case GST_VIDEO_FORMAT_AYUV64:
1130 * gst_video_format_is_gray:
1131 * @format: a #GstVideoFormat
1133 * Determine whether the video format is a grayscale format.
1137 * Returns: TRUE if @format represents grayscale video
1140 gst_video_format_is_gray (GstVideoFormat format)
1143 case GST_VIDEO_FORMAT_GRAY8:
1144 case GST_VIDEO_FORMAT_GRAY16_BE:
1145 case GST_VIDEO_FORMAT_GRAY16_LE:
1146 case GST_VIDEO_FORMAT_Y800:
1147 case GST_VIDEO_FORMAT_Y16:
1155 * gst_video_format_has_alpha:
1156 * @format: a #GstVideoFormat
1158 * Returns TRUE or FALSE depending on if the video format provides an
1163 * Returns: TRUE if @format has an alpha channel
1166 gst_video_format_has_alpha (GstVideoFormat format)
1169 case GST_VIDEO_FORMAT_AYUV:
1170 case GST_VIDEO_FORMAT_RGBA:
1171 case GST_VIDEO_FORMAT_BGRA:
1172 case GST_VIDEO_FORMAT_ARGB:
1173 case GST_VIDEO_FORMAT_ABGR:
1174 case GST_VIDEO_FORMAT_A420:
1175 case GST_VIDEO_FORMAT_RGB8_PALETTED:
1176 case GST_VIDEO_FORMAT_ARGB64:
1177 case GST_VIDEO_FORMAT_AYUV64:
1185 * gst_video_format_get_component_depth:
1186 * @format: a #GstVideoFormat
1188 * Returns the number of bits used to encode an individual pixel of
1189 * a given component. Typically this is 8, although higher and lower
1190 * values are possible for some formats.
1194 * Returns: depth of component
1197 gst_video_format_get_component_depth (GstVideoFormat format, int component)
1199 if (component == 3 && !gst_video_format_has_alpha (format))
1203 case GST_VIDEO_FORMAT_RGB16:
1204 case GST_VIDEO_FORMAT_BGR16:
1208 case GST_VIDEO_FORMAT_RGB15:
1209 case GST_VIDEO_FORMAT_BGR15:
1211 case GST_VIDEO_FORMAT_I420:
1212 case GST_VIDEO_FORMAT_YV12:
1213 case GST_VIDEO_FORMAT_YUY2:
1214 case GST_VIDEO_FORMAT_YVYU:
1215 case GST_VIDEO_FORMAT_UYVY:
1216 case GST_VIDEO_FORMAT_Y41B:
1217 case GST_VIDEO_FORMAT_Y42B:
1218 case GST_VIDEO_FORMAT_Y444:
1219 case GST_VIDEO_FORMAT_NV12:
1220 case GST_VIDEO_FORMAT_NV21:
1221 case GST_VIDEO_FORMAT_v308:
1222 case GST_VIDEO_FORMAT_Y800:
1223 case GST_VIDEO_FORMAT_YUV9:
1224 case GST_VIDEO_FORMAT_YVU9:
1225 case GST_VIDEO_FORMAT_IYU1:
1226 case GST_VIDEO_FORMAT_AYUV:
1227 case GST_VIDEO_FORMAT_RGBA:
1228 case GST_VIDEO_FORMAT_BGRA:
1229 case GST_VIDEO_FORMAT_ARGB:
1230 case GST_VIDEO_FORMAT_ABGR:
1231 case GST_VIDEO_FORMAT_A420:
1232 case GST_VIDEO_FORMAT_RGB8_PALETTED:
1233 case GST_VIDEO_FORMAT_RGBx:
1234 case GST_VIDEO_FORMAT_BGRx:
1235 case GST_VIDEO_FORMAT_xRGB:
1236 case GST_VIDEO_FORMAT_xBGR:
1237 case GST_VIDEO_FORMAT_RGB:
1238 case GST_VIDEO_FORMAT_BGR:
1241 case GST_VIDEO_FORMAT_v210:
1242 case GST_VIDEO_FORMAT_UYVP:
1243 case GST_VIDEO_FORMAT_r210:
1245 case GST_VIDEO_FORMAT_Y16:
1246 case GST_VIDEO_FORMAT_v216:
1247 case GST_VIDEO_FORMAT_ARGB64:
1248 case GST_VIDEO_FORMAT_AYUV64:
1255 * gst_video_format_get_row_stride:
1256 * @format: a #GstVideoFormat
1257 * @component: the component index
1258 * @width: the width of video
1260 * Calculates the row stride (number of bytes from one row of pixels to
1261 * the next) for the video component with an index of @component. For
1262 * YUV video, Y, U, and V have component indices of 0, 1, and 2,
1263 * respectively. For RGB video, R, G, and B have component indicies of
1264 * 0, 1, and 2, respectively. Alpha channels, if present, have a component
1265 * index of 3. The @width parameter always represents the width of the
1266 * video, not the component.
1270 * Returns: row stride of component @component
1273 gst_video_format_get_row_stride (GstVideoFormat format, int component,
1276 g_return_val_if_fail (format != GST_VIDEO_FORMAT_UNKNOWN, 0);
1277 g_return_val_if_fail (component >= 0 && component <= 3, 0);
1278 g_return_val_if_fail (width > 0, 0);
1281 case GST_VIDEO_FORMAT_I420:
1282 case GST_VIDEO_FORMAT_YV12:
1283 if (component == 0) {
1284 return GST_ROUND_UP_4 (width);
1286 return GST_ROUND_UP_4 (GST_ROUND_UP_2 (width) / 2);
1288 case GST_VIDEO_FORMAT_YUY2:
1289 case GST_VIDEO_FORMAT_YVYU:
1290 case GST_VIDEO_FORMAT_UYVY:
1291 return GST_ROUND_UP_4 (width * 2);
1292 case GST_VIDEO_FORMAT_AYUV:
1293 case GST_VIDEO_FORMAT_RGBx:
1294 case GST_VIDEO_FORMAT_BGRx:
1295 case GST_VIDEO_FORMAT_xRGB:
1296 case GST_VIDEO_FORMAT_xBGR:
1297 case GST_VIDEO_FORMAT_RGBA:
1298 case GST_VIDEO_FORMAT_BGRA:
1299 case GST_VIDEO_FORMAT_ARGB:
1300 case GST_VIDEO_FORMAT_ABGR:
1301 case GST_VIDEO_FORMAT_r210:
1303 case GST_VIDEO_FORMAT_RGB16:
1304 case GST_VIDEO_FORMAT_BGR16:
1305 case GST_VIDEO_FORMAT_RGB15:
1306 case GST_VIDEO_FORMAT_BGR15:
1307 return GST_ROUND_UP_4 (width * 2);
1308 case GST_VIDEO_FORMAT_RGB:
1309 case GST_VIDEO_FORMAT_BGR:
1310 case GST_VIDEO_FORMAT_v308:
1311 return GST_ROUND_UP_4 (width * 3);
1312 case GST_VIDEO_FORMAT_Y41B:
1313 if (component == 0) {
1314 return GST_ROUND_UP_4 (width);
1316 return GST_ROUND_UP_16 (width) / 4;
1318 case GST_VIDEO_FORMAT_Y42B:
1319 if (component == 0) {
1320 return GST_ROUND_UP_4 (width);
1322 return GST_ROUND_UP_8 (width) / 2;
1324 case GST_VIDEO_FORMAT_Y444:
1325 return GST_ROUND_UP_4 (width);
1326 case GST_VIDEO_FORMAT_v210:
1327 return ((width + 47) / 48) * 128;
1328 case GST_VIDEO_FORMAT_v216:
1329 return GST_ROUND_UP_8 (width * 4);
1330 case GST_VIDEO_FORMAT_NV12:
1331 case GST_VIDEO_FORMAT_NV21:
1332 return GST_ROUND_UP_4 (width);
1333 case GST_VIDEO_FORMAT_GRAY8:
1334 case GST_VIDEO_FORMAT_Y800:
1335 return GST_ROUND_UP_4 (width);
1336 case GST_VIDEO_FORMAT_GRAY16_BE:
1337 case GST_VIDEO_FORMAT_GRAY16_LE:
1338 case GST_VIDEO_FORMAT_Y16:
1339 return GST_ROUND_UP_4 (width * 2);
1340 case GST_VIDEO_FORMAT_UYVP:
1341 return GST_ROUND_UP_4 ((width * 2 * 5 + 3) / 4);
1342 case GST_VIDEO_FORMAT_A420:
1343 if (component == 0 || component == 3) {
1344 return GST_ROUND_UP_4 (width);
1346 return GST_ROUND_UP_4 (GST_ROUND_UP_2 (width) / 2);
1348 case GST_VIDEO_FORMAT_RGB8_PALETTED:
1349 return GST_ROUND_UP_4 (width);
1350 case GST_VIDEO_FORMAT_YUV9:
1351 case GST_VIDEO_FORMAT_YVU9:
1352 if (component == 0) {
1353 return GST_ROUND_UP_4 (width);
1355 return GST_ROUND_UP_4 (GST_ROUND_UP_4 (width) / 4);
1357 case GST_VIDEO_FORMAT_IYU1:
1358 return GST_ROUND_UP_4 (GST_ROUND_UP_4 (width) +
1359 GST_ROUND_UP_4 (width) / 2);
1360 case GST_VIDEO_FORMAT_ARGB64:
1361 case GST_VIDEO_FORMAT_AYUV64:
1369 * gst_video_format_get_pixel_stride:
1370 * @format: a #GstVideoFormat
1371 * @component: the component index
1373 * Calculates the pixel stride (number of bytes from one pixel to the
1374 * pixel to its immediate left) for the video component with an index
1375 * of @component. See @gst_video_format_get_row_stride for a description
1376 * of the component index.
1380 * Returns: pixel stride of component @component
1383 gst_video_format_get_pixel_stride (GstVideoFormat format, int component)
1385 g_return_val_if_fail (format != GST_VIDEO_FORMAT_UNKNOWN, 0);
1386 g_return_val_if_fail (component >= 0 && component <= 3, 0);
1389 case GST_VIDEO_FORMAT_I420:
1390 case GST_VIDEO_FORMAT_YV12:
1391 case GST_VIDEO_FORMAT_Y41B:
1392 case GST_VIDEO_FORMAT_Y42B:
1393 case GST_VIDEO_FORMAT_Y444:
1394 case GST_VIDEO_FORMAT_A420:
1395 case GST_VIDEO_FORMAT_YUV9:
1396 case GST_VIDEO_FORMAT_YVU9:
1398 case GST_VIDEO_FORMAT_YUY2:
1399 case GST_VIDEO_FORMAT_YVYU:
1400 case GST_VIDEO_FORMAT_UYVY:
1401 if (component == 0) {
1406 case GST_VIDEO_FORMAT_IYU1:
1407 /* doesn't make much sense for IYU1 because it's 1 or 3
1408 * for luma depending on position */
1410 case GST_VIDEO_FORMAT_AYUV:
1411 case GST_VIDEO_FORMAT_RGBx:
1412 case GST_VIDEO_FORMAT_BGRx:
1413 case GST_VIDEO_FORMAT_xRGB:
1414 case GST_VIDEO_FORMAT_xBGR:
1415 case GST_VIDEO_FORMAT_RGBA:
1416 case GST_VIDEO_FORMAT_BGRA:
1417 case GST_VIDEO_FORMAT_ARGB:
1418 case GST_VIDEO_FORMAT_ABGR:
1419 case GST_VIDEO_FORMAT_r210:
1421 case GST_VIDEO_FORMAT_RGB16:
1422 case GST_VIDEO_FORMAT_BGR16:
1423 case GST_VIDEO_FORMAT_RGB15:
1424 case GST_VIDEO_FORMAT_BGR15:
1426 case GST_VIDEO_FORMAT_RGB:
1427 case GST_VIDEO_FORMAT_BGR:
1428 case GST_VIDEO_FORMAT_v308:
1430 case GST_VIDEO_FORMAT_v210:
1431 /* v210 is packed at the bit level, so pixel stride doesn't make sense */
1433 case GST_VIDEO_FORMAT_v216:
1434 if (component == 0) {
1439 case GST_VIDEO_FORMAT_NV12:
1440 case GST_VIDEO_FORMAT_NV21:
1441 if (component == 0) {
1446 case GST_VIDEO_FORMAT_GRAY8:
1447 case GST_VIDEO_FORMAT_Y800:
1449 case GST_VIDEO_FORMAT_GRAY16_BE:
1450 case GST_VIDEO_FORMAT_GRAY16_LE:
1451 case GST_VIDEO_FORMAT_Y16:
1453 case GST_VIDEO_FORMAT_UYVP:
1454 /* UYVP is packed at the bit level, so pixel stride doesn't make sense */
1456 case GST_VIDEO_FORMAT_RGB8_PALETTED:
1458 case GST_VIDEO_FORMAT_ARGB64:
1459 case GST_VIDEO_FORMAT_AYUV64:
1467 * gst_video_format_get_component_width:
1468 * @format: a #GstVideoFormat
1469 * @component: the component index
1470 * @width: the width of video
1472 * Calculates the width of the component. See
1473 * @gst_video_format_get_row_stride for a description
1474 * of the component index.
1478 * Returns: width of component @component
1481 gst_video_format_get_component_width (GstVideoFormat format,
1482 int component, int width)
1484 g_return_val_if_fail (format != GST_VIDEO_FORMAT_UNKNOWN, 0);
1485 g_return_val_if_fail (component >= 0 && component <= 3, 0);
1486 g_return_val_if_fail (width > 0, 0);
1489 case GST_VIDEO_FORMAT_I420:
1490 case GST_VIDEO_FORMAT_YV12:
1491 case GST_VIDEO_FORMAT_YUY2:
1492 case GST_VIDEO_FORMAT_YVYU:
1493 case GST_VIDEO_FORMAT_UYVY:
1494 case GST_VIDEO_FORMAT_Y42B:
1495 case GST_VIDEO_FORMAT_v210:
1496 case GST_VIDEO_FORMAT_v216:
1497 case GST_VIDEO_FORMAT_NV12:
1498 case GST_VIDEO_FORMAT_NV21:
1499 case GST_VIDEO_FORMAT_UYVP:
1500 if (component == 0) {
1503 return GST_ROUND_UP_2 (width) / 2;
1505 case GST_VIDEO_FORMAT_Y41B:
1506 case GST_VIDEO_FORMAT_YUV9:
1507 case GST_VIDEO_FORMAT_YVU9:
1508 case GST_VIDEO_FORMAT_IYU1:
1509 if (component == 0) {
1512 return GST_ROUND_UP_4 (width) / 4;
1514 case GST_VIDEO_FORMAT_AYUV:
1515 case GST_VIDEO_FORMAT_RGBx:
1516 case GST_VIDEO_FORMAT_BGRx:
1517 case GST_VIDEO_FORMAT_xRGB:
1518 case GST_VIDEO_FORMAT_xBGR:
1519 case GST_VIDEO_FORMAT_RGBA:
1520 case GST_VIDEO_FORMAT_BGRA:
1521 case GST_VIDEO_FORMAT_ARGB:
1522 case GST_VIDEO_FORMAT_ABGR:
1523 case GST_VIDEO_FORMAT_RGB:
1524 case GST_VIDEO_FORMAT_BGR:
1525 case GST_VIDEO_FORMAT_RGB16:
1526 case GST_VIDEO_FORMAT_BGR16:
1527 case GST_VIDEO_FORMAT_RGB15:
1528 case GST_VIDEO_FORMAT_BGR15:
1529 case GST_VIDEO_FORMAT_Y444:
1530 case GST_VIDEO_FORMAT_v308:
1531 case GST_VIDEO_FORMAT_GRAY8:
1532 case GST_VIDEO_FORMAT_GRAY16_BE:
1533 case GST_VIDEO_FORMAT_GRAY16_LE:
1534 case GST_VIDEO_FORMAT_Y800:
1535 case GST_VIDEO_FORMAT_Y16:
1536 case GST_VIDEO_FORMAT_RGB8_PALETTED:
1537 case GST_VIDEO_FORMAT_ARGB64:
1538 case GST_VIDEO_FORMAT_AYUV64:
1539 case GST_VIDEO_FORMAT_r210:
1541 case GST_VIDEO_FORMAT_A420:
1542 if (component == 0 || component == 3) {
1545 return GST_ROUND_UP_2 (width) / 2;
1553 * gst_video_format_get_component_height:
1554 * @format: a #GstVideoFormat
1555 * @component: the component index
1556 * @height: the height of video
1558 * Calculates the height of the component. See
1559 * @gst_video_format_get_row_stride for a description
1560 * of the component index.
1564 * Returns: height of component @component
1567 gst_video_format_get_component_height (GstVideoFormat format,
1568 int component, int height)
1570 g_return_val_if_fail (format != GST_VIDEO_FORMAT_UNKNOWN, 0);
1571 g_return_val_if_fail (component >= 0 && component <= 3, 0);
1572 g_return_val_if_fail (height > 0, 0);
1575 case GST_VIDEO_FORMAT_I420:
1576 case GST_VIDEO_FORMAT_YV12:
1577 case GST_VIDEO_FORMAT_NV12:
1578 case GST_VIDEO_FORMAT_NV21:
1579 if (component == 0) {
1582 return GST_ROUND_UP_2 (height) / 2;
1584 case GST_VIDEO_FORMAT_Y41B:
1585 case GST_VIDEO_FORMAT_Y42B:
1586 case GST_VIDEO_FORMAT_YUY2:
1587 case GST_VIDEO_FORMAT_YVYU:
1588 case GST_VIDEO_FORMAT_UYVY:
1589 case GST_VIDEO_FORMAT_AYUV:
1590 case GST_VIDEO_FORMAT_RGBx:
1591 case GST_VIDEO_FORMAT_BGRx:
1592 case GST_VIDEO_FORMAT_xRGB:
1593 case GST_VIDEO_FORMAT_xBGR:
1594 case GST_VIDEO_FORMAT_RGBA:
1595 case GST_VIDEO_FORMAT_BGRA:
1596 case GST_VIDEO_FORMAT_ARGB:
1597 case GST_VIDEO_FORMAT_ABGR:
1598 case GST_VIDEO_FORMAT_RGB:
1599 case GST_VIDEO_FORMAT_BGR:
1600 case GST_VIDEO_FORMAT_RGB16:
1601 case GST_VIDEO_FORMAT_BGR16:
1602 case GST_VIDEO_FORMAT_RGB15:
1603 case GST_VIDEO_FORMAT_BGR15:
1604 case GST_VIDEO_FORMAT_Y444:
1605 case GST_VIDEO_FORMAT_v210:
1606 case GST_VIDEO_FORMAT_v216:
1607 case GST_VIDEO_FORMAT_v308:
1608 case GST_VIDEO_FORMAT_GRAY8:
1609 case GST_VIDEO_FORMAT_GRAY16_BE:
1610 case GST_VIDEO_FORMAT_GRAY16_LE:
1611 case GST_VIDEO_FORMAT_Y800:
1612 case GST_VIDEO_FORMAT_Y16:
1613 case GST_VIDEO_FORMAT_UYVP:
1614 case GST_VIDEO_FORMAT_RGB8_PALETTED:
1615 case GST_VIDEO_FORMAT_IYU1:
1616 case GST_VIDEO_FORMAT_ARGB64:
1617 case GST_VIDEO_FORMAT_AYUV64:
1618 case GST_VIDEO_FORMAT_r210:
1620 case GST_VIDEO_FORMAT_A420:
1621 if (component == 0 || component == 3) {
1624 return GST_ROUND_UP_2 (height) / 2;
1626 case GST_VIDEO_FORMAT_YUV9:
1627 case GST_VIDEO_FORMAT_YVU9:
1628 if (component == 0) {
1631 return GST_ROUND_UP_4 (height) / 4;
1639 * gst_video_format_get_component_offset:
1640 * @format: a #GstVideoFormat
1641 * @component: the component index
1642 * @width: the width of video
1643 * @height: the height of video
1645 * Calculates the offset (in bytes) of the first pixel of the component
1646 * with index @component. For packed formats, this will typically be a
1647 * small integer (0, 1, 2, 3). For planar formats, this will be a
1648 * (relatively) large offset to the beginning of the second or third
1649 * component planes. See @gst_video_format_get_row_stride for a description
1650 * of the component index.
1654 * Returns: offset of component @component
1657 gst_video_format_get_component_offset (GstVideoFormat format,
1658 int component, int width, int height)
1660 g_return_val_if_fail (format != GST_VIDEO_FORMAT_UNKNOWN, 0);
1661 g_return_val_if_fail (component >= 0 && component <= 3, 0);
1662 g_return_val_if_fail ((!gst_video_format_is_yuv (format)) || (width > 0
1666 case GST_VIDEO_FORMAT_I420:
1670 return GST_ROUND_UP_4 (width) * GST_ROUND_UP_2 (height);
1671 if (component == 2) {
1672 return GST_ROUND_UP_4 (width) * GST_ROUND_UP_2 (height) +
1673 GST_ROUND_UP_4 (GST_ROUND_UP_2 (width) / 2) *
1674 (GST_ROUND_UP_2 (height) / 2);
1677 case GST_VIDEO_FORMAT_YV12: /* same as I420, but components 1+2 swapped */
1681 return GST_ROUND_UP_4 (width) * GST_ROUND_UP_2 (height);
1682 if (component == 1) {
1683 return GST_ROUND_UP_4 (width) * GST_ROUND_UP_2 (height) +
1684 GST_ROUND_UP_4 (GST_ROUND_UP_2 (width) / 2) *
1685 (GST_ROUND_UP_2 (height) / 2);
1688 case GST_VIDEO_FORMAT_YUY2:
1696 case GST_VIDEO_FORMAT_YVYU:
1704 case GST_VIDEO_FORMAT_UYVY:
1712 case GST_VIDEO_FORMAT_AYUV:
1722 case GST_VIDEO_FORMAT_RGBx:
1723 case GST_VIDEO_FORMAT_RGBA:
1733 case GST_VIDEO_FORMAT_BGRx:
1734 case GST_VIDEO_FORMAT_BGRA:
1744 case GST_VIDEO_FORMAT_xRGB:
1745 case GST_VIDEO_FORMAT_ARGB:
1755 case GST_VIDEO_FORMAT_xBGR:
1756 case GST_VIDEO_FORMAT_ABGR:
1766 case GST_VIDEO_FORMAT_RGB:
1767 case GST_VIDEO_FORMAT_v308:
1775 case GST_VIDEO_FORMAT_BGR:
1783 case GST_VIDEO_FORMAT_Y41B:
1787 return GST_ROUND_UP_4 (width) * height;
1789 return (GST_ROUND_UP_4 (width) +
1790 (GST_ROUND_UP_16 (width) / 4)) * height;
1792 case GST_VIDEO_FORMAT_Y42B:
1796 return GST_ROUND_UP_4 (width) * height;
1798 return (GST_ROUND_UP_4 (width) + (GST_ROUND_UP_8 (width) / 2)) * height;
1800 case GST_VIDEO_FORMAT_Y444:
1801 return GST_ROUND_UP_4 (width) * height * component;
1802 case GST_VIDEO_FORMAT_v210:
1803 case GST_VIDEO_FORMAT_r210:
1804 /* v210 is bit-packed, so this doesn't make sense */
1806 case GST_VIDEO_FORMAT_v216:
1814 case GST_VIDEO_FORMAT_NV12:
1818 return GST_ROUND_UP_4 (width) * GST_ROUND_UP_2 (height);
1820 return GST_ROUND_UP_4 (width) * GST_ROUND_UP_2 (height) + 1;
1821 case GST_VIDEO_FORMAT_NV21:
1825 return GST_ROUND_UP_4 (width) * GST_ROUND_UP_2 (height) + 1;
1827 return GST_ROUND_UP_4 (width) * GST_ROUND_UP_2 (height);
1828 case GST_VIDEO_FORMAT_GRAY8:
1829 case GST_VIDEO_FORMAT_GRAY16_BE:
1830 case GST_VIDEO_FORMAT_GRAY16_LE:
1831 case GST_VIDEO_FORMAT_Y800:
1832 case GST_VIDEO_FORMAT_Y16:
1834 case GST_VIDEO_FORMAT_UYVP:
1835 /* UYVP is bit-packed, so this doesn't make sense */
1837 case GST_VIDEO_FORMAT_A420:
1841 return GST_ROUND_UP_4 (width) * GST_ROUND_UP_2 (height);
1842 if (component == 2) {
1843 return GST_ROUND_UP_4 (width) * GST_ROUND_UP_2 (height) +
1844 GST_ROUND_UP_4 (GST_ROUND_UP_2 (width) / 2) *
1845 (GST_ROUND_UP_2 (height) / 2);
1847 if (component == 3) {
1848 return GST_ROUND_UP_4 (width) * GST_ROUND_UP_2 (height) +
1849 2 * GST_ROUND_UP_4 (GST_ROUND_UP_2 (width) / 2) *
1850 (GST_ROUND_UP_2 (height) / 2);
1852 case GST_VIDEO_FORMAT_RGB8_PALETTED:
1854 case GST_VIDEO_FORMAT_YUV9:
1858 return GST_ROUND_UP_4 (width) * height;
1859 if (component == 2) {
1860 return GST_ROUND_UP_4 (width) * height +
1861 GST_ROUND_UP_4 (GST_ROUND_UP_4 (width) / 4) *
1862 (GST_ROUND_UP_4 (height) / 4);
1865 case GST_VIDEO_FORMAT_YVU9:
1868 if (component == 1) {
1869 return GST_ROUND_UP_4 (width) * height +
1870 GST_ROUND_UP_4 (GST_ROUND_UP_4 (width) / 4) *
1871 (GST_ROUND_UP_4 (height) / 4);
1874 return GST_ROUND_UP_4 (width) * height;
1876 case GST_VIDEO_FORMAT_IYU1:
1883 case GST_VIDEO_FORMAT_ARGB64:
1884 case GST_VIDEO_FORMAT_AYUV64:
1900 * gst_video_format_get_size:
1901 * @format: a #GstVideoFormat
1902 * @width: the width of video
1903 * @height: the height of video
1905 * Calculates the total number of bytes in the raw video format. This
1906 * number should be used when allocating a buffer for raw video.
1910 * Returns: size (in bytes) of raw video format
1913 gst_video_format_get_size (GstVideoFormat format, int width, int height)
1917 g_return_val_if_fail (format != GST_VIDEO_FORMAT_UNKNOWN, 0);
1918 g_return_val_if_fail (width > 0 && height > 0, 0);
1921 case GST_VIDEO_FORMAT_I420:
1922 case GST_VIDEO_FORMAT_YV12:
1923 size = GST_ROUND_UP_4 (width) * GST_ROUND_UP_2 (height);
1924 size += GST_ROUND_UP_4 (GST_ROUND_UP_2 (width) / 2) *
1925 (GST_ROUND_UP_2 (height) / 2) * 2;
1927 case GST_VIDEO_FORMAT_IYU1:
1928 return GST_ROUND_UP_4 (GST_ROUND_UP_4 (width) +
1929 GST_ROUND_UP_4 (width) / 2) * height;
1930 case GST_VIDEO_FORMAT_YUY2:
1931 case GST_VIDEO_FORMAT_YVYU:
1932 case GST_VIDEO_FORMAT_UYVY:
1933 return GST_ROUND_UP_4 (width * 2) * height;
1934 case GST_VIDEO_FORMAT_AYUV:
1935 case GST_VIDEO_FORMAT_RGBx:
1936 case GST_VIDEO_FORMAT_BGRx:
1937 case GST_VIDEO_FORMAT_xRGB:
1938 case GST_VIDEO_FORMAT_xBGR:
1939 case GST_VIDEO_FORMAT_RGBA:
1940 case GST_VIDEO_FORMAT_BGRA:
1941 case GST_VIDEO_FORMAT_ARGB:
1942 case GST_VIDEO_FORMAT_ABGR:
1943 case GST_VIDEO_FORMAT_r210:
1944 return width * 4 * height;
1945 case GST_VIDEO_FORMAT_RGB16:
1946 case GST_VIDEO_FORMAT_BGR16:
1947 case GST_VIDEO_FORMAT_RGB15:
1948 case GST_VIDEO_FORMAT_BGR15:
1949 return GST_ROUND_UP_4 (width * 2) * height;
1950 case GST_VIDEO_FORMAT_RGB:
1951 case GST_VIDEO_FORMAT_BGR:
1952 case GST_VIDEO_FORMAT_v308:
1953 return GST_ROUND_UP_4 (width * 3) * height;
1954 case GST_VIDEO_FORMAT_Y41B:
1955 /* simplification of ROUNDUP4(w)*h + 2*((ROUNDUP16(w)/4)*h */
1956 return (GST_ROUND_UP_4 (width) + (GST_ROUND_UP_16 (width) / 2)) * height;
1957 case GST_VIDEO_FORMAT_Y42B:
1958 /* simplification of ROUNDUP4(w)*h + 2*(ROUNDUP8(w)/2)*h */
1959 return (GST_ROUND_UP_4 (width) + GST_ROUND_UP_8 (width)) * height;
1960 case GST_VIDEO_FORMAT_Y444:
1961 return GST_ROUND_UP_4 (width) * height * 3;
1962 case GST_VIDEO_FORMAT_v210:
1963 return ((width + 47) / 48) * 128 * height;
1964 case GST_VIDEO_FORMAT_v216:
1965 return GST_ROUND_UP_8 (width * 4) * height;
1966 case GST_VIDEO_FORMAT_NV12:
1967 case GST_VIDEO_FORMAT_NV21:
1968 return GST_ROUND_UP_4 (width) * GST_ROUND_UP_2 (height) * 3 / 2;
1969 case GST_VIDEO_FORMAT_GRAY8:
1970 case GST_VIDEO_FORMAT_Y800:
1971 case GST_VIDEO_FORMAT_RGB8_PALETTED:
1972 return GST_ROUND_UP_4 (width) * height;
1973 case GST_VIDEO_FORMAT_GRAY16_BE:
1974 case GST_VIDEO_FORMAT_GRAY16_LE:
1975 case GST_VIDEO_FORMAT_Y16:
1976 return GST_ROUND_UP_4 (width * 2) * height;
1977 case GST_VIDEO_FORMAT_UYVP:
1978 return GST_ROUND_UP_4 ((width * 2 * 5 + 3) / 4) * height;
1979 case GST_VIDEO_FORMAT_A420:
1980 size = 2 * GST_ROUND_UP_4 (width) * GST_ROUND_UP_2 (height);
1981 size += GST_ROUND_UP_4 (GST_ROUND_UP_2 (width) / 2) *
1982 (GST_ROUND_UP_2 (height) / 2) * 2;
1984 case GST_VIDEO_FORMAT_YUV9:
1985 case GST_VIDEO_FORMAT_YVU9:
1986 size = GST_ROUND_UP_4 (width) * height;
1987 size += GST_ROUND_UP_4 (GST_ROUND_UP_4 (width) / 4) *
1988 (GST_ROUND_UP_4 (height) / 4) * 2;
1990 case GST_VIDEO_FORMAT_ARGB64:
1991 case GST_VIDEO_FORMAT_AYUV64:
1992 return width * 8 * height;
1999 * gst_video_format_convert:
2000 * @format: a #GstVideoFormat
2001 * @width: the width of video
2002 * @height: the height of video
2003 * @fps_n: frame rate numerator
2004 * @fps_d: frame rate denominator
2005 * @src_format: #GstFormat of the @src_value
2006 * @src_value: value to convert
2007 * @dest_format: #GstFormat of the @dest_value
2008 * @dest_value: pointer to destination value
2010 * Converts among various #GstFormat types. This function handles
2011 * GST_FORMAT_BYTES, GST_FORMAT_TIME, and GST_FORMAT_DEFAULT. For
2012 * raw video, GST_FORMAT_DEFAULT corresponds to video frames. This
2013 * function can be to handle pad queries of the type GST_QUERY_CONVERT.
2017 * Returns: TRUE if the conversion was successful.
2020 gst_video_format_convert (GstVideoFormat format, int width, int height,
2021 int fps_n, int fps_d,
2022 GstFormat src_format, gint64 src_value,
2023 GstFormat dest_format, gint64 * dest_value)
2025 gboolean ret = FALSE;
2028 g_return_val_if_fail (format != GST_VIDEO_FORMAT_UNKNOWN, 0);
2029 g_return_val_if_fail (width > 0 && height > 0, 0);
2031 size = gst_video_format_get_size (format, width, height);
2033 GST_DEBUG ("converting value %" G_GINT64_FORMAT " from %s to %s",
2034 src_value, gst_format_get_name (src_format),
2035 gst_format_get_name (dest_format));
2037 if (src_format == dest_format) {
2038 *dest_value = src_value;
2043 if (src_value == -1) {
2049 /* bytes to frames */
2050 if (src_format == GST_FORMAT_BYTES && dest_format == GST_FORMAT_DEFAULT) {
2052 *dest_value = gst_util_uint64_scale_int (src_value, 1, size);
2054 GST_ERROR ("blocksize is 0");
2061 /* frames to bytes */
2062 if (src_format == GST_FORMAT_DEFAULT && dest_format == GST_FORMAT_BYTES) {
2063 *dest_value = gst_util_uint64_scale_int (src_value, size, 1);
2068 /* time to frames */
2069 if (src_format == GST_FORMAT_TIME && dest_format == GST_FORMAT_DEFAULT) {
2071 *dest_value = gst_util_uint64_scale (src_value,
2072 fps_n, GST_SECOND * fps_d);
2074 GST_ERROR ("framerate denominator is 0");
2081 /* frames to time */
2082 if (src_format == GST_FORMAT_DEFAULT && dest_format == GST_FORMAT_TIME) {
2084 *dest_value = gst_util_uint64_scale (src_value,
2085 GST_SECOND * fps_d, fps_n);
2087 GST_ERROR ("framerate numerator is 0");
2095 if (src_format == GST_FORMAT_TIME && dest_format == GST_FORMAT_BYTES) {
2097 *dest_value = gst_util_uint64_scale (src_value,
2098 fps_n * size, GST_SECOND * fps_d);
2100 GST_ERROR ("framerate denominator is 0");
2108 if (src_format == GST_FORMAT_BYTES && dest_format == GST_FORMAT_TIME) {
2109 if (fps_n != 0 && size != 0) {
2110 *dest_value = gst_util_uint64_scale (src_value,
2111 GST_SECOND * fps_d, fps_n * size);
2113 GST_ERROR ("framerate denominator and/or blocksize is 0");
2121 GST_DEBUG ("ret=%d result %" G_GINT64_FORMAT, ret, *dest_value);
2126 #define GST_VIDEO_EVENT_STILL_STATE_NAME "GstEventStillFrame"
2129 * gst_video_event_new_still_frame:
2130 * @in_still: boolean value for the still-frame state of the event.
2132 * Creates a new Still Frame event. If @in_still is %TRUE, then the event
2133 * represents the start of a still frame sequence. If it is %FALSE, then
2134 * the event ends a still frame sequence.
2136 * To parse an event created by gst_video_event_new_still_frame() use
2137 * gst_video_event_parse_still_frame().
2139 * Returns: The new GstEvent
2143 gst_video_event_new_still_frame (gboolean in_still)
2145 GstEvent *still_event;
2148 s = gst_structure_new (GST_VIDEO_EVENT_STILL_STATE_NAME,
2149 "still-state", G_TYPE_BOOLEAN, in_still, NULL);
2150 still_event = gst_event_new_custom (GST_EVENT_CUSTOM_DOWNSTREAM, s);
2156 * gst_video_event_parse_still_frame:
2157 * @event: A #GstEvent to parse
2158 * @in_still: A boolean to receive the still-frame status from the event, or NULL
2160 * Parse a #GstEvent, identify if it is a Still Frame event, and
2161 * return the still-frame state from the event if it is.
2162 * If the event represents the start of a still frame, the in_still
2163 * variable will be set to TRUE, otherwise FALSE. It is OK to pass NULL for the
2164 * in_still variable order to just check whether the event is a valid still-frame
2167 * Create a still frame event using gst_video_event_new_still_frame()
2169 * Returns: %TRUE if the event is a valid still-frame event. %FALSE if not
2173 gst_video_event_parse_still_frame (GstEvent * event, gboolean * in_still)
2175 const GstStructure *s;
2176 gboolean ev_still_state;
2178 g_return_val_if_fail (event != NULL, FALSE);
2180 if (GST_EVENT_TYPE (event) != GST_EVENT_CUSTOM_DOWNSTREAM)
2181 return FALSE; /* Not a still frame event */
2183 s = gst_event_get_structure (event);
2185 || !gst_structure_has_name (s, GST_VIDEO_EVENT_STILL_STATE_NAME))
2186 return FALSE; /* Not a still frame event */
2187 if (!gst_structure_get_boolean (s, "still-state", &ev_still_state))
2188 return FALSE; /* Not a still frame event */
2190 *in_still = ev_still_state;
2195 * gst_video_parse_caps_palette:
2196 * @caps: #GstCaps to parse
2198 * Returns the palette data from the caps as a #GstBuffer. For
2199 * #GST_VIDEO_FORMAT_RGB8_PALETTED this is containing 256 #guint32
2200 * values, each containing ARGB colors in native endianness.
2202 * Returns: a #GstBuffer containing the palette data. Unref after usage.
2206 gst_video_parse_caps_palette (GstCaps * caps)
2212 if (!gst_caps_is_fixed (caps))
2215 s = gst_caps_get_structure (caps, 0);
2217 p_v = gst_structure_get_value (s, "palette_data");
2218 if (!p_v || !GST_VALUE_HOLDS_BUFFER (p_v))
2221 p = gst_buffer_ref (gst_value_get_buffer (p_v));