aboutsummaryrefslogtreecommitdiffstats
path: root/src/blind-linear-gradient.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2017-07-16 15:29:43 +0200
committerMattias Andrée <maandree@kth.se>2017-07-16 15:29:43 +0200
commitd05d162cb81664f292834fa5d48d623d2b6147a7 (patch)
tree9d4252fcdfa2210613188d5c965514cfab6a8ec2 /src/blind-linear-gradient.c
parentUse #include instead of #define (diff)
downloadblind-d05d162cb81664f292834fa5d48d623d2b6147a7.tar.gz
blind-d05d162cb81664f292834fa5d48d623d2b6147a7.tar.bz2
blind-d05d162cb81664f292834fa5d48d623d2b6147a7.tar.xz
Misc code improvements
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r--src/blind-linear-gradient.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/src/blind-linear-gradient.c b/src/blind-linear-gradient.c
index 57cde3c..55711ac 100644
--- a/src/blind-linear-gradient.c
+++ b/src/blind-linear-gradient.c
@@ -36,12 +36,7 @@ main(int argc, char *argv[])
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);
+ SELECT_PROCESS_FUNCTION(&stream);
if (stream.width > 2 || stream.height > 2 || stream.width * stream.height != 2)
eprintf("<stdin>: each frame must contain exactly 2 pixels\n");
@@ -63,7 +58,7 @@ PROCESS(struct stream *stream)
pixel_t buf[BUFSIZ / sizeof(pixel_t)];
TYPE *params, x1, y1, x2, y2, norm2;
TYPE x, y;
- size_t ix, iy, ptr = 0;
+ size_t i, ix, iy, ptr = 0;
for (;;) {
while (stream->ptr < stream->frame_size) {
@@ -91,7 +86,8 @@ PROCESS(struct stream *stream)
x = (x * x2 + y * y2) / norm2;
if (bilinear)
x = abs(x);
- buf[ptr][0] = buf[ptr][1] = buf[ptr][2] = buf[ptr][3] = x;
+ for (i = 0; i < stream->n_chan; i++)
+ buf[ptr][i] = x;
if (++ptr == ELEMENTSOF(buf)) {
ewriteall(STDOUT_FILENO, buf, sizeof(buf), "<stdout>");
ptr = 0;