diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2011-10-05 11:58:30 +0200 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2011-10-05 16:17:07 +0200 |
commit | 528154acaf9ab372c69b16d1e895e1556f25119f (patch) | |
tree | c1fd5d744950b05f866f6d9fee45185e45207955 | |
parent | 7030a194c84e1fad43ade86674a1e57381d825d1 (diff) |
live: Add support for periodical skipping of frames on the display
When the sensor delivers a frame rate higher than what the display can
process, the OMAP3 ISP continuously runs out of buffers. The new --skip
command line option can be used to avoid that situation by skipping
display of n frames out of n+1.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
-rw-r--r-- | live.c | 36 |
1 files changed, 28 insertions, 8 deletions
@@ -60,6 +60,9 @@ static struct timespec fps_ts = { 0, 0 }; static unsigned int fps_count = 0; static bool show_fps = true; +static unsigned int frame_count = 0; +static unsigned int frame_skip = 0; + static struct omap3_isp_device *isp = NULL; static struct videoout *vo = NULL; @@ -167,6 +170,9 @@ static void viewfinder_process(struct omap3_isp_device *isp __attribute__((__unu { struct timespec ts; float interval; + int ret; + + frame_count++; if (show_fps){ fps_count++; @@ -190,7 +196,18 @@ static void viewfinder_process(struct omap3_isp_device *isp __attribute__((__unu return; } - vo_queue_buffer(vo, buffer); + /* Queue the buffer to the display, or requeue it to the viewfinder if + * it needs to be skipped. + */ + if ((frame_count % (frame_skip + 1)) == 0) { + vo_queue_buffer(vo, buffer); + return; + } + + ret = omap3_isp_viewfinder_put_buffer(isp, buffer); + if (ret < 0) + printf("error: unable to requeue buffer: %s (%d)\n", + strerror(-ret), ret); } @@ -354,11 +371,13 @@ static void usage(const char *argv0) { printf("Usage: %s [options]\n", argv0); printf("Supported options:\n"); - printf("-h, --help Show this help screen\n"); + printf("-h, --help Show this help screen\n"); + printf("-s, --skip n Skip display of n frames out of n+1\n"); } static struct option opts[] = { { "help", 0, 0, 'h' }, + { "skip", 1, 0, 's' }, { 0, 0, 0, 0 } }; @@ -367,7 +386,6 @@ 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 count = 0; struct v4l2_rect rect; int exit_code = EXIT_FAILURE; const char *vo_devname; @@ -375,11 +393,14 @@ int main(int argc __attribute__((__unused__)), char *argv[] __attribute__((__unu int ret; int c; - while ((c = getopt_long(argc, argv, "h", opts, NULL)) != -1) { + while ((c = getopt_long(argc, argv, "hs:", opts, NULL)) != -1) { switch (c) { case 'h': usage(argv[0]); return 0; + case 's': + frame_skip = atoi(optarg); + break; default: printf("Invalid option -%c\n", c); printf("Run %s -h for help.\n", argv[0]); @@ -492,7 +513,6 @@ int main(int argc __attribute__((__unused__)), char *argv[] __attribute__((__unu } events_dispatch(&rfds, &wfds); - count++; } clock_gettime(CLOCK_MONOTONIC, &end); @@ -508,10 +528,10 @@ int main(int argc __attribute__((__unused__)), char *argv[] __attribute__((__unu end.tv_nsec += 1000000000; } - fps = count / (end.tv_sec + end.tv_nsec / 1000000000.0); + fps = frame_count / (end.tv_sec + end.tv_nsec / 1000000000.0); - printf("%u images processed in %lu.%06lu seconds (%f fps)\n", count, - end.tv_sec, end.tv_nsec / 1000, fps); + printf("%u images processed in %lu.%06lu seconds (%f fps)\n", + frame_count, end.tv_sec, end.tv_nsec / 1000, fps); exit_code = EXIT_SUCCESS; |