gst_plugins_base/gst/videotestsrc/videotestsrc.c
changeset 16 8e837d1bf446
parent 0 0e761a78d257
child 30 7e817e7e631c
--- a/gst_plugins_base/gst/videotestsrc/videotestsrc.c	Wed Mar 24 17:58:42 2010 -0500
+++ b/gst_plugins_base/gst/videotestsrc/videotestsrc.c	Wed Mar 24 18:04:17 2010 -0500
@@ -25,8 +25,11 @@
 
 #include "gstvideotestsrc.h"
 #include "videotestsrc.h"
-#include <gst/liboil.h>
+#include <liboil/liboil.h>
 
+#ifdef __SYMBIAN32__
+#include <liboil/globals.h>
+#endif
 
 #include <string.h>
 #include <stdlib.h>
@@ -209,49 +212,125 @@
   COLOR_DARK_GREY
 };
 
-static const struct vts_color_struct vts_colors[] = {
-  /* 100% white */
-  {255, 128, 128, 255, 255, 255, 255},
-  /* yellow */
-  {226, 0, 155, 255, 255, 0, 255},
-  /* cyan */
-  {179, 170, 0, 0, 255, 255, 255},
-  /* green */
-  {150, 46, 21, 0, 255, 0, 255},
-  /* magenta */
-  {105, 212, 235, 255, 0, 255, 255},
-  /* red */
-  {76, 85, 255, 255, 0, 0, 255},
-  /* blue */
-  {29, 255, 107, 0, 0, 255, 255},
-  /* black */
-  {16, 128, 128, 0, 0, 0, 255},
-  /* -I */
-  {16, 198, 21, 0, 0, 128, 255},
-  /* +Q */
-  {16, 235, 198, 0, 128, 255, 255},
-  /* superblack */
-  {0, 128, 128, 0, 0, 0, 255},
-  /* 5% grey */
-  {32, 128, 128, 32, 32, 32, 255},
+static const struct vts_color_struct_rgb vts_colors_rgb[] = {
+  {255, 255, 255},
+  {255, 255, 0},
+  {0, 255, 255},
+  {0, 255, 0},
+  {255, 0, 255},
+  {255, 0, 0},
+  {0, 0, 255},
+  {0, 0, 0},
+  {0, 0, 128},                  /* -I ? */
+  {0, 128, 255},                /* +Q ? */
+  {0, 0, 0},
+  {19, 19, 19},
+};
+
+static const struct vts_color_struct_rgb vts_colors_rgb_75[] = {
+  {191, 191, 191},
+  {191, 191, 0},
+  {0, 191, 191},
+  {0, 191, 0},
+  {191, 0, 191},
+  {191, 0, 0},
+  {0, 0, 191},
+  {0, 0, 0},
+  {0, 0, 128},                  /* -I ? */
+  {0, 128, 255},                /* +Q ? */
+  {0, 0, 0},
+  {19, 19, 19},
+};
+
+static const struct vts_color_struct_yuv vts_colors_bt709_ycbcr_100[] = {
+  {235, 128, 128},
+  {219, 16, 138},
+  {188, 154, 16},
+  {173, 42, 26},
+  {78, 214, 230},
+  {63, 102, 240},
+  {32, 240, 118},
+  {16, 128, 128},
+  {16, 198, 21},                /* -I ? */
+  {16, 235, 198},               /* +Q ? */
+  {0, 128, 128},
+  {32, 128, 128},
+};
+
+static const struct vts_color_struct_yuv vts_colors_bt709_ycbcr_75[] = {
+  {180, 128, 128},
+  {168, 44, 136},
+  {145, 147, 44},
+  {133, 63, 52},
+  {63, 193, 204},
+  {51, 109, 212},
+  {28, 212, 120},
+  {16, 128, 128},
+  {16, 198, 21},                /* -I ? */
+  {16, 235, 198},               /* +Q ? */
+  {0, 128, 128},
+  {32, 128, 128},
 };
 
+static const struct vts_color_struct_yuv vts_colors_bt601_ycbcr_100[] = {
+  {235, 128, 128},
+  {210, 16, 146},
+  {170, 166, 16},
+  {145, 54, 34},
+  {106, 202, 222},
+  {81, 90, 240},
+  {41, 240, 110},
+  {16, 128, 128},
+  {16, 198, 21},                /* -I ? */
+  {16, 235, 198},               /* +Q ? */
+  {-0, 128, 128},
+  {32, 128, 128},
+};
 
-#if 0
+static const struct vts_color_struct_yuv vts_colors_bt601_ycbcr_75[] = {
+  {180, 128, 128},
+  {162, 44, 142},
+  {131, 156, 44},
+  {112, 72, 58},
+  {84, 184, 198},
+  {65, 100, 212},
+  {35, 212, 114},
+  {16, 128, 128},
+  {16, 198, 21},                /* -I ? */
+  {16, 235, 198},               /* +Q ? */
+  {-0, 128, 128},
+  {32, 128, 128},
+};
 
-/*                        wht  yel  cya  grn  mag  red  blu  blk   -I    Q, superblack, dark grey */
-static int y_colors[] = { 255, 226, 179, 150, 105, 76, 29, 16, 16, 16, 0, 32 };
-static int u_colors[] =
-    { 128, 0, 170, 46, 212, 85, 255, 128, 198, 235, 128, 128 };
-static int v_colors[] =
-    { 128, 155, 0, 21, 235, 255, 107, 128, 21, 198, 128, 128 };
+static const struct vts_color_struct_gray vts_colors_gray_100[] = {
+  {235 << 8},
+  {210 << 8},
+  {170 << 8},
+  {145 << 8},
+  {106 << 8},
+  {81 << 8},
+  {41 << 8},
+  {16 << 8},
+  {16 << 8},
+  {16 << 8},
+  {-0 << 8},
+  {32 << 8},
+};
 
-/*                        wht  yel  cya  grn  mag  red  blu  blk   -I    Q  superblack, dark grey */
-static int r_colors[] = { 255, 255, 0, 0, 255, 255, 0, 0, 0, 0, 0, 32 };
-static int g_colors[] = { 255, 255, 255, 255, 0, 0, 0, 0, 0, 128, 0, 32 };
-static int b_colors[] = { 255, 0, 255, 0, 255, 0, 255, 0, 128, 255, 0, 32 };
-#endif
-
+static const struct vts_color_struct_gray vts_colors_gray_75[] = {
+  {180 << 8},
+  {162 << 8},
+  {131 << 8},
+  {112 << 8},
+  {84 << 8},
+  {65 << 8},
+  {35 << 8},
+  {16 << 8},
+  {16 << 8},
+  {16 << 8},
+  {-0 << 8},
+  {32 << 8},
+};
 
 static void paint_setup_I420 (paintinfo * p, unsigned char *dest);
 static void paint_setup_YV12 (paintinfo * p, unsigned char *dest);
@@ -261,8 +340,15 @@
 static void paint_setup_IYU2 (paintinfo * p, unsigned char *dest);
 static void paint_setup_Y41B (paintinfo * p, unsigned char *dest);
 static void paint_setup_Y42B (paintinfo * p, unsigned char *dest);
+static void paint_setup_Y444 (paintinfo * p, unsigned char *dest);
 static void paint_setup_Y800 (paintinfo * p, unsigned char *dest);
 static void paint_setup_AYUV (paintinfo * p, unsigned char *dest);
+static void paint_setup_v308 (paintinfo * p, unsigned char *dest);
+static void paint_setup_NV12 (paintinfo * p, unsigned char *dest);
+static void paint_setup_NV21 (paintinfo * p, unsigned char *dest);
+static void paint_setup_v410 (paintinfo * p, unsigned char *dest);
+static void paint_setup_v216 (paintinfo * p, unsigned char *dest);
+static void paint_setup_v210 (paintinfo * p, unsigned char *dest);
 
 #if 0
 static void paint_setup_IMC1 (paintinfo * p, unsigned char *dest);
@@ -288,12 +374,18 @@
 static void paint_setup_bayer (paintinfo * p, unsigned char *dest);
 
 static void paint_hline_I420 (paintinfo * p, int x, int y, int w);
+static void paint_hline_NV12_NV21 (paintinfo * p, int x, int y, int w);
 static void paint_hline_YUY2 (paintinfo * p, int x, int y, int w);
 static void paint_hline_IYU2 (paintinfo * p, int x, int y, int w);
 static void paint_hline_Y41B (paintinfo * p, int x, int y, int w);
 static void paint_hline_Y42B (paintinfo * p, int x, int y, int w);
+static void paint_hline_Y444 (paintinfo * p, int x, int y, int w);
 static void paint_hline_Y800 (paintinfo * p, int x, int y, int w);
+static void paint_hline_v308 (paintinfo * p, int x, int y, int w);
 static void paint_hline_AYUV (paintinfo * p, int x, int y, int w);
+static void paint_hline_v410 (paintinfo * p, int x, int y, int w);
+static void paint_hline_v216 (paintinfo * p, int x, int y, int w);
+static void paint_hline_v210 (paintinfo * p, int x, int y, int w);
 
 #if 0
 static void paint_hline_IMC1 (paintinfo * p, int x, int y, int w);
@@ -306,6 +398,11 @@
 
 static void paint_hline_bayer (paintinfo * p, int x, int y, int w);
 
+static void paint_setup_GRAY8 (paintinfo * p, unsigned char *dest);
+static void paint_setup_GRAY16 (paintinfo * p, unsigned char *dest);
+static void paint_hline_GRAY8 (paintinfo * p, int x, int y, int w);
+static void paint_hline_GRAY16 (paintinfo * p, int x, int y, int w);
+
 struct fourcc_list_struct fourcc_list[] = {
 /* packed */
   {VTS_YUV, "YUY2", "YUY2", 16, paint_setup_YUY2, paint_hline_YUY2},
@@ -313,7 +410,11 @@
   {VTS_YUV, "Y422", "Y422", 16, paint_setup_UYVY, paint_hline_YUY2},
   {VTS_YUV, "UYNV", "UYNV", 16, paint_setup_UYVY, paint_hline_YUY2},    /* FIXME: UYNV? */
   {VTS_YUV, "YVYU", "YVYU", 16, paint_setup_YVYU, paint_hline_YUY2},
+  {VTS_YUV, "v308", "v308", 24, paint_setup_v308, paint_hline_v308},
   {VTS_YUV, "AYUV", "AYUV", 32, paint_setup_AYUV, paint_hline_AYUV},
+  {VTS_YUV, "v410", "v410", 32, paint_setup_v410, paint_hline_v410},
+  {VTS_YUV, "v210", "v210", 21, paint_setup_v210, paint_hline_v210},
+  {VTS_YUV, "v216", "v216", 32, paint_setup_v216, paint_hline_v216},
 
   /* interlaced */
   /*{ VTS_YUV,  "IUYV", "IUY2", 16, paint_setup_YVYU, paint_hline_YUY2 }, */
@@ -345,7 +446,9 @@
   /* I420 */
   {VTS_YUV, "I420", "I420", 12, paint_setup_I420, paint_hline_I420},
   /* NV12 */
+  {VTS_YUV, "NV12", "NV12", 12, paint_setup_NV12, paint_hline_NV12_NV21},
   /* NV21 */
+  {VTS_YUV, "NV21", "NV21", 12, paint_setup_NV21, paint_hline_NV12_NV21},
 #if 0
   /* IMC1 */
   {VTS_YUV, "IMC1", "IMC1", 16, paint_setup_IMC1, paint_hline_IMC1},
@@ -361,9 +464,15 @@
   {VTS_YUV, "Y41B", "Y41B", 12, paint_setup_Y41B, paint_hline_Y41B},
   /* Y42B */
   {VTS_YUV, "Y42B", "Y42B", 16, paint_setup_Y42B, paint_hline_Y42B},
+  /* Y444 */
+  {VTS_YUV, "Y444", "Y444", 24, paint_setup_Y444, paint_hline_Y444},
   /* Y800 grayscale */
   {VTS_YUV, "Y800", "Y800", 8, paint_setup_Y800, paint_hline_Y800},
 
+  /* Not exactly YUV but it's the same as above */
+  {VTS_GRAY, "GRAY8", "GRAY8", 8, paint_setup_GRAY8, paint_hline_GRAY8},
+  {VTS_GRAY, "GRAY16", "GRAY16", 16, paint_setup_GRAY16, paint_hline_GRAY16},
+
   {VTS_RGB, "RGB ", "xRGB8888", 32, paint_setup_xRGB8888, paint_hline_str4, 24,
       0x00ff0000, 0x0000ff00, 0x000000ff},
   {VTS_RGB, "RGB ", "xBGR8888", 32, paint_setup_xBGR8888, paint_hline_str4, 24,
@@ -392,6 +501,7 @@
 
   {VTS_BAYER, "BAY8", "Bayer", 8, paint_setup_bayer, paint_hline_bayer}
 };
+
 int n_fourccs = G_N_ELEMENTS (fourcc_list);
 
 struct fourcc_list_struct *
@@ -403,7 +513,24 @@
 
   g_return_val_if_fail (structure, NULL);
 
-  if (strcmp (media_type, "video/x-raw-yuv") == 0) {
+  if (strcmp (media_type, "video/x-raw-gray") == 0) {
+    gint bpp, depth, endianness = 0;
+
+    ret = gst_structure_get_int (structure, "bpp", &bpp) &&
+        gst_structure_get_int (structure, "depth", &depth);
+    if (!ret || bpp != depth || (depth != 8 && depth != 16))
+      return NULL;
+
+    ret = gst_structure_get_int (structure, "endianness", &endianness);
+    if ((!ret || endianness != G_BYTE_ORDER) && bpp == 16)
+      return NULL;
+
+    for (i = 0; i < n_fourccs; i++) {
+      if (fourcc_list[i].type == VTS_GRAY && fourcc_list[i].bitspp == bpp) {
+        return fourcc_list + i;
+      }
+    }
+  } else if (strcmp (media_type, "video/x-raw-yuv") == 0) {
     char *s;
     int fourcc;
     guint32 format;
@@ -539,6 +666,14 @@
             format->alpha_mask, NULL);
       }
       break;
+    case VTS_GRAY:
+      structure = gst_structure_new ("video/x-raw-gray",
+          "bpp", G_TYPE_INT, format->bitspp, "depth", G_TYPE_INT,
+          format->bitspp, NULL);
+      if (format->bitspp == 16)
+        gst_structure_set (structure, "endianness", G_TYPE_INT, G_BYTE_ORDER,
+            NULL);
+      break;
     case VTS_YUV:
       structure = gst_structure_new ("video/x-raw-yuv",
           "format", GST_TYPE_FOURCC, fourcc, NULL);
@@ -584,6 +719,13 @@
   paintinfo *p = &pi;
   struct fourcc_list_struct *fourcc;
 
+  p->rgb_colors = vts_colors_rgb;
+  if (v->color_spec == GST_VIDEO_TEST_SRC_BT601) {
+    p->yuv_colors = vts_colors_bt601_ycbcr_100;
+  } else {
+    p->yuv_colors = vts_colors_bt709_ycbcr_100;
+  }
+  p->gray_colors = vts_colors_gray_100;
   p->width = w;
   p->height = h;
   fourcc = v->fourcc;
@@ -601,7 +743,9 @@
     int x1 = i * w / 7;
     int x2 = (i + 1) * w / 7;
 
-    p->color = vts_colors + i;
+    p->yuv_color = p->yuv_colors + i;
+    p->rgb_color = p->rgb_colors + i;
+    p->gray_color = p->gray_colors + i;
     for (j = 0; j < y1; j++) {
       p->paint_hline (p, x1, j, (x2 - x1));
     }
@@ -618,7 +762,9 @@
     } else {
       k = 6 - i;
     }
-    p->color = vts_colors + k;
+    p->yuv_color = p->yuv_colors + k;
+    p->rgb_color = p->rgb_colors + k;
+    p->gray_color = p->gray_colors + k;
     for (j = y1; j < y2; j++) {
       p->paint_hline (p, x1, j, (x2 - x1));
     }
@@ -637,7 +783,9 @@
     } else
       k = 9;
 
