Merge branch 'master' into 0.11
[platform/upstream/gst-plugins-base.git] / gst / videoscale / gstvideoscale.c
index 60dd5ff..01015f1 100644 (file)
@@ -20,7 +20,7 @@
 
 /**
  * SECTION:element-videoscale
- * @see_also: videorate, ffmpegcolorspace
+ * @see_also: videorate, videoconvert
  *
  * This element resizes video frames. By default the element will try to
  * negotiate to the same size on the source and sinkpad so that no scaling
  * <refsect2>
  * <title>Example pipelines</title>
  * |[
- * gst-launch -v filesrc location=videotestsrc.ogg ! oggdemux ! theoradec ! ffmpegcolorspace ! videoscale ! ximagesink
+ * gst-launch -v filesrc location=videotestsrc.ogg ! oggdemux ! theoradec ! videoconvert ! videoscale ! ximagesink
  * ]| Decode an Ogg/Theora and display the video using ximagesink. Since
  * ximagesink cannot perform scaling, the video scaling will be performed by
  * videoscale when you resize the video window.
  * To create the test Ogg/Theora file refer to the documentation of theoraenc.
  * |[
- * gst-launch -v filesrc location=videotestsrc.ogg ! oggdemux ! theoradec ! videoscale ! video/x-raw-yuv, width=50 ! xvimagesink
+ * gst-launch -v filesrc location=videotestsrc.ogg ! oggdemux ! theoradec ! videoscale ! video/x-raw, width=50 ! xvimagesink
  * ]| Decode an Ogg/Theora and display the video using xvimagesink with a width
  * of 50.
  * </refsect2>
@@ -76,7 +76,8 @@
 
 #include <math.h>
 
-#include <gst/video/video.h>
+#include <gst/video/gstvideometa.h>
+#include <gst/video/gstvideopool.h>
 
 #include "gstvideoscale.h"
 #include "gstvideoscaleorc.h"
@@ -86,6 +87,7 @@
 
 /* debug variable definition */
 GST_DEBUG_CATEGORY (video_scale_debug);
+GST_DEBUG_CATEGORY_STATIC (GST_CAT_PERFORMANCE);
 
 #define DEFAULT_PROP_METHOD       GST_VIDEO_SCALE_BILINEAR
 #define DEFAULT_PROP_ADD_BORDERS  FALSE
@@ -110,38 +112,14 @@ enum
 #undef GST_VIDEO_SIZE_RANGE
 #define GST_VIDEO_SIZE_RANGE "(int) [ 1, 32767]"
 
+#define GST_VIDEO_FORMATS "{ I420, YV12, YUY2, UYVY, AYUV, RGBx, " \
+    "BGRx, xRGB, xBGR, RGBA, BGRA, ARGB, ABGR, RGB, " \
+    "BGR, Y41B, Y42B, YVYU, Y444, GRAY8, GRAY16_BE, GRAY16_LE, " \
+    "v308, Y800, Y16, RGB16, RGB15, ARGB64, AYUV64, NV12 } "
+
+
 static GstStaticCaps gst_video_scale_format_caps[] = {
-  GST_STATIC_CAPS (GST_VIDEO_CAPS_RGBA),
-  GST_STATIC_CAPS (GST_VIDEO_CAPS_ARGB),
-  GST_STATIC_CAPS (GST_VIDEO_CAPS_BGRA),
-  GST_STATIC_CAPS (GST_VIDEO_CAPS_ABGR),
-  GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("AYUV")),
-  GST_STATIC_CAPS (GST_VIDEO_CAPS_RGBx),
-  GST_STATIC_CAPS (GST_VIDEO_CAPS_xRGB),
-  GST_STATIC_CAPS (GST_VIDEO_CAPS_BGRx),
-  GST_STATIC_CAPS (GST_VIDEO_CAPS_xBGR),
-  GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("Y444")),
-  GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("v308")),
-  GST_STATIC_CAPS (GST_VIDEO_CAPS_RGB),
-  GST_STATIC_CAPS (GST_VIDEO_CAPS_BGR),
-  GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("Y42B")),
-  GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("YUY2")),
-  GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("YVYU")),
-  GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("UYVY")),
-  GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("I420")),
-  GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("YV12")),
-  GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("Y41B")),
-  GST_STATIC_CAPS (GST_VIDEO_CAPS_RGB_16),
-  GST_STATIC_CAPS (GST_VIDEO_CAPS_RGB_15),
-  GST_STATIC_CAPS (GST_VIDEO_CAPS_GRAY16 ("BYTE_ORDER")),
-  GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("Y16 ")),
-  GST_STATIC_CAPS (GST_VIDEO_CAPS_GRAY8),
-  GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("Y800")),
-  GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("Y8  ")),
-  GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("GREY")),
-  GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("AY64")),
-  GST_STATIC_CAPS (GST_VIDEO_CAPS_ARGB_64),
-  GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("NV12"))
+  GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE (GST_VIDEO_FORMATS))
 };
 
 #define GST_TYPE_VIDEO_SCALE_METHOD (gst_video_scale_method_get_type())
@@ -191,14 +169,14 @@ static GstPadTemplate *
 gst_video_scale_src_template_factory (void)
 {
   return gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS,
-      gst_caps_ref (gst_video_scale_get_capslist ()));
+      gst_video_scale_get_capslist ());
 }
 
 static GstPadTemplate *
 gst_video_scale_sink_template_factory (void)
 {
   return gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS,
-      gst_caps_ref (gst_video_scale_get_capslist ()));
+      gst_video_scale_get_capslist ());
 }
 
 
