(wrong string) ée

From: <git_AT_suckless.org>
Date: Mon, 3 Jul 2017 14:06:19 +0200 (CEST)

commit b3042abffb9f4e4c7edd16934af99716bcdc2901
Author: Mattias Andrée <maandree_AT_kth.se>
AuthorDate: Sun Jul 2 17:18:20 2017 +0200
Commit: Mattias Andrée <maandree_AT_kth.se>
CommitDate: Sun Jul 2 17:30:02 2017 +0200

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

diff --git a/Makefile b/Makefile
index 555345e..098658d 100644
--- a/Makefile
+++ b/Makefile
_AT_@ -31,6 +31,7 @@ BIN =\
         blind-invert-luma\
         blind-make-kernel\
         blind-next-frame\
+ blind-norm\
         blind-quaternion-product\
         blind-premultiply\
         blind-read-head\
diff --git a/README b/README
index 1d8dae0..f282e2d 100644
--- a/README
+++ b/README
_AT_@ -93,6 +93,9 @@ UTILITIES
        blind-next-frame(1)
               Extracts the next frame from a video
 
+ blind-norm(1)
+ Calculate the norm of colours in a video
+
        blind-premultiply(1)
               Premultiply the alpha channel of a video
 
diff --git a/TODO b/TODO
index 8b299d3..991e9ad 100644
--- a/TODO
+++ b/TODO
_AT_@ -65,6 +65,7 @@ unsigned char (xyza 8) could be added as another format, it's probably good for
 
 
 UNTESTED:
+ blind-norm
         blind-dot-product
         blind-cross-product
         blind-quaternion-product
diff --git a/man/blind-arithm.1 b/man/blind-arithm.1
index 2e93364..5b559ef 100644
--- a/man/blind-arithm.1
+++ b/man/blind-arithm.1
_AT_@ -77,6 +77,7 @@ Do not modify the Y channel (the second channel).
 Do not modify the Z channel (the third channel).
 .SH SEE ALSO
 .BR blind (7),
+.BR blind-norm (1),
 .BR blind-dot-product (1),
 .BR blind-cross-product (1),
 .BR blind-quaternion-product (1),
diff --git a/man/blind-cross-product.1 b/man/blind-cross-product.1
index ce8074e..d1daad8 100644
--- a/man/blind-cross-product.1
+++ b/man/blind-cross-product.1
_AT_@ -24,6 +24,7 @@ is ignored but may be partially read.
 .SH SEE ALSO
 .BR blind (7),
 .BR blind-arithm (1),
+.BR blind-norm (1),
 .BR blind-dot-product (1),
 .BR blind-quaternion-product (1),
 .BR blind-vector-projection (1)
diff --git a/man/blind-dot-product.1 b/man/blind-dot-product.1
index 6547d65..9a1b6ed 100644
--- a/man/blind-dot-product.1
+++ b/man/blind-dot-product.1
_AT_@ -23,6 +23,7 @@ is ignored but may be partially read.
 .SH SEE ALSO
 .BR blind (7),
 .BR blind-arithm (1),
+.BR blind-norm (1),
 .BR blind-cross-product (1),
 .BR blind-quaternion-product (1),
 .BR blind-vector-projection (1)
diff --git a/man/blind-norm.1 b/man/blind-norm.1
new file mode 100644
index 0000000..370016d
--- /dev/null
+++ b/man/blind-norm.1
_AT_@ -0,0 +1,34 @@
+.TH BLIND-NORM 1 blind
+.SH NAME
+blind-norm - Calculate the norm of colours in a video
+.SH SYNOPSIS
+.B blind-norm
+[-axyz]
+.SH DESCRIPTION
+.B blind-norm
+reads a video from stdin, calculates the norm the
+colours of each pixel and prints the resulting
+video to stdout.
+.SH OPTIONS
+.TP
+.B -a
+Do not modify the alpha channel (the fourth channel).
+.TP
+.B -x
+Do not modify the X channel (the first channel).
+.TP
+.B -y
+Do not modify the Y channel (the second channel).
+.TP
+.B -z
+Do not modify the Z channel (the third channel).
+.SH SEE ALSO
+.BR blind (7),
+.BR blind-arithm (1),
+.BR blind-dot-product (1),
+.BR blind-cross-product (1),
+.BR blind-quaternion-product (1),
+.BR blind-vector-projection (1)
+.SH AUTHORS
+Mattias Andrée
+.RI < maandree_AT_kth.se >
diff --git a/man/blind-quaternion-product.1 b/man/blind-quaternion-product.1
index 4c0f508..ed2e563 100644
--- a/man/blind-quaternion-product.1
+++ b/man/blind-quaternion-product.1
_AT_@ -28,6 +28,7 @@ is ignored but may be partially read.
 .SH SEE ALSO
 .BR blind (7),
 .BR blind-arithm (1),
