This is an automatic generated email to let you know that the following patch 
were queued at the 
http://git.linuxtv.org/v4l-utils.git tree:

Subject: v4l2-ctl: when streaming show fps.
Author:  Hans Verkuil <[email protected]>
Date:    Wed Aug 1 11:26:26 2012 +0200

Very useful when testing.

Signed-off-by: Hans Verkuil <[email protected]>
(cherry picked from commit bd79ed49b8ac30bb9fac8b7aac60bd0b40420c9d)

Signed-off-by: Gregor Jasny <[email protected]>

 utils/v4l2-ctl/v4l2-ctl-streaming.cpp |   36 ++++++++++++++++++++++++++------
 1 files changed, 29 insertions(+), 7 deletions(-)

---

http://git.linuxtv.org/v4l-utils.git?a=commitdiff;h=5e996dcfc83d0c8bc2b6a00b5432f7ef190484ec

diff --git a/utils/v4l2-ctl/v4l2-ctl-streaming.cpp 
b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
index a566441..6612143 100644
--- a/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
@@ -231,6 +231,9 @@ void streaming_set(int fd)
                if (use_poll)
                        fcntl(fd, F_SETFL, fd_flags | O_NONBLOCK);
 
+               unsigned count = 0, last = 0;
+               struct timeval tv_last;
+
                for (;;) {
                        struct v4l2_buffer buf;
                        int ret;
@@ -271,18 +274,36 @@ void streaming_set(int fd)
                        if (ret < 0 && errno == EAGAIN)
                                continue;
                        if (ret < 0) {
-                               if (!options[OptSilent])
-                                       printf("%s: failed: %s\n", 
"VIDIOC_DQBUF", strerror(errno));
+                               fprintf(stderr, "%s: failed: %s\n", 
"VIDIOC_DQBUF", strerror(errno));
                                return;
                        }
-                       if (fout == NULL) {
-                               printf(".");
-                               fflush(stdout);
-                       } else if (!stream_skip) {
-                               fwrite(buffers[buf.index], 1, buf.length, fout);
+                       if (fout && !stream_skip) {
+                               unsigned sz = fwrite(buffers[buf.index], 1, 
buf.length, fout);
+                               if (sz != buf.length)
+                                       fprintf(stderr, "%u != %u\n", sz, 
buf.length);
                        }
                        if (doioctl(fd, VIDIOC_QBUF, &buf))
                                return;
+
+                       fprintf(stderr, ".");
+                       fflush(stderr);
+
+                       if (count == 0) {
+                               gettimeofday(&tv_last, NULL);
+                       } else {
+                               struct timeval tv_cur, res;
+
+                               gettimeofday(&tv_cur, NULL);
+                               timersub(&tv_cur, &tv_last, &res);
+                               if (res.tv_sec) {
+                                       unsigned fps = (100 * (count - last)) /
+                                               (res.tv_sec * 100 + res.tv_usec 
/ 10000);
+                                       last = count;
+                                       tv_last = tv_cur;
+                                       fprintf(stderr, " %d fps\n", fps);
+                               }
+                       }
+                       count++;
                        if (stream_skip) {
                                stream_skip--;
                                continue;
@@ -294,6 +315,7 @@ void streaming_set(int fd)
                }
                doioctl(fd, VIDIOC_STREAMOFF, &type);
                fcntl(fd, F_SETFL, fd_flags);
+               fprintf(stderr, "\n");
 
                for (unsigned i = 0; i < reqbufs.count; i++) {
                        struct v4l2_buffer buf;

_______________________________________________
linuxtv-commits mailing list
[email protected]
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linuxtv-commits

Reply via email to