@@ -208,47 +186,31 @@ static gboolean gst_video_scale_src_event (GstBaseTransform * trans,
 
 /* base transform vmethods */
 static GstCaps *gst_video_scale_transform_caps (GstBaseTransform * trans,
-    GstPadDirection direction, GstCaps * caps);
-static gboolean gst_video_scale_set_caps (GstBaseTransform * trans,
-    GstCaps * in, GstCaps * out);
-static gboolean gst_video_scale_get_unit_size (GstBaseTransform * trans,
-    GstCaps * caps, guint * size);
-static GstFlowReturn gst_video_scale_transform (GstBaseTransform * trans,
-    GstBuffer * in, GstBuffer * out);
-static void gst_video_scale_fixate_caps (GstBaseTransform * base,
+    GstPadDirection direction, GstCaps * caps, GstCaps * filter);
+static GstCaps *gst_video_scale_fixate_caps (GstBaseTransform * base,
     GstPadDirection direction, GstCaps * caps, GstCaps * othercaps);
 
+static gboolean gst_video_scale_set_info (GstVideoFilter * filter,
+    GstCaps * in, GstVideoInfo * in_info, GstCaps * out,
+    GstVideoInfo * out_info);
+static GstFlowReturn gst_video_scale_transform_frame (GstVideoFilter * filter,
+    GstVideoFrame * in, GstVideoFrame * out);
+
 static void gst_video_scale_set_property (GObject * object, guint prop_id,
     const GValue * value, GParamSpec * pspec);
 static void gst_video_scale_get_property (GObject * object, guint prop_id,
     GValue * value, GParamSpec * pspec);
 
-GST_BOILERPLATE (GstVideoScale, gst_video_scale, GstVideoFilter,
-    GST_TYPE_VIDEO_FILTER);
-
-static void
-gst_video_scale_base_init (gpointer g_class)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-  GstPadTemplate *pad_template;
-
-  gst_element_class_set_details_simple (element_class,
-      "Video scaler", "Filter/Converter/Video/Scaler",
-      "Resizes video", "Wim Taymans <wim.taymans@chello.be>");
-
-  pad_template = gst_video_scale_sink_template_factory ();
-  gst_element_class_add_pad_template (element_class, pad_template);
-  gst_object_unref (pad_template);
-  pad_template = gst_video_scale_src_template_factory ();
-  gst_element_class_add_pad_template (element_class, pad_template);
-  gst_object_unref (pad_template);
-}
+#define gst_video_scale_parent_class parent_class
+G_DEFINE_TYPE (GstVideoScale, gst_video_scale, GST_TYPE_VIDEO_FILTER);
 
 static void
 gst_video_scale_class_init (GstVideoScaleClass * klass)
 {
   GObjectClass *gobject_class = (GObjectClass *) klass;
+  GstElementClass *element_class = (GstElementClass *) klass;
   GstBaseTransformClass *trans_class = (GstBaseTransformClass *) klass;
+  GstVideoFilterClass *filter_class = (GstVideoFilterClass *) klass;
 
   gobject_class->finalize = (GObjectFinalizeFunc) gst_video_scale_finalize;
   gobject_class->set_property = gst_video_scale_set_property;
@@ -295,18 +257,27 @@ gst_video_scale_class_init (GstVideoScaleClass * klass)
           "Size of filter envelope", 0.0, 5.0, DEFAULT_PROP_ENVELOPE,
           G_PARAM_CONSTRUCT | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
 
+  gst_element_class_set_details_simple (element_class,
+      "Video scaler", "Filter/Converter/Video/Scaler",
+      "Resizes video", "Wim Taymans <wim.taymans@chello.be>");
+
+  gst_element_class_add_pad_template (element_class,
+      gst_video_scale_sink_template_factory ());
+  gst_element_class_add_pad_template (element_class,
+      gst_video_scale_src_template_factory ());
+
   trans_class->transform_caps =
       GST_DEBUG_FUNCPTR (gst_video_scale_transform_caps);
-  trans_class->set_caps = GST_DEBUG_FUNCPTR (gst_video_scale_set_caps);
-  trans_class->get_unit_size =
-      GST_DEBUG_FUNCPTR (gst_video_scale_get_unit_size);
-  trans_class->transform = GST_DEBUG_FUNCPTR (gst_video_scale_transform);
   trans_class->fixate_caps = GST_DEBUG_FUNCPTR (gst_video_scale_fixate_caps);
   trans_class->src_event = GST_DEBUG_FUNCPTR (gst_video_scale_src_event);
+
+  filter_class->set_info = GST_DEBUG_FUNCPTR (gst_video_scale_set_info);
+  filter_class->transform_frame =
+      GST_DEBUG_FUNCPTR (gst_video_scale_transform_frame);
 }
 
 static void
