From 743c6a447592e841375daca5bd08f71d6ab209bb Mon Sep 17 00:00:00 2001 From: Nicolas Dufresne Date: Thu, 4 Sep 2014 15:11:40 -0400 Subject: [PATCH] v4l2: Merge min_buffers_for* variable into one Reuse the same min_buffers variable for both capture and output, this reduce the length of lines and make the code more readable. https://bugzilla.gnome.org/show_bug.cgi?id=736072 --- sys/v4l2/gstv4l2bufferpool.c | 5 +---- sys/v4l2/gstv4l2object.c | 16 ++++++++-------- sys/v4l2/gstv4l2object.h | 4 ++-- sys/v4l2/gstv4l2videodec.c | 3 +-- 4 files changed, 12 insertions(+), 16 deletions(-) diff --git a/sys/v4l2/gstv4l2bufferpool.c b/sys/v4l2/gstv4l2bufferpool.c index d00d123..61e2faa 100644 --- a/sys/v4l2/gstv4l2bufferpool.c +++ b/sys/v4l2/gstv4l2bufferpool.c @@ -623,10 +623,7 @@ gst_v4l2_buffer_pool_start (GstBufferPool * bpool) &max_buffers)) goto wrong_config; - if (V4L2_TYPE_IS_OUTPUT (obj->type)) - min_latency = MAX (GST_V4L2_MIN_BUFFERS, obj->min_buffers_for_output); - else - min_latency = MAX (GST_V4L2_MIN_BUFFERS, obj->min_buffers_for_capture); + min_latency = MAX (GST_V4L2_MIN_BUFFERS, obj->min_buffers); switch (obj->mode) { case GST_V4L2_IO_RW: diff --git a/sys/v4l2/gstv4l2object.c b/sys/v4l2/gstv4l2object.c index 9073a48..b99bdbb 100644 --- a/sys/v4l2/gstv4l2object.c +++ b/sys/v4l2/gstv4l2object.c @@ -3206,13 +3206,13 @@ gst_v4l2_object_decide_allocation (GstV4l2Object * obj, GstQuery * query) if (v4l2_ioctl (obj->video_fd, VIDIOC_G_CTRL, &ctl) >= 0) { GST_DEBUG_OBJECT (obj->element, "driver require a minimum of %d buffers", ctl.value); - obj->min_buffers_for_capture = ctl.value; + obj->min_buffers = ctl.value; } else { - obj->min_buffers_for_capture = 0; + obj->min_buffers = 0; } /* We can't share our own pool, if it exceed V4L2 capacity */ - if (min + obj->min_buffers_for_capture + 1 > VIDEO_MAX_FRAME) + if (min + obj->min_buffers + 1 > VIDEO_MAX_FRAME) can_share_own_pool = FALSE; /* select a pool */ @@ -3289,11 +3289,11 @@ gst_v4l2_object_decide_allocation (GstV4l2Object * obj, GstQuery * query) * to fill the pipeline, the minimum required to decoder according to the * driver and 1 more, so we don't endup up with everything downstream or * held by the decoder. */ - own_min = min + obj->min_buffers_for_capture + 1; + own_min = min + obj->min_buffers + 1; } else { /* In this case we'll have to configure two buffer pool. For our buffer * pool, we'll need what the driver one, and one more, so we can dequeu */ - own_min = obj->min_buffers_for_capture + 1; + own_min = obj->min_buffers + 1; own_min = MAX (own_min, GST_V4L2_MIN_BUFFERS); /* for the downstream pool, we keep what downstream wants, though ensure @@ -3472,12 +3472,12 @@ gst_v4l2_object_propose_allocation (GstV4l2Object * obj, GstQuery * query) if (v4l2_ioctl (obj->video_fd, VIDIOC_G_CTRL, &ctl) >= 0) { GST_DEBUG_OBJECT (obj->element, "driver require a miminum of %d buffers", ctl.value); - obj->min_buffers_for_output = ctl.value; + obj->min_buffers = ctl.value; } else { - obj->min_buffers_for_output = 0; + obj->min_buffers = 0; } - min = MAX (obj->min_buffers_for_output, GST_V4L2_MIN_BUFFERS); + min = MAX (obj->min_buffers, GST_V4L2_MIN_BUFFERS); gst_query_add_allocation_pool (query, pool, size, min, max); diff --git a/sys/v4l2/gstv4l2object.h b/sys/v4l2/gstv4l2object.h index 141f62d..6dbf473 100644 --- a/sys/v4l2/gstv4l2object.h +++ b/sys/v4l2/gstv4l2object.h @@ -118,8 +118,8 @@ struct _GstV4l2Object { gboolean prefered_non_contiguous; /* This will be set if supported in decide_allocation. It can be used to - * calculate the minimum latency of a m2m decoder. */ - guint32 min_buffers_for_capture; + * calculate the minimum latency. */ + guint32 min_buffers; /* This will be set if supported in propose allocation. */ guint32 min_buffers_for_output; diff --git a/sys/v4l2/gstv4l2videodec.c b/sys/v4l2/gstv4l2videodec.c index f3e03c7..5f45d6d 100644 --- a/sys/v4l2/gstv4l2videodec.c +++ b/sys/v4l2/gstv4l2videodec.c @@ -615,8 +615,7 @@ gst_v4l2_video_dec_decide_allocation (GstVideoDecoder * decoder, ret = GST_VIDEO_DECODER_CLASS (parent_class)->decide_allocation (decoder, query); - latency = self->v4l2capture->min_buffers_for_capture * - self->v4l2capture->duration; + latency = self->v4l2capture->min_buffers * self->v4l2capture->duration; gst_video_decoder_set_latency (decoder, latency, latency); return ret; -- 2.7.4