-    p->color = vts_colors + k;
+    p->yuv_color = p->yuv_colors + k;
+    p->rgb_color = p->rgb_colors + k;
+    p->gray_color = p->gray_colors + k;
     for (j = y2; j < h; j++) {
       p->paint_hline (p, x1, j, (x2 - x1));
     }
@@ -656,7 +804,9 @@
     } else
       k = COLOR_DARK_GREY;
 
-    p->color = vts_colors + k;
+    p->yuv_color = p->yuv_colors + k;
+    p->rgb_color = p->rgb_colors + k;
+    p->gray_color = p->gray_colors + k;
     for (j = y2; j < h; j++) {
       p->paint_hline (p, x1, j, (x2 - x1));
     }
@@ -664,18 +814,26 @@
 
   {
     int x1 = w * 3 / 4;
-    struct vts_color_struct color;
+    struct vts_color_struct_rgb rgb_color;
+    struct vts_color_struct_yuv yuv_color;
+    struct vts_color_struct_gray gray_color;
 
-    color = vts_colors[COLOR_BLACK];
-    p->color = &color;
+    rgb_color = p->rgb_colors[COLOR_BLACK];
+    yuv_color = p->yuv_colors[COLOR_BLACK];
+    gray_color = p->gray_colors[COLOR_BLACK];
+    p->rgb_color = &rgb_color;
+    p->yuv_color = &yuv_color;
+    p->gray_color = &gray_color;
 
     for (i = x1; i < w; i++) {
       for (j = y2; j < h; j++) {
         /* FIXME not strictly correct */
-        color.Y = random_char ();
-        color.R = color.Y;
-        color.G = color.Y;
-        color.B = color.Y;
+        int y = random_char ();
+        yuv_color.Y = y;
+        rgb_color.R = y;
+        rgb_color.G = y;
+        rgb_color.B = y;
+        gray_color.G = (y << 8) | random_char ();
         p->paint_hline (p, i, j, 1);
       }
     }
@@ -684,6 +842,46 @@
 }
 
 void
