diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2011-01-23 02:06:19 +0100 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2011-01-23 02:06:19 +0100 |
commit | 59eddb17ffad8595804cfc7d6a25f644b042fc54 (patch) | |
tree | b420f36dcd9b12bed6e64ae49e54caeb1327b07d /yavta.c | |
parent | 71ffd6bf71632a034081e245152912570689f954 (diff) |
Display the instant frame rate for each frame during capture
This helps debugging framerate related problems.
Thanks to Martin Hostettler for submitting a first version of this
patch.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'yavta.c')
-rw-r--r-- | yavta.c | 12 |
1 files changed, 10 insertions, 2 deletions
@@ -815,6 +815,7 @@ static int video_do_capture(struct device *dev, unsigned int nframes, { char *filename = NULL; struct timeval start; + struct timeval last; struct timeval ts; struct v4l2_buffer buf; unsigned int size; @@ -835,6 +836,7 @@ static int video_do_capture(struct device *dev, unsigned int nframes, size = 0; gettimeofday(&start, NULL); + last = start; for (i = 0; i < nframes; ++i) { /* Dequeue a buffer. */ @@ -860,11 +862,17 @@ static int video_do_capture(struct device *dev, unsigned int nframes, size += buf.bytesused; + fps = (buf.timestamp.tv_sec - last.tv_sec) * 1000000 + + buf.timestamp.tv_usec - last.tv_usec; + fps = fps ? 1000000.0 / fps : 0.0; + gettimeofday(&ts, NULL); - printf("%u (%u) [%c] %u %u bytes %ld.%06ld %ld.%06ld\n", i, buf.index, + printf("%u (%u) [%c] %u %u bytes %ld.%06ld %ld.%06ld %.3f fps\n", i, buf.index, (buf.flags & V4L2_BUF_FLAG_ERROR) ? 'E' : '-', buf.sequence, buf.bytesused, buf.timestamp.tv_sec, - buf.timestamp.tv_usec, ts.tv_sec, ts.tv_usec); + buf.timestamp.tv_usec, ts.tv_sec, ts.tv_usec, fps); + + last = buf.timestamp; /* Save the image. */ if (dev->type == V4L2_BUF_TYPE_VIDEO_CAPTURE && filename_prefix && !skip) { |