Commit ebefb140 authored by Stefan Sauer's avatar Stefan Sauer
Browse files

effectv: repair color modes in radioactv by taking rgb,bgr into account

parent c1d38ea8
......@@ -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;
......
......@@ -29,6 +29,7 @@
#include <gst/gst.h>
#include <gst/video/video.h>
#include <gst/video/gstvideofilter.h>
G_BEGIN_DECLS
......@@ -53,6 +54,7 @@ struct _GstRadioacTV
/* < private > */
gint width, height;
GstVideoFormat format;
gint mode;
gint color;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment