v4l2: don't store stride in the videoinfo
authorWim Taymans <wim.taymans@collabora.co.uk>
Wed, 13 Jul 2011 12:52:30 +0000 (13:52 +0100)
committerWim Taymans <wim.taymans@collabora.co.uk>
Wed, 13 Jul 2011 12:52:30 +0000 (13:52 +0100)
We want to keep the default strides in the videoinfo. Keep the stride of the
video frames separate so that we can use both to copy a video frame and do
correct stride conversion.

sys/v4l2/gstv4l2bufferpool.c
sys/v4l2/gstv4l2object.c
sys/v4l2/gstv4l2object.h

index 3065735..a48c2a8 100644 (file)
@@ -178,11 +178,17 @@ gst_v4l2_buffer_new (GstV4l2BufferPool * pool, guint index)
 
   /* add metadata to raw video buffers */
   if (info->finfo) {
+    gsize offset[GST_VIDEO_MAX_PLANES];
+    gint stride[GST_VIDEO_MAX_PLANES];
+
+    offset[0] = 0;
+    stride[0] = obj->bytesperline;
+
     GST_DEBUG ("adding video meta");
     gst_buffer_add_meta_video_full (ret, info->flags,
         GST_VIDEO_INFO_FORMAT (info), GST_VIDEO_INFO_WIDTH (info),
         GST_VIDEO_INFO_HEIGHT (info), GST_VIDEO_INFO_N_PLANES (info),
-        info->offset, info->stride);
+        offset, stride);
   }
   return ret;
 
index 2e99130..b124a67 100644 (file)
@@ -2101,13 +2101,11 @@ gst_v4l2_object_set_format (GstV4l2Object * v4l2object, GstCaps * caps)
       format.fmt.pix.height, GST_FOURCC_ARGS (format.fmt.pix.pixelformat),
       format.fmt.pix.bytesperline);
 
-  v4l2object->custom_stride = format.fmt.pix.bytesperline != stride;
-
   if (format.type != v4l2object->type ||
       format.fmt.pix.width != width ||
       format.fmt.pix.height != height ||
       format.fmt.pix.pixelformat != pixelformat ||
-      format.fmt.pix.field != field || v4l2object->custom_stride) {
+      format.fmt.pix.field != field || format.fmt.pix.bytesperline != stride) {
     /* something different, set the format */
     GST_DEBUG_OBJECT (v4l2object->element, "Setting format to %dx%d, format "
         "%" GST_FOURCC_FORMAT " bytesperline %d", width, height,
@@ -2135,12 +2133,7 @@ gst_v4l2_object_set_format (GstV4l2Object * v4l2object, GstCaps * caps)
     if (format.fmt.pix.pixelformat != pixelformat)
       goto invalid_pixelformat;
 
-    if (v4l2object->custom_stride) {
-      stride = format.fmt.pix.bytesperline;
-      GST_DEBUG_OBJECT (v4l2object->element, "We need custom stride %d",
-          stride);
-      GST_VIDEO_INFO_PLANE_STRIDE (&info, 0) = stride;
-    }
+    v4l2object->bytesperline = format.fmt.pix.bytesperline;
   }
 
   /* Is there a reason we require the caller to always specify a framerate? */
index 6d8710f..a1ced8a 100644 (file)
@@ -108,7 +108,7 @@ struct _GstV4l2Object {
   /* the current format */
   struct v4l2_fmtdesc *fmtdesc;
   GstVideoInfo info;
-  gboolean custom_stride;
+  guint32 bytesperline;
 
   guint size;
   GstClockTime duration;