-gst_video_scale_init (GstVideoScale * videoscale, GstVideoScaleClass * klass)
+gst_video_scale_init (GstVideoScale * videoscale)
 {
   videoscale->tmp_buf = NULL;
   videoscale->method = DEFAULT_PROP_METHOD;
@@ -343,7 +314,7 @@ gst_video_scale_set_property (GObject * object, guint prop_id,
       GST_OBJECT_LOCK (vscale);
       vscale->add_borders = g_value_get_boolean (value);
       GST_OBJECT_UNLOCK (vscale);
-      gst_base_transform_reconfigure (GST_BASE_TRANSFORM_CAST (vscale));
+      gst_base_transform_reconfigure_src (GST_BASE_TRANSFORM_CAST (vscale));
       break;
     case PROP_SHARPNESS:
       GST_OBJECT_LOCK (vscale);
@@ -486,7 +457,7 @@ gst_video_scale_transform_supported (GstVideoScale * videoscale,
     GstVideoScaleMethod method, GstStructure * structure)
 {
   const GValue *val;
-  GstVideoFormat fmt;
+  GstVideoInfo info;
   gboolean supported = TRUE;
   GstStructure *s;
   GstCaps *c;
@@ -518,13 +489,16 @@ gst_video_scale_transform_supported (GstVideoScale * videoscale,
       gst_structure_set_value (s, "bpp", val);
   }
   c = gst_caps_new_full (s, NULL);
-  if (!gst_video_format_parse_caps (c, &fmt, NULL, NULL)) {
+
+  gst_video_info_init (&info);
+  if (!gst_video_info_from_caps (&info, c)) {
     GST_ERROR_OBJECT (videoscale, "couldn't parse %" GST_PTR_FORMAT, c);
-  } else if (!gst_video_scale_format_supported_for_method (fmt, method)) {
+  } else if (!gst_video_scale_format_supported_for_method (info.finfo->format,
+          method)) {
     supported = FALSE;
   }
   GST_LOG_OBJECT (videoscale, "method %d %ssupported for format %d",
-      method, (supported) ? "" : "not ", fmt);
+      method, (supported) ? "" : "not ", info.finfo->format);
   gst_caps_unref (c);
 
   return supported;
@@ -532,40 +506,56 @@ gst_video_scale_transform_supported (GstVideoScale * videoscale,
 
 static GstCaps *
 gst_video_scale_transform_caps (GstBaseTransform * trans,
-    GstPadDirection direction, GstCaps * caps)
+    GstPadDirection direction, GstCaps * caps, GstCaps * filter)
 {
   GstVideoScale *videoscale = GST_VIDEO_SCALE (trans);
   GstVideoScaleMethod method;
   GstCaps *ret;
   GstStructure *structure;
-
-  /* this function is always called with a simple caps */
-  g_return_val_if_fail (GST_CAPS_IS_SIMPLE (caps), NULL);
+  gint i, n;
 
   GST_DEBUG_OBJECT (trans,
       "Transforming caps %" GST_PTR_FORMAT " in direction %s", caps,
       (direction == GST_PAD_SINK) ? "sink" : "src");
 
-  ret = gst_caps_copy (caps);
-  structure = gst_structure_copy (gst_caps_get_structure (ret, 0));
-
   GST_OBJECT_LOCK (videoscale);
   method = videoscale->method;
   GST_OBJECT_UNLOCK (videoscale);
 
-  if (!gst_video_scale_transform_supported (videoscale, method, structure))
-    goto format_not_supported;
+  ret = gst_caps_new_empty ();
+  n = gst_caps_get_size (caps);
+  for (i = 0; i < n; i++) {
+    structure = gst_caps_get_structure (caps, i);
+
+    /* If this is already expressed by the existing caps
+     * skip this structure */
+    if (i > 0 && gst_caps_is_subset_structure (ret, structure))
+      continue;
+
+    if (!gst_video_scale_transform_supported (videoscale, method, structure))
+      goto format_not_supported;
+
+    structure = gst_structure_copy (structure);
+    gst_structure_set (structure,
+        "width", GST_TYPE_INT_RANGE, 1, G_MAXINT,
+        "height", GST_TYPE_INT_RANGE, 1, G_MAXINT, NULL);
+
+    /* if pixel aspect ratio, make a range of it */
+    if (gst_structure_has_field (structure, "pixel-aspect-ratio")) {
+      gst_structure_set (structure, "pixel-aspect-ratio",
+          GST_TYPE_FRACTION_RANGE, 1, G_MAXINT, G_MAXINT, 1, NULL);
+    }
+    gst_caps_append_structure (ret, structure);
+  }
 
-  gst_structure_set (structure,
-      "width", GST_TYPE_INT_RANGE, 1, G_MAXINT,
-      "height", GST_TYPE_INT_RANGE, 1, G_MAXINT, NULL);
+  if (filter) {
+    GstCaps *intersection;
 
-  /* if pixel aspect ratio, make a range of it */
-  if (gst_structure_has_field (structure, "pixel-aspect-ratio")) {
-    gst_structure_set (structure, "pixel-aspect-ratio", GST_TYPE_FRACTION_RANGE,
-        1, G_MAXINT, G_MAXINT, 1, NULL);
+    intersection =
+        gst_caps_intersect_full (filter, ret, GST_CAPS_INTERSECT_FIRST);
+    gst_caps_unref (ret);
+    ret = intersection;
   }
-  gst_caps_append_structure (ret, structure);
 
 done:
 
@@ -583,40 +573,21 @@ format_not_supported:
 }
 
 static gboolean
-gst_video_scale_set_caps (GstBaseTransform * trans, GstCaps * in, GstCaps * out)
+gst_video_scale_set_info (GstVideoFilter * filter, GstCaps * in,
+    GstVideoInfo * in_info, GstCaps * out, GstVideoInfo * out_info)
 {
-  GstVideoScale *videoscale = GST_VIDEO_SCALE (trans);
-  gboolean ret;
+  GstVideoScale *videoscale = GST_VIDEO_SCALE (filter);
   gint from_dar_n, from_dar_d, to_dar_n, to_dar_d;
-  gint from_par_n, from_par_d, to_par_n, to_par_d;
-
-  ret =
-      gst_video_format_parse_caps (in, &videoscale->format,
-      &videoscale->from_width, &videoscale->from_height);
-  ret &=
-      gst_video_format_parse_caps (out, NULL, &videoscale->to_width,
-      &videoscale->to_height);
-  if (!ret)
-    goto done;
-
-  videoscale->src_size = gst_video_format_get_size (videoscale->format,
-      videoscale->from_width, videoscale->from_height);
-  videoscale->dest_size = gst_video_format_get_size (videoscale->format,
-      videoscale->to_width, videoscale->to_height);
-
-  if (!gst_video_parse_caps_pixel_aspect_ratio (in, &from_par_n, &from_par_d))
-    from_par_n = from_par_d = 1;
-  if (!gst_video_parse_caps_pixel_aspect_ratio (out, &to_par_n, &to_par_d))
-    to_par_n = to_par_d = 1;
 
-  if (!gst_util_fraction_multiply (videoscale->from_width,
-          videoscale->from_height, from_par_n, from_par_d, &from_dar_n,
+  if (!gst_util_fraction_multiply (in_info->width,
+          in_info->height, out_info->par_n, out_info->par_d, &from_dar_n,
           &from_dar_d)) {
     from_dar_n = from_dar_d = -1;
   }
 
-  if (!gst_util_fraction_multiply (videoscale->to_width,
-          videoscale->to_height, to_par_n, to_par_d, &to_dar_n, &to_dar_d)) {
+  if (!gst_util_fraction_multiply (out_info->width,
+          out_info->height, out_info->par_n, out_info->par_d, &to_dar_n,
+          &to_dar_d)) {
     to_dar_n = to_dar_d = -1;
   }
 
@@ -626,17 +597,17 @@ gst_video_scale_set_caps (GstBaseTransform * trans, GstCaps * in, GstCaps * out)
       gint n, d, to_h, to_w;
 
       if (from_dar_n != -1 && from_dar_d != -1
-          && gst_util_fraction_multiply (from_dar_n, from_dar_d, to_par_n,
-              to_par_d, &n, &d)) {
-        to_h = gst_util_uint64_scale_int (videoscale->to_width, d, n);
-        if (to_h <= videoscale->to_height) {
-          videoscale->borders_h = videoscale->to_height - to_h;
+          && gst_util_fraction_multiply (from_dar_n, from_dar_d,
+              out_info->par_n, out_info->par_d, &n, &d)) {
+        to_h = gst_util_uint64_scale_int (out_info->width, d, n);
+        if (to_h <= out_info->height) {
+          videoscale->borders_h = out_info->height - to_h;
           videoscale->borders_w = 0;
         } else {
-          to_w = gst_util_uint64_scale_int (videoscale->to_height, n, d);
-          g_assert (to_w <= videoscale->to_width);
+          to_w = gst_util_uint64_scale_int (out_info->height, n, d);
+          g_assert (to_w <= out_info->width);
           videoscale->borders_h = 0;
-          videoscale->borders_w = videoscale->to_width - to_w;
+          videoscale->borders_w = out_info->width - to_w;
         }
       } else {
         GST_WARNING_OBJECT (videoscale, "Can't calculate borders");
@@ -648,39 +619,27 @@ gst_video_scale_set_caps (GstBaseTransform * trans, GstCaps * in, GstCaps * out)
 
   if (videoscale->tmp_buf)
     g_free (videoscale->tmp_buf);
-  videoscale->tmp_buf = g_malloc (videoscale->to_width * 8 * 4);
+  videoscale->tmp_buf = g_malloc (out_info->width * 8 * 4);
 
-  gst_base_transform_set_passthrough (trans,
-      (videoscale->from_width == videoscale->to_width
-          && videoscale->from_height == videoscale->to_height));
-
-  GST_DEBUG_OBJECT (videoscale, "from=%dx%d (par=%d/%d dar=%d/%d), size %d "
-      "-> to=%dx%d (par=%d/%d dar=%d/%d borders=%d:%d), size %d",
-      videoscale->from_width, videoscale->from_height, from_par_n, from_par_d,
-      from_dar_n, from_dar_d, videoscale->src_size, videoscale->to_width,
-      videoscale->to_height, to_par_n, to_par_d, to_dar_n, to_dar_d,
-      videoscale->borders_w, videoscale->borders_h, videoscale->dest_size);
-
-done:
-  return ret;
-}
-
-static gboolean
-gst_video_scale_get_unit_size (GstBaseTransform * trans, GstCaps * caps,
-    guint * size)
-{
-  GstVideoFormat format;
-  gint width, height;
-
-  if (!gst_video_format_parse_caps (caps, &format, &width, &height))
-    return FALSE;
+  if (in_info->width == out_info->width && in_info->height == out_info->height) {
+    gst_base_transform_set_passthrough (GST_BASE_TRANSFORM (filter), TRUE);
+  } else {
+    GST_CAT_DEBUG_OBJECT (GST_CAT_PERFORMANCE, filter, "setup videoscaling");
+    gst_base_transform_set_passthrough (GST_BASE_TRANSFORM (filter), FALSE);
+  }
 
-  *size = gst_video_format_get_size (format, width, height);
+  GST_DEBUG_OBJECT (videoscale, "from=%dx%d (par=%d/%d dar=%d/%d), size %"
+      G_GSIZE_FORMAT " -> to=%dx%d (par=%d/%d dar=%d/%d borders=%d:%d), "
+      "size %" G_GSIZE_FORMAT,
+      in_info->width, in_info->height, out_info->par_n, out_info->par_d,
+      from_dar_n, from_dar_d, in_info->size, out_info->width,
+      out_info->height, out_info->par_n, out_info->par_d, to_dar_n, to_dar_d,
+      videoscale->borders_w, videoscale->borders_h, out_info->size);
 
   return TRUE;
 }
 
-static void
+static GstCaps *
 gst_video_scale_fixate_caps (GstBaseTransform * base, GstPadDirection direction,
     GstCaps * caps, GstCaps * othercaps)
 {
@@ -689,7 +648,8 @@ gst_video_scale_fixate_caps (GstBaseTransform * base, GstPadDirection direction,
   GValue fpar = { 0, }, tpar = {
   0,};
 
-  g_return_if_fail (gst_caps_is_fixed (caps));
+  othercaps = gst_caps_make_writable (othercaps);
+  gst_caps_truncate (othercaps);
 
   GST_DEBUG_OBJECT (base, "trying to fixate othercaps %" GST_PTR_FORMAT
       " based on caps %" GST_PTR_FORMAT, othercaps, caps);
@@ -739,7 +699,7 @@ gst_video_scale_fixate_caps (GstBaseTransform * base, GstPadDirection direction,
     gint num, den;
 
     /* from_par should be fixed */
-    g_return_if_fail (gst_value_is_fixed (from_par));
+    g_return_val_if_fail (gst_value_is_fixed (from_par), othercaps);
 
     from_par_n = gst_value_get_fraction_numerator (from_par);
     from_par_d = gst_value_get_fraction_denominator (from_par);
@@ -1112,23 +1072,27 @@ done:
     g_value_unset (&fpar);
   if (to_par == &tpar)
     g_value_unset (&tpar);
+
+  return othercaps;
 }
 
 static void
-gst_video_scale_setup_vs_image (VSImage * image, GstVideoFormat format,
-    gint component, gint width, gint height, gint b_w, gint b_h, uint8_t * data)
+gst_video_scale_setup_vs_image (VSImage * image, GstVideoFrame * frame,
+    gint component, gint b_w, gint b_h)
 {
-  image->real_width =
-      gst_video_format_get_component_width (format, component, width);
-  image->real_height =
-      gst_video_format_get_component_height (format, component, height);
-  image->width =
-      gst_video_format_get_component_width (format, component, MAX (1,
-          width - b_w));
-  image->height =
-      gst_video_format_get_component_height (format, component, MAX (1,
-          height - b_h));
-  image->stride = gst_video_format_get_row_stride (format, component, width);
+  GstVideoFormat format;
+  gint width, height;
+
+  format = GST_VIDEO_FRAME_FORMAT (frame);
+  width = GST_VIDEO_FRAME_WIDTH (frame);
+  height = GST_VIDEO_FRAME_HEIGHT (frame);
+
+  image->real_width = GST_VIDEO_FRAME_COMP_WIDTH (frame, component);
+  image->real_height = GST_VIDEO_FRAME_COMP_HEIGHT (frame, component);
+  image->width = GST_VIDEO_FORMAT_INFO_SCALE_WIDTH (frame->info.finfo,
+      component, MAX (1, width - b_w));
+  image->height = GST_VIDEO_FORMAT_INFO_SCALE_HEIGHT (frame->info.finfo,
+      component, MAX (1, height - b_h));
 
   image->border_top = (image->real_height - image->height) / 2;
   image->border_bottom = image->real_height - image->height - image->border_top;
@@ -1147,22 +1111,12 @@ gst_video_scale_setup_vs_image (VSImage * image, GstVideoFormat format,
     image->border_right = image->real_width - image->width - image->border_left;
   }
 
-  if (format == GST_VIDEO_FORMAT_I420
-      || format == GST_VIDEO_FORMAT_YV12
-      || format == GST_VIDEO_FORMAT_Y444
-      || format == GST_VIDEO_FORMAT_Y42B || format == GST_VIDEO_FORMAT_Y41B
-      || format == GST_VIDEO_FORMAT_NV12) {
-    image->real_pixels = data + gst_video_format_get_component_offset (format,
-        component, width, height);
-  } else {
-    g_assert (component == 0);
-    image->real_pixels = data;
-  }
+  image->real_pixels = frame->data[component];
+  image->stride = frame->info.stride[component];
 
   image->pixels =
       image->real_pixels + image->border_top * image->stride +
-      image->border_left * gst_video_format_get_pixel_stride (format,
-      component);
+      image->border_left * GST_VIDEO_FRAME_COMP_PSTRIDE (frame, component);
 }
 
 static const guint8 *
@@ -1228,69 +1182,45 @@ _get_black_for_format (GstVideoFormat format)
 }
 
 static GstFlowReturn
-gst_video_scale_transform (GstBaseTransform * trans, GstBuffer * in,
-    GstBuffer * out)
+gst_video_scale_transform_frame (GstVideoFilter * filter,
+    GstVideoFrame * in_frame, GstVideoFrame * out_frame)
 {
-  GstVideoScale *videoscale = GST_VIDEO_SCALE (trans);
+  GstVideoScale *videoscale = GST_VIDEO_SCALE (filter);
   GstFlowReturn ret = GST_FLOW_OK;
-  VSImage dest = { NULL, };
-  VSImage src = { NULL, };
-  VSImage dest_u = { NULL, };
-  VSImage dest_v = { NULL, };
-  VSImage src_u = { NULL, };
-  VSImage src_v = { NULL, };
+  VSImage dest[4] = { {NULL,}, };
+  VSImage src[4] = { {NULL,}, };
   gint method;
-  const guint8 *black = _get_black_for_format (videoscale->format);
+  const guint8 *black;
   gboolean add_borders;
+  GstVideoFormat format;
+  gint i;
 
   GST_OBJECT_LOCK (videoscale);
   method = videoscale->method;
   add_borders = videoscale->add_borders;
   GST_OBJECT_UNLOCK (videoscale);
 
-  if (videoscale->from_width == 1) {
+  format = GST_VIDEO_INFO_FORMAT (&filter->in_info);
+  black = _get_black_for_format (format);
+
+  if (filter->in_info.width == 1) {
     method = GST_VIDEO_SCALE_NEAREST;
   }
   if (method == GST_VIDEO_SCALE_4TAP &&
-      (videoscale->from_width < 4 || videoscale->from_height < 4)) {
+      (filter->in_info.width < 4 || filter->in_info.height < 4)) {
     method = GST_VIDEO_SCALE_BILINEAR;
   }
 
-  gst_video_scale_setup_vs_image (&src, videoscale->format, 0,
-      videoscale->from_width, videoscale->from_height, 0, 0,
-      GST_BUFFER_DATA (in));
-  gst_video_scale_setup_vs_image (&dest, videoscale->format, 0,
-      videoscale->to_width, videoscale->to_height, videoscale->borders_w,
-      videoscale->borders_h, GST_BUFFER_DATA (out));
-
-  if (videoscale->format == GST_VIDEO_FORMAT_I420
-      || videoscale->format == GST_VIDEO_FORMAT_YV12
-      || videoscale->format == GST_VIDEO_FORMAT_Y444
-      || videoscale->format == GST_VIDEO_FORMAT_Y42B
-      || videoscale->format == GST_VIDEO_FORMAT_Y41B) {
-    gst_video_scale_setup_vs_image (&src_u, videoscale->format, 1,
-        videoscale->from_width, videoscale->from_height, 0, 0,
-        GST_BUFFER_DATA (in));
-    gst_video_scale_setup_vs_image (&src_v, videoscale->format, 2,
-        videoscale->from_width, videoscale->from_height, 0, 0,
-        GST_BUFFER_DATA (in));
-    gst_video_scale_setup_vs_image (&dest_u, videoscale->format, 1,
-        videoscale->to_width, videoscale->to_height, videoscale->borders_w,
-        videoscale->borders_h, GST_BUFFER_DATA (out));
-    gst_video_scale_setup_vs_image (&dest_v, videoscale->format, 2,
-        videoscale->to_width, videoscale->to_height, videoscale->borders_w,
-        videoscale->borders_h, GST_BUFFER_DATA (out));
-  }
-  if (videoscale->format == GST_VIDEO_FORMAT_NV12) {
-    gst_video_scale_setup_vs_image (&src_u, videoscale->format, 1,
-        videoscale->from_width, videoscale->from_height, 0, 0,
-        GST_BUFFER_DATA (in));
-    gst_video_scale_setup_vs_image (&dest_u, videoscale->format, 1,
-        videoscale->to_width, videoscale->to_height, videoscale->borders_w,
-        videoscale->borders_h, GST_BUFFER_DATA (out));
+  for (i = 0; i < GST_VIDEO_FRAME_N_PLANES (in_frame); i++) {
+    gst_video_scale_setup_vs_image (&src[i], in_frame, i, 0, 0);
+    gst_video_scale_setup_vs_image (&dest[i], out_frame, i,
+        videoscale->borders_w, videoscale->borders_h);
   }
 
-  switch (videoscale->format) {
+  GST_CAT_DEBUG_OBJECT (GST_CAT_PERFORMANCE, filter,
+      "doing videoscale format %s", GST_VIDEO_INFO_NAME (&filter->in_info));
+
+  switch (format) {
     case GST_VIDEO_FORMAT_RGBx:
     case GST_VIDEO_FORMAT_xRGB:
     case GST_VIDEO_FORMAT_BGRx:
@@ -1301,19 +1231,19 @@ gst_video_scale_transform (GstBaseTransform * trans, GstBuffer * in,
     case GST_VIDEO_FORMAT_ABGR:
     case GST_VIDEO_FORMAT_AYUV:
       if (add_borders)
-        vs_fill_borders_RGBA (&dest, black);
+        vs_fill_borders_RGBA (&dest[0], black);
       switch (method) {
         case GST_VIDEO_SCALE_NEAREST:
-          vs_image_scale_nearest_RGBA (&dest, &src, videoscale->tmp_buf);
+          vs_image_scale_nearest_RGBA (&dest[0], &src[0], videoscale->tmp_buf);
           break;
         case GST_VIDEO_SCALE_BILINEAR:
-          vs_image_scale_linear_RGBA (&dest, &src, videoscale->tmp_buf);
+          vs_image_scale_linear_RGBA (&dest[0], &src[0], videoscale->tmp_buf);
           break;
         case GST_VIDEO_SCALE_4TAP:
-          vs_image_scale_4tap_RGBA (&dest, &src, videoscale->tmp_buf);
+          vs_image_scale_4tap_RGBA (&dest[0], &src[0], videoscale->tmp_buf);
           break;
         case GST_VIDEO_SCALE_LANCZOS:
-          vs_image_scale_lanczos_AYUV (&dest, &src, videoscale->tmp_buf,
+          vs_image_scale_lanczos_AYUV (&dest[0], &src[0], videoscale->tmp_buf,
               videoscale->sharpness, videoscale->dither, videoscale->submethod,
               videoscale->envelope, videoscale->sharpen);
           break;
@@ -1324,19 +1254,20 @@ gst_video_scale_transform (GstBaseTransform * trans, GstBuffer * in,
     case GST_VIDEO_FORMAT_ARGB64:
     case GST_VIDEO_FORMAT_AYUV64:
       if (add_borders)
-        vs_fill_borders_AYUV64 (&dest, black);
+        vs_fill_borders_AYUV64 (&dest[0], black);
       switch (method) {
         case GST_VIDEO_SCALE_NEAREST:
-          vs_image_scale_nearest_AYUV64 (&dest, &src, videoscale->tmp_buf);
+          vs_image_scale_nearest_AYUV64 (&dest[0], &src[0],
+              videoscale->tmp_buf);
           break;
         case GST_VIDEO_SCALE_BILINEAR:
-          vs_image_scale_linear_AYUV64 (&dest, &src, videoscale->tmp_buf);
+          vs_image_scale_linear_AYUV64 (&dest[0], &src[0], videoscale->tmp_buf);
           break;
         case GST_VIDEO_SCALE_4TAP:
-          vs_image_scale_4tap_AYUV64 (&dest, &src, videoscale->tmp_buf);
+          vs_image_scale_4tap_AYUV64 (&dest[0], &src[0], videoscale->tmp_buf);
           break;
         case GST_VIDEO_SCALE_LANCZOS:
-          vs_image_scale_lanczos_AYUV64 (&dest, &src, videoscale->tmp_buf,
+          vs_image_scale_lanczos_AYUV64 (&dest[0], &src[0], videoscale->tmp_buf,
               videoscale->sharpness, videoscale->dither, videoscale->submethod,
               videoscale->envelope, videoscale->sharpen);
           break;
@@ -1348,16 +1279,16 @@ gst_video_scale_transform (GstBaseTransform * trans, GstBuffer * in,
     case GST_VIDEO_FORMAT_BGR:
     case GST_VIDEO_FORMAT_v308:
       if (add_borders)
-        vs_fill_borders_RGB (&dest, black);
+        vs_fill_borders_RGB (&dest[0], black);
       switch (method) {
         case GST_VIDEO_SCALE_NEAREST:
-          vs_image_scale_nearest_RGB (&dest, &src, videoscale->tmp_buf);
+          vs_image_scale_nearest_RGB (&dest[0], &src[0], videoscale->tmp_buf);
           break;
         case GST_VIDEO_SCALE_BILINEAR:
-          vs_image_scale_linear_RGB (&dest, &src, videoscale->tmp_buf);
+          vs_image_scale_linear_RGB (&dest[0], &src[0], videoscale->tmp_buf);
           break;
         case GST_VIDEO_SCALE_4TAP:
-          vs_image_scale_4tap_RGB (&dest, &src, videoscale->tmp_buf);
+          vs_image_scale_4tap_RGB (&dest[0], &src[0], videoscale->tmp_buf);
           break;
         default:
           goto unknown_mode;
@@ -1366,16 +1297,16 @@ gst_video_scale_transform (GstBaseTransform * trans, GstBuffer * in,
     case GST_VIDEO_FORMAT_YUY2:
     case GST_VIDEO_FORMAT_YVYU:
       if (add_borders)
-        vs_fill_borders_YUYV (&dest, black);
+        vs_fill_borders_YUYV (&dest[0], black);
       switch (method) {
         case GST_VIDEO_SCALE_NEAREST:
-          vs_image_scale_nearest_YUYV (&dest, &src, videoscale->tmp_buf);
+          vs_image_scale_nearest_YUYV (&dest[0], &src[0], videoscale->tmp_buf);
           break;
         case GST_VIDEO_SCALE_BILINEAR:
-          vs_image_scale_linear_YUYV (&dest, &src, videoscale->tmp_buf);
+          vs_image_scale_linear_YUYV (&dest[0], &src[0], videoscale->tmp_buf);
           break;
         case GST_VIDEO_SCALE_4TAP:
-          vs_image_scale_4tap_YUYV (&dest, &src, videoscale->tmp_buf);
+          vs_image_scale_4tap_YUYV (&dest[0], &src[0], videoscale->tmp_buf);
           break;
         default:
           goto unknown_mode;
@@ -1383,16 +1314,16 @@ gst_video_scale_transform (GstBaseTransform * trans, GstBuffer * in,
       break;
     case GST_VIDEO_FORMAT_UYVY:
       if (add_borders)
-        vs_fill_borders_UYVY (&dest, black);
+        vs_fill_borders_UYVY (&dest[0], black);
       switch (method) {
         case GST_VIDEO_SCALE_NEAREST:
-          vs_image_scale_nearest_UYVY (&dest, &src, videoscale->tmp_buf);
+          vs_image_scale_nearest_UYVY (&dest[0], &src[0], videoscale->tmp_buf);
           break;
         case GST_VIDEO_SCALE_BILINEAR:
-          vs_image_scale_linear_UYVY (&dest, &src, videoscale->tmp_buf);
+          vs_image_scale_linear_UYVY (&dest[0], &src[0], videoscale->tmp_buf);
           break;
         case GST_VIDEO_SCALE_4TAP:
-          vs_image_scale_4tap_UYVY (&dest, &src, videoscale->tmp_buf);
+          vs_image_scale_4tap_UYVY (&dest[0], &src[0], videoscale->tmp_buf);
           break;
         default:
           goto unknown_mode;
@@ -1401,16 +1332,16 @@ gst_video_scale_transform (GstBaseTransform * trans, GstBuffer * in,
     case GST_VIDEO_FORMAT_Y800:
     case GST_VIDEO_FORMAT_GRAY8:
       if (add_borders)
-        vs_fill_borders_Y (&dest, black);
+        vs_fill_borders_Y (&dest[0], black);
       switch (method) {
         case GST_VIDEO_SCALE_NEAREST:
-          vs_image_scale_nearest_Y (&dest, &src, videoscale->tmp_buf);
+          vs_image_scale_nearest_Y (&dest[0], &src[0], videoscale->tmp_buf);
           break;
         case GST_VIDEO_SCALE_BILINEAR:
-          vs_image_scale_linear_Y (&dest, &src, videoscale->tmp_buf);
+          vs_image_scale_linear_Y (&dest[0], &src[0], videoscale->tmp_buf);
           break;
         case GST_VIDEO_SCALE_4TAP:
-          vs_image_scale_4tap_Y (&dest, &src, videoscale->tmp_buf);
+          vs_image_scale_4tap_Y (&dest[0], &src[0], videoscale->tmp_buf);
           break;
         default:
           goto unknown_mode;
@@ -1420,16 +1351,16 @@ gst_video_scale_transform (GstBaseTransform * trans, GstBuffer * in,
     case GST_VIDEO_FORMAT_GRAY16_BE:
     case GST_VIDEO_FORMAT_Y16:
       if (add_borders)
-        vs_fill_borders_Y16 (&dest, 0);
+        vs_fill_borders_Y16 (&dest[0], 0);
       switch (method) {
         case GST_VIDEO_SCALE_NEAREST:
-          vs_image_scale_nearest_Y16 (&dest, &src, videoscale->tmp_buf);
+          vs_image_scale_nearest_Y16 (&dest[0], &src[0], videoscale->tmp_buf);
           break;
         case GST_VIDEO_SCALE_BILINEAR:
-          vs_image_scale_linear_Y16 (&dest, &src, videoscale->tmp_buf);
+          vs_image_scale_linear_Y16 (&dest[0], &src[0], videoscale->tmp_buf);
           break;
         case GST_VIDEO_SCALE_4TAP:
-          vs_image_scale_4tap_Y16 (&dest, &src, videoscale->tmp_buf);
+          vs_image_scale_4tap_Y16 (&dest[0], &src[0], videoscale->tmp_buf);
           break;
         default:
           goto unknown_mode;
@@ -1441,34 +1372,34 @@ gst_video_scale_transform (GstBaseTransform * trans, GstBuffer * in,
     case GST_VIDEO_FORMAT_Y42B:
     case GST_VIDEO_FORMAT_Y41B:
       if (add_borders) {
-        vs_fill_borders_Y (&dest, black);
-        vs_fill_borders_Y (&dest_u, black + 1);
-        vs_fill_borders_Y (&dest_v, black + 2);
+        vs_fill_borders_Y (&dest[0], black);
+        vs_fill_borders_Y (&dest[1], black + 1);
+        vs_fill_borders_Y (&dest[2], black + 2);
       }
       switch (method) {
         case GST_VIDEO_SCALE_NEAREST:
-          vs_image_scale_nearest_Y (&dest, &src, videoscale->tmp_buf);
-          vs_image_scale_nearest_Y (&dest_u, &src_u, videoscale->tmp_buf);
-          vs_image_scale_nearest_Y (&dest_v, &src_v, videoscale->tmp_buf);
+          vs_image_scale_nearest_Y (&dest[0], &src[0], videoscale->tmp_buf);
+          vs_image_scale_nearest_Y (&dest[1], &src[1], videoscale->tmp_buf);
+          vs_image_scale_nearest_Y (&dest[2], &src[2], videoscale->tmp_buf);
           break;
         case GST_VIDEO_SCALE_BILINEAR:
-          vs_image_scale_linear_Y (&dest, &src, videoscale->tmp_buf);
-          vs_image_scale_linear_Y (&dest_u, &src_u, videoscale->tmp_buf);
-          vs_image_scale_linear_Y (&dest_v, &src_v, videoscale->tmp_buf);
+          vs_image_scale_linear_Y (&dest[0], &src[0], videoscale->tmp_buf);
+          vs_image_scale_linear_Y (&dest[1], &src[1], videoscale->tmp_buf);
+          vs_image_scale_linear_Y (&dest[2], &src[2], videoscale->tmp_buf);
           break;
         case GST_VIDEO_SCALE_4TAP:
-          vs_image_scale_4tap_Y (&dest, &src, videoscale->tmp_buf);
-          vs_image_scale_4tap_Y (&dest_u, &src_u, videoscale->tmp_buf);
-          vs_image_scale_4tap_Y (&dest_v, &src_v, videoscale->tmp_buf);
+          vs_image_scale_4tap_Y (&dest[0], &src[0], videoscale->tmp_buf);
+          vs_image_scale_4tap_Y (&dest[1], &src[1], videoscale->tmp_buf);
+          vs_image_scale_4tap_Y (&dest[2], &src[2], videoscale->tmp_buf);
           break;
         case GST_VIDEO_SCALE_LANCZOS:
-          vs_image_scale_lanczos_Y (&dest, &src, videoscale->tmp_buf,
+          vs_image_scale_lanczos_Y (&dest[0], &src[0], videoscale->tmp_buf,
               videoscale->sharpness, videoscale->dither, videoscale->submethod,
               videoscale->envelope, videoscale->sharpen);
-          vs_image_scale_lanczos_Y (&dest_u, &src_u, videoscale->tmp_buf,
+          vs_image_scale_lanczos_Y (&dest[1], &src[1], videoscale->tmp_buf,
               videoscale->sharpness, videoscale->dither, videoscale->submethod,
               videoscale->envelope, videoscale->sharpen);
-          vs_image_scale_lanczos_Y (&dest_v, &src_v, videoscale->tmp_buf,
+          vs_image_scale_lanczos_Y (&dest[2], &src[2], videoscale->tmp_buf,
               videoscale->sharpness, videoscale->dither, videoscale->submethod,
               videoscale->envelope, videoscale->sharpen);
           break;
@@ -1479,12 +1410,12 @@ gst_video_scale_transform (GstBaseTransform * trans, GstBuffer * in,
     case GST_VIDEO_FORMAT_NV12:
       switch (method) {
         case GST_VIDEO_SCALE_NEAREST:
-          vs_image_scale_nearest_Y (&dest, &src, videoscale->tmp_buf);
-          vs_image_scale_nearest_NV12 (&dest_u, &src_u, videoscale->tmp_buf);
+          vs_image_scale_nearest_Y (&dest[0], &src[0], videoscale->tmp_buf);
+          vs_image_scale_nearest_NV12 (&dest[1], &src[1], videoscale->tmp_buf);
           break;
         case GST_VIDEO_SCALE_BILINEAR:
-          vs_image_scale_linear_Y (&dest, &src, videoscale->tmp_buf);
-          vs_image_scale_linear_NV12 (&dest_u, &src_u, videoscale->tmp_buf);
+          vs_image_scale_linear_Y (&dest[0], &src[0], videoscale->tmp_buf);
+          vs_image_scale_linear_NV12 (&dest[1], &src[1], videoscale->tmp_buf);
           break;
         default:
           goto unknown_mode;
@@ -1492,16 +1423,17 @@ gst_video_scale_transform (GstBaseTransform * trans, GstBuffer * in,
       break;
     case GST_VIDEO_FORMAT_RGB16:
       if (add_borders)
-        vs_fill_borders_RGB565 (&dest, black);
+        vs_fill_borders_RGB565 (&dest[0], black);
       switch (method) {
         case GST_VIDEO_SCALE_NEAREST:
-          vs_image_scale_nearest_RGB565 (&dest, &src, videoscale->tmp_buf);
+          vs_image_scale_nearest_RGB565 (&dest[0], &src[0],
+              videoscale->tmp_buf);
           break;
         case GST_VIDEO_SCALE_BILINEAR:
-          vs_image_scale_linear_RGB565 (&dest, &src, videoscale->tmp_buf);
+          vs_image_scale_linear_RGB565 (&dest[0], &src[0], videoscale->tmp_buf);
           break;
         case GST_VIDEO_SCALE_4TAP:
-          vs_image_scale_4tap_RGB565 (&dest, &src, videoscale->tmp_buf);
+          vs_image_scale_4tap_RGB565 (&dest[0], &src[0], videoscale->tmp_buf);
           break;
         default:
           goto unknown_mode;
@@ -1509,16 +1441,17 @@ gst_video_scale_transform (GstBaseTransform * trans, GstBuffer * in,
       break;
     case GST_VIDEO_FORMAT_RGB15:
       if (add_borders)
-        vs_fill_borders_RGB555 (&dest, black);
+        vs_fill_borders_RGB555 (&dest[0], black);
       switch (method) {
         case GST_VIDEO_SCALE_NEAREST:
-          vs_image_scale_nearest_RGB555 (&dest, &src, videoscale->tmp_buf);
+          vs_image_scale_nearest_RGB555 (&dest[0], &src[0],
+              videoscale->tmp_buf);
           break;
         case GST_VIDEO_SCALE_BILINEAR:
-          vs_image_scale_linear_RGB555 (&dest, &src, videoscale->tmp_buf);
+          vs_image_scale_linear_RGB555 (&dest[0], &src[0], videoscale->tmp_buf);
           break;
         case GST_VIDEO_SCALE_4TAP:
-          vs_image_scale_4tap_RGB555 (&dest, &src, videoscale->tmp_buf);
+          vs_image_scale_4tap_RGB555 (&dest[0], &src[0], videoscale->tmp_buf);
           break;
         default:
           goto unknown_mode;
@@ -1528,17 +1461,13 @@ gst_video_scale_transform (GstBaseTransform * trans, GstBuffer * in,
       goto unsupported;
   }
 
-  GST_LOG_OBJECT (videoscale, "pushing buffer of %d bytes",
-      GST_BUFFER_SIZE (out));
-
   return ret;
 
   /* ERRORS */
 unsupported:
   {
     GST_ELEMENT_ERROR (videoscale, STREAM, NOT_IMPLEMENTED, (NULL),
-        ("Unsupported format %d for scaling method %d",
-            videoscale->format, method));
+        ("Unsupported format %d for scaling method %d", format, method));
     return GST_FLOW_ERROR;
   }
 unknown_mode:
@@ -1552,7 +1481,8 @@ unknown_mode:
 static gboolean
 gst_video_scale_src_event (GstBaseTransform * trans, GstEvent * event)
 {
-  GstVideoScale *videoscale = GST_VIDEO_SCALE (trans);
+  GstVideoScale *videoscale = GST_VIDEO_SCALE_CAST (trans);
+  GstVideoFilter *filter = GST_VIDEO_FILTER_CAST (trans);
   gboolean ret;
   gdouble a;
   GstStructure *structure;
@@ -1568,11 +1498,11 @@ gst_video_scale_src_event (GstBaseTransform * trans, GstEvent * event)
       structure = (GstStructure *) gst_event_get_structure (event);
       if (gst_structure_get_double (structure, "pointer_x", &a)) {
         gst_structure_set (structure, "pointer_x", G_TYPE_DOUBLE,
-            a * videoscale->from_width / videoscale->to_width, NULL);
+            a * filter->in_info.width / filter->out_info.width, NULL);
       }
       if (gst_structure_get_double (structure, "pointer_y", &a)) {
         gst_structure_set (structure, "pointer_y", G_TYPE_DOUBLE,
-            a * videoscale->from_height / videoscale->to_height, NULL);
+            a * filter->in_info.height / filter->out_info.height, NULL);
       }
       break;
     default:
@@ -1595,6 +1525,7 @@ plugin_init (GstPlugin * plugin)
 
   GST_DEBUG_CATEGORY_INIT (video_scale_debug, "videoscale", 0,
       "videoscale element");
+  GST_DEBUG_CATEGORY_GET (GST_CAT_PERFORMANCE, "GST_PERFORMANCE");
 
   vs_4tap_init ();