diff options
| author | Mattias Andrée <maandree@kth.se> | 2017-05-10 16:59:26 +0200 |
|---|---|---|
| committer | Mattias Andrée <maandree@kth.se> | 2017-05-10 16:59:26 +0200 |
| commit | 6b998b5ed066aeece1146fe245b35965319b3cbd (patch) | |
| tree | c963b48fbefafcec89a4e4af238869a1cb51148e /src/blind-flip.c | |
| parent | blind-flip is optimal (diff) | |
| download | blind-6b998b5ed066aeece1146fe245b35965319b3cbd.tar.gz blind-6b998b5ed066aeece1146fe245b35965319b3cbd.tar.bz2 blind-6b998b5ed066aeece1146fe245b35965319b3cbd.tar.xz | |
Cleaner code
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'src/blind-flip.c')
| -rw-r--r-- | src/blind-flip.c | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/src/blind-flip.c b/src/blind-flip.c index 71f30c4..e1b3b72 100644 --- a/src/blind-flip.c +++ b/src/blind-flip.c @@ -2,31 +2,27 @@ #include "stream.h" #include "util.h" -#include <string.h> -#include <unistd.h> - USAGE("") int main(int argc, char *argv[]) { struct stream stream; - size_t n, rown, ptr; + size_t ptr; char *buf; UNOFLAGS(argc); eopen_stream(&stream, NULL); + echeck_dimensions(&stream, WIDTH | HEIGHT, NULL); fprint_stream_head(stdout, &stream); efflush(stdout, "<stdout>"); + buf = emalloc(stream.frame_size); - echeck_frame_size(stream.width, stream.height, stream.pixel_size, 0, stream.file); - n = stream.height * (rown = stream.width * stream.pixel_size); - buf = emalloc(n); - - while (eread_frame(&stream, buf, n)) - for (ptr = n; ptr;) - ewriteall(STDOUT_FILENO, buf + (ptr -= rown), rown, "<stdout>"); + while (eread_frame(&stream, buf)) + for (ptr = stream.frame_size; ptr;) + ewriteall(STDOUT_FILENO, buf + (ptr -= stream.row_size), + stream.row_size, "<stdout>"); /* ewriteall is faster than writev(3) and vmsplice(3) */ free(buf); |
