From c17f7a943d54c7a3855a25818bf1b4cc79300406 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Mon, 3 Jan 2011 18:05:15 +0100 Subject: [PATCH] cacasink: fix masks and strides Use the right endianness to read the masks. Use the right strides for the bitmap. Fixes #638569 --- ext/libcaca/gstcacasink.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/ext/libcaca/gstcacasink.c b/ext/libcaca/gstcacasink.c index ee05b36cc..1846c26d4 100644 --- a/ext/libcaca/gstcacasink.c +++ b/ext/libcaca/gstcacasink.c @@ -209,12 +209,14 @@ gst_cacasink_setcaps (GstBaseSink * basesink, GstCaps * caps) { GstCACASink *cacasink; GstStructure *structure; + gint endianness; cacasink = GST_CACASINK (basesink); structure = gst_caps_get_structure (caps, 0); gst_structure_get_int (structure, "width", &(cacasink->width)); gst_structure_get_int (structure, "height", &(cacasink->height)); + gst_structure_get_int (structure, "endianness", &endianness); gst_structure_get_int (structure, "bpp", (int *) &cacasink->bpp); gst_structure_get_int (structure, "red_mask", (int *) &cacasink->red_mask); gst_structure_get_int (structure, "green_mask", @@ -233,10 +235,16 @@ gst_cacasink_setcaps (GstBaseSink * basesink, GstCaps * caps) cacasink->blue_mask = GUINT32_FROM_BE (cacasink->blue_mask); } - else if (cacasink->bpp == 16 || cacasink->bpp == 15) { - cacasink->red_mask = GUINT16_FROM_BE (cacasink->red_mask); - cacasink->green_mask = GUINT16_FROM_BE (cacasink->green_mask); - cacasink->blue_mask = GUINT16_FROM_BE (cacasink->blue_mask); + else if (cacasink->bpp == 16) { + if (endianness == G_BIG_ENDIAN) { + cacasink->red_mask = GUINT16_FROM_BE (cacasink->red_mask); + cacasink->green_mask = GUINT16_FROM_BE (cacasink->green_mask); + cacasink->blue_mask = GUINT16_FROM_BE (cacasink->blue_mask); + } else { + cacasink->red_mask = GUINT16_FROM_LE (cacasink->red_mask); + cacasink->green_mask = GUINT16_FROM_LE (cacasink->green_mask); + cacasink->blue_mask = GUINT16_FROM_LE (cacasink->blue_mask); + } } if (cacasink->bitmap) { @@ -246,7 +254,7 @@ gst_cacasink_setcaps (GstBaseSink * basesink, GstCaps * caps) cacasink->bitmap = caca_create_bitmap (cacasink->bpp, cacasink->width, cacasink->height, - cacasink->width * cacasink->bpp / 8, + GST_ROUND_UP_4 (cacasink->width * cacasink->bpp / 8), cacasink->red_mask, cacasink->green_mask, cacasink->blue_mask, 0); if (!cacasink->bitmap) { -- 2.34.1