From ebefb140b99ac169babb3a3e18fe11f20524bec1 Mon Sep 17 00:00:00 2001 From: Stefan Sauer Date: Fri, 25 Nov 2011 13:13:47 +0100 Subject: [PATCH] effectv: repair color modes in radioactv by taking rgb,bgr into account --- gst/effectv/gstradioac.c | 27 ++++++++++++++++++++------- gst/effectv/gstradioac.h | 2 ++ 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/gst/effectv/gstradioac.c b/gst/effectv/gstradioac.c index fc3f9af..9886d56 100644 --- a/gst/effectv/gstradioac.c +++ b/gst/effectv/gstradioac.c @@ -134,6 +134,7 @@ enum #define RATIO 0.95 static guint32 palettes[COLORS * PATTERN]; +static gint swap_tab[] = { 2, 1, 0, 3 }; GST_BOILERPLATE (GstRadioacTV, gst_radioactv, GstVideoFilter, GST_TYPE_VIDEO_FILTER); @@ -165,18 +166,20 @@ makePalette (void) #define DELTA (255/(COLORS/2-1)) + /* red, gree, blue */ for (i = 0; i < COLORS / 2; i++) { palettes[i] = i * DELTA; palettes[COLORS + i] = (i * DELTA) << 8; palettes[COLORS * 2 + i] = (i * DELTA) << 16; } for (i = 0; i < COLORS / 2; i++) { - palettes[+i + COLORS / 2] = 255 | (i * DELTA) << 16 | (i * DELTA) << 8; + palettes[i + COLORS / 2] = 255 | (i * DELTA) << 16 | (i * DELTA) << 8; palettes[COLORS + i + COLORS / 2] = (255 << 8) | (i * DELTA) << 16 | i * DELTA; palettes[COLORS * 2 + i + COLORS / 2] = (255 << 16) | (i * DELTA) << 8 | i * DELTA; } + /* white */ for (i = 0; i < COLORS; i++) { palettes[COLORS * 3 + i] = (255 * i / COLORS) * 0x10101; } @@ -341,7 +344,19 @@ gst_radioactv_transform (GstBaseTransform * trans, GstBuffer * in, dest = (guint32 *) GST_BUFFER_DATA (out); GST_OBJECT_LOCK (filter); - palette = &palettes[COLORS * filter->color]; +#if G_BYTE_ORDER == G_LITTLE_ENDIAN + if (filter->format == GST_VIDEO_FORMAT_RGBx) { + palette = &palettes[COLORS * filter->color]; + } else { + palette = &palettes[COLORS * swap_tab[filter->color]]; + } +#else + if (filter->format == GST_VIDEO_FORMAT_xBGR) { + palette = &palettes[COLORS * filter->color]; + } else { + palette = &palettes[COLORS * swap_tab[filter->color]]; + } +#endif diff = filter->diff; if (filter->mode == 3 && filter->trigger) @@ -405,14 +420,12 @@ gst_radioactv_set_caps (GstBaseTransform * btrans, GstCaps * incaps, GstCaps * outcaps) { GstRadioacTV *filter = GST_RADIOACTV (btrans); - GstStructure *structure; gboolean ret = FALSE; - structure = gst_caps_get_structure (incaps, 0); - GST_OBJECT_LOCK (filter); - if (gst_structure_get_int (structure, "width", &filter->width) && - gst_structure_get_int (structure, "height", &filter->height)) { + + if (gst_video_format_parse_caps (incaps, &filter->format, &filter->width, + &filter->height)) { filter->buf_width_blocks = filter->width / 32; if (filter->buf_width_blocks > 255) goto out; diff --git a/gst/effectv/gstradioac.h b/gst/effectv/gstradioac.h index 34ad8ed..64a425d 100644 --- a/gst/effectv/gstradioac.h +++ b/gst/effectv/gstradioac.h @@ -29,6 +29,7 @@ #include +#include #include G_BEGIN_DECLS @@ -53,6 +54,7 @@ struct _GstRadioacTV /* < private > */ gint width, height; + GstVideoFormat format; gint mode; gint color; -- 2.7.4