v4l2: pass v4l2object to GST_V4L2_MIN_BUFFERS()

Will be used to double the number of buffers in alternate interlace
mode.
This commit is contained in:
Guillaume Desmottes 2020-01-30 12:35:02 +05:30
parent 00893baef9
commit 8a69e26f16
5 changed files with 14 additions and 12 deletions

View file

@ -551,9 +551,9 @@ gst_v4l2_buffer_pool_set_config (GstBufferPool * bpool, GstStructure * config)
| GST_V4L2_ALLOCATOR_FLAG_DMABUF_CREATE_BUFS);
}
if (min_buffers < GST_V4L2_MIN_BUFFERS) {
if (min_buffers < GST_V4L2_MIN_BUFFERS (obj)) {
updated = TRUE;
min_buffers = GST_V4L2_MIN_BUFFERS;
min_buffers = GST_V4L2_MIN_BUFFERS (obj);
GST_INFO_OBJECT (pool, "increasing minimum buffers to %u", min_buffers);
}
@ -766,7 +766,7 @@ gst_v4l2_buffer_pool_start (GstBufferPool * bpool)
&max_buffers))
goto wrong_config;
min_latency = MAX (GST_V4L2_MIN_BUFFERS, obj->min_buffers);
min_latency = MAX (GST_V4L2_MIN_BUFFERS (obj), obj->min_buffers);
switch (obj->mode) {
case GST_V4L2_IO_RW:
@ -795,7 +795,7 @@ gst_v4l2_buffer_pool_start (GstBufferPool * bpool)
V4L2_MEMORY_MMAP);
pool->num_allocated = count;
if (count < GST_V4L2_MIN_BUFFERS) {
if (count < GST_V4L2_MIN_BUFFERS (obj)) {
min_buffers = count;
goto no_buffers;
}
@ -908,7 +908,7 @@ no_buffers:
{
GST_ERROR_OBJECT (pool,
"we received %d buffer from device '%s', we want at least %d",
min_buffers, obj->videodev, GST_V4L2_MIN_BUFFERS);
min_buffers, obj->videodev, GST_V4L2_MIN_BUFFERS (obj));
gst_structure_free (config);
return FALSE;
}

View file

@ -4701,12 +4701,12 @@ gst_v4l2_object_decide_allocation (GstV4l2Object * obj, GstQuery * query)
/* 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 + 1;
own_min = MAX (own_min, GST_V4L2_MIN_BUFFERS);
own_min = MAX (own_min, GST_V4L2_MIN_BUFFERS (obj));
/* for the downstream pool, we keep what downstream wants, though ensure
* at least a minimum if downstream didn't suggest anything (we are
* expecting the base class to create a default one for the context) */
min = MAX (min, GST_V4L2_MIN_BUFFERS);
min = MAX (min, GST_V4L2_MIN_BUFFERS (obj));
/* To import we need the other pool to hold at least own_min */
if (obj->pool == pool)
@ -4844,7 +4844,7 @@ gst_v4l2_object_propose_allocation (GstV4l2Object * obj, GstQuery * query)
/* Set defaults allocation parameters */
size = obj->info.size;
min = GST_V4L2_MIN_BUFFERS;
min = GST_V4L2_MIN_BUFFERS (obj);
max = VIDEO_MAX_FRAME;
gst_query_parse_allocation (query, &caps, &need_pool);
@ -4882,7 +4882,7 @@ gst_v4l2_object_propose_allocation (GstV4l2Object * obj, GstQuery * query)
}
gst_v4l2_get_driver_min_buffers (obj);
min = MAX (obj->min_buffers, GST_V4L2_MIN_BUFFERS);
min = MAX (obj->min_buffers, GST_V4L2_MIN_BUFFERS (obj));
gst_query_add_allocation_pool (query, pool, size, min, max);

View file

@ -43,7 +43,7 @@ typedef struct _GstV4l2ObjectClassHelper GstV4l2ObjectClassHelper;
#include <gstv4l2bufferpool.h>
/* size of v4l2 buffer pool in streaming case */
#define GST_V4L2_MIN_BUFFERS 2
#define GST_V4L2_MIN_BUFFERS(obj) 2
/* max frame width/height */
#define GST_V4L2_MAX_SIZE (1<<15) /* 2^15 == 32768 */

View file

@ -893,7 +893,8 @@ gst_v4l2_transform_prepare_output_buffer (GstBaseTransform * trans,
/* Ensure input internal pool is active */
if (!gst_buffer_pool_is_active (pool)) {
GstStructure *config = gst_buffer_pool_get_config (pool);
gint min = MAX (GST_V4L2_MIN_BUFFERS, self->v4l2output->min_buffers);
gint min = MAX (GST_V4L2_MIN_BUFFERS (self->v4l2output),
self->v4l2output->min_buffers);
if (self->v4l2output->mode == GST_V4L2_IO_USERPTR ||
self->v4l2output->mode == GST_V4L2_IO_DMABUF_IMPORT) {

View file

@ -739,7 +739,8 @@ gst_v4l2_video_enc_handle_frame (GstVideoEncoder * encoder,
/* Ensure input internal pool is active */
if (!gst_buffer_pool_is_active (pool)) {
GstStructure *config = gst_buffer_pool_get_config (pool);
guint min = MAX (self->v4l2output->min_buffers, GST_V4L2_MIN_BUFFERS);
guint min = MAX (self->v4l2output->min_buffers,
GST_V4L2_MIN_BUFFERS (self->v4l2output));
gst_buffer_pool_config_set_params (config, self->input_state->caps,
self->v4l2output->info.size, min, min);