+.BR blind-norm (1),
 .BR blind-cross-product (1),
 .BR blind-quaternion-product (1),
 .BR blind-vector-projection (1)
diff --git a/man/blind-vector-projection.1 b/man/blind-vector-projection.1
index ee6b053..7e71ee4 100644
--- a/man/blind-vector-projection.1
+++ b/man/blind-vector-projection.1
_AT_@ -33,6 +33,7 @@ The scalar projection is stored in all four channels.
 .SH SEE ALSO
 .BR blind (7),
 .BR blind-arithm (1),
+.BR blind-norm (1),
 .BR blind-dot-product (1),
 .BR blind-cross-product (1),
 .BR blind-quaternion-product (1)
diff --git a/man/blind.7 b/man/blind.7
index 3a47864..48dc48a 100644
--- a/man/blind.7
+++ b/man/blind.7
_AT_@ -106,6 +106,9 @@ Create a custom convolution matrix
 .BR blind-next-frame (1)
 Extracts the next frame from a video
 .TP
+.BR blind-norm (1)
+Calculate the norm of colours in a video
+.TP
 .BR blind-premultiply (1)
 Premultiply the alpha channel of a video
 .TP
diff --git a/src/blind-norm.c b/src/blind-norm.c
new file mode 100644
index 0000000..c4d04a0
--- /dev/null
+++ b/src/blind-norm.c
_AT_@ -0,0 +1,86 @@
+/* See LICENSE file for copyright and license details. */
+#include "common.h"
+
+USAGE("[-axyz]")
+
+static int skip_a = 0;
+static int skip_x = 0;
+static int skip_y = 0;
+static int skip_z = 0;
+
+
+#define PROCESS(TYPE, SUFFIX)\
+ static void\
+ process_##SUFFIX(struct stream *stream)\
+ {\
+ size_t i, n;\
+ TYPE x, y, z, a, norm;\
+ do {\
+ n = stream->ptr / stream->pixel_size;\
+ for (i = 0; i < n; i++) {\
+ x = ((TYPE *)(stream->buf))[4 * i + 0];\
+ y = ((TYPE *)(stream->buf))[4 * i + 1];\
+ z = ((TYPE *)(stream->buf))[4 * i + 2];\
+ a = ((TYPE *)(stream->buf))[4 * i + 3];\
+ norm = sqrt(x * x + y * y + z * z + a * a);\
+ if (!skip_x)\
+ ((TYPE *)(stream->buf))[4 * i + 0] = norm;\
+ if (!skip_y)\
+ ((TYPE *)(stream->buf))[4 * i + 1] = norm;\
+ if (!skip_z)\
+ ((TYPE *)(stream->buf))[4 * i + 2] = norm;\
+ if (!skip_a)\
+ ((TYPE *)(stream->buf))[4 * i + 3] = norm;\
+ }\
+ n *= stream->pixel_size;\
+ ewriteall(STDOUT_FILENO, stream->buf, n, "<stdout>");\
+ memmove(stream->buf, stream->buf + n, stream->ptr -= n);\
+ } while (eread_stream(stream, SIZE_MAX));\
+ if (stream->ptr)\
+ eprintf("%s: incomplete frame\n", stream->file);\
+ }
+
+PROCESS(double, lf)
+PROCESS(float, f)
+
+
+int
+main(int argc, char *argv[])
+{
+ struct stream stream;
+ void (*process)(struct stream *stream);
+
+ ARGBEGIN {
+ case 'a':
+ skip_a = 1;
+ break;
+ case 'x':
+ skip_x = 1;
+ break;
+ case 'y':
+ skip_y = 1;
+ break;
+ case 'z':
+ skip_z = 1;
+ break;
+ default:
+ usage();
+ } ARGEND;
+
+ if (argc)
+ usage();
+
+ eopen_stream(&stream, NULL);
+
+ if (!strcmp(stream.pixfmt, "xyza"))
+ process = process_lf;
+ else if (!strcmp(stream.pixfmt, "xyza f"))
+ process = process_f;
+ else
+ eprintf("pixel format %s is not supported, try xyza\n", stream.pixfmt);
+
+ fprint_stream_head(stdout, &stream);
+ efflush(stdout, "<stdout>");
+ process(&stream);
+ return 0;
+}
Received on Mon Jul 03 2017 - 14:06:19 CEST

This archive was generated by hypermail 2.3.0 : Mon Jul 03 2017 - 14:13:04 CEST