blind

suckless command-line video editing utility
git clone git://git.suckless.org/blind
Log | Files | Refs | README | LICENSE

commit 687e7aa9abf91f1bade59213a8b53f9bb4ec4186
parent c22007cc4be9b731d97006b983538388c4b36033
Author: Mattias Andrée <maandree@kth.se>
Date:   Wed, 10 May 2017 22:52:21 +0200

Fix errors from the latest commits

Signed-off-by: Mattias Andrée <maandree@kth.se>

Diffstat:
Msrc/blind-cut.c | 2+-
Msrc/blind-transpose.c | 8+++++---
Msrc/stream.c | 7++++---
3 files changed, 10 insertions(+), 7 deletions(-)

diff --git 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 @@ -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 @@ -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); } } }