From 1f78a50ce5667c540d53dfe274ec068141c132fd Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Wed, 5 Oct 2011 16:19:37 +0200 Subject: live: Use global frame count to display the FPS counter Signed-off-by: Laurent Pinchart --- live.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/live.c b/live.c index 77587cb..4a920c5 100644 --- a/live.c +++ b/live.c @@ -57,8 +57,8 @@ #define SELECT_TIMEOUT 2000 /* in milliseconds */ static struct timespec fps_ts = { 0, 0 }; -static unsigned int fps_count = 0; -static bool show_fps = true; +static unsigned int fps_last = 0; +static bool fps_show = true; static unsigned int frame_count = 0; static unsigned int frame_skip = 0; @@ -174,19 +174,18 @@ static void viewfinder_process(struct omap3_isp_device *isp __attribute__((__unu frame_count++; - if (show_fps){ - fps_count++; - + if (fps_show){ clock_gettime(CLOCK_MONOTONIC, &ts); interval = ts.tv_sec - fps_ts.tv_sec; interval += (ts.tv_nsec - fps_ts.tv_nsec) / 1000000000.0; if (interval >= 5) { - if (fps_count > 1) - printf("frame rate: %f fps\n", fps_count / interval); + if (frame_count > 1) + printf("frame rate: %f fps\n", + (frame_count - fps_last) / interval); - fps_count = 0; + fps_last = frame_count; fps_ts = ts; } } -- cgit v1.2.3