+gst_video_test_src_smpte75 (GstVideoTestSrc * v, unsigned char *dest, int w,
+    int h)
+{
+  int i;
+  int j;
+  paintinfo pi = { NULL, };
+  paintinfo *p = &pi;
+  struct fourcc_list_struct *fourcc;
+
+  p->rgb_colors = vts_colors_rgb_75;
+  if (v->color_spec == GST_VIDEO_TEST_SRC_BT601) {
+    p->yuv_colors = vts_colors_bt601_ycbcr_75;
+  } else {
+    p->yuv_colors = vts_colors_bt709_ycbcr_75;
+  }
+  p->gray_colors = vts_colors_gray_75;
+  p->width = w;
+  p->height = h;
+  fourcc = v->fourcc;
+  if (fourcc == NULL)
+    return;
+
+  fourcc->paint_setup (p, dest);
+  p->paint_hline = fourcc->paint_hline;
+
+  /* color bars */
+  for (i = 0; i < 7; i++) {
+    int x1 = i * w / 7;
+    int x2 = (i + 1) * w / 7;
+
+    p->yuv_color = p->yuv_colors + i;
+    p->rgb_color = p->rgb_colors + i;
+    p->gray_color = p->gray_colors + i;
+    for (j = 0; j < h; j++) {
+      p->paint_hline (p, x1, j, (x2 - x1));
+    }
+  }
+}
+
+void
 gst_video_test_src_snow (GstVideoTestSrc * v, unsigned char *dest, int w, int h)
 {
   int i;
@@ -691,8 +889,17 @@
   paintinfo pi = { NULL, };
   paintinfo *p = &pi;
   struct fourcc_list_struct *fourcc;
-  struct vts_color_struct color;
+  struct vts_color_struct_rgb rgb_color;
+  struct vts_color_struct_yuv yuv_color;
+  struct vts_color_struct_gray gray_color;
 
+  p->rgb_colors = vts_colors_rgb;
+  if (v->color_spec == GST_VIDEO_TEST_SRC_BT601) {
+    p->yuv_colors = vts_colors_bt601_ycbcr_100;
+  } else {
+    p->yuv_colors = vts_colors_bt709_ycbcr_100;
+  }
+  p->gray_colors = vts_colors_gray_100;
   p->width = w;
   p->height = h;
   fourcc = v->fourcc;
@@ -702,16 +909,22 @@
   fourcc->paint_setup (p, dest);
   p->paint_hline = fourcc->paint_hline;
 
-  color = vts_colors[COLOR_BLACK];
-  p->color = &color;
+  rgb_color = p->rgb_colors[COLOR_BLACK];
+  yuv_color = p->yuv_colors[COLOR_BLACK];
+  gray_color = p->gray_colors[COLOR_BLACK];
+  p->rgb_color = &rgb_color;
+  p->yuv_color = &yuv_color;
+  p->gray_color = &gray_color;
 
   for (i = 0; i < w; i++) {
     for (j = 0; j < h; j++) {
       /* FIXME not strictly correct */
-      color.Y = random_char ();
-      color.R = color.Y;
-      color.G = color.Y;
-      color.B = color.Y;
+      int y = random_char ();
+      yuv_color.Y = y;
+      rgb_color.R = y;
+      rgb_color.G = y;
+      rgb_color.B = y;
+      gray_color.G = (y << 8) | random_char ();
       p->paint_hline (p, i, j, 1);
     }
   }
@@ -719,13 +932,20 @@
 
 static void
 gst_video_test_src_unicolor (GstVideoTestSrc * v, unsigned char *dest, int w,
-    int h, const struct vts_color_struct *color)
+    int h, int color_index)
 {
   int i;
   paintinfo pi = { NULL, };
   paintinfo *p = &pi;
   struct fourcc_list_struct *fourcc;
 
+  p->rgb_colors = vts_colors_rgb;
+  if (v->color_spec == GST_VIDEO_TEST_SRC_BT601) {
+    p->yuv_colors = vts_colors_bt601_ycbcr_100;
+  } else {
+    p->yuv_colors = vts_colors_bt709_ycbcr_100;
+  }
+  p->gray_colors = vts_colors_gray_100;
   p->width = w;
   p->height = h;
   fourcc = v->fourcc;
@@ -735,7 +955,9 @@
   fourcc->paint_setup (p, dest);
   p->paint_hline = fourcc->paint_hline;
 
-  p->color = color;
+  p->rgb_color = p->rgb_colors + color_index;
+  p->yuv_color = p->yuv_colors + color_index;
+  p->gray_color = p->gray_colors + color_index;
 
   for (i = 0; i < h; i++) {
     p->paint_hline (p, 0, i, w);
@@ -745,31 +967,31 @@
 void
 gst_video_test_src_black (GstVideoTestSrc * v, guchar * dest, int w, int h)
 {
-  gst_video_test_src_unicolor (v, dest, w, h, vts_colors + COLOR_BLACK);
+  gst_video_test_src_unicolor (v, dest, w, h, COLOR_BLACK);
 }
 
 void
 gst_video_test_src_white (GstVideoTestSrc * v, guchar * dest, int w, int h)
 {
-  gst_video_test_src_unicolor (v, dest, w, h, vts_colors + COLOR_WHITE);
+  gst_video_test_src_unicolor (v, dest, w, h, COLOR_WHITE);
 }
 
 void
 gst_video_test_src_red (GstVideoTestSrc * v, guchar * dest, int w, int h)
 {
-  gst_video_test_src_unicolor (v, dest, w, h, vts_colors + COLOR_RED);
+  gst_video_test_src_unicolor (v, dest, w, h, COLOR_RED);
 }
 
 void
 gst_video_test_src_green (GstVideoTestSrc * v, guchar * dest, int w, int h)
 {
-  gst_video_test_src_unicolor (v, dest, w, h, vts_colors + COLOR_GREEN);
+  gst_video_test_src_unicolor (v, dest, w, h, COLOR_GREEN);
 }
 
 void
 gst_video_test_src_blue (GstVideoTestSrc * v, guchar * dest, int w, int h)
 {
-  gst_video_test_src_unicolor (v, dest, w, h, vts_colors + COLOR_BLUE);
+  gst_video_test_src_unicolor (v, dest, w, h, COLOR_BLUE);
 }
 
 void
@@ -780,6 +1002,13 @@
   paintinfo *p = &pi;
   struct fourcc_list_struct *fourcc;
 
+  p->rgb_colors = vts_colors_rgb;
+  if (v->color_spec == GST_VIDEO_TEST_SRC_BT601) {
+    p->yuv_colors = vts_colors_bt601_ycbcr_100;
+  } else {
+    p->yuv_colors = vts_colors_bt709_ycbcr_100;
+  }
+  p->gray_colors = vts_colors_gray_100;
   p->width = w;
   p->height = h;
   fourcc = v->fourcc;
@@ -790,10 +1019,14 @@
   p->paint_hline = fourcc->paint_hline;
 
   for (y = 0; y < h; y++) {
-    p->color = vts_colors + COLOR_GREEN;
+    p->rgb_color = p->rgb_colors + COLOR_GREEN;
+    p->yuv_color = p->yuv_colors + COLOR_GREEN;
+    p->gray_color = p->gray_colors + COLOR_GREEN;
     p->paint_hline (p, 0, y, w);
     for (x = (y % 2); x < w; x += 2) {
-      p->color = vts_colors + COLOR_RED;
+      p->rgb_color = p->rgb_colors + COLOR_RED;
+      p->yuv_color = p->yuv_colors + COLOR_RED;
+      p->gray_color = p->gray_colors + COLOR_RED;
       p->paint_hline (p, x, y, 1);
     }
   }
@@ -807,6 +1040,13 @@
   paintinfo *p = &pi;
   struct fourcc_list_struct *fourcc;
 
+  p->rgb_colors = vts_colors_rgb;
+  if (v->color_spec == GST_VIDEO_TEST_SRC_BT601) {
+    p->yuv_colors = vts_colors_bt601_ycbcr_100;
+  } else {
+    p->yuv_colors = vts_colors_bt709_ycbcr_100;
+  }
+  p->gray_colors = vts_colors_gray_100;
   p->width = w;
   p->height = h;
   fourcc = v->fourcc;
@@ -816,7 +1056,9 @@
   fourcc->paint_setup (p, dest);
   p->paint_hline = fourcc->paint_hline;
 
-  p->color = vts_colors + COLOR_GREEN;
+  p->rgb_color = p->rgb_colors + COLOR_GREEN;
+  p->yuv_color = p->yuv_colors + COLOR_GREEN;
+  p->gray_color = p->gray_colors + COLOR_GREEN;
   for (y = 0; y < h; y++) {
     p->paint_hline (p, 0, y, w);
   }
@@ -825,7 +1067,9 @@
     for (x = ((y % 4) == 0) ? 0 : 2; x < w; x += 4) {
       guint len = (x < (w - 1)) ? 2 : (w - x);
 
-      p->color = vts_colors + COLOR_RED;
+      p->rgb_color = p->rgb_colors + COLOR_RED;
+      p->yuv_color = p->yuv_colors + COLOR_RED;
+      p->gray_color = p->gray_colors + COLOR_RED;
       p->paint_hline (p, x, y + 0, len);
       if (G_LIKELY ((y + 1) < h)) {
         p->paint_hline (p, x, y + 1, len);
@@ -842,6 +1086,13 @@
   paintinfo *p = &pi;
   struct fourcc_list_struct *fourcc;
 
+  p->rgb_colors = vts_colors_rgb;
+  if (v->color_spec == GST_VIDEO_TEST_SRC_BT601) {
+    p->yuv_colors = vts_colors_bt601_ycbcr_100;
+  } else {
+    p->yuv_colors = vts_colors_bt709_ycbcr_100;
+  }
+  p->gray_colors = vts_colors_gray_100;
   p->width = w;
   p->height = h;
   fourcc = v->fourcc;
@@ -851,7 +1102,9 @@
   fourcc->paint_setup (p, dest);
   p->paint_hline = fourcc->paint_hline;
 
-  p->color = vts_colors + COLOR_GREEN;
+  p->rgb_color = p->rgb_colors + COLOR_GREEN;
+  p->yuv_color = p->yuv_colors + COLOR_GREEN;
+  p->gray_color = p->gray_colors + COLOR_GREEN;
   for (y = 0; y < h; y++) {
     p->paint_hline (p, 0, y, w);
   }
@@ -860,7 +1113,9 @@
     for (x = ((y % 8) == 0) ? 0 : 4; x < w; x += 8) {
       guint len = (x < (w - 3)) ? 4 : (w - x);
 
-      p->color = vts_colors + COLOR_RED;
+      p->rgb_color = p->rgb_colors + COLOR_RED;
+      p->yuv_color = p->yuv_colors + COLOR_RED;
+      p->gray_color = p->gray_colors + COLOR_RED;
       p->paint_hline (p, x, y + 0, len);
       if (G_LIKELY ((y + 1) < h)) {
         p->paint_hline (p, x, y + 1, len);
@@ -883,6 +1138,13 @@
   paintinfo *p = &pi;
   struct fourcc_list_struct *fourcc;
 
+  p->rgb_colors = vts_colors_rgb;
+  if (v->color_spec == GST_VIDEO_TEST_SRC_BT601) {
+    p->yuv_colors = vts_colors_bt601_ycbcr_100;
+  } else {
+    p->yuv_colors = vts_colors_bt709_ycbcr_100;
+  }
+  p->gray_colors = vts_colors_gray_100;
   p->width = w;
   p->height = h;
   fourcc = v->fourcc;
@@ -892,40 +1154,183 @@
   fourcc->paint_setup (p, dest);
   p->paint_hline = fourcc->paint_hline;
 
-  p->color = vts_colors + COLOR_GREEN;
+  p->rgb_color = p->rgb_colors + COLOR_GREEN;
+  p->yuv_color = p->yuv_colors + COLOR_GREEN;
+  p->gray_color = p->gray_colors + COLOR_GREEN;
   for (y = 0; y < h; y++) {
-    p->paint_hline (p, 0, y, w);
+    for (x = 0; x < w; x += 8) {
+      int len = MIN (8, w - x);
+
+      if ((x ^ y) & (1 << 4)) {
+        p->rgb_color = p->rgb_colors + COLOR_GREEN;
+        p->yuv_color = p->yuv_colors + COLOR_GREEN;
+        p->gray_color = p->gray_colors + COLOR_GREEN;
+      } else {
+        p->rgb_color = p->rgb_colors + COLOR_RED;
+        p->yuv_color = p->yuv_colors + COLOR_RED;
+        p->gray_color = p->gray_colors + COLOR_RED;
+      }
+      p->paint_hline (p, x, y, len);
+    }
+  }
+}
+
+void
+gst_video_test_src_zoneplate (GstVideoTestSrc * v, unsigned char *dest,
+    int w, int h)
+{
+  int i;
+  int j;
+  paintinfo pi = { NULL, };
+  paintinfo *p = &pi;
+  struct fourcc_list_struct *fourcc;
+  struct vts_color_struct_rgb rgb_color;
+  struct vts_color_struct_yuv yuv_color;
+  struct vts_color_struct_gray gray_color;
+  static uint8_t sine_array[256];
+  static int sine_array_inited = FALSE;
+
+  static int t = 0;             /* time - increment phase vs time by 1 for each generated frame */
+  /* this may not fit with the correct gstreamer notion of time, so maybe FIXME? */
+
+  int xreset = -(w / 2) - v->xoffset;   /* starting values for x^2 and y^2, centering the ellipse */
+  int yreset = -(h / 2) - v->yoffset;
+
+  int x, y;
+  int accum_kx;
+  int accum_kxt;
+  int accum_ky;
+  int accum_kyt;
+  int accum_kxy;
+  int kt;
+  int kt2;
+  int ky2;
+  int delta_kxt = v->kxt * t;
+  int delta_kxy;
+  int scale_kxy = 0xffff / (w / 2);
+  int scale_kx2 = 0xffff / w;
+
+  if (!sine_array_inited) {
+    int black = 16;
+    int white = 235;
+    int range = white - black;
+    for (i = 0; i < 256; i++) {
+      sine_array[i] =
+          floor (range * (0.5 + 0.5 * sin (i * 2 * M_PI / 256)) + 0.5 + black);
+    }
+    sine_array_inited = TRUE;
   }
 
-  for (y = 0; y < h; y += 8) {
-    for (x = ((GST_ROUND_UP_8 (y) % 16) == 0) ? 0 : 8; x < w; x += 16) {
-      guint len = (x < (w - 7)) ? 8 : (w - x);
+  p->rgb_colors = vts_colors_rgb;
+  if (v->color_spec == GST_VIDEO_TEST_SRC_BT601) {
+    p->yuv_colors = vts_colors_bt601_ycbcr_100;
+  } else {
+    p->yuv_colors = vts_colors_bt709_ycbcr_100;
+  }
+  p->gray_colors = vts_colors_gray_100;
+  p->width = w;
+  p->height = h;
+  fourcc = v->fourcc;
+  if (fourcc == NULL)
+    return;
+
+  fourcc->paint_setup (p, dest);
+  p->paint_hline = fourcc->paint_hline;
+
+  rgb_color = p->rgb_colors[COLOR_BLACK];
+  yuv_color = p->yuv_colors[COLOR_BLACK];
+  gray_color = p->gray_colors[COLOR_BLACK];
+  p->rgb_color = &rgb_color;
+  p->yuv_color = &yuv_color;
+  p->gray_color = &gray_color;
 
-      p->color = vts_colors + COLOR_RED;
-      p->paint_hline (p, x, y + 0, len);
-      if (G_LIKELY ((y + 1) < h)) {
-        p->paint_hline (p, x, y + 1, len);
-        if (G_LIKELY ((y + 2) < h)) {
-          p->paint_hline (p, x, y + 2, len);
-          if (G_LIKELY ((y + 3) < h)) {
-            p->paint_hline (p, x, y + 3, len);
-            if (G_LIKELY ((y + 4) < h)) {
-              p->paint_hline (p, x, y + 4, len);
-              if (G_LIKELY ((y + 5) < h)) {
-                p->paint_hline (p, x, y + 5, len);
-                if (G_LIKELY ((y + 6) < h)) {
-                  p->paint_hline (p, x, y + 6, len);
-                  if (G_LIKELY ((y + 7) < h)) {
-                    p->paint_hline (p, x, y + 7, len);
-                  }
-                }
-              }
-            }
-          }
-        }
-      }
+  /* Zoneplate equation:
+   *
+   * phase = k0 + kx*x + ky*y + kt*t
+   *       + kxt*x*t + kyt*y*t + kxy*x*y
+   *       + kx2*x*x + ky2*y*y + Kt2*t*t
+   */
+
+#if 0
+  for (j = 0, y = yreset; j < h; j++, y++) {
+    for (i = 0, x = xreset; i < w; i++, x++) {
+
+      //zero order
+      int phase = v->k0;
+
+      //first order
+      phase = phase + (v->kx * i) + (v->ky * j) + (v->kt * t);
+
+      //cross term
+      //phase = phase + (v->kxt * i * t) + (v->kyt * j * t);
+      //phase = phase + (v->kxy * x * y) / (w/2);
+
+      /*second order */
+      /*normalise x/y terms to rate of change of phase at the picture edge */
+      phase =
+          phase + ((v->kx2 * x * x) / w) + ((v->ky2 * y * y) / h) +
+          ((v->kt2 * t * t) >> 1);
+
+      color.Y = sine_array[phase & 0xff];
+
+      color.R = color.Y;
+      color.G = color.Y;
+      color.B = color.Y;
+      p->paint_hline (p, i, j, 1);
     }
   }
+#endif
+
+  /* optimised version, with original code shown in comments */
+  accum_ky = 0;
+  accum_kyt = 0;
+  kt = v->kt * t;
+  kt2 = v->kt2 * t * t;
+  for (j = 0, y = yreset; j < h; j++, y++) {
+    accum_kx = 0;
+    accum_kxt = 0;
+    accum_ky += v->ky;
+    accum_kyt += v->kyt * t;
+    delta_kxy = v->kxy * y * scale_kxy;
+    accum_kxy = delta_kxy * xreset;
+    ky2 = (v->ky2 * y * y) / h;
+    for (i = 0, x = xreset; i < w; i++, x++) {
+
+      //zero order
+      int phase = v->k0;
+
+      //first order
+      accum_kx += v->kx;
+      //phase = phase + (v->kx * i) + (v->ky * j) + (v->kt * t);
+      phase = phase + accum_kx + accum_ky + kt;
+
+      //cross term
+      accum_kxt += delta_kxt;
+      accum_kxy += delta_kxy;
+      //phase = phase + (v->kxt * i * t) + (v->kyt * j * t);
+      phase = phase + accum_kxt + accum_kyt;
+
+      //phase = phase + (v->kxy * x * y) / (w/2);
+      //phase = phase + accum_kxy / (w/2) ;
+      phase = phase + (accum_kxy >> 16);
+
+      /*second order */
+      /*normalise x/y terms to rate of change of phase at the picture edge */
+      //phase = phase + ((v->kx2 * x * x)/w) + ((v->ky2 * y * y)/h) + ((v->kt2 * t * t)>>1);
+      phase = phase + ((v->kx2 * x * x * scale_kx2) >> 16) + ky2 + (kt2 >> 1);
+
+      yuv_color.Y = sine_array[phase & 0xff];
+
+      rgb_color.R = yuv_color.Y;
+      rgb_color.G = yuv_color.Y;
+      rgb_color.B = yuv_color.Y;
+
+      gray_color.G = yuv_color.Y << 8;
+      p->paint_hline (p, i, j, 1);
+    }
+  }
+
+  t++;
 }
 
 #undef SCALE_AMPLITUDE
@@ -938,7 +1343,9 @@
   paintinfo pi = { NULL, };
   paintinfo *p = &pi;
   struct fourcc_list_struct *fourcc;
-  struct vts_color_struct color;
+  struct vts_color_struct_rgb rgb_color;
+  struct vts_color_struct_yuv yuv_color;
+  struct vts_color_struct_gray gray_color;
   static uint8_t sine_array[256];
   static int sine_array_inited = FALSE;
   double freq[8];
@@ -956,6 +1363,13 @@
     sine_array_inited = TRUE;
   }
 
+  p->rgb_colors = vts_colors_rgb;
+  if (v->color_spec == GST_VIDEO_TEST_SRC_BT601) {
+    p->yuv_colors = vts_colors_bt601_ycbcr_100;
+  } else {
+    p->yuv_colors = vts_colors_bt709_ycbcr_100;
+  }
+  p->gray_colors = vts_colors_gray_100;
   p->width = w;
   p->height = h;
   fourcc = v->fourcc;
@@ -965,8 +1379,12 @@
   fourcc->paint_setup (p, dest);
   p->paint_hline = fourcc->paint_hline;
 
-  color = vts_colors[COLOR_BLACK];
-  p->color = &color;
+  rgb_color = p->rgb_colors[COLOR_BLACK];
+  yuv_color = p->yuv_colors[COLOR_BLACK];
+  gray_color = p->gray_colors[COLOR_BLACK];
+  p->rgb_color = &rgb_color;
+  p->yuv_color = &yuv_color;
+  p->gray_color = &gray_color;
 
   for (i = 1; i < 8; i++) {
     freq[i] = 200 * pow (2.0, -(i - 1) / 4.0);
@@ -990,7 +1408,8 @@
               h)) / (2 * w);
       seg = floor (dist * 16);
       if (seg == 0 || seg >= 8) {
-        color.Y = 255;
+        yuv_color.Y = 255;
+        gray_color.G = 65535;
       } else {
 #ifdef SCALE_AMPLITUDE
         double a;
@@ -1000,14 +1419,16 @@
         a = ampl[seg];
         if (a < 0)
           a = 0;
-        color.Y = 128 + a * (sine_array[d & 0xff] - 128);
+        yuv_color.Y = 128 + a * (sine_array[d & 0xff] - 128);
+        gray_color.G = 128 + a * (sine_array[d & 0xff] - 128);
 #else
-        color.Y = sine_array[d & 0xff];
+        yuv_color.Y = sine_array[d & 0xff];
+        gray_color.G = sine_array[d & 0xff];
 #endif
       }
-      color.R = color.Y;
-      color.G = color.Y;
-      color.B = color.Y;
+      rgb_color.R = yuv_color.Y;
+      rgb_color.G = yuv_color.Y;
+      rgb_color.B = yuv_color.Y;
       p->paint_hline (p, i, j, 1);
     }
   }
@@ -1026,6 +1447,30 @@
 }
 
 static void
+paint_setup_NV12 (paintinfo * p, unsigned char *dest)
+{
+  p->yp = dest;
+  p->ystride = GST_ROUND_UP_4 (p->width);
+  p->up = p->yp + p->ystride * GST_ROUND_UP_2 (p->height);
+  p->vp = p->up + 1;
+  p->ustride = p->ystride;
+  p->vstride = p->ystride;
+  p->endptr = p->up + (p->ystride * GST_ROUND_UP_2 (p->height)) / 2;
+}
+
+static void
+paint_setup_NV21 (paintinfo * p, unsigned char *dest)
+{
+  p->yp = dest;
+  p->ystride = GST_ROUND_UP_4 (p->width);
+  p->vp = p->yp + p->ystride * GST_ROUND_UP_2 (p->height);
+  p->up = p->vp + 1;
+  p->ustride = p->ystride;
+  p->vstride = p->ystride;
+  p->endptr = p->vp + (p->ystride * GST_ROUND_UP_2 (p->height)) / 2;
+}
+
+static void
 paint_hline_I420 (paintinfo * p, int x, int y, int w)
 {
   int x1 = x / 2;
@@ -1033,9 +1478,25 @@
   int offset = y * p->ystride;
   int offset1 = (y / 2) * p->ustride;
 
-  oil_splat_u8_ns (p->yp + offset + x, &p->color->Y, w);
-  oil_splat_u8_ns (p->up + offset1 + x1, &p->color->U, x2 - x1);
-  oil_splat_u8_ns (p->vp + offset1 + x1, &p->color->V, x2 - x1);
+  oil_splat_u8_ns (p->yp + offset + x, &p->yuv_color->Y, w);
+  oil_splat_u8_ns (p->up + offset1 + x1, &p->yuv_color->U, x2 - x1);
+  oil_splat_u8_ns (p->vp + offset1 + x1, &p->yuv_color->V, x2 - x1);
+}
+
+static void
+paint_hline_NV12_NV21 (paintinfo * p, int x, int y, int w)
+{
+  int x1 = x / 2;
+  int x2 = (x + w) / 2;
+  int offset = y * p->ystride;
+  int offsetuv = (y / 2) * p->ustride + (x & ~0x01);
+  int uvlength = x2 - x1 + 1;
+
+  oil_splat_u8_ns (p->yp + offset + x, &p->yuv_color->Y, w);
+  if (uvlength) {
+    oil_splat_u8 (p->up + offsetuv, 2, &p->yuv_color->U, uvlength);
+    oil_splat_u8 (p->vp + offsetuv, 2, &p->yuv_color->V, uvlength);
+  }
 }
 
 static void
@@ -1051,6 +1512,16 @@
 }
 
 static void
+paint_setup_v308 (paintinfo * p, unsigned char *dest)
+{
+  p->yp = dest;
+  p->up = dest + 1;
+  p->vp = dest + 2;
+  p->ystride = GST_ROUND_UP_4 (p->width * 3);
+  p->endptr = dest + p->ystride * p->height;
+}
+
+static void
 paint_setup_AYUV (paintinfo * p, unsigned char *dest)
 {
   p->ap = dest;
@@ -1062,6 +1533,38 @@
 }
 
 static void
+paint_setup_v410 (paintinfo * p, unsigned char *dest)
+{
+  p->yp = dest + 0;
+  p->up = dest + 0;
+  p->vp = dest + 0;
+  p->ystride = p->width * 4;
+  p->endptr = dest + p->ystride * p->height;
+}
+
+static void
+paint_setup_v216 (paintinfo * p, unsigned char *dest)
+{
+  p->ap = dest;
+  p->yp = dest + 2;
+  p->up = dest + 0;
+  p->vp = dest + 4;
+  p->ystride = p->width * 4;
+  p->endptr = dest + p->ystride * p->height;
+}
+
+static void
+paint_setup_v210 (paintinfo * p, unsigned char *dest)
+{
+  p->ap = dest;
+  p->yp = dest + 0;
+  p->up = dest + 0;
+  p->vp = dest + 0;
+  p->ystride = ((p->width + 47) / 48) * 128;    /* no, really. */
+  p->endptr = dest + p->ystride * p->height;
+}
+
+static void
 paint_setup_YUY2 (paintinfo * p, unsigned char *dest)
 {
   p->yp = dest;
@@ -1092,15 +1595,96 @@
 }
 
 static void
-paint_hline_AYUV (paintinfo * p, int x, int y, int w)
+paint_hline_v308 (paintinfo * p, int x, int y, int w)
 {
   int offset;
 
+  offset = (y * p->ystride) + (x * 3);
+  oil_splat_u8 (p->yp + offset, 3, &p->yuv_color->Y, w);
+  oil_splat_u8 (p->up + offset, 3, &p->yuv_color->U, w);
+  oil_splat_u8 (p->vp + offset, 3, &p->yuv_color->V, w);
+}
+
+static void
+paint_hline_AYUV (paintinfo * p, int x, int y, int w)
+{
+  int offset;
+  guint8 alpha = 255;
+
   offset = (y * p->ystride) + (x * 4);
-  oil_splat_u8 (p->yp + offset, 4, &p->color->Y, w);
-  oil_splat_u8 (p->up + offset, 4, &p->color->U, w);
-  oil_splat_u8 (p->vp + offset, 4, &p->color->V, w);
-  oil_splat_u8 (p->ap + offset, 4, &p->color->A, w);
+  oil_splat_u8 (p->yp + offset, 4, &p->yuv_color->Y, w);
+  oil_splat_u8 (p->up + offset, 4, &p->yuv_color->U, w);
+  oil_splat_u8 (p->vp + offset, 4, &p->yuv_color->V, w);
+  oil_splat_u8 (p->ap + offset, 4, &alpha, w);
+}
+
+#define TO_16(x) (((x)<<8) | (x))
+#define TO_10(x) (((x)<<2) | ((x)>>6))
+
+static void
+paint_hline_v216 (paintinfo * p, int x, int y, int w)
+{
+  int x1 = x / 2;
+  int x2 = (x + w) / 2;
+  uint16_t Y, U, V;
+  int i;
+  int offset;
+
+  offset = y * p->ystride;
+  Y = TO_16 (p->yuv_color->Y);
+  U = TO_16 (p->yuv_color->U);
+  V = TO_16 (p->yuv_color->V);
+  for (i = x; i < x + w; i++) {
+    GST_WRITE_UINT16_LE (p->yp + offset + i * 4, Y);
+  }
+  for (i = x1; i < x2; i++) {
+    GST_WRITE_UINT16_LE (p->up + offset + i * 8, U);
+    GST_WRITE_UINT16_LE (p->vp + offset + i * 8, V);
+  }
+}
+
+static void
+paint_hline_v410 (paintinfo * p, int x, int y, int w)
+{
+  uint32_t a;
+  uint8_t *data;
+  int i;
+
+  a = (TO_10 (p->yuv_color->U) << 22) |
+      (TO_10 (p->yuv_color->Y) << 12) | (TO_10 (p->yuv_color->V) << 2);
+
+  data = p->yp + y * p->ystride + x * 4;
+  for (i = 0; i < w; i++) {
+    GST_WRITE_UINT32_LE (data, a);
+  }
+}
+
+static void
+paint_hline_v210 (paintinfo * p, int x, int y, int w)
+{
+  uint32_t a0, a1, a2, a3;
+  uint8_t *data;
+  int i;
+
+  /* FIXME this is kinda gross.  it only handles x values in
+     multiples of 6 */
+
+  a0 = TO_10 (p->yuv_color->U) | (TO_10 (p->yuv_color->Y) << 10)
+      | (TO_10 (p->yuv_color->V) << 20);
+  a1 = TO_10 (p->yuv_color->Y) | (TO_10 (p->yuv_color->U) << 10)
+      | (TO_10 (p->yuv_color->Y) << 20);
+  a2 = TO_10 (p->yuv_color->V) | (TO_10 (p->yuv_color->Y) << 10)
+      | (TO_10 (p->yuv_color->U) << 20);
+  a3 = TO_10 (p->yuv_color->Y) | (TO_10 (p->yuv_color->V) << 10)
+      | (TO_10 (p->yuv_color->Y) << 20);
+
+  data = p->yp + y * p->ystride;
+  for (i = x / 6; i < (x + w) / 6; i++) {
+    GST_WRITE_UINT32_LE (data + i * 16 + 0, a0);
+    GST_WRITE_UINT32_LE (data + i * 16 + 4, a1);
+    GST_WRITE_UINT32_LE (data + i * 16 + 8, a2);
+    GST_WRITE_UINT32_LE (data + i * 16 + 12, a3);
+  }
 }
 
 static void
@@ -1111,9 +1695,9 @@
   int offset;
 
   offset = y * p->ystride;
-  oil_splat_u8 (p->yp + offset + x * 2, 2, &p->color->Y, w);
-  oil_splat_u8 (p->up + offset + x1 * 4, 4, &p->color->U, x2 - x1);
-  oil_splat_u8 (p->vp + offset + x1 * 4, 4, &p->color->V, x2 - x1);
+  oil_splat_u8 (p->yp + offset + x * 2, 2, &p->yuv_color->Y, w);
+  oil_splat_u8 (p->up + offset + x1 * 4, 4, &p->yuv_color->U, x2 - x1);
+  oil_splat_u8 (p->vp + offset + x1 * 4, 4, &p->yuv_color->V, x2 - x1);
 }
 
 static void
