aboutsummaryrefslogtreecommitdiffstats
path: root/src/blind-next-frame.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2017-01-13 09:05:08 +0100
committerMattias Andrée <maandree@kth.se>2017-01-13 09:05:08 +0100
commit4674ec0e4b833ab0d0365225ba99228df14abe87 (patch)
tree1b89fe1559fc9a2422e20048700e694a72d17751 /src/blind-next-frame.c
parentvu-from-video: fix Y'UV encoding + add vu-to-video (diff)
downloadblind-4674ec0e4b833ab0d0365225ba99228df14abe87.tar.gz
blind-4674ec0e4b833ab0d0365225ba99228df14abe87.tar.bz2
blind-4674ec0e4b833ab0d0365225ba99228df14abe87.tar.xz
Rename to blind
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'src/blind-next-frame.c')
-rw-r--r--src/blind-next-frame.c63
1 files changed, 63 insertions, 0 deletions
diff --git a/src/blind-next-frame.c b/src/blind-next-frame.c
new file mode 100644
index 0000000..6a55790
--- /dev/null
+++ b/src/blind-next-frame.c
@@ -0,0 +1,63 @@
+/* See LICENSE file for copyright and license details. */
+#include "stream.h"
+#include "util.h"
+
+#include <inttypes.h>
+#include <string.h>
+#include <unistd.h>
+
+USAGE("width height pixel-format ...")
+
+int
+main(int argc, char *argv[])
+{
+ struct stream stream;
+ size_t n, w;
+ int i, anything = 0;
+ char *p;
+
+ ENOFLAGS(argc < 3);
+
+ stream.frames = 1;
+ stream.fd = STDIN_FILENO;
+ stream.file = "<stdin>";
+ stream.pixfmt[0] = '\0';
+
+ stream.width = entozu_arg(2, "the width", argv[0], 1, SIZE_MAX);
+ stream.height = entozu_arg(2, "the height", argv[1], 1, SIZE_MAX);
+ argv += 2, argc -= 2;
+
+ n = (size_t)argc - 1;
+ for (i = 0; i < argc; i++)
+ n += strlen(argv[i]);
+ if (n < sizeof(stream.pixfmt)) {
+ p = stpcpy(stream.pixfmt, argv[0]);
+ for (i = 1; i < argc; i++) {
+ *p++ = ' ';
+ p = stpcpy(p, argv[i]);
+ }
+ }
+
+ enset_pixel_size(2, &stream);
+
+ fprint_stream_head(stdout, &stream);
+ 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>");
+ }
+ }
+done:
+
+ if (stream.height || n)
+ enprintf(2, "incomplete frame\n");
+
+ return !anything;
+}