diff options
| author | Mattias Andrée <maandree@kth.se> | 2017-07-15 17:08:02 +0200 |
|---|---|---|
| committer | Mattias Andrée <maandree@kth.se> | 2017-07-15 17:08:02 +0200 |
| commit | 3569a10c97d41913dbf7cf3114cb4d2d5f17dc7f (patch) | |
| tree | e8b08fe9b0cdc208f66582309377bc3c1817fe1f /src/blind-to-text.c | |
| parent | Generate USING_BINARY{32,64} (diff) | |
| download | blind-3569a10c97d41913dbf7cf3114cb4d2d5f17dc7f.tar.gz blind-3569a10c97d41913dbf7cf3114cb4d2d5f17dc7f.tar.bz2 blind-3569a10c97d41913dbf7cf3114cb4d2d5f17dc7f.tar.xz | |
Some improvements and fixes
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'src/blind-to-text.c')
| -rw-r--r-- | src/blind-to-text.c | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/src/blind-to-text.c b/src/blind-to-text.c index c8cf76e..7cee676 100644 --- a/src/blind-to-text.c +++ b/src/blind-to-text.c @@ -8,16 +8,13 @@ USAGE("") #define PROCESS(TYPE, CAST, FMT)\ do {\ size_t i;\ - for (i = 0; i < n; i += stream->pixel_size)\ - printf("%"FMT" %"FMT" %"FMT" %"FMT"\n",\ - (CAST)(((TYPE *)(stream->buf + i))[0]),\ - (CAST)(((TYPE *)(stream->buf + i))[1]),\ - (CAST)(((TYPE *)(stream->buf + i))[2]),\ - (CAST)(((TYPE *)(stream->buf + i))[3]));\ + TYPE *p = (TYPE *)(stream->buf);\ + for (i = 0, n /= stream->chan_size; i < n; i++)\ + printf("%"FMT"%c", (CAST)(p[i]), (i + 1) % stream->n_chan ? ' ' : '\n');\ } while (0) -static void process_xyza (struct stream *stream, size_t n) {PROCESS(double, double, ".25lf");} -static void process_xyzaf(struct stream *stream, size_t n) {PROCESS(float, double, ".25lf");} +static void process_lf(struct stream *stream, size_t n) {PROCESS(double, double, ".25lf");} +static void process_f (struct stream *stream, size_t n) {PROCESS(float, double, ".25lf");} int main(int argc, char *argv[]) @@ -29,10 +26,10 @@ main(int argc, char *argv[]) eopen_stream(&stream, NULL); - if (!strcmp(stream.pixfmt, "xyza")) - process = process_xyza; - else if (!strcmp(stream.pixfmt, "xyza f")) - process = process_xyzaf; + if (stream.encoding == DOUBLE) + process = process_lf; + else if (stream.encoding == FLOAT) + process = process_f; else eprintf("pixel format %s is not supported, try xyza\n", stream.pixfmt); |
