aboutsummaryrefslogtreecommitdiffstats
path: root/src/blind-extract-alpha.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/blind-extract-alpha.c')
-rw-r--r--src/blind-extract-alpha.c60
1 files changed, 32 insertions, 28 deletions
diff --git a/src/blind-extract-alpha.c b/src/blind-extract-alpha.c
index f65042a..6b94c19 100644
--- a/src/blind-extract-alpha.c
+++ b/src/blind-extract-alpha.c
@@ -1,36 +1,11 @@
/* See LICENSE file for copyright and license details. */
+#ifndef TYPE
#include "common.h"
USAGE("colour-file")
-#define PROCESS(TYPE, SUFFIX)\
- static void\
- process_##SUFFIX(struct stream *stream, int fd, const char *fname)\
- {\
- char buf[sizeof(stream->buf)];\
- size_t i, j, n;\
- TYPE a, *p, *b;\
- do {\
- n = stream->ptr / stream->pixel_size;\
- p = (TYPE *)(stream->buf) + stream->n_chan - 1;\
- b = (TYPE *)buf;\
- for (i = 0; i < n; i++, p += stream->n_chan) {\
- a = *p, *p = 1;\
- for (j = stream->n_chan - 1; j--;)\
- *b++ = a;\
- *b++ = 1;\
- }\
- n *= stream->pixel_size;\
- ewriteall(fd, stream->buf, n, fname);\
- ewriteall(STDOUT_FILENO, 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-extract-alpha.c"
+#include "define-functions.h"
int
main(int argc, char *argv[])
@@ -59,3 +34,32 @@ main(int argc, char *argv[])
process(&stream, fd, argv[0]);
return 0;
}
+
+#else
+
+static void
+PROCESS(struct stream *stream, int fd, const char *fname)
+{
+ char buf[sizeof(stream->buf)];
+ size_t i, j, n;
+ TYPE a, *p, *b;
+ do {
+ n = stream->ptr / stream->pixel_size;
+ p = (TYPE *)(stream->buf) + stream->n_chan - 1;
+ b = (TYPE *)buf;
+ for (i = 0; i < n; i++, p += stream->n_chan) {
+ a = *p, *p = 1;
+ for (j = stream->n_chan - 1; j--;)
+ *b++ = a;
+ *b++ = 1;
+ }
+ n *= stream->pixel_size;
+ ewriteall(fd, stream->buf, n, fname);
+ ewriteall(STDOUT_FILENO, 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