@@ -1133,9 +1717,9 @@
   int offset;
 
   offset = y * p->ystride;
-  oil_splat_u8 (p->yp + offset + x * 3, 3, &p->color->Y, w);
-  oil_splat_u8 (p->up + offset + x * 3, 3, &p->color->U, w);
-  oil_splat_u8 (p->vp + offset + x * 3, 3, &p->color->V, w);
+  oil_splat_u8 (p->yp + offset + x * 3, 3, &p->yuv_color->Y, w);
+  oil_splat_u8 (p->up + offset + x * 3, 3, &p->yuv_color->U, w);
+  oil_splat_u8 (p->vp + offset + x * 3, 3, &p->yuv_color->V, w);
 }
 
 static void
@@ -1158,9 +1742,9 @@
   int offset = y * p->ystride;
   int offset1 = y * p->ustride;
 
-  oil_splat_u8_ns (p->yp + offset + x, &p->color->Y, w);
-  oil_splat_u8_ns (p->up + offset1 + x1, &p->color->U, x2 - x1);
-  oil_splat_u8_ns (p->vp + offset1 + x1, &p->color->V, x2 - x1);
+  oil_splat_u8_ns (p->yp + offset + x, &p->yuv_color->Y, w);
+  oil_splat_u8_ns (p->up + offset1 + x1, &p->yuv_color->U, x2 - x1);
+  oil_splat_u8_ns (p->vp + offset1 + x1, &p->yuv_color->V, x2 - x1);
 }
 
 static void
