mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-23 18:21:04 +00:00
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
This commit is contained in:
parent
3afec4dd01
commit
743c6a4475
4 changed files with 12 additions and 16 deletions
|
@ -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:
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue