diff options
| author | Mattias Andrée <maandree@kth.se> | 2017-07-16 00:59:42 +0200 |
|---|---|---|
| committer | Mattias Andrée <maandree@kth.se> | 2017-07-16 00:59:42 +0200 |
| commit | c216ac3049102422a41ba2c9476b0dbf4f3e4034 (patch) | |
| tree | 809793e1f01fafcb67422f654b6e9dbcab897660 /src/blind-premultiply.c | |
| parent | Install the scripts (diff) | |
| download | blind-c216ac3049102422a41ba2c9476b0dbf4f3e4034.tar.gz blind-c216ac3049102422a41ba2c9476b0dbf4f3e4034.tar.bz2 blind-c216ac3049102422a41ba2c9476b0dbf4f3e4034.tar.xz | |
Use #include instead of #define
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'src/blind-premultiply.c')
| -rw-r--r-- | src/blind-premultiply.c | 58 |
1 files changed, 31 insertions, 27 deletions
diff --git a/src/blind-premultiply.c b/src/blind-premultiply.c index 3d9065a..5d46c06 100644 --- a/src/blind-premultiply.c +++ b/src/blind-premultiply.c @@ -1,4 +1,5 @@ /* See LICENSE file for copyright and license details. */ +#ifndef TYPE #include "common.h" USAGE("[-xyz]") @@ -7,33 +8,8 @@ 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 a;\ - do {\ - n = stream->ptr / stream->pixel_size;\ - for (i = 0; i < n; i++) {\ - a = ((TYPE *)(stream->buf))[4 * i + 3];\ - if (!skip_x)\ - ((TYPE *)(stream->buf))[4 * i + 0] *= a;\ - if (!skip_y)\ - ((TYPE *)(stream->buf))[4 * i + 1] *= a;\ - if (!skip_z)\ - ((TYPE *)(stream->buf))[4 * i + 2] *= a;\ - }\ - 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) +#define FILE "blind-premultiply.c" +#include "define-functions.h" int main(int argc, char *argv[]) @@ -72,3 +48,31 @@ main(int argc, char *argv[]) process(&stream); return 0; } + +#else + +static void +PROCESS(struct stream *stream) +{ + size_t i, n; + TYPE a; + do { + n = stream->ptr / stream->pixel_size; + for (i = 0; i < n; i++) { + a = ((TYPE *)(stream->buf))[4 * i + 3]; + if (!skip_x) + ((TYPE *)(stream->buf))[4 * i + 0] *= a; + if (!skip_y) + ((TYPE *)(stream->buf))[4 * i + 1] *= a; + if (!skip_z) + ((TYPE *)(stream->buf))[4 * i + 2] *= a; + } + 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); +} + +#endif |