@@ -1183,9 +1767,29 @@
   int offset = y * p->ystride;
   int offset1 = y * p->ustride;
 
-  oil_splat_u8_ns (p->yp + offset + x, &p->color->Y, w);
-  oil_splat_u8_ns (p->up + offset1 + x1, &p->color->U, x2 - x1);
-  oil_splat_u8_ns (p->vp + offset1 + x1, &p->color->V, x2 - x1);
+  oil_splat_u8_ns (p->yp + offset + x, &p->yuv_color->Y, w);
+  oil_splat_u8_ns (p->up + offset1 + x1, &p->yuv_color->U, x2 - x1);
+  oil_splat_u8_ns (p->vp + offset1 + x1, &p->yuv_color->V, x2 - x1);
+}
+
+static void
+paint_setup_Y444 (paintinfo * p, unsigned char *dest)
+{
+  p->yp = dest;
+  p->ystride = GST_ROUND_UP_4 (p->width);
+  p->up = p->yp + p->ystride * p->height;
+  p->vp = p->up + p->ystride * p->height;
+  p->endptr = p->vp + p->ystride * p->height;
+}
+
+static void
+paint_hline_Y444 (paintinfo * p, int x, int y, int w)
+{
+  int offset = y * p->ystride;
+
+  oil_splat_u8_ns (p->yp + offset + x, &p->yuv_color->Y, w);
+  oil_splat_u8_ns (p->up + offset + x, &p->yuv_color->U, w);
+  oil_splat_u8_ns (p->vp + offset + x, &p->yuv_color->V, w);
 }
 
 static void
