diff options
| author | Mattias Andrée <maandree@kth.se> | 2017-05-10 22:52:21 +0200 |
|---|---|---|
| committer | Mattias Andrée <maandree@kth.se> | 2017-05-10 22:52:21 +0200 |
| commit | 687e7aa9abf91f1bade59213a8b53f9bb4ec4186 (patch) | |
| tree | 98fd798df79322f72d35b375f451d8edb5c143f3 /src | |
| parent | Fix warnings (diff) | |
| download | blind-687e7aa9abf91f1bade59213a8b53f9bb4ec4186.tar.gz blind-687e7aa9abf91f1bade59213a8b53f9bb4ec4186.tar.bz2 blind-687e7aa9abf91f1bade59213a8b53f9bb4ec4186.tar.xz | |
Fix errors from the latest commits
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'src')
| -rw-r--r-- | src/blind-cut.c | 2 | ||||
| -rw-r--r-- | src/blind-transpose.c | 8 | ||||
| -rw-r--r-- | src/stream.c | 7 |
3 files changed, 10 insertions, 7 deletions
diff --git a/src/blind-cut.c b/src/blind-cut.c index b21e83d..dde7a1c 100644 --- a/src/blind-cut.c +++ b/src/blind-cut.c @@ -39,7 +39,7 @@ main(int argc, char *argv[]) efflush(stdout, "<stdout>"); esend_frames(&stream, -1, start, NULL); - esend_frames(&stream, STDOUT_FILENO, start - end, "<stdout>"); + esend_frames(&stream, STDOUT_FILENO, stream.frames, "<stdout>"); close(stream.fd); return 0; diff --git a/src/blind-transpose.c b/src/blind-transpose.c index 750de02..3bbc6fb 100644 --- a/src/blind-transpose.c +++ b/src/blind-transpose.c @@ -4,11 +4,11 @@ USAGE("") -static size_t srcw, srch, srcwps, srchps, ps; +static size_t srcw, srch, srcwps, srchps, ps, n; #define PROCESS(TYPE)\ do {\ - size_t x, i, n = ps / sizeof(TYPE);\ + size_t x, i;\ char *src, *img;\ for (x = 0; x < srchps; x += ps) {\ img = row + x;\ @@ -43,9 +43,11 @@ main(int argc, char *argv[]) buf = emalloc(stream.frame_size); image = emalloc(srchps); + ps = stream.pixel_size; process = ps % sizeof(long) ? process_char : process_long; + n = ps / (ps % sizeof(long) ? sizeof(char) : sizeof(long)); while (eread_frame(&stream, buf)) { - for (y = 0; y < srcwps; y += ps) { + for (y = 0; y < srcwps; y += stream.pixel_size) { process(image, buf + y); ewriteall(STDOUT_FILENO, image, srchps, "<stdout>"); } diff --git a/src/stream.c b/src/stream.c index 274ed25..7920ff7 100644 --- a/src/stream.c +++ b/src/stream.c @@ -279,17 +279,18 @@ enread_segment(int status, struct stream *stream, void *buf, size_t n) size_t ensend_frames(int status, struct stream *stream, int outfd, size_t frames, const char *outfname) { - size_t h, w, p; + size_t h, w, p, n; size_t ret = 0; for (ret = 0; ret < frames; ret++) { for (p = stream->pixel_size; p; p--) { for (h = stream->height; h; h--) { - for (w = stream->width; w; w -= stream->ptr, stream->ptr = 0) { + for (w = stream->width; w; w -= n, stream->ptr -= n) { if (!stream->ptr && !enread_stream(status, stream, w)) goto done; + n = MIN(stream->ptr, w); if (outfd >= 0) - enwriteall(status, outfd, stream->buf, stream->ptr, outfname); + enwriteall(status, outfd, stream->buf, n, outfname); } } } |
