summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2011-01-23 02:06:19 +0100
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2011-01-23 02:06:19 +0100
commit59eddb17ffad8595804cfc7d6a25f644b042fc54 (patch)
treeb420f36dcd9b12bed6e64ae49e54caeb1327b07d
parent71ffd6bf71632a034081e245152912570689f954 (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>
-rw-r--r--yavta.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/yavta.c b/yavta.c
index e25013b..d6fd3b2 100644
--- a/yavta.c
+++ b/yavta.c
@@ -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) {