(wrong string) ée

From: <git_AT_suckless.org>
Date: Sun, 9 Apr 2017 11:22:52 +0200 (CEST)

commit 80d76b61b0e2b1224f8b0417658285b90934880e
Author: Mattias Andrée <maandree_AT_kth.se>
AuthorDate: Sun Apr 9 10:16:50 2017 +0200
Commit: Mattias Andrée <maandree_AT_kth.se>
CommitDate: Sun Apr 9 10:52:20 2017 +0200

    blind-next-frame: add -f flag: read multiple frames
    
    Signed-off-by: Mattias Andrée <maandree_AT_kth.se>

diff --git a/TODO b/TODO
index dbe49c3..e5bfc30 100644
--- a/TODO
+++ b/TODO
_AT_@ -25,8 +25,6 @@ blind-from-video: add options to:
           print to stdout (up to user to direct to /dev/null
           for discarding)
 
-blind-next-frame: add option to read multiple frames
-
 Add [-j jobs] to blind-from-video and blind-to-video.
 
 
diff --git a/man/blind-next-frame.1 b/man/blind-next-frame.1
index c175ebc..55fe74f 100644
--- a/man/blind-next-frame.1
+++ b/man/blind-next-frame.1
_AT_@ -3,6 +3,8 @@
 blind-next-frame - Extracts the next frame from a video
 .SH SYNOPSIS
 .B blind-next-frame
+[-f
+.IR frames ]
 .I width
 .I height
 .IR pixel-format " ..."
_AT_@ -27,6 +29,12 @@ And argument following
 is appended to
 .I pixel-format
 with <space> in between.
+.SH OPTIONS
+.TP
+.BR -f " "\fIframes\fP
+Read and output the first
+.I frames
+frames rather than the first single frame.
 .SH EXIT STATUS
 .TP
 0
diff --git a/src/arg.h b/src/arg.h
index 1d04f24..5285d92 100644
--- a/src/arg.h
+++ b/src/arg.h
_AT_@ -77,7 +77,7 @@ extern char *argv0;
 
 #define LNGARG() &argv[0][0]
 
-#define ENOFLAGS(...) ARGBEGIN {\
+#define UNOFLAGS(...) ARGBEGIN {\
                         default:\
                                 usage();\
                         } ARGEND;\
diff --git a/src/blind-compress.c b/src/blind-compress.c
index c70a066..7d41f23 100644
--- a/src/blind-compress.c
+++ b/src/blind-compress.c
_AT_@ -38,7 +38,7 @@ main(int argc, char *argv[])
         size_t *cmp = NULL;
         size_t cmpsize = 0;
 
- ENOFLAGS(argc);
+ UNOFLAGS(argc);
 
         stream.file = "<stdin>";
         stream.fd = STDIN_FILENO;
diff --git a/src/blind-cut.c b/src/blind-cut.c
index 75d7fd6..c1e1bdc 100644
--- a/src/blind-cut.c
+++ b/src/blind-cut.c
_AT_@ -19,7 +19,7 @@ main(int argc, char *argv[])
         char buf[BUFSIZ];
         int to_end = 0;
 
- ENOFLAGS(argc != 3);
+ UNOFLAGS(argc != 3);
 
         if (!strcmp(argv[0], "end"))
                 eprintf("refusing to create video with zero frames\n");
diff --git a/src/blind-decompress.c b/src/blind-decompress.c
index ea24fc6..f01fa8f 100644
--- a/src/blind-decompress.c
+++ b/src/blind-decompress.c
_AT_@ -14,7 +14,7 @@ main(int argc, char *argv[])
         char *buf;
         size_t n, m, fptr, sptr, same = 0, diff = 0;
 
- ENOFLAGS(argc);
+ UNOFLAGS(argc);
 
         stream.file = "<stdin>";
         stream.fd = STDIN_FILENO;
diff --git a/src/blind-flip.c b/src/blind-flip.c
index 0c18602..b37a9d8 100644
--- a/src/blind-flip.c
+++ b/src/blind-flip.c
_AT_@ -14,7 +14,7 @@ main(int argc, char *argv[])
         size_t n, ptr, row_size;
         char *buf;
 
- ENOFLAGS(argc);
+ UNOFLAGS(argc);
 
         stream.file = "<stdin>";
         stream.fd = STDIN_FILENO;
diff --git a/src/blind-flop.c b/src/blind-flop.c
index 5f737f3..39370a5 100644
--- a/src/blind-flop.c
+++ b/src/blind-flop.c
_AT_@ -15,7 +15,7 @@ main(int argc, char *argv[])
         char *buf, *image;
         size_t i, j, n, m;
 
- ENOFLAGS(argc);
+ UNOFLAGS(argc);
 
         stream.file = "<stdin>";
         stream.fd = STDIN_FILENO;
diff --git a/src/blind-from-text.c b/src/blind-from-text.c
index 6717c99..6bd5921 100644
--- a/src/blind-from-text.c
+++ b/src/blind-from-text.c
_AT_@ -37,7 +37,7 @@ main(int argc, char *argv[])
         ssize_t len;
         void (*process)(void) = NULL;
 
