v4l2: Merge min_buffers_for* variable into one
authorNicolas Dufresne <nicolas.dufresne@collabora.co.uk>
Thu, 4 Sep 2014 19:11:40 +0000 (15:11 -0400)
committerNicolas Dufresne <nicolas.dufresne@collabora.co.uk>
Tue, 9 Sep 2014 22:39:23 +0000 (18:39 -0400)
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
sys/v4l2/gstv4l2object.c
sys/v4l2/gstv4l2object.h
sys/v4l2/gstv4l2videodec.c

index d00d123..61e2faa 100644 (file)
@@ -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:
index 9073a48..b99bdbb 100644 (file)
@@ -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);
 
index 141f62d..6dbf473 100644 (file)
@@ -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;
index f3e03c7..5f45d6d 100644 (file)
@@ -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;