videotestsrc: port to video helpers
authorWim Taymans <wim.taymans@collabora.co.uk>
Tue, 21 Jun 2011 15:33:27 +0000 (17:33 +0200)
committerWim Taymans <wim.taymans@collabora.co.uk>
Tue, 21 Jun 2011 15:36:21 +0000 (17:36 +0200)
Port videotestsrc to use the video helper functions to parse caps and handle
video frames.
Enable GstMetaVideo to make us handle strided video.

gst/videotestsrc/Makefile.am
gst/videotestsrc/gstvideotestsrc.c
gst/videotestsrc/gstvideotestsrc.h
gst/videotestsrc/videotestsrc.c
gst/videotestsrc/videotestsrc.h

index 814899f..8e1d880 100644 (file)
@@ -8,9 +8,10 @@ libgstvideotestsrc_la_SOURCES = \
                        videotestsrc.c
 nodist_libgstvideotestsrc_la_SOURCES = $(ORC_NODIST_SOURCES)
 
-libgstvideotestsrc_la_CFLAGS = $(GST_BASE_CFLAGS) $(GST_CFLAGS) $(ORC_CFLAGS)
+libgstvideotestsrc_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CFLAGS) $(ORC_CFLAGS)
 libgstvideotestsrc_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
-libgstvideotestsrc_la_LIBADD = $(GST_BASE_LIBS) $(GST_LIBS) $(ORC_LIBS) $(LIBM)
+libgstvideotestsrc_la_LIBADD = $(GST_PLUGINS_BASE_LIBS) -lgstvideo-$(GST_MAJORMINOR) \
+                              $(GST_BASE_LIBS) $(GST_LIBS) $(ORC_LIBS) $(LIBM)
 libgstvideotestsrc_la_LIBTOOLFLAGS = --tag=disable-static
 
 noinst_HEADERS = gstvideotestsrc.h videotestsrc.h
index d535a81..652dec4 100644 (file)
@@ -107,6 +107,7 @@ static gboolean gst_video_test_src_setup_allocation (GstBaseSrc * bsrc,
 static GstFlowReturn gst_video_test_src_fill (GstPushSrc * psrc,
     GstBuffer * buffer);
 static gboolean gst_video_test_src_start (GstBaseSrc * basesrc);
+static gboolean gst_video_test_src_stop (GstBaseSrc * basesrc);
 
 #define GST_TYPE_VIDEO_TEST_SRC_PATTERN (gst_video_test_src_pattern_get_type ())
 static GType
@@ -304,6 +305,7 @@ gst_video_test_src_class_init (GstVideoTestSrcClass * klass)
   gstbasesrc_class->query = gst_video_test_src_query;
   gstbasesrc_class->get_times = gst_video_test_src_get_times;
   gstbasesrc_class->start = gst_video_test_src_start;
+  gstbasesrc_class->stop = gst_video_test_src_stop;
   gstbasesrc_class->setup_allocation = gst_video_test_src_setup_allocation;
 
   gstpushsrc_class->fill = gst_video_test_src_fill;
@@ -563,6 +565,23 @@ gst_video_test_src_get_property (GObject * object, guint prop_id,
   }
 }
 
+static GstVideoTestSrcColorSpec
+to_color_spec (const gchar * csp)
+{
+  if (csp) {
+    if (strcmp (csp, "sdtv") == 0) {
+      return GST_VIDEO_TEST_SRC_BT601;
+    } else if (strcmp (csp, "hdtv") == 0) {
+      return GST_VIDEO_TEST_SRC_BT709;
+    } else {
+      GST_DEBUG ("unknown color-matrix");
+      return GST_VIDEO_TEST_SRC_UNKNOWN;
+    }
+  } else {
+    return GST_VIDEO_TEST_SRC_BT601;
+  }
+}
+
 /* threadsafe because this gets called as the plugin is loaded */
 static GstCaps *
 gst_video_test_src_getcaps (GstBaseSrc * bsrc, GstCaps * filter)
@@ -595,56 +614,32 @@ gst_video_test_src_getcaps (GstBaseSrc * bsrc, GstCaps * filter)
 
 static gboolean
 gst_video_test_src_parse_caps (const GstCaps * caps,
-    gint * width, gint * height, gint * rate_numerator, gint * rate_denominator,
-    struct format_list_struct **format, GstVideoTestSrcColorSpec * color_spec)
+    gint * width, gint * height, gint * fps_n, gint * fps_d,
+    const gchar ** color_matrix)
 {
   const GstStructure *structure;
   GstPadLinkReturn ret;
   const GValue *framerate;
-  const char *csp;
 
   GST_DEBUG ("parsing caps");
 
-  if (gst_caps_get_size (caps) < 1)
-    return FALSE;
-
   structure = gst_caps_get_structure (caps, 0);
 
-  if (!(*format = paintinfo_find_by_structure (structure)))
-    goto unknown_format;
-
   ret = gst_structure_get_int (structure, "width", width);
   ret &= gst_structure_get_int (structure, "height", height);
   framerate = gst_structure_get_value (structure, "framerate");
 
   if (framerate) {
-    *rate_numerator = gst_value_get_fraction_numerator (framerate);
-    *rate_denominator = gst_value_get_fraction_denominator (framerate);
+    *fps_n = gst_value_get_fraction_numerator (framerate);
+    *fps_d = gst_value_get_fraction_denominator (framerate);
   } else
     goto no_framerate;
 
-  csp = gst_structure_get_string (structure, "color-matrix");
-  if (csp) {
-    if (strcmp (csp, "sdtv") == 0) {
-      *color_spec = GST_VIDEO_TEST_SRC_BT601;
-    } else if (strcmp (csp, "hdtv") == 0) {
-      *color_spec = GST_VIDEO_TEST_SRC_BT709;
-    } else {
-      GST_DEBUG ("unknown color-matrix");
-      return FALSE;
-    }
-  } else {
-    *color_spec = GST_VIDEO_TEST_SRC_BT601;
-  }
+  *color_matrix = gst_structure_get_string (structure, "color-matrix");
 
   return ret;
 
   /* ERRORS */
-unknown_format:
-  {
-    GST_DEBUG ("videotestsrc format not found");
-    return FALSE;
-  }
 no_framerate:
   {
     GST_DEBUG ("videotestsrc no framerate given");
@@ -663,10 +658,16 @@ gst_video_test_src_setup_allocation (GstBaseSrc * bsrc, GstQuery * query)
 
   gst_query_parse_allocation_params (query, &size, &min, &max, &prefix,
       &alignment, &pool);
-
   /* adjust size */
-  size = MAX (size, videotestsrc->size);
+  size = MAX (size, videotestsrc->info.size);
+
+  if (pool) {
+    GstStructure *config;
 
+    config = gst_buffer_pool_get_config (pool);
+    gst_buffer_pool_config_add_meta (config, GST_META_API_VIDEO);
+    gst_buffer_pool_set_config (pool, config);
+  }
   gst_query_set_allocation_params (query, size, min, max, prefix,
       alignment, pool);
 
@@ -676,35 +677,48 @@ gst_video_test_src_setup_allocation (GstBaseSrc * bsrc, GstQuery * query)
 static gboolean
 gst_video_test_src_setcaps (GstBaseSrc * bsrc, GstCaps * caps)
 {
-  gboolean res;
-  gint width, height, rate_denominator, rate_numerator;
   struct format_list_struct *format;
+  const GstStructure *structure;
   GstVideoTestSrc *videotestsrc;
-  GstVideoTestSrcColorSpec color_spec;
+  GstVideoInfo info;
 
   videotestsrc = GST_VIDEO_TEST_SRC (bsrc);
 
-  res = gst_video_test_src_parse_caps (caps, &width, &height,
-      &rate_numerator, &rate_denominator, &format, &color_spec);
-  if (!res)
-    goto parse_failed;
+  structure = gst_caps_get_structure (caps, 0);
+
+  if (gst_structure_has_name (structure, "video/x-raw")) {
+    /* we can use the parsing code */
+    if (!gst_video_info_from_caps (&info, caps))
+      goto parse_failed;
+
+  } else if (gst_structure_has_name (structure, "video/x-raw-bayer")) {
+    if (!gst_video_test_src_parse_caps (caps, &info.width, &info.height,
+            &info.fps_n, &info.fps_d, &info.color_matrix))
+      goto parse_failed;
+
+    info.size =
+        gst_video_test_src_get_size (videotestsrc, info.width, info.height);
+  }
+
+  if (!(format = paintinfo_find_by_structure (structure)))
+    goto unknown_format;
 
   /* looks ok here */
+  videotestsrc->color_spec = to_color_spec (info.color_matrix);
   videotestsrc->format = format;
-  videotestsrc->width = width;
-  videotestsrc->height = height;
-  videotestsrc->rate_numerator = rate_numerator;
-  videotestsrc->rate_denominator = rate_denominator;
-  videotestsrc->bpp = videotestsrc->format->bitspp;
-  videotestsrc->color_spec = color_spec;
-  videotestsrc->size =
-      gst_video_test_src_get_size (videotestsrc, width, height);
+  videotestsrc->info = info;
 
   GST_DEBUG_OBJECT (videotestsrc, "size %dx%d, %d/%d fps",
-      videotestsrc->width, videotestsrc->height,
-      videotestsrc->rate_numerator, videotestsrc->rate_denominator);
+      info.width, info.height, info.fps_n, info.fps_d);
 
-  return res;
+  g_free (videotestsrc->tmpline);
+  g_free (videotestsrc->tmpline2);
+  g_free (videotestsrc->tmpline_u8);
+  videotestsrc->tmpline_u8 = g_malloc (info.width + 8);
+  videotestsrc->tmpline = g_malloc ((info.width + 8) * 4);
+  videotestsrc->tmpline2 = g_malloc ((info.width + 8) * 4);
+
+  return TRUE;
 
   /* ERRORS */
 parse_failed:
@@ -712,6 +726,11 @@ parse_failed:
     GST_DEBUG_OBJECT (bsrc, "failed to parse caps");
     return FALSE;
   }
+unknown_format:
+  {
+    GST_DEBUG ("videotestsrc format not found");
+    return FALSE;
+  }
 }
 
 static gboolean
@@ -729,61 +748,17 @@ gst_video_test_src_query (GstBaseSrc * bsrc, GstQuery * query)
       gint64 src_val, dest_val;
 
       gst_query_parse_convert (query, &src_fmt, &src_val, &dest_fmt, &dest_val);
