videotestsrc: add all colors mode
authorWim Taymans <wtaymans@redhat.com>
Tue, 10 Mar 2015 10:55:11 +0000 (11:55 +0100)
committerWim Taymans <wtaymans@redhat.com>
Tue, 10 Mar 2015 11:27:03 +0000 (12:27 +0100)
gst/videotestsrc/gstvideotestsrc.c
gst/videotestsrc/gstvideotestsrc.h
gst/videotestsrc/videotestsrc.c
gst/videotestsrc/videotestsrc.h

index a98611b..ce98cb4 100644 (file)
@@ -152,6 +152,7 @@ gst_video_test_src_pattern_get_type (void)
     {GST_VIDEO_TEST_SRC_PINWHEEL, "Pinwheel", "pinwheel"},
     {GST_VIDEO_TEST_SRC_SPOKES, "Spokes", "spokes"},
     {GST_VIDEO_TEST_SRC_GRADIENT, "Gradient", "gradient"},
+    {GST_VIDEO_TEST_SRC_COLORS, "Colors", "colors"},
     {0, NULL, NULL}
   };
 
@@ -428,6 +429,9 @@ gst_video_test_src_set_pattern (GstVideoTestSrc * videotestsrc,
     case GST_VIDEO_TEST_SRC_GRADIENT:
       videotestsrc->make_image = gst_video_test_src_gradient;
       break;
+    case GST_VIDEO_TEST_SRC_COLORS:
+      videotestsrc->make_image = gst_video_test_src_colors;
+      break;
     default:
       g_assert_not_reached ();
   }
index c43c2e1..c0dfaa4 100644 (file)
@@ -64,6 +64,8 @@ G_BEGIN_DECLS
  * @GST_VIDEO_TEST_SRC_BAR: Bar with foreground color
  * @GST_VIDEO_TEST_SRC_PINWHEEL: Pinwheel
  * @GST_VIDEO_TEST_SRC_SPOKES: Spokes
+ * @GST_VIDEO_TEST_SRC_GRADIENT: Gradient
+ * @GST_VIDEO_TEST_SRC_COLORS: All colors
  *
  * The test pattern to produce.
  *
@@ -108,7 +110,8 @@ typedef enum {
   GST_VIDEO_TEST_SRC_BAR,
   GST_VIDEO_TEST_SRC_PINWHEEL,
   GST_VIDEO_TEST_SRC_SPOKES,
-  GST_VIDEO_TEST_SRC_GRADIENT
+  GST_VIDEO_TEST_SRC_GRADIENT,
+  GST_VIDEO_TEST_SRC_COLORS
 } GstVideoTestSrcPattern;
 
 typedef struct _GstVideoTestSrc GstVideoTestSrc;
index debbca0..f082ed1 100644 (file)
@@ -1362,3 +1362,29 @@ gst_video_test_src_gradient (GstVideoTestSrc * v, GstVideoFrame * frame)
     videotestsrc_convert_tmpline (p, frame, j);
   }
 }
+
+void
+gst_video_test_src_colors (GstVideoTestSrc * v, GstVideoFrame * frame)
+{
+  int i;
+  int j;
+  paintinfo pi = PAINT_INFO_INIT;
+  paintinfo *p = &pi;
+  struct vts_color_struct color;
+  int w = frame->info.width, h = frame->info.height;
+
+  videotestsrc_setup_paintinfo (v, p, w, h);
+
+  color = p->colors[COLOR_BLACK];
+  p->color = &color;
+
+  for (j = 0; j < h; j++) {
+    for (i = 0; i < w; i++) {
+      p->tmpline[i * 4 + 0] = 0xff;
+      p->tmpline[i * 4 + 1] = ((i * 4096) / w) % 256;
+      p->tmpline[i * 4 + 2] = (((j * 16) / h) << 4) | ((i * 16) / w);
+      p->tmpline[i * 4 + 3] = ((j * 4096) / h) % 256;
+    }
+    videotestsrc_convert_tmpline (p, frame, j);
+  }
+}
index 9a23b9a..977e504 100644 (file)
@@ -83,5 +83,6 @@ void    gst_video_test_src_bar          (GstVideoTestSrc * v, GstVideoFrame *fra
 void    gst_video_test_src_pinwheel     (GstVideoTestSrc * v, GstVideoFrame * frame);
 void    gst_video_test_src_spokes       (GstVideoTestSrc * v, GstVideoFrame * frame);
 void    gst_video_test_src_gradient     (GstVideoTestSrc * v, GstVideoFrame * frame);
+void    gst_video_test_src_colors       (GstVideoTestSrc * v, GstVideoFrame * frame);
 
 #endif