diff options
author | Wim Taymans <wim.taymans@collabora.co.uk> | 2011-06-16 12:48:33 +0200 |
---|---|---|
committer | Wim Taymans <wim.taymans@collabora.co.uk> | 2011-06-16 12:52:13 +0200 |
commit | d06f59919307adf69b1712c6974ca70f9d15dc17 (patch) | |
tree | 5d80d8cfe3fc7b7f3125f485571f3fc697dfd6b1 /sys | |
parent | 3b9477e173341c10e53343b04867435b7810c8d0 (diff) |
-base: port elements to new video capsnew-video-caps
Diffstat (limited to 'sys')
-rw-r--r-- | sys/ximage/ximagesink.c | 44 | ||||
-rw-r--r-- | sys/ximage/ximagesink.h | 1 | ||||
-rw-r--r-- | sys/xvimage/xvimagesink.c | 54 |
3 files changed, 41 insertions, 58 deletions
diff --git a/sys/ximage/ximagesink.c b/sys/ximage/ximagesink.c index 070a4db2b..1107db014 100644 --- a/sys/ximage/ximagesink.c +++ b/sys/ximage/ximagesink.c @@ -89,7 +89,7 @@ * the button and a red one where you released it. (The navigationtest element * is part of gst-plugins-good.) * |[ - * gst-launch -v videotestsrc ! video/x-raw-rgb, pixel-aspect-ratio=(fraction)4/3 ! videoscale ! ximagesink + * gst-launch -v videotestsrc ! video/x-raw, pixel-aspect-ratio=(fraction)4/3 ! videoscale ! ximagesink * ]| This is faking a 4/3 pixel aspect ratio caps on video frames produced by * videotestsrc, in most cases the pixel aspect ratio of the display will be * 1/1. This means that videoscale will have to do the scaling to convert @@ -138,7 +138,7 @@ static GstStaticPadTemplate gst_ximagesink_sink_template_factory = GST_STATIC_PAD_TEMPLATE ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, - GST_STATIC_CAPS ("video/x-raw-rgb, " + GST_STATIC_CAPS ("video/x-raw, " "framerate = (fraction) [ 0, MAX ], " "width = (int) [ 1, MAX ], " "height = (int) [ 1, MAX ]") ); @@ -816,6 +816,8 @@ gst_ximagesink_xcontext_get (GstXImageSink * ximagesink) GstXContext *xcontext = NULL; XPixmapFormatValues *px_formats = NULL; gint nb_formats = 0, i; + gint endianness; + GstVideoFormat vformat; g_return_val_if_fail (GST_IS_XIMAGESINK (ximagesink), NULL); @@ -872,8 +874,7 @@ gst_ximagesink_xcontext_get (GstXImageSink * ximagesink) XFree (px_formats); - xcontext->endianness = - (ImageByteOrder (xcontext->disp) == + endianness = (ImageByteOrder (xcontext->disp) == LSBFirst) ? G_LITTLE_ENDIAN : G_BIG_ENDIAN; /* Search for XShm extension support */ @@ -889,19 +890,12 @@ gst_ximagesink_xcontext_get (GstXImageSink * ximagesink) GST_DEBUG ("ximagesink is not using XShm extension"); } - /* our caps system handles 24/32bpp RGB as big-endian. */ - if ((xcontext->bpp == 24 || xcontext->bpp == 32) && - xcontext->endianness == G_LITTLE_ENDIAN) { - xcontext->endianness = G_BIG_ENDIAN; - xcontext->visual->red_mask = GUINT32_TO_BE (xcontext->visual->red_mask); - xcontext->visual->green_mask = GUINT32_TO_BE (xcontext->visual->green_mask); - xcontext->visual->blue_mask = GUINT32_TO_BE (xcontext->visual->blue_mask); - if (xcontext->bpp == 24) { - xcontext->visual->red_mask >>= 8; - xcontext->visual->green_mask >>= 8; - xcontext->visual->blue_mask >>= 8; - } - } + vformat = gst_video_format_from_masks (xcontext->depth, xcontext->bpp, + endianness, xcontext->visual->red_mask, xcontext->visual->green_mask, + xcontext->visual->blue_mask, 0); + + if (vformat == GST_VIDEO_FORMAT_UNKNOWN) + goto unknown_format; /* update object's par with calculated one if not set yet */ if (!ximagesink->par) { @@ -909,13 +903,8 @@ gst_ximagesink_xcontext_get (GstXImageSink * ximagesink) gst_value_init_and_copy (ximagesink->par, xcontext->par); GST_DEBUG_OBJECT (ximagesink, "set calculated PAR on object's PAR"); } - xcontext->caps = gst_caps_new_simple ("video/x-raw-rgb", - "bpp", G_TYPE_INT, xcontext->bpp, - "depth", G_TYPE_INT, xcontext->depth, - "endianness", G_TYPE_INT, xcontext->endianness, - "red_mask", G_TYPE_INT, xcontext->visual->red_mask, - "green_mask", G_TYPE_INT, xcontext->visual->green_mask, - "blue_mask", G_TYPE_INT, xcontext->visual->blue_mask, + xcontext->caps = gst_caps_new_simple ("video/x-raw", + "format", G_TYPE_STRING, gst_video_format_to_string (vformat), "width", GST_TYPE_INT_RANGE, 1, G_MAXINT, "height", GST_TYPE_INT_RANGE, 1, G_MAXINT, "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1, NULL); @@ -931,6 +920,13 @@ gst_ximagesink_xcontext_get (GstXImageSink * ximagesink) g_mutex_unlock (ximagesink->x_lock); return xcontext; + + /* ERRORS */ +unknown_format: + { + GST_ERROR_OBJECT (ximagesink, "unknown format"); + return NULL; + } } /* This function cleans the X context. Closing the Display and unrefing the diff --git a/sys/ximage/ximagesink.h b/sys/ximage/ximagesink.h index b47dcde0c..7974a3fcc 100644 --- a/sys/ximage/ximagesink.h +++ b/sys/ximage/ximagesink.h @@ -98,7 +98,6 @@ struct _GstXContext gint depth; gint bpp; - gint endianness; gint width, height; gint widthmm, heightmm; diff --git a/sys/xvimage/xvimagesink.c b/sys/xvimage/xvimagesink.c index badfb4bae..0facc7b78 100644 --- a/sys/xvimage/xvimagesink.c +++ b/sys/xvimage/xvimagesink.c @@ -94,7 +94,7 @@ * position. This also handles borders correctly, limiting coordinates to the * image area * |[ - * gst-launch -v videotestsrc ! video/x-raw-yuv, pixel-aspect-ratio=(fraction)4/3 ! xvimagesink + * gst-launch -v videotestsrc ! video/x-raw, pixel-aspect-ratio=(fraction)4/3 ! xvimagesink * ]| This is faking a 4/3 pixel aspect ratio caps on video frames produced by * videotestsrc, in most cases the pixel aspect ratio of the display will be * 1/1. This means that XvImageSink will have to do the scaling to convert @@ -152,14 +152,10 @@ static void gst_xvimagesink_expose (GstXOverlay * overlay); /* Default template - initiated with class struct to allow gst-register to work without X running */ static GstStaticPadTemplate gst_xvimagesink_sink_template_factory = - GST_STATIC_PAD_TEMPLATE ("sink", +GST_STATIC_PAD_TEMPLATE ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, - GST_STATIC_CAPS ("video/x-raw-rgb, " - "framerate = (fraction) [ 0, MAX ], " - "width = (int) [ 1, MAX ], " - "height = (int) [ 1, MAX ]; " - "video/x-raw-yuv, " + GST_STATIC_CAPS ("video/x-raw, " "framerate = (fraction) [ 0, MAX ], " "width = (int) [ 1, MAX ], " "height = (int) [ 1, MAX ]") ); @@ -1053,31 +1049,17 @@ gst_xvimagesink_get_xv_support (GstXvImageSink * xvimagesink, case XvRGB: { XvImageFormatValues *fmt = &(formats[i]); - gint endianness = G_BIG_ENDIAN; - - if (fmt->byte_order == LSBFirst) { - /* our caps system handles 24/32bpp RGB as big-endian. */ - if (fmt->bits_per_pixel == 24 || fmt->bits_per_pixel == 32) { - fmt->red_mask = GUINT32_TO_BE (fmt->red_mask); - fmt->green_mask = GUINT32_TO_BE (fmt->green_mask); - fmt->blue_mask = GUINT32_TO_BE (fmt->blue_mask); - - if (fmt->bits_per_pixel == 24) { - fmt->red_mask >>= 8; - fmt->green_mask >>= 8; - fmt->blue_mask >>= 8; - } - } else - endianness = G_LITTLE_ENDIAN; - } + gint endianness; + GstVideoFormat vformat; + + endianness = + (fmt->byte_order == LSBFirst ? G_LITTLE_ENDIAN : G_BIG_ENDIAN); + + vformat = gst_video_format_from_masks (fmt->depth, fmt->bits_per_pixel, + endianness, fmt->red_mask, fmt->green_mask, fmt->blue_mask, 0); - format_caps = gst_caps_new_simple ("video/x-raw-rgb", - "endianness", G_TYPE_INT, endianness, - "depth", G_TYPE_INT, fmt->depth, - "bpp", G_TYPE_INT, fmt->bits_per_pixel, - "red_mask", G_TYPE_INT, fmt->red_mask, - "green_mask", G_TYPE_INT, fmt->green_mask, - "blue_mask", G_TYPE_INT, fmt->blue_mask, + format_caps = gst_caps_new_simple ("video/x-raw", + "format", G_TYPE_STRING, gst_video_format_to_string (vformat), "width", GST_TYPE_INT_RANGE, 1, max_w, "height", GST_TYPE_INT_RANGE, 1, max_h, "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1, NULL); @@ -1086,12 +1068,18 @@ gst_xvimagesink_get_xv_support (GstXvImageSink * xvimagesink, break; } case XvYUV: - format_caps = gst_caps_new_simple ("video/x-raw-yuv", - "format", GST_TYPE_FOURCC, formats[i].id, + { + GstVideoFormat vformat; + + vformat = gst_video_format_from_fourcc (formats[i].id); + + format_caps = gst_caps_new_simple ("video/x-raw", + "format", G_TYPE_STRING, gst_video_format_to_string (vformat), "width", GST_TYPE_INT_RANGE, 1, max_w, "height", GST_TYPE_INT_RANGE, 1, max_h, "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1, NULL); break; + } default: g_assert_not_reached (); break; |