effectv: repair color modes in radioactv by taking rgb,bgr into account
authorStefan Sauer <ensonic@users.sf.net>
Fri, 25 Nov 2011 12:13:47 +0000 (13:13 +0100)
committerStefan Sauer <ensonic@users.sf.net>
Fri, 25 Nov 2011 12:13:47 +0000 (13:13 +0100)
gst/effectv/gstradioac.c
gst/effectv/gstradioac.h

index fc3f9af..9886d56 100644 (file)
@@ -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;
index 34ad8ed..64a425d 100644 (file)
@@ -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;