-      if (src_fmt == dest_fmt) {
-        dest_val = src_val;
-        goto done;
-      }
-
-      switch (src_fmt) {
-        case GST_FORMAT_DEFAULT:
-          switch (dest_fmt) {
-            case GST_FORMAT_TIME:
-              /* frames to time */
-              if (src->rate_numerator) {
-                dest_val = gst_util_uint64_scale (src_val,
-                    src->rate_denominator * GST_SECOND, src->rate_numerator);
-              } else {
-                dest_val = 0;
-              }
-              break;
-            default:
-              goto error;
-          }
-          break;
-        case GST_FORMAT_TIME:
-          switch (dest_fmt) {
-            case GST_FORMAT_DEFAULT:
-              /* time to frames */
-              if (src->rate_numerator) {
-                dest_val = gst_util_uint64_scale (src_val,
-                    src->rate_numerator, src->rate_denominator * GST_SECOND);
-              } else {
-                dest_val = 0;
-              }
-              break;
-            default:
-              goto error;
-          }
-          break;
-        default:
-          goto error;
-      }
-    done:
+      res =
+          gst_video_info_convert (&src->info, src_fmt, src_val, dest_fmt,
+          &dest_val);
       gst_query_set_convert (query, src_fmt, src_val, dest_fmt, dest_val);
-      res = TRUE;
       break;
     }
     default:
       res = GST_BASE_SRC_CLASS (parent_class)->query (bsrc, query);
+      break;
   }
   return res;
-
-  /* ERROR */
-error:
-  {
-    GST_DEBUG_OBJECT (src, "query failed");
-    return FALSE;
-  }
 }
 
 static void
@@ -821,15 +796,15 @@ gst_video_test_src_do_seek (GstBaseSrc * bsrc, GstSegment * segment)
   position = segment->position;
 
   /* now move to the position indicated */
-  if (src->rate_numerator) {
+  if (src->info.fps_n) {
     src->n_frames = gst_util_uint64_scale (position,
-        src->rate_numerator, src->rate_denominator * GST_SECOND);
+        src->info.fps_n, src->info.fps_d * GST_SECOND);
   } else {
     src->n_frames = 0;
   }
-  if (src->rate_numerator) {
+  if (src->info.fps_n) {
     src->running_time = gst_util_uint64_scale (src->n_frames,
-        src->rate_denominator * GST_SECOND, src->rate_numerator);
+        src->info.fps_d * GST_SECOND, src->info.fps_n);
   } else {
     /* FIXME : Not sure what to set here */
     src->running_time = 0;
@@ -851,9 +826,8 @@ static GstFlowReturn
 gst_video_test_src_fill (GstPushSrc * psrc, GstBuffer * buffer)
 {
   GstVideoTestSrc *src;
-  gsize size;
   GstClockTime next_time;
-  guint8 *data;
+  GstVideoFrame frame;
 
   src = GST_VIDEO_TEST_SRC (psrc);
 
@@ -861,32 +835,26 @@ gst_video_test_src_fill (GstPushSrc * psrc, GstBuffer * buffer)
     goto not_negotiated;
 
   /* 0 framerate and we are at the second frame, eos */
-  if (G_UNLIKELY (src->rate_numerator == 0 && src->n_frames == 1))
+  if (G_UNLIKELY (src->info.fps_n == 0 && src->n_frames == 1))
     goto eos;
 
   GST_LOG_OBJECT (src,
       "creating buffer from pool for frame %d", (gint) src->n_frames);
 
-  data = gst_buffer_map (buffer, &size, NULL, GST_MAP_WRITE);
-  memset (data, 0, size);
-  src->tmpline_u8 = g_malloc (src->width + 8);
-  src->tmpline = g_malloc ((src->width + 8) * 4);
-  src->tmpline2 = g_malloc ((src->width + 8) * 4);
+  if (!gst_video_frame_map (&frame, &src->info, buffer, GST_MAP_WRITE))
+    goto invalid_frame;
 
-  src->make_image (src, (void *) data, src->width, src->height);
-  gst_buffer_unmap (buffer, data, size);
+  src->make_image (src, &frame);
 
-  g_free (src->tmpline);
-  g_free (src->tmpline2);
-  g_free (src->tmpline_u8);
+  gst_video_frame_unmap (&frame);
 
   GST_BUFFER_TIMESTAMP (buffer) = src->timestamp_offset + src->running_time;
   GST_BUFFER_OFFSET (buffer) = src->n_frames;
   src->n_frames++;
   GST_BUFFER_OFFSET_END (buffer) = src->n_frames;
-  if (src->rate_numerator) {
+  if (src->info.fps_n) {
     next_time = gst_util_uint64_scale_int (src->n_frames * GST_SECOND,
-        src->rate_denominator, src->rate_numerator);
+        src->info.fps_d, src->info.fps_n);
     GST_BUFFER_DURATION (buffer) = next_time - src->running_time;
   } else {
     next_time = src->timestamp_offset;
@@ -909,6 +877,11 @@ eos:
     GST_DEBUG_OBJECT (src, "eos: 0 framerate, frame %d", (gint) src->n_frames);
     return GST_FLOW_UNEXPECTED;
   }
+invalid_frame:
+  {
+    GST_DEBUG_OBJECT (src, "invalid frame");
+    return GST_FLOW_OK;
+  }
 }
 
 static gboolean
@@ -923,6 +896,21 @@ gst_video_test_src_start (GstBaseSrc * basesrc)
 }
 
 static gboolean
