From 398001f20d0efc47dcaeea62993d6d73b1f5d1f0 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Wed, 13 Jul 2011 13:52:30 +0100 Subject: [PATCH] v4l2: don't store stride in the videoinfo 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 | 8 +++++++- sys/v4l2/gstv4l2object.c | 11 ++--------- sys/v4l2/gstv4l2object.h | 2 +- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/sys/v4l2/gstv4l2bufferpool.c b/sys/v4l2/gstv4l2bufferpool.c index 3065735..a48c2a8 100644 --- a/sys/v4l2/gstv4l2bufferpool.c +++ b/sys/v4l2/gstv4l2bufferpool.c @@ -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; diff --git a/sys/v4l2/gstv4l2object.c b/sys/v4l2/gstv4l2object.c index 2e99130..b124a67 100644 --- a/sys/v4l2/gstv4l2object.c +++ b/sys/v4l2/gstv4l2object.c @@ -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? */ diff --git a/sys/v4l2/gstv4l2object.h b/sys/v4l2/gstv4l2object.h index 6d8710f..a1ced8a 100644 --- a/sys/v4l2/gstv4l2object.h +++ b/sys/v4l2/gstv4l2object.h @@ -108,7 +108,7 @@ struct _GstV4l2Object { /* the current format */ struct v4l2_fmtdesc *fmtdesc; GstVideoInfo info; - gboolean custom_stride; + guint32 bytesperline; guint size; GstClockTime duration; -- 2.7.4