From dac6950d9e556d5521ad7913d27a6cf83e2a90a1 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sun, 9 Apr 2017 23:46:17 +0200 Subject: Clean up MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/blind-to-image.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) (limited to 'src/blind-to-image.c') diff --git a/src/blind-to-image.c b/src/blind-to-image.c index 48cf625..7ea1586 100644 --- a/src/blind-to-image.c +++ b/src/blind-to-image.c @@ -14,6 +14,8 @@ USAGE("[-d depth | -f]") static int luma_warning_triggered = 0; static int gamut_warning_triggered = 0; static int alpha_warning_triggered = 0; +static unsigned long long int max; +static int bytes; static void write_pixel(double R, double G, double B, double A, int bytes, unsigned long long int max) @@ -57,7 +59,7 @@ write_pixel(double R, double G, double B, double A, int bytes, unsigned long lon } static void -process_xyza(struct stream *stream, size_t n, int bytes, unsigned long long int max) +process_xyza(struct stream *stream, size_t n) { size_t i; double X, Y, Z, A, R, G, B; @@ -84,10 +86,8 @@ int main(int argc, char *argv[]) { struct stream stream; - int depth = 16, bytes, farbfeld = 0; - unsigned long long int max; - size_t n; - void (*process)(struct stream *stream, size_t n, int bytes, unsigned long long int max); + int depth = 16, farbfeld = 0; + void (*process)(struct stream *stream, size_t n); ARGBEGIN { case 'd': @@ -103,9 +103,7 @@ main(int argc, char *argv[]) if (argc || (farbfeld && depth != 16)) usage(); - stream.fd = STDIN_FILENO; - stream.file = ""; - einit_stream(&stream); + eopen_stream(&stream, NULL); max = 1ULL << (depth - 1); max |= max - 1; @@ -140,11 +138,6 @@ main(int argc, char *argv[]) } efflush(stdout, ""); - do { - n = stream.ptr - (stream.ptr % stream.pixel_size); - process(&stream, n, bytes, max); - memmove(stream.buf, stream.buf + n, stream.ptr -= n); - } while (eread_stream(&stream, SIZE_MAX)); - + process_stream(&stream, process); return 0; } -- cgit v1.2.3-70-g09d2