@@ -1202,7 +1806,7 @@
 {
   int offset = y * p->ystride;
 
-  oil_splat_u8_ns (p->yp + offset + x, &p->color->Y, w);
+  oil_splat_u8_ns (p->yp + offset + x, &p->yuv_color->Y, w);
 }
 
 #if 0
@@ -1246,9 +1850,9 @@
   int offset = y * p->width;
   int offset1 = (y / 2) * p->width;
 
-  oil_splat_u8_ns (p->yp + offset + x, &p->color->Y, w);
-  oil_splat_u8_ns (p->up + offset1 + x1, &p->color->U, x2 - x1);
-  oil_splat_u8_ns (p->vp + offset1 + x1, &p->color->V, x2 - x1);
+  oil_splat_u8_ns (p->yp + offset + x, &p->yuv_color->Y, w);
+  oil_splat_u8_ns (p->up + offset1 + x1, &p->yuv_color->U, x2 - x1);
+  oil_splat_u8_ns (p->vp + offset1 + x1, &p->yuv_color->V, x2 - x1);
 }
 #endif
 
@@ -1289,9 +1893,9 @@
   int offset = y * p->ystride;
   int offset1 = (y / 4) * p->ustride;
 
-  oil_splat_u8_ns (p->yp + offset + x, &p->color->Y, w);
-  oil_splat_u8_ns (p->up + offset1 + x1, &p->color->U, x2 - x1);
-  oil_splat_u8_ns (p->vp + offset1 + x1, &p->color->V, x2 - x1);
+  oil_splat_u8_ns (p->yp + offset + x, &p->yuv_color->Y, w);
+  oil_splat_u8_ns (p->up + offset1 + x1, &p->yuv_color->U, x2 - x1);
+  oil_splat_u8_ns (p->vp + offset1 + x1, &p->yuv_color->V, x2 - x1);
 }
 
 static void
