From e57bc4386292e3f47e1bfec72973b37aee6f3625 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Zanelli?= Date: Thu, 15 Jan 2015 16:11:53 +0100 Subject: [PATCH] v4l2bufferpool: set v4l2_buffer.field when queuing buffer in an output device According to the current specification, application must set this field for an output device. https://bugzilla.gnome.org/show_bug.cgi?id=743013 --- sys/v4l2/gstv4l2bufferpool.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/sys/v4l2/gstv4l2bufferpool.c b/sys/v4l2/gstv4l2bufferpool.c index 11201f95d4..52df37cf03 100644 --- a/sys/v4l2/gstv4l2bufferpool.c +++ b/sys/v4l2/gstv4l2bufferpool.c @@ -1003,6 +1003,7 @@ static GstFlowReturn gst_v4l2_buffer_pool_qbuf (GstV4l2BufferPool * pool, GstBuffer * buf) { GstV4l2MemoryGroup *group = NULL; + const GstV4l2Object *obj = pool->obj; gint index; if (!gst_v4l2_is_buffer_valid (buf, &group)) { @@ -1021,6 +1022,28 @@ gst_v4l2_buffer_pool_qbuf (GstV4l2BufferPool * pool, GstBuffer * buf) g_atomic_int_inc (&pool->num_queued); pool->buffers[index] = buf; + if (V4L2_TYPE_IS_OUTPUT (obj->type)) { + enum v4l2_field field; + + /* Except when field is set to alternate, buffer field is the same as + * the one defined in format */ + if (V4L2_TYPE_IS_MULTIPLANAR (obj->type)) + field = obj->format.fmt.pix_mp.field; + else + field = obj->format.fmt.pix.field; + + /* NB: At this moment, we can't have alternate mode because it not handled + * yet */ + if (field == V4L2_FIELD_ALTERNATE) { + if (GST_BUFFER_FLAG_IS_SET (buf, GST_VIDEO_FRAME_FLAG_TFF)) + field = V4L2_FIELD_TOP; + else + field = V4L2_FIELD_BOTTOM; + } + + group->buffer.field = field; + } + if (!gst_v4l2_allocator_qbuf (pool->vallocator, group)) goto queue_failed;