43 int green_mask, int blue_mask, int alpha_mask); |
43 int green_mask, int blue_mask, int alpha_mask); |
44 static GstVideoFormat gst_video_format_from_rgb24_masks (int red_mask, |
44 static GstVideoFormat gst_video_format_from_rgb24_masks (int red_mask, |
45 int green_mask, int blue_mask); |
45 int green_mask, int blue_mask); |
46 |
46 |
47 |
47 |
48 /* This is simply a convenience function, nothing more or less */ |
48 /** |
|
49 * gst_video_frame_rate: |
|
50 * @pad: pointer to a #GstPad |
|
51 * |
|
52 * A convenience function to retrieve a GValue holding the framerate |
|
53 * from the caps on a pad. |
|
54 * |
|
55 * The pad needs to have negotiated caps containing a framerate property. |
|
56 * |
|
57 * Returns: NULL if the pad has no configured caps or the configured caps |
|
58 * do not contain a framerate. |
|
59 * |
|
60 */ |
49 #ifdef __SYMBIAN32__ |
61 #ifdef __SYMBIAN32__ |
50 EXPORT_C |
62 EXPORT_C |
51 #endif |
63 #endif |
52 |
64 |
53 const GValue * |
65 const GValue * |
85 GST_DEBUG_PAD_NAME (pad), fps_string); |
97 GST_DEBUG_PAD_NAME (pad), fps_string); |
86 g_free (fps_string); |
98 g_free (fps_string); |
87 |
99 |
88 return fps; |
100 return fps; |
89 } |
101 } |
90 #ifdef __SYMBIAN32__ |
102 |
91 EXPORT_C |
103 /** |
92 #endif |
104 * gst_video_get_size: |
93 |
105 * @pad: pointer to a #GstPad |
|
106 * @width: pointer to integer to hold pixel width of the video frames (output) |
|
107 * @height: pointer to integer to hold pixel height of the video frames (output) |
|
108 * |
|
109 * Inspect the caps of the provided pad and retrieve the width and height of |
|
110 * the video frames it is configured for. |
|
111 * |
|
112 * The pad needs to have negotiated caps containing width and height properties. |
|
113 * |
|
114 * Returns: TRUE if the width and height could be retrieved. |
|
115 * |
|
116 */ |
|
117 #ifdef __SYMBIAN32__ |
|
118 EXPORT_C |
|
119 #endif |
94 |
120 |
95 gboolean |
121 gboolean |
96 gst_video_get_size (GstPad * pad, gint * width, gint * height) |
122 gst_video_get_size (GstPad * pad, gint * width, gint * height) |
97 { |
123 { |
98 const GstCaps *caps = NULL; |
124 const GstCaps *caps = NULL; |
204 g_value_unset (&tmp2); |
230 g_value_unset (&tmp2); |
205 return FALSE; |
231 return FALSE; |
206 } |
232 } |
207 |
233 |
208 /** |
234 /** |
|
235 * gst_video_format_parse_caps_interlaced: |
|
236 * @caps: the fixed #GstCaps to parse |
|
237 * @interlaced: whether @caps represents interlaced video or not, may be NULL (output) |
|
238 * |
|
239 * Extracts whether the caps represents interlaced content or not and places it |
|
240 * in @interlaced. |
|
241 * |
|
242 * Since: 0.10.23 |
|
243 * |
|
244 * Returns: TRUE if @caps was parsed correctly. |
|
245 */ |
|
246 #ifdef __SYMBIAN32__ |
|
247 EXPORT_C |
|
248 #endif |
|
249 |
|
250 gboolean |
|
251 gst_video_format_parse_caps_interlaced (GstCaps * caps, gboolean * interlaced) |
|
252 { |
|
253 GstStructure *structure; |
|
254 |
|
255 if (!gst_caps_is_fixed (caps)) |
|
256 return FALSE; |
|
257 |
|
258 structure = gst_caps_get_structure (caps, 0); |
|
259 |
|
260 if (interlaced) { |
|
261 if (!gst_structure_get_boolean (structure, "interlaced", interlaced)) |
|
262 *interlaced = FALSE; |
|
263 } |
|
264 |
|
265 return TRUE; |
|
266 } |
|
267 |
|
268 /** |
209 * gst_video_format_parse_caps: |
269 * gst_video_format_parse_caps: |
210 * @caps: the #GstCaps to parse |
270 * @caps: the #GstCaps to parse |
211 * @format: the #GstVideoFormat of the video represented by @caps (output) |
271 * @format: the #GstVideoFormat of the video represented by @caps (output) |
212 * @width: the width of the video represented by @caps (output) |
272 * @width: the width of the video represented by @caps, may be NULL (output) |
213 * @height: the height of the video represented by @caps (output) |
273 * @height: the height of the video represented by @caps, may be NULL (output) |
214 * |
274 * |
215 * Determines the #GstVideoFormat of @caps and places it in the location |
275 * Determines the #GstVideoFormat of @caps and places it in the location |
216 * pointed to by @format. Extracts the size of the video and places it |
276 * pointed to by @format. Extracts the size of the video and places it |
217 * in the location pointed to by @width and @height. If @caps does not |
277 * in the location pointed to by @width and @height. If @caps does not |
218 * represent one of the raw video formats listed in #GstVideoFormat, the |
278 * represent one of the raw video formats listed in #GstVideoFormat, the |
302 } |
362 } |
303 |
363 |
304 return ok; |
364 return ok; |
305 } |
365 } |
306 |
366 |
|
367 |
307 /** |
368 /** |
308 * gst_video_parse_caps_framerate: |
369 * gst_video_parse_caps_framerate: |
309 * @caps: |
370 * @caps: pointer to a #GstCaps instance |
310 * @fps_n: pointer to numerator of frame rate (output) |
371 * @fps_n: pointer to integer to hold numerator of frame rate (output) |
311 * @fps_d: pointer to denominator of frame rate (output) |
372 * @fps_d: pointer to integer to hold denominator of frame rate (output) |
312 * |
373 * |
313 * Extracts the frame rate from @caps and places the values in the locations |
374 * Extracts the frame rate from @caps and places the values in the locations |
314 * pointed to by @fps_n and @fps_d. Returns TRUE if the values could be |
375 * pointed to by @fps_n and @fps_d. Returns TRUE if the values could be |
315 * parsed correctly, FALSE if not. |
376 * parsed correctly, FALSE if not. |
316 * |
377 * |
338 return gst_structure_get_fraction (structure, "framerate", fps_n, fps_d); |
399 return gst_structure_get_fraction (structure, "framerate", fps_n, fps_d); |
339 } |
400 } |
340 |
401 |
341 /** |
402 /** |
342 * gst_video_parse_caps_pixel_aspect_ratio: |
403 * gst_video_parse_caps_pixel_aspect_ratio: |
343 * @caps: |
404 * @caps: pointer to a #GstCaps instance |
344 * @par_n: pointer to numerator of pixel aspect ratio (output) |
405 * @par_n: pointer to numerator of pixel aspect ratio (output) |
345 * @par_d: pointer to denominator of pixel aspect ratio (output) |
406 * @par_d: pointer to denominator of pixel aspect ratio (output) |
346 * |
407 * |
347 * Extracts the pixel aspect ratio from @caps and places the values in |
408 * Extracts the pixel aspect ratio from @caps and places the values in |
348 * the locations pointed to by @par_n and @par_d. Returns TRUE if the |
409 * the locations pointed to by @par_n and @par_d. Returns TRUE if the |
373 par_n, par_d)) { |
434 par_n, par_d)) { |
374 *par_n = 1; |
435 *par_n = 1; |
375 *par_d = 1; |
436 *par_d = 1; |
376 } |
437 } |
377 return TRUE; |
438 return TRUE; |
|
439 } |
|
440 |
|
441 /** |
|
442 * gst_video_format_new_caps_interlaced: |
|
443 * @format: the #GstVideoFormat describing the raw video format |
|
444 * @width: width of video |
|
445 * @height: height of video |
|
446 * @framerate_n: numerator of frame rate |
|
447 * @framerate_d: denominator of frame rate |
|
448 * @par_n: numerator of pixel aspect ratio |
|
449 * @par_d: denominator of pixel aspect ratio |
|
450 * @interlaced: #TRUE if the format is interlaced |
|
451 * |
|
452 * Creates a new #GstCaps object based on the parameters provided. |
|
453 * |
|
454 * Since: 0.10.23 |
|
455 * |
|
456 * Returns: a new #GstCaps object, or NULL if there was an error |
|
457 */ |
|
458 #ifdef __SYMBIAN32__ |
|
459 EXPORT_C |
|
460 #endif |
|
461 |
|
462 GstCaps * |
|
463 gst_video_format_new_caps_interlaced (GstVideoFormat format, int width, |
|
464 int height, int framerate_n, int framerate_d, int par_n, int par_d, |
|
465 gboolean interlaced) |
|
466 { |
|
467 GstCaps *res; |
|
468 |
|
469 res = |
|
470 gst_video_format_new_caps (format, width, height, framerate_n, |
|
471 framerate_d, par_n, par_d); |
|
472 if (interlaced && (res != NULL)) |
|
473 gst_caps_set_simple (res, "interlaced", G_TYPE_BOOLEAN, TRUE, NULL); |
|
474 |
|
475 return res; |
378 } |
476 } |
379 |
477 |
380 /** |
478 /** |
381 * gst_video_format_new_caps: |
479 * gst_video_format_new_caps: |
382 * @format: the #GstVideoFormat describing the raw video format |
480 * @format: the #GstVideoFormat describing the raw video format |
399 |
497 |
400 GstCaps * |
498 GstCaps * |
401 gst_video_format_new_caps (GstVideoFormat format, int width, int height, |
499 gst_video_format_new_caps (GstVideoFormat format, int width, int height, |
402 int framerate_n, int framerate_d, int par_n, int par_d) |
500 int framerate_n, int framerate_d, int par_n, int par_d) |
403 { |
501 { |
|
502 g_return_val_if_fail (format != GST_VIDEO_FORMAT_UNKNOWN, NULL); |
|
503 g_return_val_if_fail (width > 0 && height > 0, NULL); |
|
504 |
404 if (gst_video_format_is_yuv (format)) { |
505 if (gst_video_format_is_yuv (format)) { |
405 return gst_caps_new_simple ("video/x-raw-yuv", |
506 return gst_caps_new_simple ("video/x-raw-yuv", |
406 "format", GST_TYPE_FOURCC, gst_video_format_to_fourcc (format), |
507 "format", GST_TYPE_FOURCC, gst_video_format_to_fourcc (format), |
407 "width", G_TYPE_INT, width, |
508 "width", G_TYPE_INT, width, |
408 "height", G_TYPE_INT, height, |
509 "height", G_TYPE_INT, height, |
507 return GST_VIDEO_FORMAT_I420; |
608 return GST_VIDEO_FORMAT_I420; |
508 case GST_MAKE_FOURCC ('Y', 'V', '1', '2'): |
609 case GST_MAKE_FOURCC ('Y', 'V', '1', '2'): |
509 return GST_VIDEO_FORMAT_YV12; |
610 return GST_VIDEO_FORMAT_YV12; |
510 case GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'): |
611 case GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'): |
511 return GST_VIDEO_FORMAT_YUY2; |
612 return GST_VIDEO_FORMAT_YUY2; |
|
613 case GST_MAKE_FOURCC ('Y', 'V', 'Y', 'U'): |
|
614 return GST_VIDEO_FORMAT_YVYU; |
512 case GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y'): |
615 case GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y'): |
513 return GST_VIDEO_FORMAT_UYVY; |
616 return GST_VIDEO_FORMAT_UYVY; |
514 case GST_MAKE_FOURCC ('A', 'Y', 'U', 'V'): |
617 case GST_MAKE_FOURCC ('A', 'Y', 'U', 'V'): |
515 return GST_VIDEO_FORMAT_AYUV; |
618 return GST_VIDEO_FORMAT_AYUV; |
516 case GST_MAKE_FOURCC ('Y', '4', '1', 'B'): |
619 case GST_MAKE_FOURCC ('Y', '4', '1', 'B'): |
517 return GST_VIDEO_FORMAT_Y41B; |
620 return GST_VIDEO_FORMAT_Y41B; |
518 case GST_MAKE_FOURCC ('Y', '4', '2', 'B'): |
621 case GST_MAKE_FOURCC ('Y', '4', '2', 'B'): |
519 return GST_VIDEO_FORMAT_Y42B; |
622 return GST_VIDEO_FORMAT_Y42B; |
|
623 case GST_MAKE_FOURCC ('Y', '4', '4', '4'): |
|
624 return GST_VIDEO_FORMAT_Y444; |
|
625 case GST_MAKE_FOURCC ('v', '2', '1', '0'): |
|
626 return GST_VIDEO_FORMAT_v210; |
|
627 case GST_MAKE_FOURCC ('v', '2', '1', '6'): |
|
628 return GST_VIDEO_FORMAT_v216; |
520 default: |
629 default: |
521 return GST_VIDEO_FORMAT_UNKNOWN; |
630 return GST_VIDEO_FORMAT_UNKNOWN; |
522 } |
631 } |
523 } |
632 } |
524 |
633 |
539 #endif |
648 #endif |
540 |
649 |
541 guint32 |
650 guint32 |
542 gst_video_format_to_fourcc (GstVideoFormat format) |
651 gst_video_format_to_fourcc (GstVideoFormat format) |
543 { |
652 { |
|
653 g_return_val_if_fail (format != GST_VIDEO_FORMAT_UNKNOWN, 0); |
|
654 |
544 switch (format) { |
655 switch (format) { |
545 case GST_VIDEO_FORMAT_I420: |
656 case GST_VIDEO_FORMAT_I420: |
546 return GST_MAKE_FOURCC ('I', '4', '2', '0'); |
657 return GST_MAKE_FOURCC ('I', '4', '2', '0'); |
547 case GST_VIDEO_FORMAT_YV12: |
658 case GST_VIDEO_FORMAT_YV12: |
548 return GST_MAKE_FOURCC ('Y', 'V', '1', '2'); |
659 return GST_MAKE_FOURCC ('Y', 'V', '1', '2'); |
549 case GST_VIDEO_FORMAT_YUY2: |
660 case GST_VIDEO_FORMAT_YUY2: |
550 return GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'); |
661 return GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'); |
|
662 case GST_VIDEO_FORMAT_YVYU: |
|
663 return GST_MAKE_FOURCC ('Y', 'V', 'Y', 'U'); |
551 case GST_VIDEO_FORMAT_UYVY: |
664 case GST_VIDEO_FORMAT_UYVY: |
552 return GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y'); |
665 return GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y'); |
553 case GST_VIDEO_FORMAT_AYUV: |
666 case GST_VIDEO_FORMAT_AYUV: |
554 return GST_MAKE_FOURCC ('A', 'Y', 'U', 'V'); |
667 return GST_MAKE_FOURCC ('A', 'Y', 'U', 'V'); |
555 case GST_VIDEO_FORMAT_Y41B: |
668 case GST_VIDEO_FORMAT_Y41B: |
556 return GST_MAKE_FOURCC ('Y', '4', '1', 'B'); |
669 return GST_MAKE_FOURCC ('Y', '4', '1', 'B'); |
557 case GST_VIDEO_FORMAT_Y42B: |
670 case GST_VIDEO_FORMAT_Y42B: |
558 return GST_MAKE_FOURCC ('Y', '4', '2', 'B'); |
671 return GST_MAKE_FOURCC ('Y', '4', '2', 'B'); |
|
672 case GST_VIDEO_FORMAT_Y444: |
|
673 return GST_MAKE_FOURCC ('Y', '4', '4', '4'); |
|
674 case GST_VIDEO_FORMAT_v210: |
|
675 return GST_MAKE_FOURCC ('v', '2', '1', '0'); |
|
676 case GST_VIDEO_FORMAT_v216: |
|
677 return GST_MAKE_FOURCC ('v', '2', '1', '6'); |
559 default: |
678 default: |
560 return 0; |
679 return 0; |
561 } |
680 } |
562 } |
681 } |
563 |
682 |
564 /** |
683 /* |
565 * gst_video_format_from_rgb32_masks: |
684 * gst_video_format_from_rgb32_masks: |
566 * @red_mask: red bit mask |
685 * @red_mask: red bit mask |
567 * @green_mask: green bit mask |
686 * @green_mask: green bit mask |
568 * @blue_mask: blue bit mask |
687 * @blue_mask: blue bit mask |
569 * |
688 * |
651 { |
772 { |
652 switch (format) { |
773 switch (format) { |
653 case GST_VIDEO_FORMAT_I420: |
774 case GST_VIDEO_FORMAT_I420: |
654 case GST_VIDEO_FORMAT_YV12: |
775 case GST_VIDEO_FORMAT_YV12: |
655 case GST_VIDEO_FORMAT_YUY2: |
776 case GST_VIDEO_FORMAT_YUY2: |
|
777 case GST_VIDEO_FORMAT_YVYU: |
656 case GST_VIDEO_FORMAT_UYVY: |
778 case GST_VIDEO_FORMAT_UYVY: |
657 case GST_VIDEO_FORMAT_AYUV: |
779 case GST_VIDEO_FORMAT_AYUV: |
658 case GST_VIDEO_FORMAT_Y41B: |
780 case GST_VIDEO_FORMAT_Y41B: |
659 case GST_VIDEO_FORMAT_Y42B: |
781 case GST_VIDEO_FORMAT_Y42B: |
|
782 case GST_VIDEO_FORMAT_Y444: |
|
783 case GST_VIDEO_FORMAT_v210: |
|
784 case GST_VIDEO_FORMAT_v216: |
660 return FALSE; |
785 return FALSE; |
661 case GST_VIDEO_FORMAT_RGBx: |
786 case GST_VIDEO_FORMAT_RGBx: |
662 case GST_VIDEO_FORMAT_BGRx: |
787 case GST_VIDEO_FORMAT_BGRx: |
663 case GST_VIDEO_FORMAT_xRGB: |
788 case GST_VIDEO_FORMAT_xRGB: |
664 case GST_VIDEO_FORMAT_xBGR: |
789 case GST_VIDEO_FORMAT_xBGR: |
691 { |
818 { |
692 switch (format) { |
819 switch (format) { |
693 case GST_VIDEO_FORMAT_I420: |
820 case GST_VIDEO_FORMAT_I420: |
694 case GST_VIDEO_FORMAT_YV12: |
821 case GST_VIDEO_FORMAT_YV12: |
695 case GST_VIDEO_FORMAT_YUY2: |
822 case GST_VIDEO_FORMAT_YUY2: |
|
823 case GST_VIDEO_FORMAT_YVYU: |
696 case GST_VIDEO_FORMAT_UYVY: |
824 case GST_VIDEO_FORMAT_UYVY: |
697 case GST_VIDEO_FORMAT_AYUV: |
825 case GST_VIDEO_FORMAT_AYUV: |
698 case GST_VIDEO_FORMAT_Y41B: |
826 case GST_VIDEO_FORMAT_Y41B: |
699 case GST_VIDEO_FORMAT_Y42B: |
827 case GST_VIDEO_FORMAT_Y42B: |
|
828 case GST_VIDEO_FORMAT_Y444: |
|
829 case GST_VIDEO_FORMAT_v210: |
|
830 case GST_VIDEO_FORMAT_v216: |
700 return TRUE; |
831 return TRUE; |
701 case GST_VIDEO_FORMAT_RGBx: |
832 case GST_VIDEO_FORMAT_RGBx: |
702 case GST_VIDEO_FORMAT_BGRx: |
833 case GST_VIDEO_FORMAT_BGRx: |
703 case GST_VIDEO_FORMAT_xRGB: |
834 case GST_VIDEO_FORMAT_xRGB: |
704 case GST_VIDEO_FORMAT_xBGR: |
835 case GST_VIDEO_FORMAT_xBGR: |
731 { |
865 { |
732 switch (format) { |
866 switch (format) { |
733 case GST_VIDEO_FORMAT_I420: |
867 case GST_VIDEO_FORMAT_I420: |
734 case GST_VIDEO_FORMAT_YV12: |
868 case GST_VIDEO_FORMAT_YV12: |
735 case GST_VIDEO_FORMAT_YUY2: |
869 case GST_VIDEO_FORMAT_YUY2: |
|
870 case GST_VIDEO_FORMAT_YVYU: |
736 case GST_VIDEO_FORMAT_UYVY: |
871 case GST_VIDEO_FORMAT_UYVY: |
737 case GST_VIDEO_FORMAT_Y41B: |
872 case GST_VIDEO_FORMAT_Y41B: |
738 case GST_VIDEO_FORMAT_Y42B: |
873 case GST_VIDEO_FORMAT_Y42B: |
|
874 case GST_VIDEO_FORMAT_Y444: |
|
875 case GST_VIDEO_FORMAT_v210: |
|
876 case GST_VIDEO_FORMAT_v216: |
739 return FALSE; |
877 return FALSE; |
740 case GST_VIDEO_FORMAT_AYUV: |
878 case GST_VIDEO_FORMAT_AYUV: |
741 case GST_VIDEO_FORMAT_RGBA: |
879 case GST_VIDEO_FORMAT_RGBA: |
742 case GST_VIDEO_FORMAT_BGRA: |
880 case GST_VIDEO_FORMAT_BGRA: |
743 case GST_VIDEO_FORMAT_ARGB: |
881 case GST_VIDEO_FORMAT_ARGB: |
779 |
917 |
780 int |
918 int |
781 gst_video_format_get_row_stride (GstVideoFormat format, int component, |
919 gst_video_format_get_row_stride (GstVideoFormat format, int component, |
782 int width) |
920 int width) |
783 { |
921 { |
|
922 g_return_val_if_fail (format != GST_VIDEO_FORMAT_UNKNOWN, 0); |
|
923 g_return_val_if_fail (component >= 0 && component <= 3, 0); |
|
924 g_return_val_if_fail (width > 0, 0); |
|
925 |
784 switch (format) { |
926 switch (format) { |
785 case GST_VIDEO_FORMAT_I420: |
927 case GST_VIDEO_FORMAT_I420: |
786 case GST_VIDEO_FORMAT_YV12: |
928 case GST_VIDEO_FORMAT_YV12: |
787 if (component == 0) { |
929 if (component == 0) { |
788 return GST_ROUND_UP_4 (width); |
930 return GST_ROUND_UP_4 (width); |
789 } else { |
931 } else { |
790 return GST_ROUND_UP_4 (GST_ROUND_UP_2 (width) / 2); |
932 return GST_ROUND_UP_4 (GST_ROUND_UP_2 (width) / 2); |
791 } |
933 } |
792 case GST_VIDEO_FORMAT_YUY2: |
934 case GST_VIDEO_FORMAT_YUY2: |
|
935 case GST_VIDEO_FORMAT_YVYU: |
793 case GST_VIDEO_FORMAT_UYVY: |
936 case GST_VIDEO_FORMAT_UYVY: |
794 return GST_ROUND_UP_4 (width * 2); |
937 return GST_ROUND_UP_4 (width * 2); |
795 case GST_VIDEO_FORMAT_AYUV: |
938 case GST_VIDEO_FORMAT_AYUV: |
796 case GST_VIDEO_FORMAT_RGBx: |
939 case GST_VIDEO_FORMAT_RGBx: |
797 case GST_VIDEO_FORMAT_BGRx: |
940 case GST_VIDEO_FORMAT_BGRx: |
841 #endif |
990 #endif |
842 |
991 |
843 int |
992 int |
844 gst_video_format_get_pixel_stride (GstVideoFormat format, int component) |
993 gst_video_format_get_pixel_stride (GstVideoFormat format, int component) |
845 { |
994 { |
|
995 g_return_val_if_fail (format != GST_VIDEO_FORMAT_UNKNOWN, 0); |
|
996 g_return_val_if_fail (component >= 0 && component <= 3, 0); |
|
997 |
846 switch (format) { |
998 switch (format) { |
847 case GST_VIDEO_FORMAT_I420: |
999 case GST_VIDEO_FORMAT_I420: |
848 case GST_VIDEO_FORMAT_YV12: |
1000 case GST_VIDEO_FORMAT_YV12: |
849 case GST_VIDEO_FORMAT_Y41B: |
1001 case GST_VIDEO_FORMAT_Y41B: |
850 case GST_VIDEO_FORMAT_Y42B: |
1002 case GST_VIDEO_FORMAT_Y42B: |
|
1003 case GST_VIDEO_FORMAT_Y444: |
851 return 1; |
1004 return 1; |
852 case GST_VIDEO_FORMAT_YUY2: |
1005 case GST_VIDEO_FORMAT_YUY2: |
|
1006 case GST_VIDEO_FORMAT_YVYU: |
853 case GST_VIDEO_FORMAT_UYVY: |
1007 case GST_VIDEO_FORMAT_UYVY: |
854 if (component == 0) { |
1008 if (component == 0) { |
855 return 2; |
1009 return 2; |
856 } else { |
1010 } else { |
857 return 4; |
1011 return 4; |
894 |
1057 |
895 int |
1058 int |
896 gst_video_format_get_component_width (GstVideoFormat format, int component, |
1059 gst_video_format_get_component_width (GstVideoFormat format, int component, |
897 int width) |
1060 int width) |
898 { |
1061 { |
|
1062 g_return_val_if_fail (format != GST_VIDEO_FORMAT_UNKNOWN, 0); |
|
1063 g_return_val_if_fail (component >= 0 && component <= 3, 0); |
|
1064 g_return_val_if_fail (width > 0, 0); |
|
1065 |
899 switch (format) { |
1066 switch (format) { |
900 case GST_VIDEO_FORMAT_I420: |
1067 case GST_VIDEO_FORMAT_I420: |
901 case GST_VIDEO_FORMAT_YV12: |
1068 case GST_VIDEO_FORMAT_YV12: |
902 case GST_VIDEO_FORMAT_YUY2: |
1069 case GST_VIDEO_FORMAT_YUY2: |
|
1070 case GST_VIDEO_FORMAT_YVYU: |
903 case GST_VIDEO_FORMAT_UYVY: |
1071 case GST_VIDEO_FORMAT_UYVY: |
|
1072 case GST_VIDEO_FORMAT_Y42B: |
|
1073 case GST_VIDEO_FORMAT_v210: |
|
1074 case GST_VIDEO_FORMAT_v216: |
904 if (component == 0) { |
1075 if (component == 0) { |
905 return width; |
1076 return width; |
906 } else { |
1077 } else { |
907 return GST_ROUND_UP_2 (width) / 2; |
1078 return GST_ROUND_UP_2 (width) / 2; |
908 } |
1079 } |
909 case GST_VIDEO_FORMAT_Y41B: /* CHECKME: component_width for Y41B */ |
1080 case GST_VIDEO_FORMAT_Y41B: |
910 if (component == 0) { |
1081 if (component == 0) { |
911 return width; |
1082 return width; |
912 } else { |
1083 } else { |
913 return GST_ROUND_UP_8 (width) / 4; |
1084 return GST_ROUND_UP_4 (width) / 4; |
914 } |
|
915 case GST_VIDEO_FORMAT_Y42B: /* CHECKME: component_width for Y42B */ |
|
916 if (component == 0) { |
|
917 return width; |
|
918 } else { |
|
919 return GST_ROUND_UP_8 (width) / 2; |
|
920 } |
1085 } |
921 case GST_VIDEO_FORMAT_AYUV: |
1086 case GST_VIDEO_FORMAT_AYUV: |
922 case GST_VIDEO_FORMAT_RGBx: |
1087 case GST_VIDEO_FORMAT_RGBx: |
923 case GST_VIDEO_FORMAT_BGRx: |
1088 case GST_VIDEO_FORMAT_BGRx: |
924 case GST_VIDEO_FORMAT_xRGB: |
1089 case GST_VIDEO_FORMAT_xRGB: |
966 return GST_ROUND_UP_2 (height) / 2; |
1136 return GST_ROUND_UP_2 (height) / 2; |
967 } |
1137 } |
968 case GST_VIDEO_FORMAT_Y41B: |
1138 case GST_VIDEO_FORMAT_Y41B: |
969 case GST_VIDEO_FORMAT_Y42B: |
1139 case GST_VIDEO_FORMAT_Y42B: |
970 case GST_VIDEO_FORMAT_YUY2: |
1140 case GST_VIDEO_FORMAT_YUY2: |
|
1141 case GST_VIDEO_FORMAT_YVYU: |
971 case GST_VIDEO_FORMAT_UYVY: |
1142 case GST_VIDEO_FORMAT_UYVY: |
972 case GST_VIDEO_FORMAT_AYUV: |
1143 case GST_VIDEO_FORMAT_AYUV: |
973 case GST_VIDEO_FORMAT_RGBx: |
1144 case GST_VIDEO_FORMAT_RGBx: |
974 case GST_VIDEO_FORMAT_BGRx: |
1145 case GST_VIDEO_FORMAT_BGRx: |
975 case GST_VIDEO_FORMAT_xRGB: |
1146 case GST_VIDEO_FORMAT_xRGB: |
1161 |
1360 |
1162 int |
1361 int |
1163 gst_video_format_get_size (GstVideoFormat format, int width, int height) |
1362 gst_video_format_get_size (GstVideoFormat format, int width, int height) |
1164 { |
1363 { |
1165 int size; |
1364 int size; |
|
1365 |
|
1366 g_return_val_if_fail (format != GST_VIDEO_FORMAT_UNKNOWN, 0); |
|
1367 g_return_val_if_fail (width > 0 && height > 0, 0); |
1166 |
1368 |
1167 switch (format) { |
1369 switch (format) { |
1168 case GST_VIDEO_FORMAT_I420: |
1370 case GST_VIDEO_FORMAT_I420: |
1169 case GST_VIDEO_FORMAT_YV12: |
1371 case GST_VIDEO_FORMAT_YV12: |
1170 size = GST_ROUND_UP_4 (width) * GST_ROUND_UP_2 (height); |
1372 size = GST_ROUND_UP_4 (width) * GST_ROUND_UP_2 (height); |
1171 size += GST_ROUND_UP_4 (GST_ROUND_UP_2 (width) / 2) * |
1373 size += GST_ROUND_UP_4 (GST_ROUND_UP_2 (width) / 2) * |
1172 (GST_ROUND_UP_2 (height) / 2) * 2; |
1374 (GST_ROUND_UP_2 (height) / 2) * 2; |
1173 return size; |
1375 return size; |
1174 case GST_VIDEO_FORMAT_YUY2: |
1376 case GST_VIDEO_FORMAT_YUY2: |
|
1377 case GST_VIDEO_FORMAT_YVYU: |
1175 case GST_VIDEO_FORMAT_UYVY: |
1378 case GST_VIDEO_FORMAT_UYVY: |
1176 return GST_ROUND_UP_4 (width * 2) * height; |
1379 return GST_ROUND_UP_4 (width * 2) * height; |
1177 case GST_VIDEO_FORMAT_AYUV: |
1380 case GST_VIDEO_FORMAT_AYUV: |
1178 case GST_VIDEO_FORMAT_RGBx: |
1381 case GST_VIDEO_FORMAT_RGBx: |
1179 case GST_VIDEO_FORMAT_BGRx: |
1382 case GST_VIDEO_FORMAT_BGRx: |
1191 /* simplification of ROUNDUP4(w)*h + 2*((ROUNDUP8(w)/4)*h */ |
1394 /* simplification of ROUNDUP4(w)*h + 2*((ROUNDUP8(w)/4)*h */ |
1192 return (GST_ROUND_UP_4 (width) + (GST_ROUND_UP_8 (width) / 2)) * height; |
1395 return (GST_ROUND_UP_4 (width) + (GST_ROUND_UP_8 (width) / 2)) * height; |
1193 case GST_VIDEO_FORMAT_Y42B: |
1396 case GST_VIDEO_FORMAT_Y42B: |
1194 /* simplification of ROUNDUP4(w)*h + 2*(ROUNDUP8(w)/2)*h: */ |
1397 /* simplification of ROUNDUP4(w)*h + 2*(ROUNDUP8(w)/2)*h: */ |
1195 return (GST_ROUND_UP_4 (width) + GST_ROUND_UP_8 (width)) * height; |
1398 return (GST_ROUND_UP_4 (width) + GST_ROUND_UP_8 (width)) * height; |
|
1399 case GST_VIDEO_FORMAT_Y444: |
|
1400 return GST_ROUND_UP_4 (width) * height * 3; |
|
1401 case GST_VIDEO_FORMAT_v210: |
|
1402 return ((width + 47) / 48) * 128 * height; |
|
1403 case GST_VIDEO_FORMAT_v216: |
|
1404 return GST_ROUND_UP_8 (width * 4) * height; |
1196 default: |
1405 default: |
1197 return 0; |
1406 return 0; |
1198 } |
1407 } |
1199 } |
1408 } |
1200 |
1409 |
1229 GstFormat src_format, gint64 src_value, |
1438 GstFormat src_format, gint64 src_value, |
1230 GstFormat dest_format, gint64 * dest_value) |
1439 GstFormat dest_format, gint64 * dest_value) |
1231 { |
1440 { |
1232 gboolean ret = FALSE; |
1441 gboolean ret = FALSE; |
1233 int size; |
1442 int size; |
|
1443 |
|
1444 g_return_val_if_fail (format != GST_VIDEO_FORMAT_UNKNOWN, 0); |
|
1445 g_return_val_if_fail (width > 0 && height > 0, 0); |
1234 |
1446 |
1235 size = gst_video_format_get_size (format, width, height); |
1447 size = gst_video_format_get_size (format, width, height); |
1236 |
1448 |
1237 GST_DEBUG ("converting value %" G_GINT64_FORMAT " from %s to %s", |
1449 GST_DEBUG ("converting value %" G_GINT64_FORMAT " from %s to %s", |
1238 src_value, gst_format_get_name (src_format), |
1450 src_value, gst_format_get_name (src_format), |