+gst_video_test_src_stop (GstBaseSrc * basesrc)
+{
+  GstVideoTestSrc *src = GST_VIDEO_TEST_SRC (basesrc);
+
+  g_free (src->tmpline);
+  src->tmpline = NULL;
+  g_free (src->tmpline2);
+  src->tmpline2 = NULL;
+  g_free (src->tmpline_u8);
+  src->tmpline_u8 = NULL;
+
+  return TRUE;
+}
+
+static gboolean
 plugin_init (GstPlugin * plugin)
 {
   gst_videotestsrc_orc_init ();
index abbd899..ac723bc 100644 (file)
@@ -24,6 +24,8 @@
 #include <gst/gst.h>
 #include <gst/base/gstpushsrc.h>
 
+#include <gst/video/gstmetavideo.h>
+
 G_BEGIN_DECLS
 
 #define GST_TYPE_VIDEO_TEST_SRC \
@@ -111,6 +113,7 @@ typedef enum {
  * The color specification to use.
  */
 typedef enum {
+  GST_VIDEO_TEST_SRC_UNKNOWN,
   GST_VIDEO_TEST_SRC_BT601,
   GST_VIDEO_TEST_SRC_BT709
 } GstVideoTestSrcColorSpec;
@@ -135,14 +138,10 @@ struct _GstVideoTestSrc {
   GstVideoTestSrcColorSpec color_spec;
 
   /* video state */
+  GstVideoInfo info;
+
   char *format_name;
-  gint width;
-  gint height;
   struct format_list_struct *format;
-  gint bpp;
-  gint rate_numerator;
-  gint rate_denominator;
-  guint size;
 
   /* private */
   gint64 timestamp_offset;              /* base offset */
@@ -171,7 +170,7 @@ struct _GstVideoTestSrc {
   gint horizontal_offset;
   gint horizontal_speed;
 
-  void (*make_image) (GstVideoTestSrc *v, unsigned char *dest, int w, int h);
+  void (*make_image) (GstVideoTestSrc *v, GstVideoFrame *frame);
 
   /* temporary AYUV/ARGB scanline */
   guint8 *tmpline_u8;
index 8a589b7..c39ac9e 100644 (file)
@@ -125,50 +125,50 @@ static const struct vts_color_struct vts_colors_bt601_ycbcr_75[] = {
 };
 
 
-static void paint_setup_I420 (paintinfo * p, unsigned char *dest);
-static void paint_setup_YV12 (paintinfo * p, unsigned char *dest);
-static void paint_setup_YUY2 (paintinfo * p, unsigned char *dest);
-static void paint_setup_UYVY (paintinfo * p, unsigned char *dest);
-static void paint_setup_YVYU (paintinfo * p, unsigned char *dest);
+static void paint_setup_I420 (paintinfo * p, GstVideoFrame * frame);
+static void paint_setup_YV12 (paintinfo * p, GstVideoFrame * frame);
+static void paint_setup_YUY2 (paintinfo * p, GstVideoFrame * frame);
+static void paint_setup_UYVY (paintinfo * p, GstVideoFrame * frame);
+static void paint_setup_YVYU (paintinfo * p, GstVideoFrame * frame);
 #ifdef disabled
-static void paint_setup_IYU2 (paintinfo * p, unsigned char *dest);
+static void paint_setup_IYU2 (paintinfo * p, GstVideoFrame * frame);
 #endif
-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_Y41B (paintinfo * p, GstVideoFrame * frame);
+static void paint_setup_Y42B (paintinfo * p, GstVideoFrame * frame);
+static void paint_setup_Y444 (paintinfo * p, GstVideoFrame * frame);
+static void paint_setup_Y800 (paintinfo * p, GstVideoFrame * frame);
+static void paint_setup_AYUV (paintinfo * p, GstVideoFrame * frame);
+static void paint_setup_v308 (paintinfo * p, GstVideoFrame * frame);
+static void paint_setup_NV12 (paintinfo * p, GstVideoFrame * frame);
+static void paint_setup_NV21 (paintinfo * p, GstVideoFrame * frame);
 #ifdef disabled
-static void paint_setup_v410 (paintinfo * p, unsigned char *dest);
+static void paint_setup_v410 (paintinfo * p, GstVideoFrame * frame);
 #endif
-static void paint_setup_v216 (paintinfo * p, unsigned char *dest);
-static void paint_setup_v210 (paintinfo * p, unsigned char *dest);
-static void paint_setup_UYVP (paintinfo * p, unsigned char *dest);
-static void paint_setup_AY64 (paintinfo * p, unsigned char *dest);
-
-static void paint_setup_YUV9 (paintinfo * p, unsigned char *dest);
-static void paint_setup_YVU9 (paintinfo * p, unsigned char *dest);
-static void paint_setup_ARGB8888 (paintinfo * p, unsigned char *dest);
-static void paint_setup_ABGR8888 (paintinfo * p, unsigned char *dest);
-static void paint_setup_RGBA8888 (paintinfo * p, unsigned char *dest);
-static void paint_setup_BGRA8888 (paintinfo * p, unsigned char *dest);
-static void paint_setup_xRGB8888 (paintinfo * p, unsigned char *dest);
-static void paint_setup_xBGR8888 (paintinfo * p, unsigned char *dest);
-static void paint_setup_RGBx8888 (paintinfo * p, unsigned char *dest);
-static void paint_setup_BGRx8888 (paintinfo * p, unsigned char *dest);
-static void paint_setup_RGB888 (paintinfo * p, unsigned char *dest);
-static void paint_setup_BGR888 (paintinfo * p, unsigned char *dest);
-static void paint_setup_RGB565 (paintinfo * p, unsigned char *dest);
-static void paint_setup_xRGB1555 (paintinfo * p, unsigned char *dest);
-static void paint_setup_ARGB64 (paintinfo * p, unsigned char *dest);
-
-static void paint_setup_bayer_bggr (paintinfo * p, unsigned char *dest);
-static void paint_setup_bayer_rggb (paintinfo * p, unsigned char *dest);
-static void paint_setup_bayer_gbrg (paintinfo * p, unsigned char *dest);
-static void paint_setup_bayer_grbg (paintinfo * p, unsigned char *dest);
+static void paint_setup_v216 (paintinfo * p, GstVideoFrame * frame);
+static void paint_setup_v210 (paintinfo * p, GstVideoFrame * frame);
+static void paint_setup_UYVP (paintinfo * p, GstVideoFrame * frame);
+static void paint_setup_AY64 (paintinfo * p, GstVideoFrame * frame);
+
+static void paint_setup_YUV9 (paintinfo * p, GstVideoFrame * frame);
+static void paint_setup_YVU9 (paintinfo * p, GstVideoFrame * frame);
+static void paint_setup_ARGB8888 (paintinfo * p, GstVideoFrame * frame);
+static void paint_setup_ABGR8888 (paintinfo * p, GstVideoFrame * frame);
+static void paint_setup_RGBA8888 (paintinfo * p, GstVideoFrame * frame);
+static void paint_setup_BGRA8888 (paintinfo * p, GstVideoFrame * frame);
+static void paint_setup_xRGB8888 (paintinfo * p, GstVideoFrame * frame);
+static void paint_setup_xBGR8888 (paintinfo * p, GstVideoFrame * frame);
+static void paint_setup_RGBx8888 (paintinfo * p, GstVideoFrame * frame);
+static void paint_setup_BGRx8888 (paintinfo * p, GstVideoFrame * frame);
+static void paint_setup_RGB888 (paintinfo * p, GstVideoFrame * frame);
+static void paint_setup_BGR888 (paintinfo * p, GstVideoFrame * frame);
+static void paint_setup_RGB565 (paintinfo * p, GstVideoFrame * frame);
+static void paint_setup_xRGB1555 (paintinfo * p, GstVideoFrame * frame);
+static void paint_setup_ARGB64 (paintinfo * p, GstVideoFrame * frame);
+
+static void paint_setup_bayer_bggr (paintinfo * p, GstVideoFrame * frame);
+static void paint_setup_bayer_rggb (paintinfo * p, GstVideoFrame * frame);
+static void paint_setup_bayer_gbrg (paintinfo * p, GstVideoFrame * frame);
+static void paint_setup_bayer_grbg (paintinfo * p, GstVideoFrame * frame);
 
 static void convert_hline_I420 (paintinfo * p, int y);
 static void convert_hline_NV12 (paintinfo * p, int y);
@@ -201,8 +201,8 @@ static void convert_hline_xRGB1555 (paintinfo * p, int y);
 
 static void convert_hline_bayer (paintinfo * p, int y);
 
-static void paint_setup_GRAY8 (paintinfo * p, unsigned char *dest);
-static void paint_setup_GRAY16 (paintinfo * p, unsigned char *dest);
+static void paint_setup_GRAY8 (paintinfo * p, GstVideoFrame * frame);
+static void paint_setup_GRAY16 (paintinfo * p, GstVideoFrame * frame);
 static void convert_hline_GRAY8 (paintinfo * p, int y);
 static void convert_hline_GRAY16 (paintinfo * p, int y);
 
@@ -460,7 +460,7 @@ gst_video_test_src_get_size (GstVideoTestSrc * v, int w, int h)
 
   format->paint_setup (p, NULL);
 
-  return (unsigned long) p->endptr;
+  return p->size;
 }
 
 #define SCALEBITS 10
@@ -635,8 +635,7 @@ videotestsrc_blend_line (GstVideoTestSrc * v, guint8 * dest, guint8 * src,
 }
 
 void
-gst_video_test_src_smpte (GstVideoTestSrc * v, unsigned char *dest, int w,
-    int h)
+gst_video_test_src_smpte (GstVideoTestSrc * v, GstVideoFrame * frame)
 {
   int i;
   int y1, y2;
@@ -644,13 +643,14 @@ gst_video_test_src_smpte (GstVideoTestSrc * v, unsigned char *dest, int w,
   paintinfo pi = { NULL, };
   paintinfo *p = &pi;
   struct format_list_struct *format;
+  int w = frame->info.width, h = frame->info.height;
 
-  videotestsrc_setup_paintinfo (v, p, w, h);
+  videotestsrc_setup_paintinfo (v, p, frame->info.width, frame->info.height);
   format = v->format;
   if (format == NULL)
     return;
 
-  format->paint_setup (p, dest);
+  format->paint_setup (p, frame);
 
   y1 = 2 * h / 3;
   y2 = h * 0.75;
@@ -741,14 +741,14 @@ gst_video_test_src_smpte (GstVideoTestSrc * v, unsigned char *dest, int w,
 }
 
 void
-gst_video_test_src_smpte75 (GstVideoTestSrc * v, unsigned char *dest, int w,
-    int h)
+gst_video_test_src_smpte75 (GstVideoTestSrc * v, GstVideoFrame * frame)
 {
   int i;
   int j;
   paintinfo pi = { NULL, };
   paintinfo *p = &pi;
   struct format_list_struct *format;
+  int w = frame->info.width, h = frame->info.height;
 
   videotestsrc_setup_paintinfo (v, p, w, h);
   if (v->color_spec == GST_VIDEO_TEST_SRC_BT601) {
@@ -760,7 +760,7 @@ gst_video_test_src_smpte75 (GstVideoTestSrc * v, unsigned char *dest, int w,
   if (format == NULL)
     return;
 
-  format->paint_setup (p, dest);
+  format->paint_setup (p, frame);
 
   /* color bars */
   for (j = 0; j < h; j++) {
@@ -776,21 +776,21 @@ gst_video_test_src_smpte75 (GstVideoTestSrc * v, unsigned char *dest, int w,
 }
 
 void
-gst_video_test_src_smpte100 (GstVideoTestSrc * v, unsigned char *dest, int w,
-    int h)
+gst_video_test_src_smpte100 (GstVideoTestSrc * v, GstVideoFrame * frame)
 {
   int i;
   int j;
   paintinfo pi = { NULL, };
   paintinfo *p = &pi;
   struct format_list_struct *format;
+  int w = frame->info.width, h = frame->info.height;
 
   videotestsrc_setup_paintinfo (v, p, w, h);
   format = v->format;
   if (format == NULL)
     return;
 
-  format->paint_setup (p, dest);
+  format->paint_setup (p, frame);
 
   /* color bars */
   for (j = 0; j < h; j++) {
@@ -806,19 +806,20 @@ gst_video_test_src_smpte100 (GstVideoTestSrc * v, unsigned char *dest, int w,
 }
 
 void
-gst_video_test_src_bar (GstVideoTestSrc * v, unsigned char *dest, int w, int h)
+gst_video_test_src_bar (GstVideoTestSrc * v, GstVideoFrame * frame)
 {
   int j;
   paintinfo pi = { NULL, };
   paintinfo *p = &pi;
   struct format_list_struct *format;
+  int w = frame->info.width, h = frame->info.height;
 
   videotestsrc_setup_paintinfo (v, p, w, h);
   format = v->format;
   if (format == NULL)
     return;
 
-  format->paint_setup (p, dest);
+  format->paint_setup (p, frame);
 
   for (j = 0; j < h; j++) {
     /* use fixed size for now */
@@ -833,7 +834,7 @@ gst_video_test_src_bar (GstVideoTestSrc * v, unsigned char *dest, int w, int h)
 }
 
 void
-gst_video_test_src_snow (GstVideoTestSrc * v, unsigned char *dest, int w, int h)
+gst_video_test_src_snow (GstVideoTestSrc * v, GstVideoFrame * frame)
 {
   int i;
   int j;
@@ -841,13 +842,14 @@ gst_video_test_src_snow (GstVideoTestSrc * v, unsigned char *dest, int w, int h)
   paintinfo *p = &pi;
   struct format_list_struct *format;
   struct vts_color_struct color;
+  int w = frame->info.width, h = frame->info.height;
 
   videotestsrc_setup_paintinfo (v, p, w, h);
   format = v->format;
   if (format == NULL)
     return;
 
-  format->paint_setup (p, dest);
+  format->paint_setup (p, frame);
 
   color = p->colors[COLOR_BLACK];
   p->color = &color;
@@ -864,20 +866,21 @@ gst_video_test_src_snow (GstVideoTestSrc * v, unsigned char *dest, int w, int h)
 }
 
 static void
-gst_video_test_src_unicolor (GstVideoTestSrc * v, unsigned char *dest, int w,
-    int h, int color_index)
+gst_video_test_src_unicolor (GstVideoTestSrc * v, GstVideoFrame * frame,
+    int color_index)
 {
   int i;
   paintinfo pi = { NULL, };
   paintinfo *p = &pi;
   struct format_list_struct *format;
+  int w = frame->info.width, h = frame->info.height;
 
   videotestsrc_setup_paintinfo (v, p, w, h);
   format = v->format;
   if (format == NULL)
     return;
 
-  format->paint_setup (p, dest);
+  format->paint_setup (p, frame);
 
   p->color = p->colors + color_index;
   if (color_index == COLOR_BLACK) {
@@ -894,43 +897,43 @@ gst_video_test_src_unicolor (GstVideoTestSrc * v, unsigned char *dest, int w,
 }
 
 void
-gst_video_test_src_black (GstVideoTestSrc * v, guchar * dest, int w, int h)
+gst_video_test_src_black (GstVideoTestSrc * v, GstVideoFrame * frame)
 {
-  gst_video_test_src_unicolor (v, dest, w, h, COLOR_BLACK);
+  gst_video_test_src_unicolor (v, frame, COLOR_BLACK);
 }
 
 void
-gst_video_test_src_white (GstVideoTestSrc * v, guchar * dest, int w, int h)
+gst_video_test_src_white (GstVideoTestSrc * v, GstVideoFrame * frame)
 {
-  gst_video_test_src_unicolor (v, dest, w, h, COLOR_WHITE);
+  gst_video_test_src_unicolor (v, frame, COLOR_WHITE);
 }
 
 void
-gst_video_test_src_red (GstVideoTestSrc * v, guchar * dest, int w, int h)
+gst_video_test_src_red (GstVideoTestSrc * v, GstVideoFrame * frame)
 {
-  gst_video_test_src_unicolor (v, dest, w, h, COLOR_RED);
+  gst_video_test_src_unicolor (v, frame, COLOR_RED);
 }
 
 void
-gst_video_test_src_green (GstVideoTestSrc * v, guchar * dest, int w, int h)
+gst_video_test_src_green (GstVideoTestSrc * v, GstVideoFrame * frame)
 {
-  gst_video_test_src_unicolor (v, dest, w, h, COLOR_GREEN);
+  gst_video_test_src_unicolor (v, frame, COLOR_GREEN);
 }
 
 void
-gst_video_test_src_blue (GstVideoTestSrc * v, guchar * dest, int w, int h)
+gst_video_test_src_blue (GstVideoTestSrc * v, GstVideoFrame * frame)
 {
-  gst_video_test_src_unicolor (v, dest, w, h, COLOR_BLUE);
+  gst_video_test_src_unicolor (v, frame, COLOR_BLUE);
 }
 
 void
-gst_video_test_src_blink (GstVideoTestSrc * v, unsigned char *dest, int w,
-    int h)
+gst_video_test_src_blink (GstVideoTestSrc * v, GstVideoFrame * frame)
 {
   int i;
   paintinfo pi = { NULL, };
   paintinfo *p = &pi;
   struct format_list_struct *format;
+  int w = frame->info.width, h = frame->info.height;
 
   videotestsrc_setup_paintinfo (v, p, w, h);
 
@@ -938,7 +941,7 @@ gst_video_test_src_blink (GstVideoTestSrc * v, unsigned char *dest, int w,
   if (format == NULL)
     return;
 
-  format->paint_setup (p, dest);
+  format->paint_setup (p, frame);
 
   if (v->n_frames & 1) {
     p->color = &p->foreground_color;
@@ -953,13 +956,13 @@ gst_video_test_src_blink (GstVideoTestSrc * v, unsigned char *dest, int w,
 }
 
 void
-gst_video_test_src_solid (GstVideoTestSrc * v, unsigned char *dest, int w,
-    int h)
+gst_video_test_src_solid (GstVideoTestSrc * v, GstVideoFrame * frame)
 {
   int i;
   paintinfo pi = { NULL, };
   paintinfo *p = &pi;
   struct format_list_struct *format;
+  int w = frame->info.width, h = frame->info.height;
 
   videotestsrc_setup_paintinfo (v, p, w, h);
 
@@ -967,7 +970,7 @@ gst_video_test_src_solid (GstVideoTestSrc * v, unsigned char *dest, int w,
   if (format == NULL)
     return;
 
-  format->paint_setup (p, dest);
+  format->paint_setup (p, frame);
 
   p->color = &p->foreground_color;
 
@@ -978,12 +981,13 @@ gst_video_test_src_solid (GstVideoTestSrc * v, unsigned char *dest, int w,
 }
 
 void
-gst_video_test_src_checkers1 (GstVideoTestSrc * v, guchar * dest, int w, int h)
+gst_video_test_src_checkers1 (GstVideoTestSrc * v, GstVideoFrame * frame)
 {
   int x, y;
   paintinfo pi = { NULL, };
   paintinfo *p = &pi;
   struct format_list_struct *format;
+  int w = frame->info.width, h = frame->info.height;
 
   videotestsrc_setup_paintinfo (v, p, w, h);
 
@@ -991,7 +995,7 @@ gst_video_test_src_checkers1 (GstVideoTestSrc * v, guchar * dest, int w, int h)
   if (format == NULL)
     return;
 
-  format->paint_setup (p, dest);
+  format->paint_setup (p, frame);
 
   for (y = 0; y < h; y++) {
     for (x = 0; x < w; x++) {
@@ -1007,19 +1011,20 @@ gst_video_test_src_checkers1 (GstVideoTestSrc * v, guchar * dest, int w, int h)
 }
 
 void
-gst_video_test_src_checkers2 (GstVideoTestSrc * v, guchar * dest, int w, int h)
+gst_video_test_src_checkers2 (GstVideoTestSrc * v, GstVideoFrame * frame)
 {
   int x, y;
   paintinfo pi = { NULL, };
   paintinfo *p = &pi;
   struct format_list_struct *format;
+  int w = frame->info.width, h = frame->info.height;
 
   videotestsrc_setup_paintinfo (v, p, w, h);
   format = v->format;
   if (format == NULL)
     return;
 
-  format->paint_setup (p, dest);
+  format->paint_setup (p, frame);
 
   for (y = 0; y < h; y++) {
     for (x = 0; x < w; x += 2) {
@@ -1037,19 +1042,20 @@ gst_video_test_src_checkers2 (GstVideoTestSrc * v, guchar * dest, int w, int h)
 }
 
 void
-gst_video_test_src_checkers4 (GstVideoTestSrc * v, guchar * dest, int w, int h)
+gst_video_test_src_checkers4 (GstVideoTestSrc * v, GstVideoFrame * frame)
 {
   int x, y;
   paintinfo pi = { NULL, };
   paintinfo *p = &pi;
   struct format_list_struct *format;
+  int w = frame->info.width, h = frame->info.height;
 
   videotestsrc_setup_paintinfo (v, p, w, h);
   format = v->format;
   if (format == NULL)
     return;
 
-  format->paint_setup (p, dest);
+  format->paint_setup (p, frame);
 
   for (y = 0; y < h; y++) {
     for (x = 0; x < w; x += 4) {
@@ -1067,19 +1073,20 @@ gst_video_test_src_checkers4 (GstVideoTestSrc * v, guchar * dest, int w, int h)
 }
 
 void
-gst_video_test_src_checkers8 (GstVideoTestSrc * v, guchar * dest, int w, int h)
+gst_video_test_src_checkers8 (GstVideoTestSrc * v, GstVideoFrame * frame)
 {
   int x, y;
   paintinfo pi = { NULL, };
   paintinfo *p = &pi;
   struct format_list_struct *format;
+  int w = frame->info.width, h = frame->info.height;
 
   videotestsrc_setup_paintinfo (v, p, w, h);
   format = v->format;
   if (format == NULL)
     return;
 
-  format->paint_setup (p, dest);
+  format->paint_setup (p, frame);
 
   for (y = 0; y < h; y++) {
     for (x = 0; x < w; x += 8) {
@@ -1133,8 +1140,7 @@ static const guint8 sine_table[256] = {
 
 
 void
-gst_video_test_src_zoneplate (GstVideoTestSrc * v, unsigned char *dest,
-    int w, int h)
+gst_video_test_src_zoneplate (GstVideoTestSrc * v, GstVideoFrame * frame)
 {
   int i;
   int j;
@@ -1143,6 +1149,7 @@ gst_video_test_src_zoneplate (GstVideoTestSrc * v, unsigned char *dest,
   struct format_list_struct *format;
   struct vts_color_struct color;
   int t = v->n_frames;
+  int w = frame->info.width, h = frame->info.height;
   int xreset = -(w / 2) - v->xoffset;   /* starting values for x^2 and y^2, centering the ellipse */
   int yreset = -(h / 2) - v->yoffset;
 
@@ -1165,7 +1172,7 @@ gst_video_test_src_zoneplate (GstVideoTestSrc * v, unsigned char *dest,
   if (format == NULL)
     return;
 
-  format->paint_setup (p, dest);
+  format->paint_setup (p, frame);
 
   color = p->colors[COLOR_BLACK];
   p->color = &color;
@@ -1254,8 +1261,7 @@ gst_video_test_src_zoneplate (GstVideoTestSrc * v, unsigned char *dest,
 }
 
 void
-gst_video_test_src_chromazoneplate (GstVideoTestSrc * v, unsigned char *dest,
-    int w, int h)
+gst_video_test_src_chromazoneplate (GstVideoTestSrc * v, GstVideoFrame * frame)
 {
   int i;
   int j;
@@ -1264,6 +1270,7 @@ gst_video_test_src_chromazoneplate (GstVideoTestSrc * v, unsigned char *dest,
   struct format_list_struct *format;
   struct vts_color_struct color;
   int t = v->n_frames;
+  int w = frame->info.width, h = frame->info.height;
 
   int xreset = -(w / 2) - v->xoffset;   /* starting values for x^2 and y^2, centering the ellipse */
   int yreset = -(h / 2) - v->yoffset;
@@ -1287,7 +1294,7 @@ gst_video_test_src_chromazoneplate (GstVideoTestSrc * v, unsigned char *dest,
   if (format == NULL)
     return;
 
-  format->paint_setup (p, dest);
+  format->paint_setup (p, frame);
 
   color = p->colors[COLOR_BLACK];
   p->color = &color;
@@ -1354,8 +1361,7 @@ gst_video_test_src_chromazoneplate (GstVideoTestSrc * v, unsigned char *dest,
 
 #undef SCALE_AMPLITUDE
 void
-gst_video_test_src_circular (GstVideoTestSrc * v, unsigned char *dest,
-    int w, int h)
+gst_video_test_src_circular (GstVideoTestSrc * v, GstVideoFrame * frame)
 {
   int i;
   int j;
@@ -1363,6 +1369,7 @@ gst_video_test_src_circular (GstVideoTestSrc * v, unsigned char *dest,
   paintinfo *p = &pi;
   struct format_list_struct *format;
   double freq[8];
+  int w = frame->info.width, h = frame->info.height;
 
   int d;
 
@@ -1371,7 +1378,7 @@ gst_video_test_src_circular (GstVideoTestSrc * v, unsigned char *dest,
   if (format == NULL)
     return;
 
-  format->paint_setup (p, dest);
+  format->paint_setup (p, frame);
 
   for (i = 1; i < 8; i++) {
     freq[i] = 200 * pow (2.0, -(i - 1) / 4.0);
@@ -1400,7 +1407,7 @@ gst_video_test_src_circular (GstVideoTestSrc * v, unsigned char *dest,
 }
 
 void
-gst_video_test_src_gamut (GstVideoTestSrc * v, guchar * dest, int w, int h)
+gst_video_test_src_gamut (GstVideoTestSrc * v, GstVideoFrame * frame)
 {
   int x, y;
   paintinfo pi = { NULL, };
@@ -1408,13 +1415,14 @@ gst_video_test_src_gamut (GstVideoTestSrc * v, guchar * dest, int w, int h)
   struct format_list_struct *format;
   struct vts_color_struct yuv_primary;
   struct vts_color_struct yuv_secondary;
+  int w = frame->info.width, h = frame->info.height;
 
   videotestsrc_setup_paintinfo (v, p, w, h);
   format = v->format;
   if (format == NULL)
     return;
 
-  format->paint_setup (p, dest);
+  format->paint_setup (p, frame);
 
   for (y = 0; y < h; y++) {
     int region = (y * 4) / h;
@@ -1457,7 +1465,7 @@ gst_video_test_src_gamut (GstVideoTestSrc * v, guchar * dest, int w, int h)
 }
 
 void
-gst_video_test_src_ball (GstVideoTestSrc * v, unsigned char *dest, int w, int h)
+gst_video_test_src_ball (GstVideoTestSrc * v, GstVideoFrame * frame)
 {
   int i;
   paintinfo pi = { NULL, };
@@ -1466,13 +1474,14 @@ gst_video_test_src_ball (GstVideoTestSrc * v, unsigned char *dest, int w, int h)
   int t = v->n_frames;
   double x, y;
   int radius = 20;
+  int w = frame->info.width, h = frame->info.height;
 
   videotestsrc_setup_paintinfo (v, p, w, h);
   format = v->format;
   if (format == NULL)
     return;
 
-  format->paint_setup (p, dest);
+  format->paint_setup (p, frame);
 
   x = radius + (0.5 + 0.5 * sin (2 * G_PI * t / 200)) * (w - 2 * radius);
   y = radius + (0.5 + 0.5 * sin (2 * G_PI * sqrt (2) * t / 200)) * (h -
@@ -1551,39 +1560,39 @@ paint_tmpline_AYUV (paintinfo * p, int x, int w)
 
 
 static void
-paint_setup_I420 (paintinfo * p, unsigned char *dest)
+paint_setup_I420 (paintinfo * p, GstVideoFrame * frame)
 {
-  p->yp = dest;
-  p->ystride = GST_ROUND_UP_4 (p->width);
-  p->up = p->yp + p->ystride * GST_ROUND_UP_2 (p->height);
-  p->ustride = GST_ROUND_UP_8 (p->width) / 2;
-  p->vp = p->up + p->ustride * GST_ROUND_UP_2 (p->height) / 2;
-  p->vstride = GST_ROUND_UP_8 (p->ystride) / 2;
-  p->endptr = p->vp + p->vstride * GST_ROUND_UP_2 (p->height) / 2;
+  p->yp = GST_VIDEO_FRAME_DATA (frame, 0);
+  p->ystride = GST_VIDEO_FRAME_STRIDE (frame, 0);
+  p->up = GST_VIDEO_FRAME_DATA (frame, 1);
+  p->ustride = GST_VIDEO_FRAME_STRIDE (frame, 1);
+  p->vp = GST_VIDEO_FRAME_DATA (frame, 2);
+  p->vstride = GST_VIDEO_FRAME_STRIDE (frame, 2);
+  p->size = frame->info.size;
 }
 
 static void
-paint_setup_NV12 (paintinfo * p, unsigned char *dest)
+paint_setup_NV12 (paintinfo * p, GstVideoFrame * frame)
 {
-  p->yp = dest;
-  p->ystride = GST_ROUND_UP_4 (p->width);
-  p->up = p->yp + p->ystride * GST_ROUND_UP_2 (p->height);
+  p->yp = GST_VIDEO_FRAME_DATA (frame, 0);
+  p->ystride = GST_VIDEO_FRAME_STRIDE (frame, 0);
+  p->up = GST_VIDEO_FRAME_DATA (frame, 1);
+  p->ustride = GST_VIDEO_FRAME_STRIDE (frame, 1);
   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;
+  p->vstride = p->ustride;
+  p->size = frame->info.size;
 }
 
 static void
-paint_setup_NV21 (paintinfo * p, unsigned char *dest)
+paint_setup_NV21 (paintinfo * p, GstVideoFrame * frame)
 {
-  p->yp = dest;
-  p->ystride = GST_ROUND_UP_4 (p->width);
-  p->vp = p->yp + p->ystride * GST_ROUND_UP_2 (p->height);
+  p->yp = GST_VIDEO_FRAME_DATA (frame, 0);
+  p->ystride = GST_VIDEO_FRAME_STRIDE (frame, 0);
+  p->vp = GST_VIDEO_FRAME_DATA (frame, 1);
+  p->vstride = GST_VIDEO_FRAME_STRIDE (frame, 1);
   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;
+  p->ustride = p->vstride;
+  p->size = frame->info.size;
 }
 
 static void
@@ -1642,137 +1651,146 @@ convert_hline_NV21 (paintinfo * p, int y)
 
 
 static void
-paint_setup_YV12 (paintinfo * p, unsigned char *dest)
+paint_setup_YV12 (paintinfo * p, GstVideoFrame * frame)
 {
-  p->yp = dest;
-  p->ystride = GST_ROUND_UP_4 (p->width);
-  p->vp = p->yp + p->ystride * GST_ROUND_UP_2 (p->height);
-  p->vstride = GST_ROUND_UP_8 (p->ystride) / 2;
-  p->up = p->vp + p->vstride * GST_ROUND_UP_2 (p->height) / 2;
-  p->ustride = GST_ROUND_UP_8 (p->ystride) / 2;
-  p->endptr = p->up + p->ustride * GST_ROUND_UP_2 (p->height) / 2;
+  p->yp = GST_VIDEO_FRAME_DATA (frame, 0);
+  p->ystride = GST_VIDEO_FRAME_STRIDE (frame, 0);
+  p->up = GST_VIDEO_FRAME_DATA (frame, 1);
+  p->ustride = GST_VIDEO_FRAME_STRIDE (frame, 1);
+  p->vp = GST_VIDEO_FRAME_DATA (frame, 2);
+  p->vstride = GST_VIDEO_FRAME_STRIDE (frame, 2);
+  p->size = frame->info.size;
 }
 
 static void
-paint_setup_v308 (paintinfo * p, unsigned char *dest)
+paint_setup_v308 (paintinfo * p, GstVideoFrame * frame)
 {
-  p->yp = dest;
-  p->up = dest + 1;
-  p->vp = dest + 2;
-  p->ystride = GST_ROUND_UP_4 (p->width * 3);
-  p->ustride = GST_ROUND_UP_4 (p->width * 3);
-  p->vstride = GST_ROUND_UP_4 (p->width * 3);
-  p->endptr = dest + p->ystride * p->height;
+  p->yp = GST_VIDEO_FRAME_DATA (frame, 0);
+  p->up = p->yp + 1;
+  p->vp = p->yp + 2;
+  p->ystride = GST_VIDEO_FRAME_STRIDE (frame, 0);
+  p->ustride = p->ystride;
+  p->vstride = p->ystride;
+  p->size = frame->info.size;
 }
 
 static void
-paint_setup_AYUV (paintinfo * p, unsigned char *dest)
+paint_setup_AYUV (paintinfo * p, GstVideoFrame * frame)
 {
-  p->ap = dest;
-  p->yp = dest + 1;
-  p->up = dest + 2;
-  p->vp = dest + 3;
-  p->ystride = p->width * 4;
-  p->ustride = p->width * 4;
-  p->vstride = p->width * 4;
-  p->endptr = dest + p->ystride * p->height;
+  p->ap = GST_VIDEO_FRAME_DATA (frame, 0);
+  p->yp = p->ap + 1;
+  p->up = p->ap + 2;
+  p->vp = p->ap + 3;
+  p->astride = GST_VIDEO_FRAME_STRIDE (frame, 0);
+  p->ystride = p->astride;;
+  p->ustride = p->astride;
+  p->vstride = p->astride;
+  p->size = frame->info.size;
 }
 
 #ifdef disabled
 static void
-paint_setup_v410 (paintinfo * p, unsigned char *dest)
+paint_setup_v410 (paintinfo * p, GstVideoFrame * frame)
 {
   p->yp = dest + 0;
   p->up = dest + 0;
   p->vp = dest + 0;
   p->ystride = p->width * 4;
   p->endptr = dest + p->ystride * p->height;
+  p->size = frame->info.size;
 }
 #endif
 
 static void
-paint_setup_v216 (paintinfo * p, unsigned char *dest)
+paint_setup_v216 (paintinfo * p, GstVideoFrame * frame)
 {
-  p->ap = dest;
-  p->yp = dest + 2;
-  p->up = dest + 0;
-  p->vp = dest + 4;
-  p->ystride = p->width * 4;
-  p->ustride = p->width * 4;
-  p->vstride = p->width * 4;
-  p->endptr = dest + p->ystride * p->height;
+  p->ap = GST_VIDEO_FRAME_DATA (frame, 0);
+  p->yp = p->ap + 2;
+  p->up = p->ap + 0;
+  p->vp = p->ap + 4;
+  p->astride = GST_VIDEO_FRAME_STRIDE (frame, 0);
+  p->ystride = p->astride;;
+  p->ustride = p->astride;
+  p->vstride = p->astride;
+  p->size = frame->info.size;
 }
 
 static void
-paint_setup_v210 (paintinfo * p, unsigned char *dest)
+paint_setup_v210 (paintinfo * p, GstVideoFrame * frame)
 {
-  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;
+  p->ap = GST_VIDEO_FRAME_DATA (frame, 0);
+  p->yp = p->ap;
+  p->up = p->ap;
+  p->vp = p->ap;
+  p->astride = GST_VIDEO_FRAME_STRIDE (frame, 0);
+  p->ystride = p->astride;;
+  p->ustride = p->astride;
+  p->vstride = p->astride;
+  p->size = frame->info.size;
 }
 
 static void
-paint_setup_UYVP (paintinfo * p, unsigned char *dest)
+paint_setup_UYVP (paintinfo * p, GstVideoFrame * frame)
 {
-  p->ap = dest;
-  p->yp = dest + 0;
-  p->up = dest + 0;
-  p->vp = dest + 0;
-  p->ystride = GST_ROUND_UP_4 ((p->width * 2 * 5 + 3) / 4);
-  GST_ERROR ("stride %d", p->ystride);
-  p->endptr = dest + p->ystride * p->height;
+  p->ap = GST_VIDEO_FRAME_DATA (frame, 0);
+  p->yp = p->ap;
+  p->up = p->ap;
+  p->vp = p->ap;
+  p->astride = GST_VIDEO_FRAME_STRIDE (frame, 0);
+  p->ystride = p->astride;;
+  p->ustride = p->astride;
+  p->vstride = p->astride;
+  p->size = frame->info.size;
 }
 
 static void
-paint_setup_YUY2 (paintinfo * p, unsigned char *dest)
+paint_setup_YUY2 (paintinfo * p, GstVideoFrame * frame)
 {
-  p->yp = dest;
-  p->up = dest + 1;
-  p->vp = dest + 3;
-  p->ystride = GST_ROUND_UP_2 (p->width) * 2;
-  p->ustride = GST_ROUND_UP_2 (p->width) * 2;
-  p->vstride = GST_ROUND_UP_2 (p->width) * 2;
-  p->endptr = dest + p->ystride * p->height;
+  p->yp = GST_VIDEO_FRAME_DATA (frame, 0);
+  p->up = p->yp + 1;
+  p->vp = p->yp + 3;
+  p->ystride = GST_VIDEO_FRAME_STRIDE (frame, 0);
+  p->ustride = p->ystride;
+  p->vstride = p->ystride;
+  p->size = frame->info.size;
 }
 
 static void
-paint_setup_UYVY (paintinfo * p, unsigned char *dest)
+paint_setup_UYVY (paintinfo * p, GstVideoFrame * frame)
 {
-  p->yp = dest + 1;
-  p->up = dest;
-  p->vp = dest + 2;
-  p->ystride = GST_ROUND_UP_2 (p->width) * 2;
-  p->ustride = GST_ROUND_UP_2 (p->width) * 2;
-  p->vstride = GST_ROUND_UP_2 (p->width) * 2;
-  p->endptr = dest + p->ystride * p->height;
+  p->up = GST_VIDEO_FRAME_DATA (frame, 0);
+  p->yp = p->up + 1;
+  p->vp = p->up + 2;
+  p->ystride = GST_VIDEO_FRAME_STRIDE (frame, 0);
+  p->ustride = p->ystride;
+  p->vstride = p->ystride;
+  p->size = frame->info.size;
 }
 
 static void
-paint_setup_YVYU (paintinfo * p, unsigned char *dest)
+paint_setup_YVYU (paintinfo * p, GstVideoFrame * frame)
 {
-  p->yp = dest;
-  p->up = dest + 3;
-  p->vp = dest + 1;
-  p->ystride = GST_ROUND_UP_2 (p->width) * 2;
-  p->ustride = GST_ROUND_UP_2 (p->width) * 2;
-  p->vstride = GST_ROUND_UP_2 (p->width) * 2;
-  p->endptr = dest + p->ystride * p->height;
+  p->yp = GST_VIDEO_FRAME_DATA (frame, 0);
+  p->up = p->yp + 3;
+  p->vp = p->yp + 1;
+  p->ystride = GST_VIDEO_FRAME_STRIDE (frame, 0);
+  p->ustride = p->ystride;
+  p->vstride = p->ystride;
+  p->size = frame->info.size;
 }
 
 static void
-paint_setup_AY64 (paintinfo * p, unsigned char *dest)
+paint_setup_AY64 (paintinfo * p, GstVideoFrame * frame)
 {
-  p->ap = dest;
-  p->yp = dest + 2;
-  p->up = dest + 4;
-  p->vp = dest + 6;
-  p->ystride = p->width * 8;
-  p->ustride = p->width * 8;
-  p->vstride = p->width * 8;
-  p->endptr = dest + p->ystride * p->height;
+  p->ap = GST_VIDEO_FRAME_DATA (frame, 0);
+  p->yp = p->ap + 2;
+  p->up = p->ap + 4;
+  p->vp = p->ap + 6;
+  p->astride = GST_VIDEO_FRAME_STRIDE (frame, 0);
+  p->ystride = p->astride;
+  p->ustride = p->astride;
+  p->vstride = p->astride;
+  p->size = frame->info.size;
 }
 
 static void
@@ -1956,14 +1974,16 @@ convert_hline_AY64 (paintinfo * p, int y)
 
 #ifdef disabled
 static void
-paint_setup_IYU2 (paintinfo * p, unsigned char *dest)
+paint_setup_IYU2 (paintinfo * p, GstVideoFrame * frame)
 {
   /* untested */
-  p->yp = dest + 1;
-  p->up = dest + 0;
-  p->vp = dest + 2;
-  p->ystride = GST_ROUND_UP_4 (p->width * 3);
-  p->endptr = dest + p->ystride * p->height;
+  p->up = GST_VIDEO_FRAME_DATA (frame, 0);
+  p->yp = p->up + 1;
+  p->vp = p->up + 2;
+  p->ystride = GST_VIDEO_FRAME_STRIDE (frame, 0);
+  p->ustride = p->ystride;
+  p->vstride = p->ystride;
+  p->size = frame->info.size;
 }
 
 static void
@@ -1984,15 +2004,15 @@ convert_hline_IYU2 (paintinfo * p, int y)
 #endif
 
 static void
-paint_setup_Y41B (paintinfo * p, unsigned char *dest)
+paint_setup_Y41B (paintinfo * p, GstVideoFrame * frame)
 {
-  p->yp = dest;
-  p->ystride = GST_ROUND_UP_4 (p->width);
-  p->up = p->yp + p->ystride * p->height;
-  p->ustride = GST_ROUND_UP_16 (p->width) / 4;
-  p->vp = p->up + p->ustride * p->height;
-  p->vstride = GST_ROUND_UP_16 (p->width) / 4;
-  p->endptr = p->vp + p->vstride * p->height;
+  p->yp = GST_VIDEO_FRAME_DATA (frame, 0);
+  p->up = GST_VIDEO_FRAME_DATA (frame, 1);
+  p->vp = GST_VIDEO_FRAME_DATA (frame, 2);
+  p->ystride = GST_VIDEO_FRAME_STRIDE (frame, 0);
+  p->ustride = GST_VIDEO_FRAME_STRIDE (frame, 1);
+  p->vstride = GST_VIDEO_FRAME_STRIDE (frame, 2);
+  p->size = frame->info.size;
 }
 
 static void
@@ -2016,15 +2036,15 @@ convert_hline_Y41B (paintinfo * p, int y)
 }
 
 static void
-paint_setup_Y42B (paintinfo * p, unsigned char *dest)
+paint_setup_Y42B (paintinfo * p, GstVideoFrame * frame)
 {
-  p->yp = dest;
-  p->ystride = GST_ROUND_UP_4 (p->width);
-  p->up = p->yp + p->ystride * p->height;
-  p->ustride = GST_ROUND_UP_8 (p->width) / 2;
-  p->vp = p->up + p->ustride * p->height;
-  p->vstride = GST_ROUND_UP_8 (p->width) / 2;
-  p->endptr = p->vp + p->vstride * p->height;
+  p->yp = GST_VIDEO_FRAME_DATA (frame, 0);
+  p->up = GST_VIDEO_FRAME_DATA (frame, 1);
+  p->vp = GST_VIDEO_FRAME_DATA (frame, 2);
+  p->ystride = GST_VIDEO_FRAME_STRIDE (frame, 0);
+  p->ustride = GST_VIDEO_FRAME_STRIDE (frame, 1);
+  p->vstride = GST_VIDEO_FRAME_STRIDE (frame, 2);
+  p->size = frame->info.size;
 }
 
 static void
@@ -2046,15 +2066,15 @@ convert_hline_Y42B (paintinfo * p, int y)
 }
 
 static void
-paint_setup_Y444 (paintinfo * p, unsigned char *dest)
+paint_setup_Y444 (paintinfo * p, GstVideoFrame * frame)
 {
-  p->yp = dest;
-  p->ystride = GST_ROUND_UP_4 (p->width);
-  p->ustride = GST_ROUND_UP_4 (p->width);
-  p->vstride = 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;
+  p->yp = GST_VIDEO_FRAME_DATA (frame, 0);
+  p->up = GST_VIDEO_FRAME_DATA (frame, 1);
+  p->vp = GST_VIDEO_FRAME_DATA (frame, 2);
+  p->ystride = GST_VIDEO_FRAME_STRIDE (frame, 0);
+  p->ustride = GST_VIDEO_FRAME_STRIDE (frame, 1);
+  p->vstride = GST_VIDEO_FRAME_STRIDE (frame, 2);
+  p->size = frame->info.size;
 }
 
 static void
@@ -2074,12 +2094,12 @@ convert_hline_Y444 (paintinfo * p, int y)
 }
 
 static void
-paint_setup_Y800 (paintinfo * p, unsigned char *dest)
+paint_setup_Y800 (paintinfo * p, GstVideoFrame * frame)
 {
   /* untested */
-  p->yp = dest;
-  p->ystride = GST_ROUND_UP_4 (p->width);
-  p->endptr = dest + p->ystride * p->height;
+  p->yp = GST_VIDEO_FRAME_DATA (frame, 0);
+  p->ystride = GST_VIDEO_FRAME_STRIDE (frame, 0);
+  p->size = frame->info.size;
 }
 
 static void
@@ -2095,32 +2115,27 @@ convert_hline_Y800 (paintinfo * p, int y)
 }
 
 static void
-paint_setup_YVU9 (paintinfo * p, unsigned char *dest)
+paint_setup_YVU9 (paintinfo * p, GstVideoFrame * frame)
 {
-  int h = GST_ROUND_UP_4 (p->height);
-
-  p->yp = dest;
-  p->ystride = GST_ROUND_UP_4 (p->width);
-  p->vp = p->yp + p->ystride * h;
-  p->vstride = GST_ROUND_UP_4 (p->ystride / 4);
-  p->up = p->vp + p->vstride * h / 4;
-  p->ustride = GST_ROUND_UP_4 (p->ystride / 4);
-  p->endptr = p->up + p->ustride * h / 4;
+  p->yp = GST_VIDEO_FRAME_DATA (frame, 0);
+  p->up = GST_VIDEO_FRAME_DATA (frame, 1);
+  p->vp = GST_VIDEO_FRAME_DATA (frame, 2);
+  p->ystride = GST_VIDEO_FRAME_STRIDE (frame, 0);
+  p->ustride = GST_VIDEO_FRAME_STRIDE (frame, 1);
+  p->vstride = GST_VIDEO_FRAME_STRIDE (frame, 2);
+  p->size = frame->info.size;
 }
 
 static void
-paint_setup_YUV9 (paintinfo * p, unsigned char *dest)
+paint_setup_YUV9 (paintinfo * p, GstVideoFrame * frame)
 {
-  /* untested */
-  int h = GST_ROUND_UP_4 (p->height);
-
-  p->yp = dest;
-  p->ystride = GST_ROUND_UP_4 (p->width);
-  p->up = p->yp + p->ystride * h;
-  p->ustride = GST_ROUND_UP_4 (p->ystride / 4);
-  p->vp = p->up + p->ustride * h / 4;
-  p->vstride = GST_ROUND_UP_4 (p->ystride / 4);
-  p->endptr = p->vp + p->vstride * h / 4;
+  p->yp = GST_VIDEO_FRAME_DATA (frame, 0);
+  p->up = GST_VIDEO_FRAME_DATA (frame, 1);
+  p->vp = GST_VIDEO_FRAME_DATA (frame, 2);
+  p->ystride = GST_VIDEO_FRAME_STRIDE (frame, 0);
+  p->ustride = GST_VIDEO_FRAME_STRIDE (frame, 1);
+  p->vstride = GST_VIDEO_FRAME_STRIDE (frame, 2);
+  p->size = frame->info.size;
 }
 
 static void
@@ -2144,116 +2159,121 @@ convert_hline_YUV9 (paintinfo * p, int y)
 }
 
 static void
-paint_setup_ARGB8888 (paintinfo * p, unsigned char *dest)
+paint_setup_ARGB8888 (paintinfo * p, GstVideoFrame * frame)
 {
-  paint_setup_xRGB8888 (p, dest);
+  paint_setup_xRGB8888 (p, frame);
 }
 
 static void
-paint_setup_ABGR8888 (paintinfo * p, unsigned char *dest)
+paint_setup_ABGR8888 (paintinfo * p, GstVideoFrame * frame)
 {
-  paint_setup_xBGR8888 (p, dest);
+  paint_setup_xBGR8888 (p, frame);
 }
 
 static void
-paint_setup_RGBA8888 (paintinfo * p, unsigned char *dest)
+paint_setup_RGBA8888 (paintinfo * p, GstVideoFrame * frame)
 {
-  paint_setup_RGBx8888 (p, dest);
+  paint_setup_RGBx8888 (p, frame);
 }
 
 static void
-paint_setup_BGRA8888 (paintinfo * p, unsigned char *dest)
+paint_setup_BGRA8888 (paintinfo * p, GstVideoFrame * frame)
 {
-  paint_setup_BGRx8888 (p, dest);
+  paint_setup_BGRx8888 (p, frame);
 }
 
 static void
-paint_setup_xRGB8888 (paintinfo * p, unsigned char *dest)
+paint_setup_xRGB8888 (paintinfo * p, GstVideoFrame * frame)
 {
-  p->yp = dest + 1;
-  p->up = dest + 2;
-  p->vp = dest + 3;
-  p->ap = dest;
-  p->ystride = p->width * 4;
-  p->ustride = p->width * 4;
-  p->vstride = p->width * 4;
-  p->endptr = p->dest + p->ystride * p->height;
+  p->ap = GST_VIDEO_FRAME_DATA (frame, 0);
+  p->yp = p->ap + 1;
+  p->up = p->ap + 2;
+  p->vp = p->ap + 3;
+  p->astride = GST_VIDEO_FRAME_STRIDE (frame, 0);
+  p->ystride = p->astride;
+  p->ustride = p->astride;
+  p->vstride = p->astride;
+  p->size = frame->info.size;
 }
 
 static void
-paint_setup_xBGR8888 (paintinfo * p, unsigned char *dest)
+paint_setup_xBGR8888 (paintinfo * p, GstVideoFrame * frame)
 {
-  p->yp = dest + 3;
-  p->up = dest + 2;
-  p->vp = dest + 1;
-  p->ap = dest;
-  p->ystride = p->width * 4;
-  p->ustride = p->width * 4;
-  p->vstride = p->width * 4;
-  p->endptr = p->dest + p->ystride * p->height;
+  p->ap = GST_VIDEO_FRAME_DATA (frame, 0);
+  p->yp = p->ap + 3;
+  p->up = p->ap + 2;
+  p->vp = p->ap + 1;
+  p->astride = GST_VIDEO_FRAME_STRIDE (frame, 0);
+  p->ystride = p->astride;
+  p->ustride = p->astride;
+  p->vstride = p->astride;
+  p->size = frame->info.size;
 }
 
 static void
-paint_setup_RGBx8888 (paintinfo * p, unsigned char *dest)
+paint_setup_RGBx8888 (paintinfo * p, GstVideoFrame * frame)
 {
-  p->yp = dest + 0;
-  p->up = dest + 1;
-  p->vp = dest + 2;
-  p->ap = dest + 3;
-  p->ystride = p->width * 4;
-  p->ustride = p->width * 4;
-  p->vstride = p->width * 4;
-  p->endptr = p->dest + p->ystride * p->height;
+  p->yp = GST_VIDEO_FRAME_DATA (frame, 0);
+  p->up = p->yp + 1;
+  p->vp = p->yp + 2;
+  p->ap = p->yp + 3;
+  p->astride = GST_VIDEO_FRAME_STRIDE (frame, 0);
+  p->ystride = p->astride;
+  p->ustride = p->astride;
+  p->vstride = p->astride;
+  p->size = frame->info.size;
 }
 
 static void
-paint_setup_BGRx8888 (paintinfo * p, unsigned char *dest)
+paint_setup_BGRx8888 (paintinfo * p, GstVideoFrame * frame)
 {
-  p->yp = dest + 2;
-  p->up = dest + 1;
-  p->vp = dest + 0;
-  p->ap = dest + 3;
-  p->ystride = p->width * 4;
-  p->ustride = p->width * 4;
-  p->vstride = p->width * 4;
-  p->endptr = p->dest + p->ystride * p->height;
+  p->vp = GST_VIDEO_FRAME_DATA (frame, 0);
+  p->up = p->vp + 1;
+  p->yp = p->vp + 2;
+  p->ap = p->vp + 3;
+  p->astride = GST_VIDEO_FRAME_STRIDE (frame, 0);
+  p->ystride = p->astride;
+  p->ustride = p->astride;
+  p->vstride = p->astride;
+  p->size = frame->info.size;
 }
 
 static void
-paint_setup_RGB888 (paintinfo * p, unsigned char *dest)
+paint_setup_RGB888 (paintinfo * p, GstVideoFrame * frame)
 {
-  p->yp = dest + 0;
-  p->up = dest + 1;
-  p->vp = dest + 2;
-  p->ystride = GST_ROUND_UP_4 (p->width * 3);
-  p->ustride = GST_ROUND_UP_4 (p->width * 3);
-  p->vstride = GST_ROUND_UP_4 (p->width * 3);
-  p->endptr = p->dest + p->ystride * p->height;
+  p->yp = GST_VIDEO_FRAME_DATA (frame, 0);
+  p->up = p->yp + 1;
+  p->vp = p->yp + 2;
+  p->ystride = GST_VIDEO_FRAME_STRIDE (frame, 0);
+  p->ustride = p->ystride;
+  p->vstride = p->ystride;
+  p->size = frame->info.size;
 }
 
 static void
-paint_setup_BGR888 (paintinfo * p, unsigned char *dest)
+paint_setup_BGR888 (paintinfo * p, GstVideoFrame * frame)
 {
-  p->yp = dest + 2;
-  p->up = dest + 1;
-  p->vp = dest + 0;
-  p->ystride = GST_ROUND_UP_4 (p->width * 3);
-  p->ustride = GST_ROUND_UP_4 (p->width * 3);
-  p->vstride = GST_ROUND_UP_4 (p->width * 3);
-  p->endptr = p->dest + p->ystride * p->height;
+  p->vp = GST_VIDEO_FRAME_DATA (frame, 0);
+  p->up = p->vp + 1;
+  p->yp = p->vp + 2;
+  p->ystride = GST_VIDEO_FRAME_STRIDE (frame, 0);
+  p->ustride = p->ystride;
+  p->vstride = p->ystride;
+  p->size = frame->info.size;
 }
 
 static void
-paint_setup_ARGB64 (paintinfo * p, unsigned char *dest)
+paint_setup_ARGB64 (paintinfo * p, GstVideoFrame * frame)
 {
-  p->yp = dest + 2;
-  p->up = dest + 4;
-  p->vp = dest + 6;
-  p->ap = dest;
-  p->ystride = p->width * 8;
-  p->ustride = p->width * 8;
-  p->vstride = p->width * 8;
-  p->endptr = p->dest + p->ystride * p->height;
+  p->ap = GST_VIDEO_FRAME_DATA (frame, 0);
+  p->yp = p->ap + 2;
+  p->up = p->ap + 4;
+  p->yp = p->ap + 6;
+  p->astride = GST_VIDEO_FRAME_STRIDE (frame, 0);
+  p->ystride = p->astride;
+  p->ustride = p->astride;
+  p->vstride = p->astride;
+  p->size = frame->info.size;
 }
 
 static void
@@ -2327,13 +2347,13 @@ convert_hline_str3 (paintinfo * p, int y)
 }
 
 static void
-paint_setup_RGB565 (paintinfo * p, unsigned char *dest)
+paint_setup_RGB565 (paintinfo * p, GstVideoFrame * frame)
 {
-  p->yp = dest;
-  p->ystride = GST_ROUND_UP_4 (p->width * 2);
-  p->ustride = GST_ROUND_UP_4 (p->width * 2);
-  p->vstride = GST_ROUND_UP_4 (p->width * 2);
-  p->endptr = p->dest + p->ystride * p->height;
+  p->yp = GST_VIDEO_FRAME_DATA (frame, 0);
+  p->ystride = GST_VIDEO_FRAME_STRIDE (frame, 0);
+  p->ustride = p->ystride;
+  p->vstride = p->ystride;
+  p->size = frame->info.size;
 }
 
 static void
@@ -2373,60 +2393,60 @@ convert_hline_xRGB1555 (paintinfo * p, int y)
 }
 
 static void
-paint_setup_xRGB1555 (paintinfo * p, unsigned char *dest)
+paint_setup_xRGB1555 (paintinfo * p, GstVideoFrame * frame)
 {
-  p->yp = dest;
-  p->ystride = GST_ROUND_UP_4 (p->width * 2);
-  p->ustride = GST_ROUND_UP_4 (p->width * 2);
-  p->vstride = GST_ROUND_UP_4 (p->width * 2);
-  p->endptr = p->dest + p->ystride * p->height;
+  p->yp = GST_VIDEO_FRAME_DATA (frame, 0);
+  p->ystride = GST_VIDEO_FRAME_STRIDE (frame, 0);
+  p->ustride = p->ystride;
+  p->vstride = p->ystride;
+  p->size = frame->info.size;
 }
 
 
 static void
-paint_setup_bayer_bggr (paintinfo * p, unsigned char *dest)
+paint_setup_bayer_bggr (paintinfo * p, GstVideoFrame * frame)
 {
-  p->yp = dest;
+  p->yp = GST_VIDEO_FRAME_DATA (frame, 0);
   p->ystride = GST_ROUND_UP_4 (p->width);
   p->ustride = GST_ROUND_UP_4 (p->width);
   p->vstride = GST_ROUND_UP_4 (p->width);
-  p->endptr = p->dest + p->ystride * p->height;
+  p->size = p->ystride * p->height;
   p->bayer_x_invert = 0;
   p->bayer_y_invert = 0;
 }
 
 static void
-paint_setup_bayer_rggb (paintinfo * p, unsigned char *dest)
+paint_setup_bayer_rggb (paintinfo * p, GstVideoFrame * frame)
 {
-  p->yp = dest;
+  p->yp = GST_VIDEO_FRAME_DATA (frame, 0);
   p->ystride = GST_ROUND_UP_4 (p->width);
   p->ustride = GST_ROUND_UP_4 (p->width);
   p->vstride = GST_ROUND_UP_4 (p->width);
-  p->endptr = p->dest + p->ystride * p->height;
+  p->size = p->ystride * p->height;
   p->bayer_x_invert = 1;
   p->bayer_y_invert = 1;
 }
 
 static void
-paint_setup_bayer_grbg (paintinfo * p, unsigned char *dest)
+paint_setup_bayer_grbg (paintinfo * p, GstVideoFrame * frame)
 {
-  p->yp = dest;
+  p->yp = GST_VIDEO_FRAME_DATA (frame, 0);
   p->ystride = GST_ROUND_UP_4 (p->width);
   p->ustride = GST_ROUND_UP_4 (p->width);
   p->vstride = GST_ROUND_UP_4 (p->width);
-  p->endptr = p->dest + p->ystride * p->height;
+  p->size = p->ystride * p->height;
   p->bayer_x_invert = 0;
   p->bayer_y_invert = 1;
 }
 
 static void
-paint_setup_bayer_gbrg (paintinfo * p, unsigned char *dest)
+paint_setup_bayer_gbrg (paintinfo * p, GstVideoFrame * frame)
 {
-  p->yp = dest;
+  p->yp = GST_VIDEO_FRAME_DATA (frame, 0);
   p->ystride = GST_ROUND_UP_4 (p->width);
   p->ustride = GST_ROUND_UP_4 (p->width);
   p->vstride = GST_ROUND_UP_4 (p->width);
-  p->endptr = p->dest + p->ystride * p->height;
+  p->size = p->ystride * p->height;
   p->bayer_x_invert = 1;
   p->bayer_y_invert = 0;
 }
@@ -2460,11 +2480,11 @@ convert_hline_bayer (paintinfo * p, int y)
 }
 
 static void
-paint_setup_GRAY8 (paintinfo * p, unsigned char *dest)
+paint_setup_GRAY8 (paintinfo * p, GstVideoFrame * frame)
 {
-  p->yp = dest;
-  p->ystride = GST_ROUND_UP_4 (p->width);
-  p->endptr = dest + p->ystride * p->height;
+  p->yp = GST_VIDEO_FRAME_DATA (frame, 0);
+  p->ystride = GST_VIDEO_FRAME_STRIDE (frame, 0);
+  p->size = frame->info.size;
 }
 
 static void
@@ -2481,11 +2501,11 @@ convert_hline_GRAY8 (paintinfo * p, int y)
 }
 
 static void
-paint_setup_GRAY16 (paintinfo * p, unsigned char *dest)
+paint_setup_GRAY16 (paintinfo * p, GstVideoFrame * frame)
 {
-  p->yp = dest;
-  p->ystride = GST_ROUND_UP_4 (p->width * 2);
-  p->endptr = dest + p->ystride * p->height;
+  p->yp = GST_VIDEO_FRAME_DATA (frame, 0);
+  p->ystride = GST_VIDEO_FRAME_STRIDE (frame, 0);
+  p->size = frame->info.size;
 }
 
 static void
index 4281c77..ee1f4f2 100644 (file)
@@ -46,14 +46,11 @@ struct vts_color_struct {
 typedef struct paintinfo_struct paintinfo;
 struct paintinfo_struct
 {
-  unsigned char *dest;          /* pointer to first byte of video data */
-  unsigned char *yp, *up, *vp;  /* pointers to first byte of each component
-                                 * for both packed/planar YUV and RGB */
-  unsigned char *ap;            /* pointer to first byte of alpha component */
-  unsigned char *endptr;        /* pointer to byte beyond last video data */
-  int ystride;
-  int ustride;
-  int vstride;
+  unsigned char *ap, *yp, *up, *vp; /* pointers to first byte of each component
+                                     * for both packed/planar YUV and RGB */
+  int astride, ystride, ustride, vstride;
+
+  int size;                     /* size of a frame */
   int width;
   int height;
   const struct vts_color_struct *colors;
@@ -81,7 +78,7 @@ struct format_list_struct
   const char *format;
   const char *name;
   int bitspp;
-  void (*paint_setup) (paintinfo * p, unsigned char *dest);
+  void (*paint_setup) (paintinfo * p, GstVideoFrame *frame);
   void (*convert_hline) (paintinfo * p, int y);
   int depth;
   unsigned int red_mask;
@@ -98,49 +95,29 @@ struct format_list_struct *
         paintinfo_find_by_structure     (const GstStructure *structure);
 GstStructure *
         paint_get_structure             (struct format_list_struct *format);
+
 int     gst_video_test_src_get_size     (GstVideoTestSrc * v, int w, int h);
-void    gst_video_test_src_smpte        (GstVideoTestSrc * v,
-                                         unsigned char *dest, int w, int h);
-void    gst_video_test_src_smpte75      (GstVideoTestSrc * v,
-                                         unsigned char *dest, int w, int h);
-void    gst_video_test_src_snow         (GstVideoTestSrc * v,
-                                         unsigned char *dest, int w, int h);
-void    gst_video_test_src_black        (GstVideoTestSrc * v,
-                                         unsigned char *dest, int w, int h);
-void    gst_video_test_src_white        (GstVideoTestSrc * v,
-                                         unsigned char *dest, int w, int h);
-void    gst_video_test_src_red          (GstVideoTestSrc * v,
-                                         unsigned char *dest, int w, int h);
-void    gst_video_test_src_green        (GstVideoTestSrc * v,
-                                         unsigned char *dest, int w, int h);
-void    gst_video_test_src_blue         (GstVideoTestSrc * v,
-                                         unsigned char *dest, int w, int h);
-void    gst_video_test_src_solid        (GstVideoTestSrc * v,
-                                         unsigned char *dest, int w, int h);
-void    gst_video_test_src_blink        (GstVideoTestSrc * v,
-                                         unsigned char *dest, int w, int h);
-void    gst_video_test_src_checkers1    (GstVideoTestSrc * v,
-                                         unsigned char *dest, int w, int h);
-void    gst_video_test_src_checkers2    (GstVideoTestSrc * v,
-                                         unsigned char *dest, int w, int h);
-void    gst_video_test_src_checkers4    (GstVideoTestSrc * v,
-                                         unsigned char *dest, int w, int h);
-void    gst_video_test_src_checkers8    (GstVideoTestSrc * v,
-                                         unsigned char *dest, int w, int h);
-void    gst_video_test_src_circular     (GstVideoTestSrc * v,
-                                         unsigned char *dest, int w, int h);
-void    gst_video_test_src_zoneplate    (GstVideoTestSrc * v,
-                                         unsigned char *dest, int w, int h);
-void    gst_video_test_src_gamut        (GstVideoTestSrc * v,
-                                         unsigned char *dest, int w, int h);
-void    gst_video_test_src_chromazoneplate (GstVideoTestSrc * v,
-                                            unsigned char *dest, int w, int h);
-void    gst_video_test_src_ball         (GstVideoTestSrc * v,
-                                         unsigned char *dest, int w, int h);
-void    gst_video_test_src_smpte100     (GstVideoTestSrc * v,
-                                         unsigned char *dest, int w, int h);
-void    gst_video_test_src_bar          (GstVideoTestSrc * v,
-                                         unsigned char *dest, int w, int h);
+void    gst_video_test_src_smpte        (GstVideoTestSrc * v, GstVideoFrame *frame);
+void    gst_video_test_src_smpte75      (GstVideoTestSrc * v, GstVideoFrame *frame);
+void    gst_video_test_src_snow         (GstVideoTestSrc * v, GstVideoFrame *frame);
+void    gst_video_test_src_black        (GstVideoTestSrc * v, GstVideoFrame *frame);
+void    gst_video_test_src_white        (GstVideoTestSrc * v, GstVideoFrame *frame);
+void    gst_video_test_src_red          (GstVideoTestSrc * v, GstVideoFrame *frame);
+void    gst_video_test_src_green        (GstVideoTestSrc * v, GstVideoFrame *frame);
+void    gst_video_test_src_blue         (GstVideoTestSrc * v, GstVideoFrame *frame);
+void    gst_video_test_src_solid        (GstVideoTestSrc * v, GstVideoFrame *frame);
+void    gst_video_test_src_blink        (GstVideoTestSrc * v, GstVideoFrame *frame);
+void    gst_video_test_src_checkers1    (GstVideoTestSrc * v, GstVideoFrame *frame);
+void    gst_video_test_src_checkers2    (GstVideoTestSrc * v, GstVideoFrame *frame);
+void    gst_video_test_src_checkers4    (GstVideoTestSrc * v, GstVideoFrame *frame);
+void    gst_video_test_src_checkers8    (GstVideoTestSrc * v, GstVideoFrame *frame);
+void    gst_video_test_src_circular     (GstVideoTestSrc * v, GstVideoFrame *frame);
+void    gst_video_test_src_zoneplate    (GstVideoTestSrc * v, GstVideoFrame *frame);
+void    gst_video_test_src_gamut        (GstVideoTestSrc * v, GstVideoFrame *frame);
+void    gst_video_test_src_chromazoneplate (GstVideoTestSrc * v, GstVideoFrame *frame);
+void    gst_video_test_src_ball         (GstVideoTestSrc * v, GstVideoFrame *frame);
+void    gst_video_test_src_smpte100     (GstVideoTestSrc * v, GstVideoFrame *frame);
+void    gst_video_test_src_bar          (GstVideoTestSrc * v, GstVideoFrame *frame);
 
 extern struct format_list_struct format_list[];
 extern int n_formats;