@@ -1386,13 +1990,14 @@
 paint_hline_str4 (paintinfo * p, int x, int y, int w)
 {
   int offset = y * p->ystride;
+  guint8 alpha = 255;
 
-  oil_splat_u8 (p->yp + offset + x * 4, 4, &p->color->R, w);
-  oil_splat_u8 (p->up + offset + x * 4, 4, &p->color->G, w);
-  oil_splat_u8 (p->vp + offset + x * 4, 4, &p->color->B, w);
+  oil_splat_u8 (p->yp + offset + x * 4, 4, &p->rgb_color->R, w);
+  oil_splat_u8 (p->up + offset + x * 4, 4, &p->rgb_color->G, w);
+  oil_splat_u8 (p->vp + offset + x * 4, 4, &p->rgb_color->B, w);
 
   if (p->ap != NULL) {
-    oil_splat_u8 (p->ap + offset + (x * 4), 4, &p->color->A, w);
+    oil_splat_u8 (p->ap + offset + (x * 4), 4, &alpha, w);
   }
 }
 
@@ -1401,9 +2006,9 @@
 {
   int offset = y * p->ystride;
 
-  oil_splat_u8 (p->yp + offset + x * 3, 3, &p->color->R, w);
-  oil_splat_u8 (p->up + offset + x * 3, 3, &p->color->G, w);
-  oil_splat_u8 (p->vp + offset + x * 3, 3, &p->color->B, w);
+  oil_splat_u8 (p->yp + offset + x * 3, 3, &p->rgb_color->R, w);
+  oil_splat_u8 (p->up + offset + x * 3, 3, &p->rgb_color->G, w);
+  oil_splat_u8 (p->vp + offset + x * 3, 3, &p->rgb_color->B, w);
 }
 
 static void
