-base: port elements to new video caps

This commit is contained in:
Wim Taymans 2011-06-16 12:48:33 +02:00
parent 3b9477e173
commit d06f599193
22 changed files with 283 additions and 458 deletions

View File

@ -101,13 +101,13 @@ GType gst_visual_get_type (void);
static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src", static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC, GST_PAD_SRC,
GST_PAD_ALWAYS, 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 #if G_BYTE_ORDER == G_BIG_ENDIAN
GST_VIDEO_CAPS_RGB "; " "\"xRGB\", " "\"RGB\", "
#else #else
GST_VIDEO_CAPS_BGR "; " "\"BGRx\", " "\"BGR\", "
#endif #endif
GST_VIDEO_CAPS_RGB_16) "\"RGB16\" } "))
); );
static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink", 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)", GST_DEBUG_OBJECT (visual, "libvisual plugin supports depths %u (0x%04x)",
depths, depths); depths, depths);
/* if (depths & VISUAL_VIDEO_DEPTH_32BIT) Always supports 32bit output */ /* 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 (depths & VISUAL_VIDEO_DEPTH_24BIT) {
#if G_BYTE_ORDER == G_BIG_ENDIAN #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 #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 #endif
} }
if (depths & VISUAL_VIDEO_DEPTH_16BIT) { 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: beach:
@ -330,6 +334,7 @@ gst_visual_src_setcaps (GstVisual * visual, GstCaps * caps)
gboolean res; gboolean res;
GstStructure *structure; GstStructure *structure;
gint depth, pitch; gint depth, pitch;
const gchar *fmt;
structure = gst_caps_get_structure (caps, 0); structure = gst_caps_get_structure (caps, 0);
@ -339,12 +344,19 @@ gst_visual_src_setcaps (GstVisual * visual, GstCaps * caps)
goto error; goto error;
if (!gst_structure_get_int (structure, "height", &visual->height)) if (!gst_structure_get_int (structure, "height", &visual->height))
goto error; goto error;
if (!gst_structure_get_int (structure, "bpp", &depth)) if (!(fmt = gst_structure_get_string (structure, "format")))
goto error; goto error;
if (!gst_structure_get_fraction (structure, "framerate", &visual->fps_n, if (!gst_structure_get_fraction (structure, "framerate", &visual->fps_n,
&visual->fps_d)) &visual->fps_d))
goto error; 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_set_depth (visual->video,
visual_video_depth_enum_from_value (depth)); visual_video_depth_enum_from_value (depth));
visual_video_set_dimension (visual->video, visual->width, visual->height); 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); target = gst_caps_copy (caps);
gst_caps_unref (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 /* 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 * already fixed. For video we always try to fixate to something like
* 320x240x25 by convention. */ * 320x240x25 by convention. */
structure = gst_caps_get_structure (target, 0); 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, "width", DEFAULT_WIDTH);
gst_structure_fixate_field_nearest_int (structure, "height", DEFAULT_HEIGHT); gst_structure_fixate_field_nearest_int (structure, "height", DEFAULT_HEIGHT);
gst_structure_fixate_field_nearest_fraction (structure, "framerate", gst_structure_fixate_field_nearest_fraction (structure, "framerate",
DEFAULT_FPS_N, DEFAULT_FPS_D); 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); gst_visual_src_setcaps (visual, target);
/* try to get a bufferpool now */ /* try to get a bufferpool now */
@ -870,8 +888,8 @@ gst_visual_change_state (GstElement * element, GstStateChange transition)
switch (transition) { switch (transition) {
case GST_STATE_CHANGE_NULL_TO_READY: case GST_STATE_CHANGE_NULL_TO_READY:
visual->actor = visual->actor =
visual_actor_new (GST_VISUAL_GET_CLASS (visual)->plugin->info-> visual_actor_new (GST_VISUAL_GET_CLASS (visual)->plugin->
plugname); info->plugname);
visual->video = visual_video_new (); visual->video = visual_video_new ();
visual->audio = visual_audio_new (); visual->audio = visual_audio_new ();
/* can't have a play without actors */ /* can't have a play without actors */

View File

@ -27,7 +27,7 @@
* <refsect2> * <refsect2>
* <title>Example pipelines</title> * <title>Example pipelines</title>
* |[ * |[
* 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 * ]| Encodes a video stream captured from a v4l2-compatible camera to Ogg/Theora
* (the encoding will stop automatically after 500 frames) * (the encoding will stop automatically after 500 frames)
* </refsect2> * </refsect2>

View File

@ -192,34 +192,20 @@ enum
PROP_LAST PROP_LAST
}; };
#define VIDEO_FORMATS "{ BGRx, RGBx, xRGB, xBGR, RGBA, BGRA, ARGB, ABGR, AYUV, I420, UYVY, NV12, NV21 } "
static GstStaticPadTemplate src_template_factory = static GstStaticPadTemplate src_template_factory =
GST_STATIC_PAD_TEMPLATE ("src", GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC, GST_PAD_SRC,
GST_PAD_ALWAYS, GST_PAD_ALWAYS,
GST_STATIC_CAPS (GST_VIDEO_CAPS_BGRx ";" GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE (VIDEO_FORMATS))
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}"))
); );
static GstStaticPadTemplate video_sink_template_factory = static GstStaticPadTemplate video_sink_template_factory =
GST_STATIC_PAD_TEMPLATE ("video_sink", GST_STATIC_PAD_TEMPLATE ("video_sink",
GST_PAD_SINK, GST_PAD_SINK,
GST_PAD_ALWAYS, GST_PAD_ALWAYS,
GST_STATIC_CAPS (GST_VIDEO_CAPS_BGRx ";" GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE (VIDEO_FORMATS))
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}"))
); );
#define GST_TYPE_BASE_TEXT_OVERLAY_VALIGN (gst_base_text_overlay_valign_get_type()) #define GST_TYPE_BASE_TEXT_OVERLAY_VALIGN (gst_base_text_overlay_valign_get_type())

View File

@ -86,12 +86,13 @@ enum
PROP_FONT_DESC PROP_FONT_DESC
}; };
#define VIDEO_FORMATS "{ AYUV, ARGB } "
static GstStaticPadTemplate src_template_factory = static GstStaticPadTemplate src_template_factory =
GST_STATIC_PAD_TEMPLATE ("src", GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC, GST_PAD_SRC,
GST_PAD_ALWAYS, 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 = static GstStaticPadTemplate sink_template_factory =
@ -326,19 +327,20 @@ gst_text_render_check_argb (GstTextRender * render)
/* Check if AYUV or ARGB is first */ /* Check if AYUV or ARGB is first */
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
GstStructure *s = gst_caps_get_structure (peer_caps, i); GstStructure *s;
if (gst_structure_has_name (s, "video/x-raw-rgb") && GstVideoFormat vformat;
gst_structure_has_field (s, "alpha_mask")) { const gchar *fmt;
render->use_ARGB = TRUE;
break; s = gst_caps_get_structure (peer_caps, i);
} else if (gst_structure_has_name (s, "video/x-raw-yuv")) { if (!gst_structure_has_name (s, "video/x-raw"))
guint fourcc; continue;
if (gst_structure_get_fourcc (s, "format", &fourcc) &&
fourcc == GST_MAKE_FOURCC ('A', 'Y', 'U', 'V')) { fmt = gst_structure_get_string (s, "format");
render->use_ARGB = FALSE; if (fmt == NULL)
break; continue;
}
} vformat = gst_video_format_from_string (fmt);
render->use_ARGB = gst_video_format_has_alpha (vformat);
} }
gst_caps_unref (peer_caps); gst_caps_unref (peer_caps);
} }

