diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2011-10-05 16:02:16 +0200 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2011-10-05 16:26:02 +0200 |
commit | d5e0f9b31e8a5da5b25a01bb1955314859c62760 (patch) | |
tree | cbeafbfd850155c9ce0021f7f1d63efea4c4b1f2 | |
parent | acd2b7a13e607a46a2185125b7b3fbac81324985 (diff) |
live: Make the number of video buffers configurable
The -b argument can be used to set the number of video display buffers.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
-rw-r--r-- | live.c | 9 | ||||
-rw-r--r-- | videoout.c | 10 | ||||
-rw-r--r-- | videoout.h | 1 |
3 files changed, 15 insertions, 5 deletions
@@ -370,6 +370,7 @@ static void usage(const char *argv0) { printf("Usage: %s [options]\n", argv0); printf("Supported options:\n"); + printf("-b, --buffers n Use n display buffers\n"); printf("-h, --help Show this help screen\n"); printf("-s, --skip n Skip display of n frames out of n+1\n"); } @@ -385,6 +386,7 @@ int main(int argc __attribute__((__unused__)), char *argv[] __attribute__((__unu struct v4l2_mbus_framefmt view_format; struct v4l2_buffers_pool *pool = NULL; struct timespec start, end; + unsigned int buffers = 3; struct v4l2_rect rect; int exit_code = EXIT_FAILURE; const char *vo_devname; @@ -392,8 +394,11 @@ int main(int argc __attribute__((__unused__)), char *argv[] __attribute__((__unu int ret; int c; - while ((c = getopt_long(argc, argv, "hs:", opts, NULL)) != -1) { + while ((c = getopt_long(argc, argv, "b:hs:", opts, NULL)) != -1) { switch (c) { + case 'b': + buffers = atoi(optarg); + break; case 'h': usage(argv[0]); return 0; @@ -450,7 +455,7 @@ int main(int argc __attribute__((__unused__)), char *argv[] __attribute__((__unu goto cleanup; } - vo = vo_init(vo_devname, &vo_ops, rect.width, rect.height); + vo = vo_init(vo_devname, &vo_ops, buffers, rect.width, rect.height); if (vo == NULL) { printf("error: unable to initialize video output\n"); goto cleanup; @@ -37,7 +37,7 @@ #include "isp/v4l2.h" #include "isp/v4l2-pool.h" -#define NUM_BUFFERS 3 +#define MAX_BUFFERS 16 struct videoout { @@ -47,12 +47,13 @@ struct videoout int streaming; - int queued[NUM_BUFFERS]; + int queued[MAX_BUFFERS]; int num_queued; }; struct videoout *vo_init(const char *devname, const struct video_out_operations *ops, + unsigned int buffers, unsigned int width, unsigned int height) { struct v4l2_pix_format pixfmt; @@ -110,7 +111,10 @@ struct videoout *vo_init(const char *devname, } /* Allocate buffers. */ - vo->pool = v4l2_buffers_pool_new(NUM_BUFFERS); + if (buffers > MAX_BUFFERS) + buffers = MAX_BUFFERS; + + vo->pool = v4l2_buffers_pool_new(buffers); if (vo->pool == NULL) { printf("error: unable to allocate buffers pool for display.\n"); goto error; @@ -34,6 +34,7 @@ struct video_out_operations { struct videoout *vo_init(const char *devname, const struct video_out_operations *ops, + unsigned int buffers, unsigned int width, unsigned int height); void vo_cleanup(struct videoout *vo); int vo_enable_colorkey(struct videoout *vo, unsigned int val); |