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: v4l2grab: Convert "default" values into parameters
Author:  Mauro Carvalho Chehab <[email protected]>
Date:    Mon Dec 6 09:07:38 2010 -0200

Signed-off-by: Mauro Carvalho Chehab <[email protected]>

 contrib/test/v4l2grab.c |   27 +++++++++++++++++++--------
 1 files changed, 19 insertions(+), 8 deletions(-)

---

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

diff --git a/contrib/test/v4l2grab.c b/contrib/test/v4l2grab.c
index f68fc1e..de42be9 100644
--- a/contrib/test/v4l2grab.c
+++ b/contrib/test/v4l2grab.c
@@ -44,7 +44,8 @@ static void xioctl(int fh, unsigned long int request, void 
*arg)
        }
 }
 
-int main(int argc, char **argv)
+static int capture(char *dev_name, int x_res, int y_res, int n_frames,
+                  char *out_dir)
 {
        struct v4l2_format              fmt;
        struct v4l2_buffer              buf;
@@ -54,8 +55,7 @@ int main(int argc, char **argv)
        struct timeval                  tv;
        int                             r, fd = -1;
        unsigned int                    i, n_buffers;
-       char                            *dev_name = "/dev/video0";
-       char                            out_name[256];
+       char                            out_name[25 + strlen(out_dir)];
        FILE                            *fout;
        struct buffer                   *buffers;
 
@@ -67,8 +67,8 @@ int main(int argc, char **argv)
 
        CLEAR(fmt);
        fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
-       fmt.fmt.pix.width       = 640;
-       fmt.fmt.pix.height      = 480;
+       fmt.fmt.pix.width       = x_res;
+       fmt.fmt.pix.height      = y_res;
        fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_RGB24;
        fmt.fmt.pix.field       = V4L2_FIELD_INTERLACED;
        xioctl(fd, VIDIOC_S_FMT, &fmt);
@@ -76,7 +76,7 @@ int main(int argc, char **argv)
                printf("Libv4l didn't accept RGB24 format. Can't proceed.\n");
                exit(EXIT_FAILURE);
        }
-       if ((fmt.fmt.pix.width != 640) || (fmt.fmt.pix.height != 480))
+       if ((fmt.fmt.pix.width != x_res) || (fmt.fmt.pix.height != y_res))
                printf("Warning: driver is sending image at %dx%d\n",
                        fmt.fmt.pix.width, fmt.fmt.pix.height);
 
@@ -117,7 +117,7 @@ int main(int argc, char **argv)
        type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
 
        xioctl(fd, VIDIOC_STREAMON, &type);
-       for (i = 0; i < 20; i++) {
+       for (i = 0; i < n_frames; i++) {
                do {
                        FD_ZERO(&fds);
                        FD_SET(fd, &fds);
@@ -138,7 +138,7 @@ int main(int argc, char **argv)
                buf.memory = V4L2_MEMORY_MMAP;
                xioctl(fd, VIDIOC_DQBUF, &buf);
 
-               sprintf(out_name, "out%03d.ppm", i);
+               sprintf(out_name, "%s/out%03d.ppm", out_dir, i);
                fout = fopen(out_name, "w");
                if (!fout) {
                        perror("Cannot open image");
@@ -160,3 +160,14 @@ int main(int argc, char **argv)
 
        return 0;
 }
+
+int main(int argc, char **argv)
+{
+       char    *dev_name = "/dev/video0";
+       char    *out_dir = ".";
+       int     x_res = 640;
+       int     y_res = 480;
+       int     n_frames = 20;
+
+       return capture(dev_name, x_res, y_res, n_frames, out_dir);
+}

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

Reply via email to