From d06f59919307adf69b1712c6974ca70f9d15dc17 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Thu, 16 Jun 2011 12:48:33 +0200 Subject: [PATCH] -base: port elements to new video caps --- ext/libvisual/visual.c | 40 ++-- ext/ogg/gstoggmux.c | 2 +- ext/pango/gstbasetextoverlay.c | 26 +-- ext/pango/gsttextrender.c | 32 +-- ext/theora/gsttheoradec.c | 12 +- ext/theora/gsttheoraenc.c | 10 +- gst/encoding/gstencodebin.c | 7 +- gst/playback/gstdecodebin2.c | 4 +- gst/playback/gstplaysink.c | 4 +- gst/playback/gstplaysinkaudioconvert.c | 2 +- gst/playback/gstplaysinkvideoconvert.c | 2 +- gst/playback/gstrawcaps.h | 4 +- gst/videoconvert/gstvideoconvert.c | 63 +----- gst/videorate/gstvideorate.c | 10 +- gst/videoscale/gstvideoscale.c | 43 +--- gst/videotestsrc/gstvideotestsrc.c | 18 +- gst/videotestsrc/gstvideotestsrc.h | 2 +- gst/videotestsrc/videotestsrc.c | 347 ++++++++++++--------------------- gst/videotestsrc/videotestsrc.h | 18 +- sys/ximage/ximagesink.c | 44 ++--- sys/ximage/ximagesink.h | 1 - sys/xvimage/xvimagesink.c | 54 ++--- 22 files changed, 285 insertions(+), 460 deletions(-) diff --git a/ext/libvisual/visual.c b/ext/libvisual/visual.c index 3d12300..bee75f3 100644 --- a/ext/libvisual/visual.c +++ b/ext/libvisual/visual.c @@ -101,13 +101,13 @@ GType gst_visual_get_type (void); static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src", GST_PAD_SRC, GST_PAD_ALWAYS, - GST_STATIC_CAPS (GST_VIDEO_CAPS_xRGB_HOST_ENDIAN "; " + GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE (" { " #if G_BYTE_ORDER == G_BIG_ENDIAN - GST_VIDEO_CAPS_RGB "; " + "\"xRGB\", " "\"RGB\", " #else - GST_VIDEO_CAPS_BGR "; " + "\"BGRx\", " "\"BGR\", " #endif - GST_VIDEO_CAPS_RGB_16) + "\"RGB16\" } ")) ); static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink", @@ -295,17 +295,21 @@ gst_visual_getcaps (GstPad * pad, GstCaps * filter) GST_DEBUG_OBJECT (visual, "libvisual plugin supports depths %u (0x%04x)", depths, depths); /* if (depths & VISUAL_VIDEO_DEPTH_32BIT) Always supports 32bit output */ - gst_caps_append (ret, gst_caps_from_string (GST_VIDEO_CAPS_xRGB_HOST_ENDIAN)); +#if G_BYTE_ORDER == G_BIG_ENDIAN + gst_caps_append (ret, gst_caps_from_string (GST_VIDEO_CAPS_MAKE ("xRGB"))); +#else + gst_caps_append (ret, gst_caps_from_string (GST_VIDEO_CAPS_MAKE ("BGRx"))); +#endif if (depths & VISUAL_VIDEO_DEPTH_24BIT) { #if G_BYTE_ORDER == G_BIG_ENDIAN - gst_caps_append (ret, gst_caps_from_string (GST_VIDEO_CAPS_RGB)); + gst_caps_append (ret, gst_caps_from_string (GST_VIDEO_CAPS_MAKE ("RGB"))); #else - gst_caps_append (ret, gst_caps_from_string (GST_VIDEO_CAPS_BGR)); + gst_caps_append (ret, gst_caps_from_string (GST_VIDEO_CAPS_MAKE ("BGR"))); #endif } if (depths & VISUAL_VIDEO_DEPTH_16BIT) { - gst_caps_append (ret, gst_caps_from_string (GST_VIDEO_CAPS_RGB_16)); + gst_caps_append (ret, gst_caps_from_string (GST_VIDEO_CAPS_MAKE ("RGB16"))); } beach: @@ -330,6 +334,7 @@ gst_visual_src_setcaps (GstVisual * visual, GstCaps * caps) gboolean res; GstStructure *structure; gint depth, pitch; + const gchar *fmt; structure = gst_caps_get_structure (caps, 0); @@ -339,12 +344,19 @@ gst_visual_src_setcaps (GstVisual * visual, GstCaps * caps) goto error; if (!gst_structure_get_int (structure, "height", &visual->height)) goto error; - if (!gst_structure_get_int (structure, "bpp", &depth)) + if (!(fmt = gst_structure_get_string (structure, "format"))) goto error; if (!gst_structure_get_fraction (structure, "framerate", &visual->fps_n, &visual->fps_d)) goto error; + if (!strcmp (fmt, "BGR") || !strcmp (fmt, "RGB")) + depth = 24; + else if (!strcmp (fmt, "BGRx") || !strcmp (fmt, "xRGB")) + depth = 32; + else + depth = 16; + visual_video_set_depth (visual->video, visual_video_depth_enum_from_value (depth)); visual_video_set_dimension (visual->video, visual->width, visual->height); @@ -422,16 +434,22 @@ gst_vis_src_negotiate (GstVisual * visual) target = gst_caps_copy (caps); gst_caps_unref (caps); } + GST_DEBUG_OBJECT (visual, "before fixate caps %" GST_PTR_FORMAT, target); /* fixate in case something is not fixed. This does nothing if the value is * already fixed. For video we always try to fixate to something like * 320x240x25 by convention. */ structure = gst_caps_get_structure (target, 0); gst_structure_fixate_field_nearest_int (structure, "width", DEFAULT_WIDTH); + gst_structure_fixate_field_nearest_int (structure, "width", DEFAULT_WIDTH); gst_structure_fixate_field_nearest_int (structure, "height", DEFAULT_HEIGHT); gst_structure_fixate_field_nearest_fraction (structure, "framerate", DEFAULT_FPS_N, DEFAULT_FPS_D); + gst_pad_fixate_caps (visual->srcpad, target); + + GST_DEBUG_OBJECT (visual, "after fixate caps %" GST_PTR_FORMAT, target); + gst_visual_src_setcaps (visual, target); /* try to get a bufferpool now */ @@ -870,8 +888,8 @@ gst_visual_change_state (GstElement * element, GstStateChange transition) switch (transition) { case GST_STATE_CHANGE_NULL_TO_READY: visual->actor = - visual_actor_new (GST_VISUAL_GET_CLASS (visual)->plugin->info-> - plugname); + visual_actor_new (GST_VISUAL_GET_CLASS (visual)->plugin-> + info->plugname); visual->video = visual_video_new (); visual->audio = visual_audio_new (); /* can't have a play without actors */ diff --git a/ext/ogg/gstoggmux.c b/ext/ogg/gstoggmux.c index 0cc6ab0..34a2722 100644 --- a/ext/ogg/gstoggmux.c +++ b/ext/ogg/gstoggmux.c @@ -27,7 +27,7 @@ * * Example pipelines * |[ - * gst-launch v4l2src num-buffers=500 ! video/x-raw-yuv,width=320,height=240 ! ffmpegcolorspace ! theoraenc ! oggmux ! filesink location=video.ogg + * gst-launch v4l2src num-buffers=500 ! video/x-raw,width=320,height=240 ! ffmpegcolorspace ! theoraenc ! oggmux ! filesink location=video.ogg * ]| Encodes a video stream captured from a v4l2-compatible camera to Ogg/Theora * (the encoding will stop automatically after 500 frames) * diff --git a/ext/pango/gstbasetextoverlay.c b/ext/pango/gstbasetextoverlay.c index 4b5554e..159b4f6 100644 --- a/ext/pango/gstbasetextoverlay.c +++ b/ext/pango/gstbasetextoverlay.c @@ -192,34 +192,20 @@ enum PROP_LAST }; +#define VIDEO_FORMATS "{ BGRx, RGBx, xRGB, xBGR, RGBA, BGRA, ARGB, ABGR, AYUV, I420, UYVY, NV12, NV21 } " + static GstStaticPadTemplate src_template_factory = - GST_STATIC_PAD_TEMPLATE ("src", +GST_STATIC_PAD_TEMPLATE ("src", GST_PAD_SRC, GST_PAD_ALWAYS, - GST_STATIC_CAPS (GST_VIDEO_CAPS_BGRx ";" - GST_VIDEO_CAPS_RGBx ";" - GST_VIDEO_CAPS_xRGB ";" - GST_VIDEO_CAPS_xBGR ";" - GST_VIDEO_CAPS_RGBA ";" - GST_VIDEO_CAPS_BGRA ";" - GST_VIDEO_CAPS_ARGB ";" - GST_VIDEO_CAPS_ABGR ";" - GST_VIDEO_CAPS_YUV ("{AYUV, I420, UYVY, NV12, NV21}")) + GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE (VIDEO_FORMATS)) ); static GstStaticPadTemplate video_sink_template_factory = - GST_STATIC_PAD_TEMPLATE ("video_sink", +GST_STATIC_PAD_TEMPLATE ("video_sink", GST_PAD_SINK, GST_PAD_ALWAYS, - GST_STATIC_CAPS (GST_VIDEO_CAPS_BGRx ";" - GST_VIDEO_CAPS_RGBx ";" - GST_VIDEO_CAPS_xRGB ";" - GST_VIDEO_CAPS_xBGR ";" - GST_VIDEO_CAPS_RGBA ";" - GST_VIDEO_CAPS_BGRA ";" - GST_VIDEO_CAPS_ARGB ";" - GST_VIDEO_CAPS_ABGR ";" - GST_VIDEO_CAPS_YUV ("{AYUV, I420, UYVY, NV12, NV21}")) + GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE (VIDEO_FORMATS)) ); #define GST_TYPE_BASE_TEXT_OVERLAY_VALIGN (gst_base_text_overlay_valign_get_type()) diff --git a/ext/pango/gsttextrender.c b/ext/pango/gsttextrender.c index ac2d4b3..e012dc2 100644 --- a/ext/pango/gsttextrender.c +++ b/ext/pango/gsttextrender.c @@ -86,12 +86,13 @@ enum PROP_FONT_DESC }; +#define VIDEO_FORMATS "{ AYUV, ARGB } " static GstStaticPadTemplate src_template_factory = - GST_STATIC_PAD_TEMPLATE ("src", +GST_STATIC_PAD_TEMPLATE ("src", GST_PAD_SRC, GST_PAD_ALWAYS, - GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("AYUV") ";" GST_VIDEO_CAPS_ARGB) + GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE (VIDEO_FORMATS)) ); static GstStaticPadTemplate sink_template_factory = @@ -326,19 +327,20 @@ gst_text_render_check_argb (GstTextRender * render) /* Check if AYUV or ARGB is first */ for (i = 0; i < n; i++) { - GstStructure *s = gst_caps_get_structure (peer_caps, i); - if (gst_structure_has_name (s, "video/x-raw-rgb") && - gst_structure_has_field (s, "alpha_mask")) { - render->use_ARGB = TRUE; - break; - } else if (gst_structure_has_name (s, "video/x-raw-yuv")) { - guint fourcc; - if (gst_structure_get_fourcc (s, "format", &fourcc) && - fourcc == GST_MAKE_FOURCC ('A', 'Y', 'U', 'V')) { - render->use_ARGB = FALSE; - break; - } - } + GstStructure *s; + GstVideoFormat vformat; + const gchar *fmt; + + s = gst_caps_get_structure (peer_caps, i); + if (!gst_structure_has_name (s, "video/x-raw")) + continue; + + fmt = gst_structure_get_string (s, "format"); + if (fmt == NULL) + continue; + + vformat = gst_video_format_from_string (fmt); + render->use_ARGB = gst_video_format_has_alpha (vformat); } gst_caps_unref (peer_caps); } diff --git a/ext/theora/gsttheoradec.c b/ext/theora/gsttheoradec.c index eadf889..77012e3 100644 --- a/ext/theora/gsttheoradec.c +++ b/ext/theora/gsttheoradec.c @@ -68,8 +68,8 @@ static GstStaticPadTemplate theora_dec_src_factory = GST_STATIC_PAD_TEMPLATE ("src", GST_PAD_SRC, GST_PAD_ALWAYS, - GST_STATIC_CAPS ("video/x-raw-yuv, " - "format = (fourcc) { I420, Y42B, Y444 }, " + GST_STATIC_CAPS ("video/x-raw, " + "format = (string) { I420, Y42B, Y444 }, " "framerate = (fraction) [0/1, MAX], " "width = (int) [ 1, MAX ], " "height = (int) [ 1, MAX ]") ); @@ -844,7 +844,6 @@ theora_handle_type_packet (GstTheoraDec * dec, ogg_packet * packet) gint par_num, par_den; GstFlowReturn ret = GST_FLOW_OK; GList *walk; - guint32 fourcc; GST_DEBUG_OBJECT (dec, "fps %d/%d, PAR %d/%d", dec->info.fps_numerator, dec->info.fps_denominator, @@ -883,17 +882,14 @@ theora_handle_type_packet (GstTheoraDec * dec, ogg_packet * packet) case TH_PF_444: dec->output_bpp = 24; dec->format = GST_VIDEO_FORMAT_Y444; - fourcc = GST_MAKE_FOURCC ('Y', '4', '4', '4'); break; case TH_PF_420: dec->output_bpp = 12; /* Average bits per pixel. */ dec->format = GST_VIDEO_FORMAT_I420; - fourcc = GST_MAKE_FOURCC ('I', '4', '2', '0'); break; case TH_PF_422: dec->output_bpp = 16; dec->format = GST_VIDEO_FORMAT_Y42B; - fourcc = GST_MAKE_FOURCC ('Y', '4', '2', 'B'); break; default: goto invalid_format; @@ -946,8 +942,8 @@ theora_handle_type_packet (GstTheoraDec * dec, ogg_packet * packet) GST_WARNING_OBJECT (dec, "Could not enable BITS mode visualisation"); } - caps = gst_caps_new_simple ("video/x-raw-yuv", - "format", GST_TYPE_FOURCC, fourcc, + caps = gst_caps_new_simple ("video/x-raw", + "format", G_TYPE_STRING, gst_video_format_to_string (dec->format), "framerate", GST_TYPE_FRACTION, dec->info.fps_numerator, dec->info.fps_denominator, "pixel-aspect-ratio", GST_TYPE_FRACTION, par_num, par_den, diff --git a/ext/theora/gsttheoraenc.c b/ext/theora/gsttheoraenc.c index 25f333a..f486212 100644 --- a/ext/theora/gsttheoraenc.c +++ b/ext/theora/gsttheoraenc.c @@ -230,8 +230,8 @@ static GstStaticPadTemplate theora_enc_sink_factory = GST_STATIC_PAD_TEMPLATE ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, - GST_STATIC_CAPS ("video/x-raw-yuv, " - "format = (fourcc) { I420, Y42B, Y444 }, " + GST_STATIC_CAPS ("video/x-raw, " + "format = (string) { I420, Y42B, Y444 }, " "framerate = (fraction) [1/MAX, MAX], " "width = (int) [ 1, MAX ], " "height = (int) [ 1, MAX ]") ); @@ -401,8 +401,8 @@ gst_theora_enc_class_init (GstTheoraEncClass * klass) "encode raw YUV video to a theora stream", "Wim Taymans "); - caps_string = g_strdup_printf ("video/x-raw-yuv, " - "format = (fourcc) { %s }, " + caps_string = g_strdup_printf ("video/x-raw, " + "format = (string) { %s }, " "framerate = (fraction) [1/MAX, MAX], " "width = (int) [ 1, MAX ], " "height = (int) [ 1, MAX ]", theora_enc_get_supported_formats ()); @@ -620,7 +620,7 @@ theora_enc_sink_getcaps (GstPad * pad, GstCaps * filter) for (i = 0; i < n; i++) { s = gst_caps_get_structure (peer_caps, i); - gst_structure_set_name (s, "video/x-raw-yuv"); + gst_structure_set_name (s, "video/x-raw"); gst_structure_remove_field (s, "streamheader"); } diff --git a/gst/encoding/gstencodebin.c b/gst/encoding/gstencodebin.c index 6947f16..6c24ab7 100644 --- a/gst/encoding/gstencodebin.c +++ b/gst/encoding/gstencodebin.c @@ -218,9 +218,7 @@ struct _StreamGroup #define DEFAULT_AVOID_REENCODING FALSE #define DEFAULT_RAW_CAPS \ - "video/x-raw-yuv; " \ - "video/x-raw-rgb; " \ - "video/x-raw-gray; " \ + "video/x-raw; " \ "audio/x-raw-int; " \ "audio/x-raw-float; " \ "text/plain; " \ @@ -435,8 +433,7 @@ gst_encode_bin_init (GstEncodeBin * encode_bin) gst_element_factory_list_get_elements (GST_ELEMENT_FACTORY_TYPE_PARSER, GST_RANK_MARGINAL); - encode_bin->raw_video_caps = - gst_caps_from_string ("video/x-raw-yuv;video/x-raw-rgb;video/x-raw-gray"); + encode_bin->raw_video_caps = gst_caps_from_string ("video/x-raw"); encode_bin->raw_audio_caps = gst_caps_from_string ("audio/x-raw-int;audio/x-raw-float"); /* encode_bin->raw_text_caps = */ diff --git a/gst/playback/gstdecodebin2.c b/gst/playback/gstdecodebin2.c index 2d7c3fd..fd6c805 100644 --- a/gst/playback/gstdecodebin2.c +++ b/gst/playback/gstdecodebin2.c @@ -3038,7 +3038,7 @@ sort_end_pads (GstDecodePad * da, GstDecodePad * db) namea = gst_structure_get_name (sa); nameb = gst_structure_get_name (sb); - if (g_strrstr (namea, "video/x-raw-")) + if (g_strrstr (namea, "video/x-raw")) va = 0; else if (g_strrstr (namea, "video/")) va = 1; @@ -3049,7 +3049,7 @@ sort_end_pads (GstDecodePad * da, GstDecodePad * db) else va = 4; - if (g_strrstr (nameb, "video/x-raw-")) + if (g_strrstr (nameb, "video/x-raw")) vb = 0; else if (g_strrstr (nameb, "video/")) vb = 1; diff --git a/gst/playback/gstplaysink.c b/gst/playback/gstplaysink.c index 5d31635..cf6a0c1 100644 --- a/gst/playback/gstplaysink.c +++ b/gst/playback/gstplaysink.c @@ -2818,8 +2818,8 @@ is_raw_structure (GstStructure * s) name = gst_structure_get_name (s); - if (g_str_has_prefix (name, "video/x-raw-") || - g_str_has_prefix (name, "audio/x-raw-")) + if (g_str_has_prefix (name, "video/x-raw") || + g_str_has_prefix (name, "audio/x-raw")) return TRUE; return FALSE; } diff --git a/gst/playback/gstplaysinkaudioconvert.c b/gst/playback/gstplaysinkaudioconvert.c index 9e6d990..1bef613 100644 --- a/gst/playback/gstplaysinkaudioconvert.c +++ b/gst/playback/gstplaysinkaudioconvert.c @@ -255,7 +255,7 @@ gst_play_sink_audio_convert_sink_setcaps (GstPlaySinkAudioConvert * self, s = gst_caps_get_structure (caps, 0); name = gst_structure_get_name (s); - if (g_str_has_prefix (name, "audio/x-raw-")) { + if (g_str_has_prefix (name, "audio/x-raw")) { if (!self->raw && !gst_pad_is_blocked (self->sink_proxypad)) { GST_DEBUG_OBJECT (self, "Changing caps from non-raw to raw"); reconfigure = TRUE; diff --git a/gst/playback/gstplaysinkvideoconvert.c b/gst/playback/gstplaysinkvideoconvert.c index a9a5818..bba335e 100644 --- a/gst/playback/gstplaysinkvideoconvert.c +++ b/gst/playback/gstplaysinkvideoconvert.c @@ -236,7 +236,7 @@ gst_play_sink_video_convert_sink_setcaps (GstPlaySinkVideoConvert * self, s = gst_caps_get_structure (caps, 0); name = gst_structure_get_name (s); - if (g_str_has_prefix (name, "video/x-raw-")) { + if (g_str_has_prefix (name, "video/x-raw")) { if (!self->raw && !gst_pad_is_blocked (self->sink_proxypad)) { GST_DEBUG_OBJECT (self, "Changing caps from non-raw to raw"); reconfigure = TRUE; diff --git a/gst/playback/gstrawcaps.h b/gst/playback/gstrawcaps.h index 0297e33..5fb156e 100644 --- a/gst/playback/gstrawcaps.h +++ b/gst/playback/gstrawcaps.h @@ -26,9 +26,7 @@ G_BEGIN_DECLS #define DEFAULT_RAW_CAPS \ - "video/x-raw-yuv; " \ - "video/x-raw-rgb; " \ - "video/x-raw-gray; " \ + "video/x-raw; " \ "audio/x-raw-int; " \ "audio/x-raw-float; " \ "text/plain; " \ diff --git a/gst/videoconvert/gstvideoconvert.c b/gst/videoconvert/gstvideoconvert.c index 3a8bc85..18dd4a4 100644 --- a/gst/videoconvert/gstvideoconvert.c +++ b/gst/videoconvert/gstvideoconvert.c @@ -23,12 +23,12 @@ /** * SECTION:element-videoconvert * - * Convert video frames between a great variety of videoconvert formats. + * Convert video frames between a great variety of video formats. * * * Example launch line * |[ - * gst-launch -v videotestsrc ! video/x-raw-yuv,format=\(fourcc\)YUY2 ! videoconvert ! ximagesink + * gst-launch -v videotestsrc ! video/x-raw,format=\(fourcc\)YUY2 ! videoconvert ! ximagesink * ]| * */ @@ -52,30 +52,7 @@ enum PROP_DITHER }; -#define CSP_VIDEO_CAPS \ - "video/x-raw-yuv, width = "GST_VIDEO_SIZE_RANGE" , " \ - "height="GST_VIDEO_SIZE_RANGE",framerate="GST_VIDEO_FPS_RANGE"," \ - "format= (fourcc) { I420 , NV12 , NV21 , YV12 , YUY2 , Y42B , Y444 , YUV9 , YVU9 , Y41B , Y800 , Y8 , GREY , Y16 , UYVY , YVYU , IYU1 , v308 , AYUV, v210, v216, A420, AY64 } ;" \ - GST_VIDEO_CAPS_RGB";" \ - GST_VIDEO_CAPS_BGR";" \ - GST_VIDEO_CAPS_RGBx";" \ - GST_VIDEO_CAPS_xRGB";" \ - GST_VIDEO_CAPS_BGRx";" \ - GST_VIDEO_CAPS_xBGR";" \ - GST_VIDEO_CAPS_RGBA";" \ - GST_VIDEO_CAPS_ARGB";" \ - GST_VIDEO_CAPS_BGRA";" \ - GST_VIDEO_CAPS_ABGR";" \ - GST_VIDEO_CAPS_RGB_16";" \ - GST_VIDEO_CAPS_BGR_16";" \ - GST_VIDEO_CAPS_RGB_15";" \ - GST_VIDEO_CAPS_BGR_15";" \ - GST_VIDEO_CAPS_RGB8_PALETTED "; " \ - GST_VIDEO_CAPS_GRAY8";" \ - GST_VIDEO_CAPS_GRAY16("BIG_ENDIAN")";" \ - GST_VIDEO_CAPS_GRAY16("LITTLE_ENDIAN")";" \ - GST_VIDEO_CAPS_r210";" \ - GST_VIDEO_CAPS_ARGB_64 +#define CSP_VIDEO_CAPS GST_VIDEO_CAPS_MAKE (GST_VIDEO_FORMATS_ALL) static GstStaticPadTemplate gst_video_convert_src_template = GST_STATIC_PAD_TEMPLATE ("src", @@ -105,11 +82,6 @@ static gboolean gst_video_convert_get_unit_size (GstBaseTransform * btrans, static GstFlowReturn gst_video_convert_transform (GstBaseTransform * btrans, GstBuffer * inbuf, GstBuffer * outbuf); -static GQuark _QRAWRGB; /* "video/x-raw-rgb" */ -static GQuark _QRAWYUV; /* "video/x-raw-yuv" */ -static GQuark _QALPHAMASK; /* "alpha_mask" */ - - static GType dither_method_get_type (void) { @@ -132,7 +104,7 @@ dither_method_get_type (void) static GstCaps * gst_video_convert_caps_remove_format_info (GstCaps * caps) { - GstStructure *yuvst, *rgbst, *grayst; + GstStructure *st; gint i, n; GstCaps *res; @@ -140,29 +112,18 @@ gst_video_convert_caps_remove_format_info (GstCaps * caps) n = gst_caps_get_size (caps); for (i = 0; i < n; i++) { - yuvst = gst_caps_get_structure (caps, i); + st = gst_caps_get_structure (caps, i); /* If this is already expressed by the existing caps * skip this structure */ - if (i > 0 && gst_caps_is_subset_structure (res, yuvst)) + if (i > 0 && gst_caps_is_subset_structure (res, st)) continue; - yuvst = gst_structure_copy (yuvst); - gst_structure_set_name (yuvst, "video/x-raw-yuv"); - gst_structure_remove_fields (yuvst, "format", "endianness", "depth", - "bpp", "red_mask", "green_mask", "blue_mask", "alpha_mask", - "palette_data", NULL); - - rgbst = gst_structure_copy (yuvst); - gst_structure_set_name (rgbst, "video/x-raw-rgb"); - gst_structure_remove_fields (rgbst, "color-matrix", "chroma-site", NULL); + st = gst_structure_copy (st); + gst_structure_remove_fields (st, "format", "palette_data", + "color-matrix", "chroma-site", NULL); - grayst = gst_structure_copy (rgbst); - gst_structure_set_name (grayst, "video/x-raw-gray"); - - gst_caps_append_structure (res, yuvst); - gst_caps_append_structure (res, rgbst); - gst_caps_append_structure (res, grayst); + gst_caps_append_structure (res, st); } return res; @@ -413,10 +374,6 @@ gst_video_convert_class_init (GstVideoConvertClass * klass) "Converts video from one colorspace to another", "GStreamer maintainers "); - _QRAWRGB = g_quark_from_string ("video/x-raw-rgb"); - _QRAWYUV = g_quark_from_string ("video/x-raw-yuv"); - _QALPHAMASK = g_quark_from_string ("alpha_mask"); - gstbasetransform_class->transform_caps = GST_DEBUG_FUNCPTR (gst_video_convert_transform_caps); gstbasetransform_class->set_caps = diff --git a/gst/videorate/gstvideorate.c b/gst/videorate/gstvideorate.c index 3156c5f..a0b3701 100644 --- a/gst/videorate/gstvideorate.c +++ b/gst/videorate/gstvideorate.c @@ -55,11 +55,11 @@ * * Example pipelines * |[ - * gst-launch -v filesrc location=videotestsrc.ogg ! oggdemux ! theoradec ! videorate ! video/x-raw-yuv,framerate=15/1 ! xvimagesink + * gst-launch -v filesrc location=videotestsrc.ogg ! oggdemux ! theoradec ! videorate ! video/x-raw,framerate=15/1 ! xvimagesink * ]| Decode an Ogg/Theora file and adjust the framerate to 15 fps before playing. * To create the test Ogg/Theora file refer to the documentation of theoraenc. * |[ - * gst-launch -v v4l2src ! videorate ! video/x-raw-yuv,framerate=25/2 ! theoraenc ! oggmux ! filesink location=recording.ogg + * gst-launch -v v4l2src ! videorate ! video/x-raw,framerate=25/2 ! theoraenc ! oggmux ! filesink location=recording.ogg * ]| Capture video from a V4L device, and adjust the stream to 12.5 fps before * encoding to Ogg/Theora. * @@ -108,16 +108,14 @@ static GstStaticPadTemplate gst_video_rate_src_template = GST_STATIC_PAD_TEMPLATE ("src", GST_PAD_SRC, GST_PAD_ALWAYS, - GST_STATIC_CAPS ("video/x-raw-yuv;" - "video/x-raw-rgb;" "video/x-raw-gray;" "image/jpeg;" "image/png") + GST_STATIC_CAPS ("video/x-raw;" "image/jpeg;" "image/png") ); static GstStaticPadTemplate gst_video_rate_sink_template = GST_STATIC_PAD_TEMPLATE ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, - GST_STATIC_CAPS ("video/x-raw-yuv;" - "video/x-raw-rgb;" "video/x-raw-gray;" "image/jpeg;" "image/png") + GST_STATIC_CAPS ("video/x-raw;" "image/jpeg;" "image/png") ); static void gst_video_rate_swap_prev (GstVideoRate * videorate, diff --git a/gst/videoscale/gstvideoscale.c b/gst/videoscale/gstvideoscale.c index 4a54c0a..a5cdf15 100644 --- a/gst/videoscale/gstvideoscale.c +++ b/gst/videoscale/gstvideoscale.c @@ -20,7 +20,7 @@ /** * SECTION:element-videoscale - * @see_also: videorate, ffmpegcolorspace + * @see_also: videorate, videoconvert * * This element resizes video frames. By default the element will try to * negotiate to the same size on the source and sinkpad so that no scaling @@ -34,13 +34,13 @@ * * Example pipelines * |[ - * gst-launch -v filesrc location=videotestsrc.ogg ! oggdemux ! theoradec ! ffmpegcolorspace ! videoscale ! ximagesink + * gst-launch -v filesrc location=videotestsrc.ogg ! oggdemux ! theoradec ! videoconvert ! videoscale ! ximagesink * ]| Decode an Ogg/Theora and display the video using ximagesink. Since * ximagesink cannot perform scaling, the video scaling will be performed by * videoscale when you resize the video window. * To create the test Ogg/Theora file refer to the documentation of theoraenc. * |[ - * gst-launch -v filesrc location=videotestsrc.ogg ! oggdemux ! theoradec ! videoscale ! video/x-raw-yuv, width=50 ! xvimagesink + * gst-launch -v filesrc location=videotestsrc.ogg ! oggdemux ! theoradec ! videoscale ! video/x-raw, width=50 ! xvimagesink * ]| Decode an Ogg/Theora and display the video using xvimagesink with a width * of 50. * @@ -101,37 +101,14 @@ enum #undef GST_VIDEO_SIZE_RANGE #define GST_VIDEO_SIZE_RANGE "(int) [ 1, 32767]" +#define GST_VIDEO_FORMATS "{ \"I420\", \"YV12\", \"YUY2\", \"UYVY\", \"AYUV\", \"RGBx\", " \ + "\"BGRx\", \"xRGB\", \"xBGR\", \"RGBA\", \"BGRA\", \"ARGB\", \"ABGR\", \"RGB\", " \ + "\"BGR\", \"Y41B\", \"Y42B\", \"YVYU\", \"Y444\", \"GRAY8\", \"GRAY16_BE\", \"GRAY16_LE\", " \ + "\"v308\", \"Y800\", \"Y16\", \"RGB16\", \"RGB15\", \"ARGB64\", \"AYUV64\" } " + + static GstStaticCaps gst_video_scale_format_caps[] = { - GST_STATIC_CAPS (GST_VIDEO_CAPS_RGBA), - GST_STATIC_CAPS (GST_VIDEO_CAPS_ARGB), - GST_STATIC_CAPS (GST_VIDEO_CAPS_BGRA), - GST_STATIC_CAPS (GST_VIDEO_CAPS_ABGR), - GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("AYUV")), - GST_STATIC_CAPS (GST_VIDEO_CAPS_RGBx), - GST_STATIC_CAPS (GST_VIDEO_CAPS_xRGB), - GST_STATIC_CAPS (GST_VIDEO_CAPS_BGRx), - GST_STATIC_CAPS (GST_VIDEO_CAPS_xBGR), - GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("Y444")), - GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("v308")), - GST_STATIC_CAPS (GST_VIDEO_CAPS_RGB), - GST_STATIC_CAPS (GST_VIDEO_CAPS_BGR), - GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("Y42B")), - GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("YUY2")), - GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("YVYU")), - GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("UYVY")), - GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("I420")), - GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("YV12")), - GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("Y41B")), - GST_STATIC_CAPS (GST_VIDEO_CAPS_RGB_16), - GST_STATIC_CAPS (GST_VIDEO_CAPS_RGB_15), - GST_STATIC_CAPS (GST_VIDEO_CAPS_GRAY16 ("BYTE_ORDER")), - GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("Y16 ")), - GST_STATIC_CAPS (GST_VIDEO_CAPS_GRAY8), - GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("Y800")), - GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("Y8 ")), - GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("GREY")), - GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("AY64")), - GST_STATIC_CAPS (GST_VIDEO_CAPS_ARGB_64) + GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE (GST_VIDEO_FORMATS)) }; #define GST_TYPE_VIDEO_SCALE_METHOD (gst_video_scale_method_get_type()) diff --git a/gst/videotestsrc/gstvideotestsrc.c b/gst/videotestsrc/gstvideotestsrc.c index 21616b4..d535a81 100644 --- a/gst/videotestsrc/gstvideotestsrc.c +++ b/gst/videotestsrc/gstvideotestsrc.c @@ -575,8 +575,8 @@ gst_video_test_src_getcaps (GstBaseSrc * bsrc, GstCaps * filter) int i; caps = gst_caps_new_empty (); - for (i = 0; i < n_fourccs; i++) { - structure = paint_get_structure (fourcc_list + i); + for (i = 0; i < n_formats; i++) { + structure = paint_get_structure (format_list + i); gst_structure_set (structure, "width", GST_TYPE_INT_RANGE, 1, G_MAXINT, "height", GST_TYPE_INT_RANGE, 1, G_MAXINT, @@ -596,7 +596,7 @@ gst_video_test_src_getcaps (GstBaseSrc * bsrc, GstCaps * filter) static gboolean gst_video_test_src_parse_caps (const GstCaps * caps, gint * width, gint * height, gint * rate_numerator, gint * rate_denominator, - struct fourcc_list_struct **fourcc, GstVideoTestSrcColorSpec * color_spec) + struct format_list_struct **format, GstVideoTestSrcColorSpec * color_spec) { const GstStructure *structure; GstPadLinkReturn ret; @@ -610,7 +610,7 @@ gst_video_test_src_parse_caps (const GstCaps * caps, structure = gst_caps_get_structure (caps, 0); - if (!(*fourcc = paintinfo_find_by_structure (structure))) + if (!(*format = paintinfo_find_by_structure (structure))) goto unknown_format; ret = gst_structure_get_int (structure, "width", width); @@ -678,24 +678,24 @@ gst_video_test_src_setcaps (GstBaseSrc * bsrc, GstCaps * caps) { gboolean res; gint width, height, rate_denominator, rate_numerator; - struct fourcc_list_struct *fourcc; + struct format_list_struct *format; GstVideoTestSrc *videotestsrc; GstVideoTestSrcColorSpec color_spec; videotestsrc = GST_VIDEO_TEST_SRC (bsrc); res = gst_video_test_src_parse_caps (caps, &width, &height, - &rate_numerator, &rate_denominator, &fourcc, &color_spec); + &rate_numerator, &rate_denominator, &format, &color_spec); if (!res) goto parse_failed; /* looks ok here */ - videotestsrc->fourcc = fourcc; + videotestsrc->format = format; videotestsrc->width = width; videotestsrc->height = height; videotestsrc->rate_numerator = rate_numerator; videotestsrc->rate_denominator = rate_denominator; - videotestsrc->bpp = videotestsrc->fourcc->bitspp; + videotestsrc->bpp = videotestsrc->format->bitspp; videotestsrc->color_spec = color_spec; videotestsrc->size = gst_video_test_src_get_size (videotestsrc, width, height); @@ -857,7 +857,7 @@ gst_video_test_src_fill (GstPushSrc * psrc, GstBuffer * buffer) src = GST_VIDEO_TEST_SRC (psrc); - if (G_UNLIKELY (src->fourcc == NULL)) + if (G_UNLIKELY (src->format == NULL)) goto not_negotiated; /* 0 framerate and we are at the second frame, eos */ diff --git a/gst/videotestsrc/gstvideotestsrc.h b/gst/videotestsrc/gstvideotestsrc.h index a106923..abbd899 100644 --- a/gst/videotestsrc/gstvideotestsrc.h +++ b/gst/videotestsrc/gstvideotestsrc.h @@ -138,7 +138,7 @@ struct _GstVideoTestSrc { char *format_name; gint width; gint height; - struct fourcc_list_struct *fourcc; + struct format_list_struct *format; gint bpp; gint rate_numerator; gint rate_denominator; diff --git a/gst/videotestsrc/videotestsrc.c b/gst/videotestsrc/videotestsrc.c index ecc83f8..9089cb1 100644 --- a/gst/videotestsrc/videotestsrc.c +++ b/gst/videotestsrc/videotestsrc.c @@ -206,7 +206,7 @@ static void paint_setup_GRAY16 (paintinfo * p, unsigned char *dest); static void convert_hline_GRAY8 (paintinfo * p, int y); static void convert_hline_GRAY16 (paintinfo * p, int y); -struct fourcc_list_struct fourcc_list[] = { +struct format_list_struct format_list[] = { /* packed */ {VTS_YUV, "YUY2", "YUY2", 16, paint_setup_YUY2, convert_hline_YUY2}, {VTS_YUV, "UYVY", "UYVY", 16, paint_setup_UYVY, convert_hline_YUY2}, @@ -255,43 +255,49 @@ struct fourcc_list_struct fourcc_list[] = { /* Not exactly YUV but it's the same as above */ {VTS_GRAY, "GRAY8", "GRAY8", 8, paint_setup_GRAY8, convert_hline_GRAY8}, - {VTS_GRAY, "GRAY16", "GRAY16", 16, paint_setup_GRAY16, convert_hline_GRAY16}, +#if G_BYTE_ORDER == G_LITTLE_ENDIAN + {VTS_GRAY, "GRAY16_LE", "GRAY16", 16, paint_setup_GRAY16, + convert_hline_GRAY16}, +#else + {VTS_GRAY, "GRAY16_BE", "GRAY16", 16, paint_setup_GRAY16, + convert_hline_GRAY16}, +#endif - {VTS_RGB, "RGB ", "xRGB8888", 32, paint_setup_xRGB8888, convert_hline_str4, + {VTS_RGB, "xRGB", "xRGB8888", 32, paint_setup_xRGB8888, convert_hline_str4, 24, 0x00ff0000, 0x0000ff00, 0x000000ff}, - {VTS_RGB, "RGB ", "xBGR8888", 32, paint_setup_xBGR8888, convert_hline_str4, + {VTS_RGB, "xBGR", "xBGR8888", 32, paint_setup_xBGR8888, convert_hline_str4, 24, 0x000000ff, 0x0000ff00, 0x00ff0000}, - {VTS_RGB, "RGB ", "RGBx8888", 32, paint_setup_RGBx8888, convert_hline_str4, + {VTS_RGB, "RGBx", "RGBx8888", 32, paint_setup_RGBx8888, convert_hline_str4, 24, 0xff000000, 0x00ff0000, 0x0000ff00}, - {VTS_RGB, "RGB ", "BGRx8888", 32, paint_setup_BGRx8888, convert_hline_str4, + {VTS_RGB, "BGRx", "BGRx8888", 32, paint_setup_BGRx8888, convert_hline_str4, 24, 0x0000ff00, 0x00ff0000, 0xff000000}, - {VTS_RGB, "RGB ", "ARGB8888", 32, paint_setup_ARGB8888, convert_hline_astr4, + {VTS_RGB, "ARGB", "ARGB8888", 32, paint_setup_ARGB8888, convert_hline_astr4, 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000}, - {VTS_RGB, "RGB ", "ABGR8888", 32, paint_setup_ABGR8888, convert_hline_astr4, + {VTS_RGB, "ABGR", "ABGR8888", 32, paint_setup_ABGR8888, convert_hline_astr4, 32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000}, - {VTS_RGB, "RGB ", "RGBA8888", 32, paint_setup_RGBA8888, convert_hline_astr4, + {VTS_RGB, "RGBA", "RGBA8888", 32, paint_setup_RGBA8888, convert_hline_astr4, 32, 0xff000000, 0x00ff0000, 0x0000ff00, 0x000000ff}, - {VTS_RGB, "RGB ", "BGRA8888", 32, paint_setup_BGRA8888, convert_hline_astr4, + {VTS_RGB, "BGRA", "BGRA8888", 32, paint_setup_BGRA8888, convert_hline_astr4, 32, 0x0000ff00, 0x00ff0000, 0xff000000, 0x000000ff}, - {VTS_RGB, "RGB ", "RGB888", 24, paint_setup_RGB888, convert_hline_str3, 24, + {VTS_RGB, "RGB", "RGB888", 24, paint_setup_RGB888, convert_hline_str3, 24, 0x00ff0000, 0x0000ff00, 0x000000ff}, - {VTS_RGB, "RGB ", "BGR888", 24, paint_setup_BGR888, convert_hline_str3, 24, + {VTS_RGB, "BGR", "BGR888", 24, paint_setup_BGR888, convert_hline_str3, 24, 0x000000ff, 0x0000ff00, 0x00ff0000}, - {VTS_RGB, "RGB ", "RGB565", 16, paint_setup_RGB565, convert_hline_RGB565, 16, + {VTS_RGB, "RGB16", "RGB565", 16, paint_setup_RGB565, convert_hline_RGB565, 16, 0x0000f800, 0x000007e0, 0x0000001f}, - {VTS_RGB, "RGB ", "xRGB1555", 16, paint_setup_xRGB1555, + {VTS_RGB, "RGB15", "xRGB1555", 16, paint_setup_xRGB1555, convert_hline_xRGB1555, 15, 0x00007c00, 0x000003e0, 0x0000001f}, - {VTS_RGB, "RGB ", "ARGB8888", 64, paint_setup_ARGB64, convert_hline_astr8, + {VTS_RGB, "ARGB64", "ARGB8888", 64, paint_setup_ARGB64, convert_hline_astr8, 64, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000}, @@ -301,84 +307,28 @@ struct fourcc_list_struct fourcc_list[] = { {VTS_BAYER, "gbrg", "Bayer", 8, paint_setup_bayer_gbrg, convert_hline_bayer} }; -int n_fourccs = G_N_ELEMENTS (fourcc_list); +int n_formats = G_N_ELEMENTS (format_list); -struct fourcc_list_struct * +struct format_list_struct * paintinfo_find_by_structure (const GstStructure * structure) { int i; const char *media_type = gst_structure_get_name (structure); - int ret; g_return_val_if_fail (structure, NULL); - if (strcmp (media_type, "video/x-raw-gray") == 0) { - gint bpp, depth, endianness = 0; - - ret = gst_structure_get_int (structure, "bpp", &bpp) && - gst_structure_get_int (structure, "depth", &depth); - if (!ret || bpp != depth || (depth != 8 && depth != 16)) - return NULL; - - ret = gst_structure_get_int (structure, "endianness", &endianness); - if ((!ret || endianness != G_BYTE_ORDER) && bpp == 16) - return NULL; - - for (i = 0; i < n_fourccs; i++) { - if (fourcc_list[i].type == VTS_GRAY && fourcc_list[i].bitspp == bpp) { - return fourcc_list + i; - } - } - } else if (strcmp (media_type, "video/x-raw-yuv") == 0) { - const char *s; - int fourcc; - guint32 format; - - ret = gst_structure_get_fourcc (structure, "format", &format); - if (!ret) - return NULL; - for (i = 0; i < n_fourccs; i++) { - s = fourcc_list[i].fourcc; - /* g_print("testing %" GST_FOURCC_FORMAT " and %s\n", GST_FOURCC_ARGS(format), s); */ - fourcc = GST_MAKE_FOURCC (s[0], s[1], s[2], s[3]); - if (fourcc_list[i].type == VTS_YUV && fourcc == format) { - return fourcc_list + i; - } - } - } else if (strcmp (media_type, "video/x-raw-rgb") == 0) { - int red_mask; - int green_mask; - int blue_mask; - int alpha_mask; - int depth; - int bpp; - - ret = gst_structure_get_int (structure, "red_mask", &red_mask); - ret &= gst_structure_get_int (structure, "green_mask", &green_mask); - ret &= gst_structure_get_int (structure, "blue_mask", &blue_mask); - ret &= gst_structure_get_int (structure, "depth", &depth); - ret &= gst_structure_get_int (structure, "bpp", &bpp); - - if (depth == 32) { - ret &= gst_structure_get_int (structure, "alpha_mask", &alpha_mask); - ret &= (alpha_mask != 0); - } else { - alpha_mask = 0; - } + if (strcmp (media_type, "video/x-raw") == 0) { + const gchar *format; - if (!ret) { + format = gst_structure_get_string (structure, "format"); + if (!format) { GST_WARNING ("incomplete caps structure: %" GST_PTR_FORMAT, structure); return NULL; } - for (i = 0; i < n_fourccs; i++) { - if (fourcc_list[i].type == VTS_RGB && - fourcc_list[i].red_mask == red_mask && - fourcc_list[i].green_mask == green_mask && - fourcc_list[i].blue_mask == blue_mask && - (alpha_mask == 0 || fourcc_list[i].alpha_mask == alpha_mask) && - fourcc_list[i].depth == depth && fourcc_list[i].bitspp == bpp) { - return fourcc_list + i; + for (i = 0; i < n_formats; i++) { + if (g_str_equal (format, format_list[i].format)) { + return format_list + i; } } return NULL; @@ -391,10 +341,10 @@ paintinfo_find_by_structure (const GstStructure * structure) return NULL; } - for (i = 0; i < n_fourccs; i++) { - if (fourcc_list[i].type == VTS_BAYER && - g_str_equal (format, fourcc_list[i].fourcc)) { - return fourcc_list + i; + for (i = 0; i < n_formats; i++) { + if (format_list[i].type == VTS_BAYER && + g_str_equal (format, format_list[i].format)) { + return format_list + i; } } return NULL; @@ -405,37 +355,27 @@ paintinfo_find_by_structure (const GstStructure * structure) return NULL; } -struct fourcc_list_struct * -paintrect_find_fourcc (int find_fourcc) +struct format_list_struct * +paintrect_find_format (const gchar * find_format) { int i; - for (i = 0; i < n_fourccs; i++) { - const char *s; - int fourcc; - - s = fourcc_list[i].fourcc; - fourcc = GST_MAKE_FOURCC (s[0], s[1], s[2], s[3]); - if (find_fourcc == fourcc) { - /* If YUV format, it's good */ - if (!fourcc_list[i].type == VTS_YUV) { - return fourcc_list + i; - } - - return fourcc_list + i; + for (i = 0; i < n_formats; i++) { + if (strcmp (find_format, format_list[i].format) == 0) { + return format_list + i; } } return NULL; } -struct fourcc_list_struct * +struct format_list_struct * paintrect_find_name (const char *name) { int i; - for (i = 0; i < n_fourccs; i++) { - if (strcmp (name, fourcc_list[i].name) == 0) { - return fourcc_list + i; + for (i = 0; i < n_formats; i++) { + if (strcmp (name, format_list[i].name) == 0) { + return format_list + i; } } return NULL; @@ -443,54 +383,27 @@ paintrect_find_name (const char *name) GstStructure * -paint_get_structure (struct fourcc_list_struct * format) +paint_get_structure (struct format_list_struct * format) { GstStructure *structure = NULL; - unsigned int fourcc; - int endianness; g_return_val_if_fail (format, NULL); - fourcc = - GST_MAKE_FOURCC (format->fourcc[0], format->fourcc[1], format->fourcc[2], - format->fourcc[3]); - switch (format->type) { case VTS_RGB: - if (format->bitspp == 16) { - endianness = G_BYTE_ORDER; - } else { - endianness = G_BIG_ENDIAN; - } - structure = gst_structure_new ("video/x-raw-rgb", - "bpp", G_TYPE_INT, format->bitspp, - "endianness", G_TYPE_INT, endianness, - "depth", G_TYPE_INT, format->depth, - "red_mask", G_TYPE_INT, format->red_mask, - "green_mask", G_TYPE_INT, format->green_mask, - "blue_mask", G_TYPE_INT, format->blue_mask, NULL); - if (format->depth == 32 && format->alpha_mask > 0) { - gst_structure_set (structure, "alpha_mask", G_TYPE_INT, - format->alpha_mask, NULL); - } - break; case VTS_GRAY: - structure = gst_structure_new ("video/x-raw-gray", - "bpp", G_TYPE_INT, format->bitspp, "depth", G_TYPE_INT, - format->bitspp, NULL); - if (format->bitspp == 16) - gst_structure_set (structure, "endianness", G_TYPE_INT, G_BYTE_ORDER, - NULL); + structure = gst_structure_new ("video/x-raw", + "format", G_TYPE_STRING, format->format, NULL); break; case VTS_YUV: { GValue value_list = { 0 }; GValue value = { 0 }; - structure = gst_structure_new ("video/x-raw-yuv", - "format", GST_TYPE_FOURCC, fourcc, NULL); + structure = gst_structure_new ("video/x-raw", + "format", G_TYPE_STRING, format->format, NULL); - if (fourcc != GST_STR_FOURCC ("Y800")) { + if (strcmp (format->format, "Y800") != 0) { g_value_init (&value_list, GST_TYPE_LIST); g_value_init (&value, G_TYPE_STRING); @@ -503,10 +416,10 @@ paint_get_structure (struct fourcc_list_struct * format) gst_structure_set_value (structure, "color-matrix", &value_list); g_value_reset (&value_list); - if (fourcc != GST_STR_FOURCC ("AYUV") && - fourcc != GST_STR_FOURCC ("v308") && - fourcc != GST_STR_FOURCC ("v410") && - fourcc != GST_STR_FOURCC ("Y444")) { + if (strcmp (format->format, "AYUV") && + strcmp (format->format, "v308") && + strcmp (format->format, "v410") && + strcmp (format->format, "Y444")) { g_value_set_static_string (&value, "mpeg2"); gst_value_list_append_value (&value_list, &value); @@ -521,7 +434,7 @@ paint_get_structure (struct fourcc_list_struct * format) break; case VTS_BAYER: structure = gst_structure_new ("video/x-raw-bayer", - "format", G_TYPE_STRING, format->fourcc, NULL); + "format", G_TYPE_STRING, format->format, NULL); break; default: g_assert_not_reached (); @@ -531,21 +444,21 @@ paint_get_structure (struct fourcc_list_struct * format) } /* returns the size in bytes for one video frame of the given dimensions - * given the fourcc in GstVideoTestSrc */ + * given the format in GstVideoTestSrc */ int gst_video_test_src_get_size (GstVideoTestSrc * v, int w, int h) { paintinfo pi = { NULL, }; paintinfo *p = π - struct fourcc_list_struct *fourcc; + struct format_list_struct *format; p->width = w; p->height = h; - fourcc = v->fourcc; - if (fourcc == NULL) + format = v->format; + if (format == NULL) return 0; - fourcc->paint_setup (p, NULL); + format->paint_setup (p, NULL); return (unsigned long) p->endptr; } @@ -603,8 +516,8 @@ videotestsrc_setup_paintinfo (GstVideoTestSrc * v, paintinfo * p, int w, int h) p->width = w; p->height = h; - p->convert_tmpline = v->fourcc->convert_hline; - if (v->fourcc->type == VTS_RGB || v->fourcc->type == VTS_BAYER) { + p->convert_tmpline = v->format->convert_hline; + if (v->format->type == VTS_RGB || v->format->type == VTS_BAYER) { p->paint_tmpline = paint_tmpline_ARGB; } else { p->paint_tmpline = paint_tmpline_AYUV; @@ -703,7 +616,7 @@ videotestsrc_blend_line (GstVideoTestSrc * v, guint8 * dest, guint8 * src, struct vts_color_struct *a, struct vts_color_struct *b, int n) { int i; - if (v->fourcc->type == VTS_RGB || v->fourcc->type == VTS_BAYER) { + if (v->format->type == VTS_RGB || v->format->type == VTS_BAYER) { for (i = 0; i < n; i++) { dest[i * 4 + 0] = BLEND (a->A, b->A, src[i]); dest[i * 4 + 1] = BLEND (a->R, b->R, src[i]); @@ -730,14 +643,14 @@ gst_video_test_src_smpte (GstVideoTestSrc * v, unsigned char *dest, int w, int j; paintinfo pi = { NULL, }; paintinfo *p = π - struct fourcc_list_struct *fourcc; + struct format_list_struct *format; videotestsrc_setup_paintinfo (v, p, w, h); - fourcc = v->fourcc; - if (fourcc == NULL) + format = v->format; + if (format == NULL) return; - fourcc->paint_setup (p, dest); + format->paint_setup (p, dest); y1 = 2 * h / 3; y2 = h * 0.75; @@ -835,7 +748,7 @@ gst_video_test_src_smpte75 (GstVideoTestSrc * v, unsigned char *dest, int w, int j; paintinfo pi = { NULL, }; paintinfo *p = π - struct fourcc_list_struct *fourcc; + struct format_list_struct *format; videotestsrc_setup_paintinfo (v, p, w, h); if (v->color_spec == GST_VIDEO_TEST_SRC_BT601) { @@ -843,11 +756,11 @@ gst_video_test_src_smpte75 (GstVideoTestSrc * v, unsigned char *dest, int w, } else { p->colors = vts_colors_bt709_ycbcr_75; } - fourcc = v->fourcc; - if (fourcc == NULL) + format = v->format; + if (format == NULL) return; - fourcc->paint_setup (p, dest); + format->paint_setup (p, dest); /* color bars */ for (j = 0; j < h; j++) { @@ -870,14 +783,14 @@ gst_video_test_src_smpte100 (GstVideoTestSrc * v, unsigned char *dest, int w, int j; paintinfo pi = { NULL, }; paintinfo *p = π - struct fourcc_list_struct *fourcc; + struct format_list_struct *format; videotestsrc_setup_paintinfo (v, p, w, h); - fourcc = v->fourcc; - if (fourcc == NULL) + format = v->format; + if (format == NULL) return; - fourcc->paint_setup (p, dest); + format->paint_setup (p, dest); /* color bars */ for (j = 0; j < h; j++) { @@ -898,14 +811,14 @@ gst_video_test_src_bar (GstVideoTestSrc * v, unsigned char *dest, int w, int h) int j; paintinfo pi = { NULL, }; paintinfo *p = π - struct fourcc_list_struct *fourcc; + struct format_list_struct *format; videotestsrc_setup_paintinfo (v, p, w, h); - fourcc = v->fourcc; - if (fourcc == NULL) + format = v->format; + if (format == NULL) return; - fourcc->paint_setup (p, dest); + format->paint_setup (p, dest); for (j = 0; j < h; j++) { /* use fixed size for now */ @@ -926,15 +839,15 @@ gst_video_test_src_snow (GstVideoTestSrc * v, unsigned char *dest, int w, int h) int j; paintinfo pi = { NULL, }; paintinfo *p = π - struct fourcc_list_struct *fourcc; + struct format_list_struct *format; struct vts_color_struct color; videotestsrc_setup_paintinfo (v, p, w, h); - fourcc = v->fourcc; - if (fourcc == NULL) + format = v->format; + if (format == NULL) return; - fourcc->paint_setup (p, dest); + format->paint_setup (p, dest); color = p->colors[COLOR_BLACK]; p->color = &color; @@ -957,14 +870,14 @@ gst_video_test_src_unicolor (GstVideoTestSrc * v, unsigned char *dest, int w, int i; paintinfo pi = { NULL, }; paintinfo *p = π - struct fourcc_list_struct *fourcc; + struct format_list_struct *format; videotestsrc_setup_paintinfo (v, p, w, h); - fourcc = v->fourcc; - if (fourcc == NULL) + format = v->format; + if (format == NULL) return; - fourcc->paint_setup (p, dest); + format->paint_setup (p, dest); p->color = p->colors + color_index; if (color_index == COLOR_BLACK) { @@ -1017,15 +930,15 @@ gst_video_test_src_blink (GstVideoTestSrc * v, unsigned char *dest, int w, int i; paintinfo pi = { NULL, }; paintinfo *p = π - struct fourcc_list_struct *fourcc; + struct format_list_struct *format; videotestsrc_setup_paintinfo (v, p, w, h); - fourcc = v->fourcc; - if (fourcc == NULL) + format = v->format; + if (format == NULL) return; - fourcc->paint_setup (p, dest); + format->paint_setup (p, dest); if (v->n_frames & 1) { p->color = &p->foreground_color; @@ -1046,15 +959,15 @@ gst_video_test_src_solid (GstVideoTestSrc * v, unsigned char *dest, int w, int i; paintinfo pi = { NULL, }; paintinfo *p = π - struct fourcc_list_struct *fourcc; + struct format_list_struct *format; videotestsrc_setup_paintinfo (v, p, w, h); - fourcc = v->fourcc; - if (fourcc == NULL) + format = v->format; + if (format == NULL) return; - fourcc->paint_setup (p, dest); + format->paint_setup (p, dest); p->color = &p->foreground_color; @@ -1070,15 +983,15 @@ gst_video_test_src_checkers1 (GstVideoTestSrc * v, guchar * dest, int w, int h) int x, y; paintinfo pi = { NULL, }; paintinfo *p = π - struct fourcc_list_struct *fourcc; + struct format_list_struct *format; videotestsrc_setup_paintinfo (v, p, w, h); - fourcc = v->fourcc; - if (fourcc == NULL) + format = v->format; + if (format == NULL) return; - fourcc->paint_setup (p, dest); + format->paint_setup (p, dest); for (y = 0; y < h; y++) { for (x = 0; x < w; x++) { @@ -1099,14 +1012,14 @@ gst_video_test_src_checkers2 (GstVideoTestSrc * v, guchar * dest, int w, int h) int x, y; paintinfo pi = { NULL, }; paintinfo *p = π - struct fourcc_list_struct *fourcc; + struct format_list_struct *format; videotestsrc_setup_paintinfo (v, p, w, h); - fourcc = v->fourcc; - if (fourcc == NULL) + format = v->format; + if (format == NULL) return; - fourcc->paint_setup (p, dest); + format->paint_setup (p, dest); for (y = 0; y < h; y++) { for (x = 0; x < w; x += 2) { @@ -1129,14 +1042,14 @@ gst_video_test_src_checkers4 (GstVideoTestSrc * v, guchar * dest, int w, int h) int x, y; paintinfo pi = { NULL, }; paintinfo *p = π - struct fourcc_list_struct *fourcc; + struct format_list_struct *format; videotestsrc_setup_paintinfo (v, p, w, h); - fourcc = v->fourcc; - if (fourcc == NULL) + format = v->format; + if (format == NULL) return; - fourcc->paint_setup (p, dest); + format->paint_setup (p, dest); for (y = 0; y < h; y++) { for (x = 0; x < w; x += 4) { @@ -1159,14 +1072,14 @@ gst_video_test_src_checkers8 (GstVideoTestSrc * v, guchar * dest, int w, int h) int x, y; paintinfo pi = { NULL, }; paintinfo *p = π - struct fourcc_list_struct *fourcc; + struct format_list_struct *format; videotestsrc_setup_paintinfo (v, p, w, h); - fourcc = v->fourcc; - if (fourcc == NULL) + format = v->format; + if (format == NULL) return; - fourcc->paint_setup (p, dest); + format->paint_setup (p, dest); for (y = 0; y < h; y++) { for (x = 0; x < w; x += 8) { @@ -1227,7 +1140,7 @@ gst_video_test_src_zoneplate (GstVideoTestSrc * v, unsigned char *dest, int j; paintinfo pi = { NULL, }; paintinfo *p = π - struct fourcc_list_struct *fourcc; + struct format_list_struct *format; struct vts_color_struct color; int t = v->n_frames; int xreset = -(w / 2) - v->xoffset; /* starting values for x^2 and y^2, centering the ellipse */ @@ -1248,11 +1161,11 @@ gst_video_test_src_zoneplate (GstVideoTestSrc * v, unsigned char *dest, int scale_kx2 = 0xffff / w; videotestsrc_setup_paintinfo (v, p, w, h); - fourcc = v->fourcc; - if (fourcc == NULL) + format = v->format; + if (format == NULL) return; - fourcc->paint_setup (p, dest); + format->paint_setup (p, dest); color = p->colors[COLOR_BLACK]; p->color = &color; @@ -1348,7 +1261,7 @@ gst_video_test_src_chromazoneplate (GstVideoTestSrc * v, unsigned char *dest, int j; paintinfo pi = { NULL, }; paintinfo *p = π - struct fourcc_list_struct *fourcc; + struct format_list_struct *format; struct vts_color_struct color; int t = v->n_frames; @@ -1370,11 +1283,11 @@ gst_video_test_src_chromazoneplate (GstVideoTestSrc * v, unsigned char *dest, int scale_kx2 = 0xffff / w; videotestsrc_setup_paintinfo (v, p, w, h); - fourcc = v->fourcc; - if (fourcc == NULL) + format = v->format; + if (format == NULL) return; - fourcc->paint_setup (p, dest); + format->paint_setup (p, dest); color = p->colors[COLOR_BLACK]; p->color = &color; @@ -1448,17 +1361,17 @@ gst_video_test_src_circular (GstVideoTestSrc * v, unsigned char *dest, int j; paintinfo pi = { NULL, }; paintinfo *p = π - struct fourcc_list_struct *fourcc; + struct format_list_struct *format; double freq[8]; int d; videotestsrc_setup_paintinfo (v, p, w, h); - fourcc = v->fourcc; - if (fourcc == NULL) + format = v->format; + if (format == NULL) return; - fourcc->paint_setup (p, dest); + format->paint_setup (p, dest); for (i = 1; i < 8; i++) { freq[i] = 200 * pow (2.0, -(i - 1) / 4.0); @@ -1492,16 +1405,16 @@ gst_video_test_src_gamut (GstVideoTestSrc * v, guchar * dest, int w, int h) int x, y; paintinfo pi = { NULL, }; paintinfo *p = π - struct fourcc_list_struct *fourcc; + struct format_list_struct *format; struct vts_color_struct yuv_primary; struct vts_color_struct yuv_secondary; videotestsrc_setup_paintinfo (v, p, w, h); - fourcc = v->fourcc; - if (fourcc == NULL) + format = v->format; + if (format == NULL) return; - fourcc->paint_setup (p, dest); + format->paint_setup (p, dest); for (y = 0; y < h; y++) { int region = (y * 4) / h; @@ -1549,17 +1462,17 @@ gst_video_test_src_ball (GstVideoTestSrc * v, unsigned char *dest, int w, int h) int i; paintinfo pi = { NULL, }; paintinfo *p = π - struct fourcc_list_struct *fourcc; + struct format_list_struct *format; int t = v->n_frames; double x, y; int radius = 20; videotestsrc_setup_paintinfo (v, p, w, h); - fourcc = v->fourcc; - if (fourcc == NULL) + format = v->format; + if (format == NULL) return; - fourcc->paint_setup (p, dest); + format->paint_setup (p, dest); x = radius + (0.5 + 0.5 * sin (2 * G_PI * t / 200)) * (w - 2 * radius); y = radius + (0.5 + 0.5 * sin (2 * G_PI * sqrt (2) * t / 200)) * (h - diff --git a/gst/videotestsrc/videotestsrc.h b/gst/videotestsrc/videotestsrc.h index b93b704..4281c77 100644 --- a/gst/videotestsrc/videotestsrc.h +++ b/gst/videotestsrc/videotestsrc.h @@ -75,10 +75,10 @@ struct paintinfo_struct struct vts_color_struct background_color; }; -struct fourcc_list_struct +struct format_list_struct { int type; - const char *fourcc; + const char *format; const char *name; int bitspp; void (*paint_setup) (paintinfo * p, unsigned char *dest); @@ -90,14 +90,14 @@ struct fourcc_list_struct unsigned int alpha_mask; }; -struct fourcc_list_struct * - paintrect_find_fourcc (int find_fourcc); -struct fourcc_list_struct * +struct format_list_struct * + paintrect_find_format (const gchar *find_format); +struct format_list_struct * paintrect_find_name (const char *name); -struct fourcc_list_struct * +struct format_list_struct * paintinfo_find_by_structure (const GstStructure *structure); GstStructure * - paint_get_structure (struct fourcc_list_struct *format); + paint_get_structure (struct format_list_struct *format); int gst_video_test_src_get_size (GstVideoTestSrc * v, int w, int h); void gst_video_test_src_smpte (GstVideoTestSrc * v, unsigned char *dest, int w, int h); @@ -142,7 +142,7 @@ void gst_video_test_src_smpte100 (GstVideoTestSrc * v, void gst_video_test_src_bar (GstVideoTestSrc * v, unsigned char *dest, int w, int h); -extern struct fourcc_list_struct fourcc_list[]; -extern int n_fourccs; +extern struct format_list_struct format_list[]; +extern int n_formats; #endif diff --git a/sys/ximage/ximagesink.c b/sys/ximage/ximagesink.c index 070a4db..1107db0 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 b47dcde..7974a3f 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 badfb4b..0facc7b 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; -- 2.7.4