aboutsummaryrefslogtreecommitdiffstats
path: root/src/blind-transpose.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-transpose.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-transpose.c')
-rw-r--r--src/blind-transpose.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/blind-transpose.c b/src/blind-transpose.c
new file mode 100644
index 0000000..0c32d81
--- /dev/null
+++ b/src/blind-transpose.c
@@ -0,0 +1,45 @@
+/* See LICENSE file for copyright and license details. */
+#include "stream.h"
+#include "util.h"
+
+#include <fcntl.h>
+#include <inttypes.h>
+#include <string.h>
+#include <unistd.h>
+
+USAGE("")
+
+int
+main(int argc, char *argv[])
+{
+ struct stream stream;
+ char *buf, *image;
+ size_t n, imgw, imgh, x, y, i, b;
+
+ ENOFLAGS(argc);
+
+ stream.file = "<stdin>";
+ stream.fd = STDIN_FILENO;
+ einit_stream(&stream);
+ fprint_stream_head(stdout, &stream);
+ efflush(stdout, "<stdout>");
+
+ echeck_frame_size(stream.width, stream.height, stream.pixel_size, 0, "<stdin>");
+ n = stream.width * stream.height * stream.pixel_size;
+ buf = emalloc(n);
+ image = emalloc(n);
+
+ imgw = stream.width * (imgh = stream.height * stream.pixel_size);
+ memcpy(buf, stream.buf, stream.ptr);
+ while (eread_frame(&stream, buf, n)) {
+ for (b = y = 0; y < imgh; y += stream.pixel_size)
+ for (x = 0; x < imgw; x += imgh)
+ for (i = 0; i < stream.pixel_size; i++)
+ image[x + y + i] = buf[b++];
+ ewriteall(STDOUT_FILENO, image, n, "<stdout>");
+ }
+
+ free(buf);
+ free(image);
+ return 0;
+}