cairorender: Fix caps and colorspace handling

This commit is contained in:
Sebastian Dröge 2009-07-17 13:41:19 +02:00
parent 12fbfabb6a
commit 52f17631d9
2 changed files with 22 additions and 10 deletions

View file

@ -122,7 +122,7 @@ gst_cairo_render_chain (GstPad * pad, GstBuffer * buf)
s = cairo_image_surface_create_from_png_stream (read_buffer, buf); s = cairo_image_surface_create_from_png_stream (read_buffer, buf);
} else } else
s = cairo_image_surface_create_for_data (GST_BUFFER_DATA (buf), s = cairo_image_surface_create_for_data (GST_BUFFER_DATA (buf),
c->format, c->width, c->height, c->width); c->format, c->width, c->height, c->stride);
success = gst_cairo_render_push_surface (c, s); success = gst_cairo_render_push_surface (c, s);
gst_buffer_unref (buf); gst_buffer_unref (buf);
return success ? GST_FLOW_OK : GST_FLOW_ERROR; return success ? GST_FLOW_OK : GST_FLOW_ERROR;
@ -148,14 +148,13 @@ gst_cairo_render_setcaps_sink (GstPad * pad, GstCaps * caps)
return FALSE; return FALSE;
} }
/* Colorspace /* Colorspace */
* FIXME: I couldn't figure out the right caps. The solution below if (!strcmp (mime, "video/x-raw-yuv") || !strcmp (mime, "video/x-raw-grey")) {
* results in a black and white result which is better than nothing.
* If you know how to fix this, please do it. */
if (!strcmp (mime, "video/x-raw-yuv")) {
c->format = CAIRO_FORMAT_A8; c->format = CAIRO_FORMAT_A8;
c->stride = GST_ROUND_UP_4 (c->width);
} else if (!strcmp (mime, "video/x-raw-rgb")) { } else if (!strcmp (mime, "video/x-raw-rgb")) {
c->format = CAIRO_FORMAT_RGB24; c->format = CAIRO_FORMAT_RGB24;
c->stride = 4 * c->width;
} else { } else {
GST_DEBUG_OBJECT (c, "Unknown mime type '%s'.", mime); GST_DEBUG_OBJECT (c, "Unknown mime type '%s'.", mime);
return FALSE; return FALSE;
@ -233,13 +232,26 @@ static GstStaticPadTemplate t_src = GST_STATIC_PAD_TEMPLATE ("src",
";" ";"
#endif #endif
#if CAIRO_HAS_PNG_FUNCTIONS #if CAIRO_HAS_PNG_FUNCTIONS
"image/png" "image/png, " "width = (int) [ 1, MAX], " "height = (int) [ 1, MAX] "
#endif #endif
)); ));
static GstStaticPadTemplate t_snk = GST_STATIC_PAD_TEMPLATE ("sink", static GstStaticPadTemplate t_snk = GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK, GST_PAD_ALWAYS, GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("I420") GST_PAD_SINK, GST_PAD_ALWAYS, GST_STATIC_CAPS (
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
GST_VIDEO_CAPS_BGRx " ; "
#else
GST_VIDEO_CAPS_xRGB " ; "
#endif
GST_VIDEO_CAPS_YUV ("Y800") " ; "
"video/x-raw-gray, "
"bpp = 8, "
"depth = 8, "
"width = " GST_VIDEO_SIZE_RANGE ", "
"height = " GST_VIDEO_SIZE_RANGE ", " "framerate = " GST_VIDEO_FPS_RANGE
" ; "
#if CAIRO_HAS_PNG_FUNCTIONS #if CAIRO_HAS_PNG_FUNCTIONS
";image/png" "image/png, "
"width = " GST_VIDEO_SIZE_RANGE ", " "height = " GST_VIDEO_SIZE_RANGE
#endif #endif
)); ));

View file

@ -43,7 +43,7 @@ struct _GstCairoRender
/* Source */ /* Source */
cairo_surface_t *surface; cairo_surface_t *surface;
gint width, height; gint width, height, stride;
/* Sink */ /* Sink */
gint64 offset, duration; gint64 offset, duration;