From bd9ec0f3334b460babf61cac9a60e34cad11ceb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Mon, 15 Jun 2015 20:39:59 +0200 Subject: [PATCH] gtk: Cairo color formats are in native endianness, GStreamer's in memory order CAIRO_FORMAT_ARGB32 is ARGB on big endian and BGRA on little endian. --- ext/gtk/gstgtksink.c | 8 +++++++- ext/gtk/gtkgstwidget.c | 5 +++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/ext/gtk/gstgtksink.c b/ext/gtk/gstgtksink.c index be5bf15e76..baf495088c 100644 --- a/ext/gtk/gstgtksink.c +++ b/ext/gtk/gstgtksink.c @@ -51,11 +51,17 @@ static gboolean gst_gtk_sink_set_caps (GstBaseSink * bsink, GstCaps * caps); static GstFlowReturn gst_gtk_sink_show_frame (GstVideoSink * bsink, GstBuffer * buf); +#if G_BYTE_ORDER == G_LITTLE_ENDIAN +#define FORMATS "BGRA" +#else +#define FORMATS "ARGB" +#endif + static GstStaticPadTemplate gst_gtk_sink_template = GST_STATIC_PAD_TEMPLATE ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, - GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE ("BGRA")) + GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE (FORMATS)) ); #define DEFAULT_FORCE_ASPECT_RATIO TRUE diff --git a/ext/gtk/gtkgstwidget.c b/ext/gtk/gtkgstwidget.c index ac3e5a9e0b..2f4b0bf102 100644 --- a/ext/gtk/gtkgstwidget.c +++ b/ext/gtk/gtkgstwidget.c @@ -431,8 +431,13 @@ gtk_gst_widget_set_caps (GtkGstWidget * widget, GstCaps * caps) return FALSE; /* FIXME: support other formats */ +#if G_BYTE_ORDER == G_LITTLE_ENDIAN g_return_val_if_fail (GST_VIDEO_INFO_FORMAT (&v_info) == GST_VIDEO_FORMAT_BGRA, FALSE); +#else + g_return_val_if_fail (GST_VIDEO_INFO_FORMAT (&v_info) == + GST_VIDEO_FORMAT_ARGB, FALSE); +#endif g_mutex_lock (&widget->priv->lock);