(wrong string) ée

From: <git_AT_suckless.org>
Date: Fri, 14 Jul 2017 00:32:54 +0200 (CEST)

commit 8a2f7656c100fe9062782977ec5c82212d092ab9
Author: Mattias Andrée <maandree_AT_kth.se>
AuthorDate: Fri Jul 14 00:32:31 2017 +0200
Commit: Mattias Andrée <maandree_AT_kth.se>
CommitDate: Fri Jul 14 00:32:31 2017 +0200

    Add blind-mosaic-edges
    
    Signed-off-by: Mattias Andrée <maandree_AT_kth.se>

diff --git a/Makefile b/Makefile
index 91000b1..fda6b87 100644
--- a/Makefile
+++ b/Makefile
_AT_@ -42,6 +42,7 @@ BIN =\
         blind-linear-gradient\
         blind-make-kernel\
         blind-mosaic\
+ blind-mosaic-edges\
         blind-next-frame\
         blind-norm\
         blind-quaternion-product\
diff --git a/man/blind-mosaic-edges.1 b/man/blind-mosaic-edges.1
index ec7f6bf..92b7edc 100644
--- a/man/blind-mosaic-edges.1
+++ b/man/blind-mosaic-edges.1
_AT_@ -20,13 +20,11 @@ At the upper and lower edges of the video,
 wrap around to the opposite edges.
 .SH REQUIREMENTS
 .B blind-mosaic-edges
-requires enough free memory to load one full row into
-memory. A row requires 32 bytes per pixel it contains.
-If
-.B -x
-is used, two full rows all be needed, and if
-.B -y
-is used, one full frame will be needed.
+requires enough free memory to load one full frame into
+memory and 1 bit per pixel on a frame. A frame requires
+32 bytes per pixel it contains.
+.B blind-mosaic-edges
+is optimised for simplicity rather the memory usage.
 .SH SEE ALSO
 .BR blind (7),
 .BR blind-hexagon-tessellation (1),
diff --git a/src/blind-mosaic-edges.c b/src/blind-mosaic-edges.c
new file mode 100644
index 0000000..2e08078
--- /dev/null
+++ b/src/blind-mosaic-edges.c
_AT_@ -0,0 +1,114 @@
+/* See LICENSE file for copyright and license details. */
+#include "common.h"
+
+USAGE("[-xy]")
+
+int
+main(int argc, char *argv[])
+{
+ int tiled_x = 0;
+ int tiled_y = 0;
+ struct stream stream;
+ void *colours[2];
+ char *buf;
+ char *edges;
+ char *here;
+ size_t i, n, x, y;
+ int v;
+
+ ARGBEGIN {
+ case 'x':
+ tiled_x = 1;
+ break;
+ case 'y':
+ tiled_y = 1;
+ break;
+ default:
+ usage();
+ } ARGEND;
+
+ if (argc)
+ usage();
+
+ eopen_stream(&stream, NULL);
+ echeck_dimensions(&stream, WIDTH | HEIGHT, NULL);
+
+ n = stream.width * stream.height;
+ buf = emalloc(stream.frame_size);
+ edges = emalloc((n + 7) / 8);
+
+ colours[0] = alloca(stream.pixel_size);
+ colours[1] = alloca(stream.pixel_size);
+ memset(colours[0], 0, stream.pixel_size);
+
+ if (!strcmp(stream.pixfmt, "xyza")) {
+ ((double *)(colours[1]))[0] = (double)1;
+ ((double *)(colours[1]))[1] = (double)1;
+ ((double *)(colours[1]))[2] = (double)1;
+ ((double *)(colours[1]))[3] = (double)1;
+ } else if (!strcmp(stream.pixfmt, "xyza f")) {
+ ((float *)(colours[1]))[0] = (float)1;
+ ((float *)(colours[1]))[1] = (float)1;
+ ((float *)(colours[1]))[2] = (float)1;
+ ((float *)(colours[1]))[3] = (float)1;
+ } else {
+ eprintf("pixel format %s is not supported, try xyza\n", stream.pixfmt);
+ }
+
+ fprint_stream_head(stdout, &stream);
+ efflush(stdout, "<stdout>");
+
+ while (eread_frame(&stream, buf)) {
+ memset(edges, 0, (n + 7) / 8);
+ for (i = 0; i < n; i++) {
+ here = buf + i * stream.pixel_size;
+ x = i % stream.width;
+ y = i / stream.width;
+
+ if (x != stream.width - 1 &&
+ memcmp(here + stream.pixel_size, here, stream.pixel_size))
+ goto at_edge;
+
+ if (tiled_x && x == stream.width - 1 &&
+ memcmp(here + stream.pixel_size - stream.row_size, here, stream.pixel_size))
+ goto at_edge;
+
+ if (x &&
+ memcmp(here - stream.pixel_size, here, stream.pixel_size))
+ goto at_edge;
+
+ if (tiled_x && !x &&
+ memcmp(here + stream.row_size - stream.pixel_size, here, stream.pixel_size))
+ goto at_edge;
+
+ if (y != stream.height - 1 &&
+ memcmp(here + stream.row_size, here, stream.pixel_size))
+ goto at_edge;
+
+ if (tiled_y && y == stream.height - 1 &&
+ memcmp(here + stream.row_size - stream.frame_size, here, stream.pixel_size))
+ goto at_edge;
+
+ if (y &&
+ memcmp(here - stream.row_size, here, stream.pixel_size))
+ goto at_edge;
+
+ if (tiled_y && !y &&
+ memcmp(here + stream.frame_size - stream.row_size, here, stream.pixel_size))
+ goto at_edge;
+
+ continue;
+ at_edge:
+ edges[i >> 3] |= 1 << (i & 7);
+ }
+ for (i = 0; i < n; i++) {
+ v = (edges[i >> 3] >> (i & 7)) & 1;
+ memcpy(buf + i * stream.pixel_size, colours[v], stream.pixel_size);
+ }
+ ewriteall(STDOUT_FILENO, buf, stream.frame_size, "<stdout>");
+ }
+
+ free(buf);
+ free(edges);
+ return 0;
+}
Received on Fri Jul 14 2017 - 00:32:54 CEST

This archive was generated by hypermail 2.3.0 : Fri Jul 14 2017 - 00:36:57 CEST