View File

@ -68,8 +68,8 @@ static GstStaticPadTemplate theora_dec_src_factory =
GST_STATIC_PAD_TEMPLATE ("src", GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC, GST_PAD_SRC,
GST_PAD_ALWAYS, GST_PAD_ALWAYS,
GST_STATIC_CAPS ("video/x-raw-yuv, " GST_STATIC_CAPS ("video/x-raw, "
"format = (fourcc) { I420, Y42B, Y444 }, " "format = (string) { I420, Y42B, Y444 }, "
"framerate = (fraction) [0/1, MAX], " "framerate = (fraction) [0/1, MAX], "
"width = (int) [ 1, MAX ], " "height = (int) [ 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; gint par_num, par_den;
GstFlowReturn ret = GST_FLOW_OK; GstFlowReturn ret = GST_FLOW_OK;
GList *walk; GList *walk;
guint32 fourcc;
GST_DEBUG_OBJECT (dec, "fps %d/%d, PAR %d/%d", GST_DEBUG_OBJECT (dec, "fps %d/%d, PAR %d/%d",
dec->info.fps_numerator, dec->info.fps_denominator, 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: case TH_PF_444:
dec->output_bpp = 24; dec->output_bpp = 24;
dec->format = GST_VIDEO_FORMAT_Y444; dec->format = GST_VIDEO_FORMAT_Y444;
fourcc = GST_MAKE_FOURCC ('Y', '4', '4', '4');
break; break;
case TH_PF_420: case TH_PF_420:
dec->output_bpp = 12; /* Average bits per pixel. */ dec->output_bpp = 12; /* Average bits per pixel. */
dec->format = GST_VIDEO_FORMAT_I420; dec->format = GST_VIDEO_FORMAT_I420;
fourcc = GST_MAKE_FOURCC ('I', '4', '2', '0');
break; break;
case TH_PF_422: case TH_PF_422:
dec->output_bpp = 16; dec->output_bpp = 16;
dec->format = GST_VIDEO_FORMAT_Y42B; dec->format = GST_VIDEO_FORMAT_Y42B;
fourcc = GST_MAKE_FOURCC ('Y', '4', '2', 'B');
break; break;
default: default:
goto invalid_format; 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"); GST_WARNING_OBJECT (dec, "Could not enable BITS mode visualisation");
} }
caps = gst_caps_new_simple ("video/x-raw-yuv", caps = gst_caps_new_simple ("video/x-raw",
"format", GST_TYPE_FOURCC, fourcc, "format", G_TYPE_STRING, gst_video_format_to_string (dec->format),
"framerate", GST_TYPE_FRACTION, "framerate", GST_TYPE_FRACTION,
dec->info.fps_numerator, dec->info.fps_denominator, dec->info.fps_numerator, dec->info.fps_denominator,
"pixel-aspect-ratio", GST_TYPE_FRACTION, par_num, par_den, "pixel-aspect-ratio", GST_TYPE_FRACTION, par_num, par_den,

View File

@ -230,8 +230,8 @@ static GstStaticPadTemplate theora_enc_sink_factory =
GST_STATIC_PAD_TEMPLATE ("sink", GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK, GST_PAD_SINK,
GST_PAD_ALWAYS, GST_PAD_ALWAYS,
GST_STATIC_CAPS ("video/x-raw-yuv, " GST_STATIC_CAPS ("video/x-raw, "
"format = (fourcc) { I420, Y42B, Y444 }, " "format = (string) { I420, Y42B, Y444 }, "
"framerate = (fraction) [1/MAX, MAX], " "framerate = (fraction) [1/MAX, MAX], "
"width = (int) [ 1, MAX ], " "height = (int) [ 1, 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", "encode raw YUV video to a theora stream",
"Wim Taymans <wim@fluendo.com>"); "Wim Taymans <wim@fluendo.com>");
caps_string = g_strdup_printf ("video/x-raw-yuv, " caps_string = g_strdup_printf ("video/x-raw, "
"format = (fourcc) { %s }, " "format = (string) { %s }, "
"framerate = (fraction) [1/MAX, MAX], " "framerate = (fraction) [1/MAX, MAX], "
"width = (int) [ 1, MAX ], " "height = (int) [ 1, MAX ]", "width = (int) [ 1, MAX ], " "height = (int) [ 1, MAX ]",
theora_enc_get_supported_formats ()); theora_enc_get_supported_formats ());
@ -620,7 +620,7 @@ theora_enc_sink_getcaps (GstPad * pad, GstCaps * filter)
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
s = gst_caps_get_structure (peer_caps, 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"); gst_structure_remove_field (s, "streamheader");
} }

View File

@ -218,9 +218,7 @@ struct _StreamGroup
#define DEFAULT_AVOID_REENCODING FALSE #define DEFAULT_AVOID_REENCODING FALSE
#define DEFAULT_RAW_CAPS \ #define DEFAULT_RAW_CAPS \
"video/x-raw-yuv; " \ "video/x-raw; " \
"video/x-raw-rgb; " \
"video/x-raw-gray; " \
"audio/x-raw-int; " \ "audio/x-raw-int; " \
"audio/x-raw-float; " \ "audio/x-raw-float; " \
"text/plain; " \ "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_element_factory_list_get_elements (GST_ELEMENT_FACTORY_TYPE_PARSER,
GST_RANK_MARGINAL); GST_RANK_MARGINAL);
encode_bin->raw_video_caps = encode_bin->raw_video_caps = gst_caps_from_string ("video/x-raw");
gst_caps_from_string ("video/x-raw-yuv;video/x-raw-rgb;video/x-raw-gray");
encode_bin->raw_audio_caps = encode_bin->raw_audio_caps =
gst_caps_from_string ("audio/x-raw-int;audio/x-raw-float"); gst_caps_from_string ("audio/x-raw-int;audio/x-raw-float");
/* encode_bin->raw_text_caps = */ /* encode_bin->raw_text_caps = */

View File

@ -3038,7 +3038,7 @@ sort_end_pads (GstDecodePad * da, GstDecodePad * db)
namea = gst_structure_get_name (sa); namea = gst_structure_get_name (sa);
nameb = gst_structure_get_name (sb); nameb = gst_structure_get_name (sb);
if (g_strrstr (namea, "video/x-raw-")) if (g_strrstr (namea, "video/x-raw"))
va = 0; va = 0;
else if (g_strrstr (namea, "video/")) else if (g_strrstr (namea, "video/"))
va = 1; va = 1;
@ -3049,7 +3049,7 @@ sort_end_pads (GstDecodePad * da, GstDecodePad * db)
else else
va = 4; va = 4;
if (g_strrstr (nameb, "video/x-raw-")) if (g_strrstr (nameb, "video/x-raw"))
vb = 0; vb = 0;
else if (g_strrstr (nameb, "video/")) else if (g_strrstr (nameb, "video/"))
vb = 1; vb = 1;

View File

@ -2818,8 +2818,8 @@ is_raw_structure (GstStructure * s)
name = gst_structure_get_name (s); name = gst_structure_get_name (s);
if (g_str_has_prefix (name, "video/x-raw-") || if (g_str_has_prefix (name, "video/x-raw") ||
g_str_has_prefix (name, "audio/x-raw-")) g_str_has_prefix (name, "audio/x-raw"))
return TRUE; return TRUE;
return FALSE; return FALSE;
} }

View File

@ -255,7 +255,7 @@ gst_play_sink_audio_convert_sink_setcaps (GstPlaySinkAudioConvert * self,
s = gst_caps_get_structure (caps, 0); s = gst_caps_get_structure (caps, 0);
name = gst_structure_get_name (s); 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)) { if (!self->raw && !gst_pad_is_blocked (self->sink_proxypad)) {
GST_DEBUG_OBJECT (self, "Changing caps from non-raw to raw"); GST_DEBUG_OBJECT (self, "Changing caps from non-raw to raw");
reconfigure = TRUE; reconfigure = TRUE;

View File

@ -236,7 +236,7 @@ gst_play_sink_video_convert_sink_setcaps (GstPlaySinkVideoConvert * self,
s = gst_caps_get_structure (caps, 0); s = gst_caps_get_structure (caps, 0);
name = gst_structure_get_name (s); 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)) { if (!self->raw && !gst_pad_is_blocked (self->sink_proxypad)) {
GST_DEBUG_OBJECT (self, "Changing caps from non-raw to raw"); GST_DEBUG_OBJECT (self, "Changing caps from non-raw to raw");
reconfigure = TRUE; reconfigure = TRUE;

View File

@ -26,9 +26,7 @@
G_BEGIN_DECLS G_BEGIN_DECLS
#define DEFAULT_RAW_CAPS \ #define DEFAULT_RAW_CAPS \
"video/x-raw-yuv; " \ "video/x-raw; " \
"video/x-raw-rgb; " \
"video/x-raw-gray; " \
"audio/x-raw-int; " \ "audio/x-raw-int; " \
"audio/x-raw-float; " \ "audio/x-raw-float; " \
"text/plain; " \ "text/plain; " \

View File

@ -23,12 +23,12 @@
/** /**
* SECTION:element-videoconvert * SECTION:element-videoconvert
* *
* Convert video frames between a great variety of videoconvert formats. * Convert video frames between a great variety of video formats.
* *
* <refsect2> * <refsect2>
* <title>Example launch line</title> * <title>Example launch line</title>
* |[ * |[
* 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
* ]| * ]|
* </refsect2> * </refsect2>
*/ */
@ -52,30 +52,7 @@ enum
PROP_DITHER PROP_DITHER
}; };
#define CSP_VIDEO_CAPS \ #define CSP_VIDEO_CAPS GST_VIDEO_CAPS_MAKE (GST_VIDEO_FORMATS_ALL)
"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
static GstStaticPadTemplate gst_video_convert_src_template = static GstStaticPadTemplate gst_video_convert_src_template =
GST_STATIC_PAD_TEMPLATE ("src", 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, static GstFlowReturn gst_video_convert_transform (GstBaseTransform * btrans,
GstBuffer * inbuf, GstBuffer * outbuf); 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 static GType
dither_method_get_type (void) dither_method_get_type (void)
{ {
@ -132,7 +104,7 @@ dither_method_get_type (void)
static GstCaps * static GstCaps *
gst_video_convert_caps_remove_format_info (GstCaps * caps) gst_video_convert_caps_remove_format_info (GstCaps * caps)
{ {
GstStructure *yuvst, *rgbst, *grayst; GstStructure *st;
gint i, n; gint i, n;
GstCaps *res; GstCaps *res;
@ -140,29 +112,18 @@ gst_video_convert_caps_remove_format_info (GstCaps * caps)
n = gst_caps_get_size (caps); n = gst_caps_get_size (caps);
for (i = 0; i < n; i++) { 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 /* If this is already expressed by the existing caps
* skip this structure */ * skip this structure */
if (i > 0 && gst_caps_is_subset_structure (res, yuvst)) if (i > 0 && gst_caps_is_subset_structure (res, st))
continue; continue;
yuvst = gst_structure_copy (yuvst); st = gst_structure_copy (st);
gst_structure_set_name (yuvst, "video/x-raw-yuv"); gst_structure_remove_fields (st, "format", "palette_data",
gst_structure_remove_fields (yuvst, "format", "endianness", "depth", "color-matrix", "chroma-site", NULL);
"bpp", "red_mask", "green_mask", "blue_mask", "alpha_mask",
"palette_data", NULL);
rgbst = gst_structure_copy (yuvst); gst_caps_append_structure (res, st);
gst_structure_set_name (rgbst, "video/x-raw-rgb");
gst_structure_remove_fields (rgbst, "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);
} }
return res; return res;
@ -413,10 +374,6 @@ gst_video_convert_class_init (GstVideoConvertClass * klass)
"Converts video from one colorspace to another", "Converts video from one colorspace to another",
"GStreamer maintainers <gstreamer-devel@lists.sourceforge.net>"); "GStreamer maintainers <gstreamer-devel@lists.sourceforge.net>");
_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 = gstbasetransform_class->transform_caps =
GST_DEBUG_FUNCPTR (gst_video_convert_transform_caps); GST_DEBUG_FUNCPTR (gst_video_convert_transform_caps);
gstbasetransform_class->set_caps = gstbasetransform_class->set_caps =

View File

@ -55,11 +55,11 @@
* <refsect2> * <refsect2>
* <title>Example pipelines</title> * <title>Example pipelines</title>
* |[ * |[
* 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. * ]| 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. * 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 * ]| Capture video from a V4L device, and adjust the stream to 12.5 fps before
* encoding to Ogg/Theora. * encoding to Ogg/Theora.
* </refsect2> * </refsect2>
@ -108,16 +108,14 @@ static GstStaticPadTemplate gst_video_rate_src_template =
GST_STATIC_PAD_TEMPLATE ("src", GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC, GST_PAD_SRC,
GST_PAD_ALWAYS, GST_PAD_ALWAYS,
GST_STATIC_CAPS ("video/x-raw-yuv;" GST_STATIC_CAPS ("video/x-raw;" "image/jpeg;" "image/png")
"video/x-raw-rgb;" "video/x-raw-gray;" "image/jpeg;" "image/png")
); );
static GstStaticPadTemplate gst_video_rate_sink_template = static GstStaticPadTemplate gst_video_rate_sink_template =
GST_STATIC_PAD_TEMPLATE ("sink", GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK, GST_PAD_SINK,
GST_PAD_ALWAYS, GST_PAD_ALWAYS,
GST_STATIC_CAPS ("video/x-raw-yuv;" GST_STATIC_CAPS ("video/x-raw;" "image/jpeg;" "image/png")
"video/x-raw-rgb;" "video/x-raw-gray;" "image/jpeg;" "image/png")
); );
static void gst_video_rate_swap_prev (GstVideoRate * videorate, static void gst_video_rate_swap_prev (GstVideoRate * videorate,

View File

@ -20,7 +20,7 @@
/** /**
* SECTION:element-videoscale * SECTION:element-videoscale
* @see_also: videorate, ffmpegcolorspace * @see_also: videorate, videoconvert
* *
* This element resizes video frames. By default the element will try to * 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 * negotiate to the same size on the source and sinkpad so that no scaling
@ -34,13 +34,13 @@
* <refsect2> * <refsect2>
* <title>Example pipelines</title> * <title>Example pipelines</title>
* |[ * |[
* 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 * ]| Decode an Ogg/Theora and display the video using ximagesink. Since
* ximagesink cannot perform scaling, the video scaling will be performed by * ximagesink cannot perform scaling, the video scaling will be performed by
* videoscale when you resize the video window. * videoscale when you resize the video window.
* To create the test Ogg/Theora file refer to the documentation of theoraenc. * 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 * ]| Decode an Ogg/Theora and display the video using xvimagesink with a width
* of 50. * of 50.
* </refsect2> * </refsect2>
@ -101,37 +101,14 @@ enum
#undef GST_VIDEO_SIZE_RANGE #undef GST_VIDEO_SIZE_RANGE
#define GST_VIDEO_SIZE_RANGE "(int) [ 1, 32767]" #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[] = { static GstStaticCaps gst_video_scale_format_caps[] = {
GST_STATIC_CAPS (GST_VIDEO_CAPS_RGBA), GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE (GST_VIDEO_FORMATS))
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)
}; };
#define GST_TYPE_VIDEO_SCALE_METHOD (gst_video_scale_method_get_type()) #define GST_TYPE_VIDEO_SCALE_METHOD (gst_video_scale_method_get_type())

View File

@ -575,8 +575,8 @@ gst_video_test_src_getcaps (GstBaseSrc * bsrc, GstCaps * filter)
int i; int i;
caps = gst_caps_new_empty (); caps = gst_caps_new_empty ();
for (i = 0; i < n_fourccs; i++) { for (i = 0; i < n_formats; i++) {
structure = paint_get_structure (fourcc_list + i); structure = paint_get_structure (format_list + i);
gst_structure_set (structure, gst_structure_set (structure,
"width", GST_TYPE_INT_RANGE, 1, G_MAXINT, "width", GST_TYPE_INT_RANGE, 1, G_MAXINT,
"height", 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 static gboolean
gst_video_test_src_parse_caps (const GstCaps * caps, gst_video_test_src_parse_caps (const GstCaps * caps,
gint * width, gint * height, gint * rate_numerator, gint * rate_denominator, 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; const GstStructure *structure;
GstPadLinkReturn ret; GstPadLinkReturn ret;
@ -610,7 +610,7 @@ gst_video_test_src_parse_caps (const GstCaps * caps,
structure = gst_caps_get_structure (caps, 0); structure = gst_caps_get_structure (caps, 0);
if (!(*fourcc = paintinfo_find_by_structure (structure))) if (!(*format = paintinfo_find_by_structure (structure)))
goto unknown_format; goto unknown_format;
ret = gst_structure_get_int (structure, "width", width); ret = gst_structure_get_int (structure, "width", width);
@ -678,24 +678,24 @@ gst_video_test_src_setcaps (GstBaseSrc * bsrc, GstCaps * caps)
{ {
gboolean res; gboolean res;
gint width, height, rate_denominator, rate_numerator; gint width, height, rate_denominator, rate_numerator;
struct fourcc_list_struct *fourcc; struct format_list_struct *format;
GstVideoTestSrc *videotestsrc; GstVideoTestSrc *videotestsrc;
GstVideoTestSrcColorSpec color_spec; GstVideoTestSrcColorSpec color_spec;
videotestsrc = GST_VIDEO_TEST_SRC (bsrc); videotestsrc = GST_VIDEO_TEST_SRC (bsrc);
res = gst_video_test_src_parse_caps (caps, &width, &height, 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) if (!res)
goto parse_failed; goto parse_failed;
/* looks ok here */ /* looks ok here */
videotestsrc->fourcc = fourcc; videotestsrc->format = format;
videotestsrc->width = width; videotestsrc->width = width;
videotestsrc->height = height; videotestsrc->height = height;
videotestsrc->rate_numerator = rate_numerator; videotestsrc->rate_numerator = rate_numerator;
videotestsrc->rate_denominator = rate_denominator; videotestsrc->rate_denominator = rate_denominator;
videotestsrc->bpp = videotestsrc->fourcc->bitspp; videotestsrc->bpp = videotestsrc->format->bitspp;
videotestsrc->color_spec = color_spec; videotestsrc->color_spec = color_spec;
videotestsrc->size = videotestsrc->size =
gst_video_test_src_get_size (videotestsrc, width, height); 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); src = GST_VIDEO_TEST_SRC (psrc);
if (G_UNLIKELY (src->fourcc == NULL)) if (G_UNLIKELY (src->format == NULL))
goto not_negotiated; goto not_negotiated;
/* 0 framerate and we are at the second frame, eos */ /* 0 framerate and we are at the second frame, eos */

View File

@ -138,7 +138,7 @@ struct _GstVideoTestSrc {
char *format_name; char *format_name;
gint width; gint width;
gint height; gint height;
struct fourcc_list_struct *fourcc; struct format_list_struct *format;
gint bpp; gint bpp;
gint rate_numerator; gint rate_numerator;
gint rate_denominator; gint rate_denominator;

View File

@ -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_GRAY8 (paintinfo * p, int y);
static void convert_hline_GRAY16 (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 */ /* packed */
{VTS_YUV, "YUY2", "YUY2", 16, paint_setup_YUY2, convert_hline_YUY2}, {VTS_YUV, "YUY2", "YUY2", 16, paint_setup_YUY2, convert_hline_YUY2},
{VTS_YUV, "UYVY", "UYVY", 16, paint_setup_UYVY, 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 */ /* Not exactly YUV but it's the same as above */
{VTS_GRAY, "GRAY8", "GRAY8", 8, paint_setup_GRAY8, convert_hline_GRAY8}, {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, 24,
0x00ff0000, 0x0000ff00, 0x000000ff}, 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, 24,
0x000000ff, 0x0000ff00, 0x00ff0000}, 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, 24,
0xff000000, 0x00ff0000, 0x0000ff00}, 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, 24,
0x0000ff00, 0x00ff0000, 0xff000000}, 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, 32,
0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000}, 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, 32,
0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000}, 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, 32,
0xff000000, 0x00ff0000, 0x0000ff00, 0x000000ff}, 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, 32,
0x0000ff00, 0x00ff0000, 0xff000000, 0x000000ff}, 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}, 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}, 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}, 0x0000f800, 0x000007e0, 0x0000001f},
{VTS_RGB, "RGB ", "xRGB1555", 16, paint_setup_xRGB1555, {VTS_RGB, "RGB15", "xRGB1555", 16, paint_setup_xRGB1555,
convert_hline_xRGB1555, convert_hline_xRGB1555,
15, 15,
0x00007c00, 0x000003e0, 0x0000001f}, 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, 64,
0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000}, 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} {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) paintinfo_find_by_structure (const GstStructure * structure)
{ {
int i; int i;
const char *media_type = gst_structure_get_name (structure); const char *media_type = gst_structure_get_name (structure);
int ret;
g_return_val_if_fail (structure, NULL); g_return_val_if_fail (structure, NULL);
if (strcmp (media_type, "video/x-raw-gray") == 0) { if (strcmp (media_type, "video/x-raw") == 0) {
gint bpp, depth, endianness = 0; const gchar *format;
ret = gst_structure_get_int (structure, "bpp", &bpp) && format = gst_structure_get_string (structure, "format");
gst_structure_get_int (structure, "depth", &depth); if (!format) {
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 (!ret) {
GST_WARNING ("incomplete caps structure: %" GST_PTR_FORMAT, structure); GST_WARNING ("incomplete caps structure: %" GST_PTR_FORMAT, structure);
return NULL; return NULL;
} }
for (i = 0; i < n_fourccs; i++) { for (i = 0; i < n_formats; i++) {
if (fourcc_list[i].type == VTS_RGB && if (g_str_equal (format, format_list[i].format)) {
fourcc_list[i].red_mask == red_mask && return format_list + i;
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;
} }
} }
return NULL; return NULL;
@ -391,10 +341,10 @@ paintinfo_find_by_structure (const GstStructure * structure)
return NULL; return NULL;
} }
for (i = 0; i < n_fourccs; i++) { for (i = 0; i < n_formats; i++) {
if (fourcc_list[i].type == VTS_BAYER && if (format_list[i].type == VTS_BAYER &&
g_str_equal (format, fourcc_list[i].fourcc)) { g_str_equal (format, format_list[i].format)) {
return fourcc_list + i; return format_list + i;
} }
} }
return NULL; return NULL;
@ -405,37 +355,27 @@ paintinfo_find_by_structure (const GstStructure * structure)
return NULL; return NULL;
} }
struct fourcc_list_struct * struct format_list_struct *
paintrect_find_fourcc (int find_fourcc) paintrect_find_format (const gchar * find_format)
{ {
int i; int i;
for (i = 0; i < n_fourccs; i++) { for (i = 0; i < n_formats; i++) {
const char *s; if (strcmp (find_format, format_list[i].format) == 0) {
int fourcc; return format_list + i;
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;
} }
} }
return NULL; return NULL;
} }
struct fourcc_list_struct * struct format_list_struct *
paintrect_find_name (const char *name) paintrect_find_name (const char *name)
{ {
int i; int i;
for (i = 0; i < n_fourccs; i++) { for (i = 0; i < n_formats; i++) {
if (strcmp (name, fourcc_list[i].name) == 0) { if (strcmp (name, format_list[i].name) == 0) {
return fourcc_list + i; return format_list + i;
} }
} }
return NULL; return NULL;
@ -443,54 +383,27 @@ paintrect_find_name (const char *name)
GstStructure * GstStructure *
paint_get_structure (struct fourcc_list_struct * format) paint_get_structure (struct format_list_struct * format)
{ {
GstStructure *structure = NULL; GstStructure *structure = NULL;
unsigned int fourcc;
int endianness;
g_return_val_if_fail (format, NULL); 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) { switch (format->type) {
case VTS_RGB: 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: case VTS_GRAY:
structure = gst_structure_new ("video/x-raw-gray", structure = gst_structure_new ("video/x-raw",
"bpp", G_TYPE_INT, format->bitspp, "depth", G_TYPE_INT, "format", G_TYPE_STRING, format->format, NULL);
format->bitspp, NULL);
if (format->bitspp == 16)
gst_structure_set (structure, "endianness", G_TYPE_INT, G_BYTE_ORDER,
NULL);
break; break;
case VTS_YUV: case VTS_YUV:
{ {
GValue value_list = { 0 }; GValue value_list = { 0 };
GValue value = { 0 }; GValue value = { 0 };
structure = gst_structure_new ("video/x-raw-yuv", structure = gst_structure_new ("video/x-raw",
"format", GST_TYPE_FOURCC, fourcc, NULL); "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_list, GST_TYPE_LIST);
g_value_init (&value, G_TYPE_STRING); 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); gst_structure_set_value (structure, "color-matrix", &value_list);
g_value_reset (&value_list); g_value_reset (&value_list);
if (fourcc != GST_STR_FOURCC ("AYUV") && if (strcmp (format->format, "AYUV") &&
fourcc != GST_STR_FOURCC ("v308") && strcmp (format->format, "v308") &&
fourcc != GST_STR_FOURCC ("v410") && strcmp (format->format, "v410") &&
fourcc != GST_STR_FOURCC ("Y444")) { strcmp (format->format, "Y444")) {
g_value_set_static_string (&value, "mpeg2"); g_value_set_static_string (&value, "mpeg2");
gst_value_list_append_value (&value_list, &value); gst_value_list_append_value (&value_list, &value);
@ -521,7 +434,7 @@ paint_get_structure (struct fourcc_list_struct * format)
break; break;
case VTS_BAYER: case VTS_BAYER:
structure = gst_structure_new ("video/x-raw-bayer", structure = gst_structure_new ("video/x-raw-bayer",
"format", G_TYPE_STRING, format->fourcc, NULL); "format", G_TYPE_STRING, format->format, NULL);
break; break;
default: default:
g_assert_not_reached (); 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 /* returns the size in bytes for one video frame of the given dimensions
* given the fourcc in GstVideoTestSrc */ * given the format in GstVideoTestSrc */
int int
gst_video_test_src_get_size (GstVideoTestSrc * v, int w, int h) gst_video_test_src_get_size (GstVideoTestSrc * v, int w, int h)
{ {
paintinfo pi = { NULL, }; paintinfo pi = { NULL, };
paintinfo *p = &pi; paintinfo *p = &pi;
struct fourcc_list_struct *fourcc; struct format_list_struct *format;
p->width = w; p->width = w;
p->height = h; p->height = h;
fourcc = v->fourcc; format = v->format;
if (fourcc == NULL) if (format == NULL)
return 0; return 0;
fourcc->paint_setup (p, NULL); format->paint_setup (p, NULL);
return (unsigned long) p->endptr; return (unsigned long) p->endptr;
} }
@ -603,8 +516,8 @@ videotestsrc_setup_paintinfo (GstVideoTestSrc * v, paintinfo * p, int w, int h)
p->width = w; p->width = w;
p->height = h; p->height = h;
p->convert_tmpline = v->fourcc->convert_hline; p->convert_tmpline = v->format->convert_hline;
if (v->fourcc->type == VTS_RGB || v->fourcc->type == VTS_BAYER) { if (v->format->type == VTS_RGB || v->format->type == VTS_BAYER) {
p->paint_tmpline = paint_tmpline_ARGB; p->paint_tmpline = paint_tmpline_ARGB;
} else { } else {
p->paint_tmpline = paint_tmpline_AYUV; 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) struct vts_color_struct *a, struct vts_color_struct *b, int n)
{ {
int i; 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++) { for (i = 0; i < n; i++) {
dest[i * 4 + 0] = BLEND (a->A, b->A, src[i]); dest[i * 4 + 0] = BLEND (a->A, b->A, src[i]);
dest[i * 4 + 1] = BLEND (a->R, b->R, 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; int j;
paintinfo pi = { NULL, }; paintinfo pi = { NULL, };
paintinfo *p = &pi; paintinfo *p = &pi;
struct fourcc_list_struct *fourcc; struct format_list_struct *format;
videotestsrc_setup_paintinfo (v, p, w, h); videotestsrc_setup_paintinfo (v, p, w, h);
fourcc = v->fourcc; format = v->format;
if (fourcc == NULL) if (format == NULL)
return; return;
fourcc->paint_setup (p, dest); format->paint_setup (p, dest);
y1 = 2 * h / 3; y1 = 2 * h / 3;
y2 = h * 0.75; y2 = h * 0.75;
@ -835,7 +748,7 @@ gst_video_test_src_smpte75 (GstVideoTestSrc * v, unsigned char *dest, int w,
int j; int j;
paintinfo pi = { NULL, }; paintinfo pi = { NULL, };
paintinfo *p = &pi; paintinfo *p = &pi;
struct fourcc_list_struct *fourcc; struct format_list_struct *format;
videotestsrc_setup_paintinfo (v, p, w, h); videotestsrc_setup_paintinfo (v, p, w, h);
if (v->color_spec == GST_VIDEO_TEST_SRC_BT601) { 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 { } else {
p->colors = vts_colors_bt709_ycbcr_75; p->colors = vts_colors_bt709_ycbcr_75;
} }
fourcc = v->fourcc; format = v->format;
if (fourcc == NULL) if (format == NULL)
return; return;
fourcc->paint_setup (p, dest); format->paint_setup (p, dest);
/* color bars */ /* color bars */
for (j = 0; j < h; j++) { for (j = 0; j < h; j++) {
@ -870,14 +783,14 @@ gst_video_test_src_smpte100 (GstVideoTestSrc * v, unsigned char *dest, int w,
int j; int j;
paintinfo pi = { NULL, }; paintinfo pi = { NULL, };
paintinfo *p = &pi; paintinfo *p = &pi;
struct fourcc_list_struct *fourcc; struct format_list_struct *format;
videotestsrc_setup_paintinfo (v, p, w, h); videotestsrc_setup_paintinfo (v, p, w, h);
fourcc = v->fourcc; format = v->format;
if (fourcc == NULL) if (format == NULL)
return; return;
fourcc->paint_setup (p, dest); format->paint_setup (p, dest);
/* color bars */ /* color bars */
for (j = 0; j < h; j++) { 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; int j;
paintinfo pi = { NULL, }; paintinfo pi = { NULL, };
paintinfo *p = &pi; paintinfo *p = &pi;
struct fourcc_list_struct *fourcc; struct format_list_struct *format;
videotestsrc_setup_paintinfo (v, p, w, h); videotestsrc_setup_paintinfo (v, p, w, h);
fourcc = v->fourcc; format = v->format;
if (fourcc == NULL) if (format == NULL)
return; return;
fourcc->paint_setup (p, dest); format->paint_setup (p, dest);
for (j = 0; j < h; j++) { for (j = 0; j < h; j++) {
/* use fixed size for now */ /* 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; int j;
paintinfo pi = { NULL, }; paintinfo pi = { NULL, };
paintinfo *p = &pi; paintinfo *p = &pi;
struct fourcc_list_struct *fourcc; struct format_list_struct *format;
struct vts_color_struct color; struct vts_color_struct color;
videotestsrc_setup_paintinfo (v, p, w, h); videotestsrc_setup_paintinfo (v, p, w, h);
fourcc = v->fourcc; format = v->format;
if (fourcc == NULL) if (format == NULL)
return; return;
fourcc->paint_setup (p, dest); format->paint_setup (p, dest);
color = p->colors[COLOR_BLACK]; color = p->colors[COLOR_BLACK];
p->color = &color; p->color = &color;
@ -957,14 +870,14 @@ gst_video_test_src_unicolor (GstVideoTestSrc * v, unsigned char *dest, int w,
int i; int i;
paintinfo pi = { NULL, }; paintinfo pi = { NULL, };
paintinfo *p = &pi; paintinfo *p = &pi;
struct fourcc_list_struct *fourcc; struct format_list_struct *format;
videotestsrc_setup_paintinfo (v, p, w, h); videotestsrc_setup_paintinfo (v, p, w, h);
fourcc = v->fourcc; format = v->format;
if (fourcc == NULL) if (format == NULL)
return; return;
fourcc->paint_setup (p, dest); format->paint_setup (p, dest);
p->color = p->colors + color_index; p->color = p->colors + color_index;
if (color_index == COLOR_BLACK) { if (color_index == COLOR_BLACK) {
@ -1017,15 +930,15 @@ gst_video_test_src_blink (GstVideoTestSrc * v, unsigned char *dest, int w,
int i; int i;
paintinfo pi = { NULL, }; paintinfo pi = { NULL, };
paintinfo *p = &pi; paintinfo *p = &pi;
struct fourcc_list_struct *fourcc; struct format_list_struct *format;
videotestsrc_setup_paintinfo (v, p, w, h); videotestsrc_setup_paintinfo (v, p, w, h);
fourcc = v->fourcc; format = v->format;
if (fourcc == NULL) if (format == NULL)
return; return;
fourcc->paint_setup (p, dest); format->paint_setup (p, dest);
if (v->n_frames & 1) { if (v->n_frames & 1) {
p->color = &p->foreground_color; p->color = &p->foreground_color;
@ -1046,15 +959,15 @@ gst_video_test_src_solid (GstVideoTestSrc * v, unsigned char *dest, int w,
int i; int i;
paintinfo pi = { NULL, }; paintinfo pi = { NULL, };
paintinfo *p = &pi; paintinfo *p = &pi;
struct fourcc_list_struct *fourcc; struct format_list_struct *format;
videotestsrc_setup_paintinfo (v, p, w, h); videotestsrc_setup_paintinfo (v, p, w, h);
fourcc = v->fourcc; format = v->format;
if (fourcc == NULL) if (format == NULL)
return; return;
fourcc->paint_setup (p, dest); format->paint_setup (p, dest);
p->color = &p->foreground_color; 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; int x, y;
paintinfo pi = { NULL, }; paintinfo pi = { NULL, };
paintinfo *p = &pi; paintinfo *p = &pi;
struct fourcc_list_struct *fourcc; struct format_list_struct *format;
videotestsrc_setup_paintinfo (v, p, w, h); videotestsrc_setup_paintinfo (v, p, w, h);
fourcc = v->fourcc; format = v->format;
if (fourcc == NULL) if (format == NULL)
return; return;
fourcc->paint_setup (p, dest); format->paint_setup (p, dest);
for (y = 0; y < h; y++) { for (y = 0; y < h; y++) {
for (x = 0; x < w; x++) { 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; int x, y;
paintinfo pi = { NULL, }; paintinfo pi = { NULL, };
paintinfo *p = &pi; paintinfo *p = &pi;
struct fourcc_list_struct *fourcc; struct format_list_struct *format;
videotestsrc_setup_paintinfo (v, p, w, h); videotestsrc_setup_paintinfo (v, p, w, h);
fourcc = v->fourcc; format = v->format;
if (fourcc == NULL) if (format == NULL)
return; return;
fourcc->paint_setup (p, dest); format->paint_setup (p, dest);
for (y = 0; y < h; y++) { for (y = 0; y < h; y++) {
for (x = 0; x < w; x += 2) { 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; int x, y;
paintinfo pi = { NULL, }; paintinfo pi = { NULL, };
paintinfo *p = &pi; paintinfo *p = &pi;
struct fourcc_list_struct *fourcc; struct format_list_struct *format;
videotestsrc_setup_paintinfo (v, p, w, h); videotestsrc_setup_paintinfo (v, p, w, h);
fourcc = v->fourcc; format = v->format;
if (fourcc == NULL) if (format == NULL)
return; return;
fourcc->paint_setup (p, dest); format->paint_setup (p, dest);
for (y = 0; y < h; y++) { for (y = 0; y < h; y++) {
for (x = 0; x < w; x += 4) { 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; int x, y;
paintinfo pi = { NULL, }; paintinfo pi = { NULL, };
paintinfo *p = &pi; paintinfo *p = &pi;
struct fourcc_list_struct *fourcc; struct format_list_struct *format;
videotestsrc_setup_paintinfo (v, p, w, h); videotestsrc_setup_paintinfo (v, p, w, h);
fourcc = v->fourcc; format = v->format;
if (fourcc == NULL) if (format == NULL)
return; return;
fourcc->paint_setup (p, dest); format->paint_setup (p, dest);
for (y = 0; y < h; y++) { for (y = 0; y < h; y++) {
for (x = 0; x < w; x += 8) { for (x = 0; x < w; x += 8) {
@ -1227,7 +1140,7 @@ gst_video_test_src_zoneplate (GstVideoTestSrc * v, unsigned char *dest,
int j; int j;
paintinfo pi = { NULL, }; paintinfo pi = { NULL, };
paintinfo *p = &pi; paintinfo *p = &pi;
struct fourcc_list_struct *fourcc; struct format_list_struct *format;
struct vts_color_struct color; struct vts_color_struct color;
int t = v->n_frames; int t = v->n_frames;
int xreset = -(w / 2) - v->xoffset; /* starting values for x^2 and y^2, centering the ellipse */ 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; int scale_kx2 = 0xffff / w;
videotestsrc_setup_paintinfo (v, p, w, h); videotestsrc_setup_paintinfo (v, p, w, h);
fourcc = v->fourcc; format = v->format;
if (fourcc == NULL) if (format == NULL)
return; return;
fourcc->paint_setup (p, dest); format->paint_setup (p, dest);
color = p->colors[COLOR_BLACK]; color = p->colors[COLOR_BLACK];
p->color = &color; p->color = &color;
@ -1348,7 +1261,7 @@ gst_video_test_src_chromazoneplate (GstVideoTestSrc * v, unsigned char *dest,
int j; int j;
paintinfo pi = { NULL, }; paintinfo pi = { NULL, };
paintinfo *p = &pi; paintinfo *p = &pi;
struct fourcc_list_struct *fourcc; struct format_list_struct *format;
struct vts_color_struct color; struct vts_color_struct color;
int t = v->n_frames; int t = v->n_frames;
@ -1370,11 +1283,11 @@ gst_video_test_src_chromazoneplate (GstVideoTestSrc * v, unsigned char *dest,
int scale_kx2 = 0xffff / w; int scale_kx2 = 0xffff / w;
videotestsrc_setup_paintinfo (v, p, w, h); videotestsrc_setup_paintinfo (v, p, w, h);
fourcc = v->fourcc; format = v->format;
if (fourcc == NULL) if (format == NULL)
return; return;
fourcc->paint_setup (p, dest); format->paint_setup (p, dest);
color = p->colors[COLOR_BLACK]; color = p->colors[COLOR_BLACK];
p->color = &color; p->color = &color;
@ -1448,17 +1361,17 @@ gst_video_test_src_circular (GstVideoTestSrc * v, unsigned char *dest,
int j; int j;
paintinfo pi = { NULL, }; paintinfo pi = { NULL, };
paintinfo *p = &pi; paintinfo *p = &pi;
struct fourcc_list_struct *fourcc; struct format_list_struct *format;
double freq[8]; double freq[8];
int d; int d;
videotestsrc_setup_paintinfo (v, p, w, h); videotestsrc_setup_paintinfo (v, p, w, h);
fourcc = v->fourcc; format = v->format;
if (fourcc == NULL) if (format == NULL)
return; return;
fourcc->paint_setup (p, dest); format->paint_setup (p, dest);
for (i = 1; i < 8; i++) { for (i = 1; i < 8; i++) {
freq[i] = 200 * pow (2.0, -(i - 1) / 4.0); 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; int x, y;
paintinfo pi = { NULL, }; paintinfo pi = { NULL, };
paintinfo *p = &pi; paintinfo *p = &pi;
struct fourcc_list_struct *fourcc; struct format_list_struct *format;
struct vts_color_struct yuv_primary; struct vts_color_struct yuv_primary;
struct vts_color_struct yuv_secondary; struct vts_color_struct yuv_secondary;
videotestsrc_setup_paintinfo (v, p, w, h); videotestsrc_setup_paintinfo (v, p, w, h);
fourcc = v->fourcc; format = v->format;
if (fourcc == NULL) if (format == NULL)
return; return;
fourcc->paint_setup (p, dest); format->paint_setup (p, dest);
for (y = 0; y < h; y++) { for (y = 0; y < h; y++) {
int region = (y * 4) / h; 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; int i;
paintinfo pi = { NULL, }; paintinfo pi = { NULL, };
paintinfo *p = &pi; paintinfo *p = &pi;
struct fourcc_list_struct *fourcc; struct format_list_struct *format;
int t = v->n_frames; int t = v->n_frames;
double x, y; double x, y;
int radius = 20; int radius = 20;
videotestsrc_setup_paintinfo (v, p, w, h); videotestsrc_setup_paintinfo (v, p, w, h);
fourcc = v->fourcc; format = v->format;
if (fourcc == NULL) if (format == NULL)
return; 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); 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 - y = radius + (0.5 + 0.5 * sin (2 * G_PI * sqrt (2) * t / 200)) * (h -

View File

@ -75,10 +75,10 @@ struct paintinfo_struct
struct vts_color_struct background_color; struct vts_color_struct background_color;
}; };
struct fourcc_list_struct struct format_list_struct
{ {
int type; int type;
const char *fourcc; const char *format;
const char *name; const char *name;
int bitspp; int bitspp;
void (*paint_setup) (paintinfo * p, unsigned char *dest); void (*paint_setup) (paintinfo * p, unsigned char *dest);
@ -90,14 +90,14 @@ struct fourcc_list_struct
unsigned int alpha_mask; unsigned int alpha_mask;
}; };
struct fourcc_list_struct * struct format_list_struct *
paintrect_find_fourcc (int find_fourcc); paintrect_find_format (const gchar *find_format);
struct fourcc_list_struct * struct format_list_struct *
paintrect_find_name (const char *name); paintrect_find_name (const char *name);
struct fourcc_list_struct * struct format_list_struct *
paintinfo_find_by_structure (const GstStructure *structure); paintinfo_find_by_structure (const GstStructure *structure);
GstStructure * 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); int gst_video_test_src_get_size (GstVideoTestSrc * v, int w, int h);
void gst_video_test_src_smpte (GstVideoTestSrc * v, void gst_video_test_src_smpte (GstVideoTestSrc * v,
unsigned char *dest, int w, int h); 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, void gst_video_test_src_bar (GstVideoTestSrc * v,
unsigned char *dest, int w, int h); unsigned char *dest, int w, int h);
extern struct fourcc_list_struct fourcc_list[]; extern struct format_list_struct format_list[];
extern int n_fourccs; extern int n_formats;
#endif #endif

View File

@ -89,7 +89,7 @@
* the button and a red one where you released it. (The navigationtest element * the button and a red one where you released it. (The navigationtest element
* is part of gst-plugins-good.) * 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 * ]| 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 * 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 * 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_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK, GST_PAD_SINK,
GST_PAD_ALWAYS, GST_PAD_ALWAYS,
GST_STATIC_CAPS ("video/x-raw-rgb, " GST_STATIC_CAPS ("video/x-raw, "
"framerate = (fraction) [ 0, MAX ], " "framerate = (fraction) [ 0, MAX ], "
"width = (int) [ 1, MAX ], " "height = (int) [ 1, MAX ]") "width = (int) [ 1, MAX ], " "height = (int) [ 1, MAX ]")
); );
@ -816,6 +816,8 @@ gst_ximagesink_xcontext_get (GstXImageSink * ximagesink)
GstXContext *xcontext = NULL; GstXContext *xcontext = NULL;
XPixmapFormatValues *px_formats = NULL; XPixmapFormatValues *px_formats = NULL;
gint nb_formats = 0, i; gint nb_formats = 0, i;
gint endianness;
GstVideoFormat vformat;
g_return_val_if_fail (GST_IS_XIMAGESINK (ximagesink), NULL); g_return_val_if_fail (GST_IS_XIMAGESINK (ximagesink), NULL);
@ -872,8 +874,7 @@ gst_ximagesink_xcontext_get (GstXImageSink * ximagesink)
XFree (px_formats); XFree (px_formats);
xcontext->endianness = endianness = (ImageByteOrder (xcontext->disp) ==
(ImageByteOrder (xcontext->disp) ==
LSBFirst) ? G_LITTLE_ENDIAN : G_BIG_ENDIAN; LSBFirst) ? G_LITTLE_ENDIAN : G_BIG_ENDIAN;
/* Search for XShm extension support */ /* Search for XShm extension support */
@ -889,19 +890,12 @@ gst_ximagesink_xcontext_get (GstXImageSink * ximagesink)
GST_DEBUG ("ximagesink is not using XShm extension"); GST_DEBUG ("ximagesink is not using XShm extension");
} }
/* our caps system handles 24/32bpp RGB as big-endian. */ vformat = gst_video_format_from_masks (xcontext->depth, xcontext->bpp,
if ((xcontext->bpp == 24 || xcontext->bpp == 32) && endianness, xcontext->visual->red_mask, xcontext->visual->green_mask,
xcontext->endianness == G_LITTLE_ENDIAN) { xcontext->visual->blue_mask, 0);
xcontext->endianness = G_BIG_ENDIAN;
xcontext->visual->red_mask = GUINT32_TO_BE (xcontext->visual->red_mask); if (vformat == GST_VIDEO_FORMAT_UNKNOWN)
xcontext->visual->green_mask = GUINT32_TO_BE (xcontext->visual->green_mask); goto unknown_format;
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;
}
}
/* update object's par with calculated one if not set yet */ /* update object's par with calculated one if not set yet */
if (!ximagesink->par) { if (!ximagesink->par) {
@ -909,13 +903,8 @@ gst_ximagesink_xcontext_get (GstXImageSink * ximagesink)
gst_value_init_and_copy (ximagesink->par, xcontext->par); gst_value_init_and_copy (ximagesink->par, xcontext->par);
GST_DEBUG_OBJECT (ximagesink, "set calculated PAR on object's PAR"); GST_DEBUG_OBJECT (ximagesink, "set calculated PAR on object's PAR");
} }
xcontext->caps = gst_caps_new_simple ("video/x-raw-rgb", xcontext->caps = gst_caps_new_simple ("video/x-raw",
"bpp", G_TYPE_INT, xcontext->bpp, "format", G_TYPE_STRING, gst_video_format_to_string (vformat),
"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,
"width", GST_TYPE_INT_RANGE, 1, G_MAXINT, "width", GST_TYPE_INT_RANGE, 1, G_MAXINT,
"height", 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); "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); g_mutex_unlock (ximagesink->x_lock);
return xcontext; 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 /* This function cleans the X context. Closing the Display and unrefing the

View File

@ -98,7 +98,6 @@ struct _GstXContext
gint depth; gint depth;
gint bpp; gint bpp;
gint endianness;
gint width, height; gint width, height;
gint widthmm, heightmm; gint widthmm, heightmm;

View File

@ -94,7 +94,7 @@
* position. This also handles borders correctly, limiting coordinates to the * position. This also handles borders correctly, limiting coordinates to the
* image area * 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 * ]| 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 * 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 * 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 /* Default template - initiated with class struct to allow gst-register to work
without X running */ without X running */
static GstStaticPadTemplate gst_xvimagesink_sink_template_factory = static GstStaticPadTemplate gst_xvimagesink_sink_template_factory =
GST_STATIC_PAD_TEMPLATE ("sink", GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK, GST_PAD_SINK,
GST_PAD_ALWAYS, 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 ]; "
"video/x-raw-yuv, "
"framerate = (fraction) [ 0, MAX ], " "framerate = (fraction) [ 0, MAX ], "
"width = (int) [ 1, MAX ], " "height = (int) [ 1, MAX ]") "width = (int) [ 1, MAX ], " "height = (int) [ 1, MAX ]")
); );
@ -1053,31 +1049,17 @@ gst_xvimagesink_get_xv_support (GstXvImageSink * xvimagesink,
case XvRGB: case XvRGB:
{ {
XvImageFormatValues *fmt = &(formats[i]); XvImageFormatValues *fmt = &(formats[i]);
gint endianness = G_BIG_ENDIAN; gint endianness;
GstVideoFormat vformat;
if (fmt->byte_order == LSBFirst) { endianness =
/* our caps system handles 24/32bpp RGB as big-endian. */ (fmt->byte_order == LSBFirst ? G_LITTLE_ENDIAN : G_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) { vformat = gst_video_format_from_masks (fmt->depth, fmt->bits_per_pixel,
fmt->red_mask >>= 8; endianness, fmt->red_mask, fmt->green_mask, fmt->blue_mask, 0);
fmt->green_mask >>= 8;
fmt->blue_mask >>= 8;
}
} else
endianness = G_LITTLE_ENDIAN;
}
format_caps = gst_caps_new_simple ("video/x-raw-rgb", format_caps = gst_caps_new_simple ("video/x-raw",
"endianness", G_TYPE_INT, endianness, "format", G_TYPE_STRING, gst_video_format_to_string (vformat),
"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,
"width", GST_TYPE_INT_RANGE, 1, max_w, "width", GST_TYPE_INT_RANGE, 1, max_w,
"height", GST_TYPE_INT_RANGE, 1, max_h, "height", GST_TYPE_INT_RANGE, 1, max_h,
"framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1, NULL); "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1, NULL);
@ -1086,12 +1068,18 @@ gst_xvimagesink_get_xv_support (GstXvImageSink * xvimagesink,
break; break;
} }
case XvYUV: 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, "width", GST_TYPE_INT_RANGE, 1, max_w,
"height", GST_TYPE_INT_RANGE, 1, max_h, "height", GST_TYPE_INT_RANGE, 1, max_h,
"framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1, NULL); "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1, NULL);
break; break;
}
default: default:
g_assert_not_reached (); g_assert_not_reached ();
break; break;