@@ -1420,8 +2025,8 @@
   int offset = y * p->ystride;
   uint8_t a, b;
 
-  a = (p->color->R & 0xf8) | (p->color->G >> 5);
-  b = ((p->color->G << 3) & 0xe0) | (p->color->B >> 3);
+  a = (p->rgb_color->R & 0xf8) | (p->rgb_color->G >> 5);
+  b = ((p->rgb_color->G << 3) & 0xe0) | (p->rgb_color->B >> 3);
 
 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
   oil_splat_u8 (p->yp + offset + x * 2 + 0, 2, &b, w);
@@ -1446,8 +2051,8 @@
   int offset = y * p->ystride;
   uint8_t a, b;
 
-  a = ((p->color->R >> 1) & 0x7c) | (p->color->G >> 6);
-  b = ((p->color->G << 2) & 0xe0) | (p->color->B >> 3);
+  a = ((p->rgb_color->R >> 1) & 0x7c) | (p->rgb_color->G >> 6);
+  b = ((p->rgb_color->G << 2) & 0xe0) | (p->rgb_color->B >> 3);
 
 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
   oil_splat_u8 (p->yp + offset + x * 2 + 0, 2, &b, w);
@@ -1477,18 +2082,51 @@
   if (y & 1) {
     for (i = x; i < x + w; i++) {
       if (i & 1) {
-        dest[i] = p->color->G;
+        dest[i] = p->rgb_color->G;
       } else {
-        dest[i] = p->color->B;
+        dest[i] = p->rgb_color->B;
       }
     }
   } else {
     for (i = x; i < x + w; i++) {
       if (i & 1) {
-        dest[i] = p->color->R;
+        dest[i] = p->rgb_color->R;
       } else {
-        dest[i] = p->color->G;
+        dest[i] = p->rgb_color->G;
       }
     }
   }
 }
+
+static void
+paint_setup_GRAY8 (paintinfo * p, unsigned char *dest)
+{
+  p->yp = dest;
+  p->ystride = GST_ROUND_UP_4 (p->width);
+  p->endptr = dest + p->ystride * p->height;
+}
+
+static void
+paint_hline_GRAY8 (paintinfo * p, int x, int y, int w)
+{
+  int offset = y * p->ystride;
+  guint8 color = p->gray_color->G >> 8;
+
+  oil_splat_u8_ns (p->yp + offset + x, &color, w);
+}
+
+static void
+paint_setup_GRAY16 (paintinfo * p, unsigned char *dest)
+{
+  p->yp = dest;
+  p->ystride = GST_ROUND_UP_4 (p->width * 2);
+  p->endptr = dest + p->ystride * p->height;
+}
+
+static void
+paint_hline_GRAY16 (paintinfo * p, int x, int y, int w)
+{
+  int offset = y * p->ystride;
+
+  oil_splat_u16_ns ((guint16 *) (p->yp + offset + 2 * x), &p->gray_color->G, w);
+}