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-compress.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-compress.c')
| -rw-r--r-- | src/blind-compress.c | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/src/blind-compress.c b/src/blind-compress.c index 7669227..375055d 100644 --- a/src/blind-compress.c +++ b/src/blind-compress.c @@ -2,9 +2,6 @@ #include "stream.h" #include "util.h" -#include <string.h> -#include <unistd.h> - USAGE("") static size_t @@ -33,7 +30,7 @@ main(int argc, char *argv[]) { struct stream stream; char *buf[2]; - size_t n, parts, part, off; + size_t parts, part, off; int i; size_t *cmp = NULL; size_t cmpsize = 0; @@ -41,16 +38,15 @@ main(int argc, char *argv[]) UNOFLAGS(argc); eopen_stream(&stream, NULL); + echeck_dimensions(&stream, WIDTH | HEIGHT, NULL); fprint_stream_head(stdout, &stream); efflush(stdout, "<stdout>"); - echeck_frame_size(stream.width, stream.height, stream.pixel_size, 0, "<stdin>"); - n = stream.width * stream.height * stream.pixel_size; - buf[0] = emalloc(n); - buf[1] = ecalloc(1, n); + buf[0] = emalloc(stream.frame_size); + buf[1] = ecalloc(1, stream.frame_size); - for (i = 0; eread_frame(&stream, buf[i], n); i ^= 1) { - parts = compare(buf[i], buf[i ^ 1], n, &cmp, &cmpsize); + for (i = 0; eread_frame(&stream, buf[i]); i ^= 1) { + parts = compare(buf[i], buf[i ^ 1], stream.frame_size, &cmp, &cmpsize); for (off = part = 0; part < parts; part += 2) { off += cmp[part]; ewriteall(STDOUT_FILENO, cmp + part, 2 * sizeof(size_t), "<stdout>"); |