- ENOFLAGS(argc);
+ UNOFLAGS(argc);
 
         len = getline(&line, &size, stdin);
         if (len < 0) {
diff --git a/src/blind-next-frame.c b/src/blind-next-frame.c
index 8afa725..41ab0ca 100644
--- a/src/blind-next-frame.c
+++ b/src/blind-next-frame.c
_AT_@ -6,19 +6,27 @@
 #include <string.h>
 #include <unistd.h>
 
-USAGE("width height pixel-format ...")
+USAGE("[-f frames] width height pixel-format ...")
 
 int
 main(int argc, char *argv[])
 {
         struct stream stream;
- size_t n, w;
+ size_t n, w, h = 0;
         int i, anything = 0;
         char *p;
 
- ENOFLAGS(argc < 3);
-
         stream.frames = 1;
+
+ ARGBEGIN {
+ case 'f':
+ stream.frames = etozu_flag('f', UARGF(), 1, SIZE_MAX);
+ break;
+ } ARGEND;
+
+ if (argc < 3)
+ usage();
+
         stream.fd = STDIN_FILENO;
         stream.file = "<stdin>";
         stream.pixfmt[0] = '\0';
_AT_@ -44,20 +52,23 @@ main(int argc, char *argv[])
         enfflush(2, stdout, "<stdout>");
 
         w = stream.width * stream.pixel_size;
- while (stream.height) {
- stream.height--;
- for (n = w; n; n -= stream.ptr) {
- stream.ptr = 0;
- if (!enread_stream(2, &stream, n))
- goto done;
- anything = 1;
- enwriteall(2, STDOUT_FILENO, stream.buf, stream.ptr, "<stdout>");
+ while (stream.frames) {
+ stream.frames--;
+ for (h = stream.height; h;) {
+ h--;
+ for (n = w; n; n -= stream.ptr) {
+ stream.ptr = 0;
+ if (!enread_stream(2, &stream, n))
+ goto done;
+ anything = 1;
+ enwriteall(2, STDOUT_FILENO, stream.buf, stream.ptr, "<stdout>");
+ }
                 }
         }
 done:
 
- if (anything && (stream.height || n))
- enprintf(2, "incomplete frame\n");
+ if (anything && (h || n || stream.frames))
+ enprintf(2, "%s: is shorted than expected\n", stream.file);
 
         return !anything;
 }
diff --git a/src/blind-read-head.c b/src/blind-read-head.c
index afb2fbc..c31e2b0 100644
--- a/src/blind-read-head.c
+++ b/src/blind-read-head.c
_AT_@ -16,7 +16,7 @@ main(int argc, char *argv[])
         size_t i, ptr;
         ssize_t r;
 
- ENOFLAGS(argc);
+ UNOFLAGS(argc);
 
         for (ptr = 0; ptr < sizeof(buf);) {
                 r = read(STDIN_FILENO, buf + ptr, 1);
diff --git a/src/blind-repeat.c b/src/blind-repeat.c
index 82c924f..29089c6 100644
--- a/src/blind-repeat.c
+++ b/src/blind-repeat.c
_AT_@ -98,7 +98,7 @@ main(int argc, char *argv[])
         size_t count = 0;
         int inf = 0;
 
- ENOFLAGS(argc != 2);
+ UNOFLAGS(argc != 2);
 
         if (!strcmp(argv[0], "inf"))
                 inf = 1;
diff --git a/src/blind-set-luma.c b/src/blind-set-luma.c
index 49cbc08..f4bd3d5 100644
--- a/src/blind-set-luma.c
+++ b/src/blind-set-luma.c
_AT_@ -92,7 +92,7 @@ main(int argc, char *argv[])
         struct stream colour, luma;
         void (*process)(struct stream *colour, struct stream *luma, size_t n);
 
- ENOFLAGS(argc != 1);
+ UNOFLAGS(argc != 1);
 
         colour.file = "<stdin>";
         colour.fd = STDIN_FILENO;
diff --git a/src/blind-to-text.c b/src/blind-to-text.c
index 5467787..c196dcb 100644
--- a/src/blind-to-text.c
+++ b/src/blind-to-text.c
_AT_@ -27,7 +27,7 @@ main(int argc, char *argv[])
         size_t n;
         void (*process)(struct stream *stream, size_t n) = NULL;
 
- ENOFLAGS(argc);
+ UNOFLAGS(argc);
 
         stream.file = "<stdin>";
         stream.fd = STDIN_FILENO;
diff --git a/src/blind-transpose.c b/src/blind-transpose.c
index cf1036b..9421fc5 100644
--- a/src/blind-transpose.c
+++ b/src/blind-transpose.c
_AT_@ -16,7 +16,7 @@ main(int argc, char *argv[])
         char *buf, *image;
         size_t n, imgw, srcw, srch, ps, x, y, i, b, dx;
 
- ENOFLAGS(argc);
+ UNOFLAGS(argc);
 
         stream.file = "<stdin>";
         stream.fd = STDIN_FILENO;
diff --git a/src/blind-write-head.c b/src/blind-write-head.c
index 9e7c4a3..81f36b4 100644
--- a/src/blind-write-head.c
+++ b/src/blind-write-head.c
_AT_@ -6,7 +6,7 @@ USAGE("parameters ...")
 int
 main(int argc, char *argv[])
 {
- ENOFLAGS(!argc);
+ UNOFLAGS(!argc);
 
         printf("%s", *argv++);
         while (*argv)
Received on Sun Apr 09 2017 - 11:22:52 CEST

This archive was generated by hypermail 2.3.0 : Sun Apr 09 2017 - 11:24:16 CEST