aboutsummaryrefslogtreecommitdiffstats
path: root/src/blind-radial-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-radial-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 'src/blind-radial-gradient.c')
-rw-r--r--src/blind-radial-gradient.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/src/blind-radial-gradient.c b/src/blind-radial-gradient.c
index e3483d3..a97e474 100644
--- a/src/blind-radial-gradient.c
+++ b/src/blind-radial-gradient.c
@@ -33,12 +33,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 > 3 || stream.height > 3 ||
stream.width * stream.height < 2 ||
@@ -64,7 +59,7 @@ PROCESS(struct stream *stream)
pixel_t buf[BUFSIZ / sizeof(pixel_t)];
TYPE *params, x1, y1, x2, y2, norm, rd = 1, pe = 2, re = 2, e = 0.5;
TYPE x, y, p, r, rx, ry;
- size_t ix, iy, ptr = 0;
+ size_t i, ix, iy, ptr = 0;
for (;;) {
while (stream->ptr < stream->frame_size) {
if (!eread_stream(stream, stream->frame_size - stream->ptr)) {
@@ -97,7 +92,8 @@ PROCESS(struct stream *stream)
for (ix = 0; ix < width; ix++) {
x = (TYPE)ix - x1;
x = sqrt(x * x + y) / norm;
- 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;
@@ -116,7 +112,8 @@ PROCESS(struct stream *stream)
p = pow(abs(p / norm), pe);
r = pow(abs(r / norm), re);
x = pow(p + r, e);
- 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;