diff options
| author | Mattias Andrée <maandree@kth.se> | 2017-07-16 15:29:43 +0200 |
|---|---|---|
| committer | Mattias Andrée <maandree@kth.se> | 2017-07-16 15:29:43 +0200 |
| commit | d05d162cb81664f292834fa5d48d623d2b6147a7 (patch) | |
| tree | 9d4252fcdfa2210613188d5c965514cfab6a8ec2 /src/blind-from-portable.c | |
| parent | Use #include instead of #define (diff) | |
| download | blind-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-from-portable.c')
| -rw-r--r-- | src/blind-from-portable.c | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/src/blind-from-portable.c b/src/blind-from-portable.c index 6e24100..c51e2db 100644 --- a/src/blind-from-portable.c +++ b/src/blind-from-portable.c @@ -3,6 +3,8 @@ USAGE("[-s]") +static int strict = 1; + #define CONV(ITYPE, SITYPE, OTYPE, EXPONENT, HA2EXPONENT, FRACTION)\ do {\ static int cache_i = 0;\ @@ -74,15 +76,14 @@ USAGE("[-s]") static double conv_double(uint64_t portable) {CONV(uint64_t, int64_t, double, 11, 1023, 52);} static float conv_float (uint32_t portable) {CONV(uint32_t, int32_t, float, 8, 127, 23);} -static void process_lf(struct stream *stream, int strict) {PROCESS(uint64_t, double, 64);} -static void process_f (struct stream *stream, int strict) {PROCESS(uint32_t, float, 32);} +static void process_lf(struct stream *stream) {PROCESS(uint64_t, double, 64);} +static void process_f (struct stream *stream) {PROCESS(uint32_t, float, 32);} int main(int argc, char *argv[]) { struct stream stream; - int strict = 1; - void (*process)(struct stream *stream, int strict); + void (*process)(struct stream *stream); ARGBEGIN { case 's': @@ -91,20 +92,16 @@ main(int argc, char *argv[]) default: usage(); } ARGEND; + if (argc) usage(); eopen_stream(&stream, NULL); - if (stream.encoding == DOUBLE) - process = process_lf; - else if (stream.encoding == FLOAT) - process = process_f; - else - eprintf("pixel format %s is not supported\n", stream.pixfmt); + SELECT_PROCESS_FUNCTION(&stream); fprint_stream_head(stdout, &stream); efflush(stdout, "<stdout>"); - process(&stream, strict); + process(&stream); return 0; } |
