videoconvert: fix the transform_size function
authorWim Taymans <wim.taymans@collabora.co.uk>
Thu, 1 Dec 2011 14:47:16 +0000 (15:47 +0100)
committerWim Taymans <wim.taymans@collabora.co.uk>
Thu, 1 Dec 2011 14:47:16 +0000 (15:47 +0100)
The output size of a buffer does not depend on the input size but simply on the
caps of the output buffers. Don't let the base implementation deal with
unit_sizes, because input buffers might not be a multiple of that when they have
padding or non-default strides. instead, implement a transform size function
that simply calculate the natural size of an output buffer based on the caps.

gst/videoconvert/gstvideoconvert.c

index 4b81892..3c5eadb 100644 (file)
@@ -79,8 +79,9 @@ static void gst_video_convert_get_property (GObject * object,
 
 static gboolean gst_video_convert_set_caps (GstBaseTransform * btrans,
     GstCaps * incaps, GstCaps * outcaps);
-static gboolean gst_video_convert_get_unit_size (GstBaseTransform * btrans,
-    GstCaps * caps, gsize * size);
+static gboolean gst_video_convert_transform_size (GstBaseTransform * btrans,
+    GstPadDirection direction, GstCaps * caps, gsize size,
+    GstCaps * othercaps, gsize * othersize);
 static GstFlowReturn gst_video_convert_transform (GstBaseTransform * btrans,
     GstBuffer * inbuf, GstBuffer * outbuf);
 
@@ -366,8 +367,8 @@ gst_video_convert_class_init (GstVideoConvertClass * klass)
       GST_DEBUG_FUNCPTR (gst_video_convert_transform_caps);
   gstbasetransform_class->set_caps =
       GST_DEBUG_FUNCPTR (gst_video_convert_set_caps);
-  gstbasetransform_class->get_unit_size =
-      GST_DEBUG_FUNCPTR (gst_video_convert_get_unit_size);
+  gstbasetransform_class->transform_size =
+      GST_DEBUG_FUNCPTR (gst_video_convert_transform_size);
   gstbasetransform_class->decide_allocation =
       GST_DEBUG_FUNCPTR (gst_video_convert_decide_allocation);
   gstbasetransform_class->transform =
@@ -424,18 +425,18 @@ gst_video_convert_get_property (GObject * object, guint property_id,
 }
 
 static gboolean
-gst_video_convert_get_unit_size (GstBaseTransform * btrans, GstCaps * caps,
-    gsize * size)
+gst_video_convert_transform_size (GstBaseTransform * btrans,
+    GstPadDirection direction, GstCaps * caps, gsize size,
+    GstCaps * othercaps, gsize * othersize)
 {
   gboolean ret = TRUE;
   GstVideoInfo info;
 
   g_assert (size);
 
-  ret = gst_video_info_from_caps (&info, caps);
-  if (ret) {
-    *size = info.size;
-  }
+  ret = gst_video_info_from_caps (&info, othercaps);
+  if (ret)
+    *othersize = info.size;
 
   return ret;
 }