blind

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

commit 1921219eb7606c0be7ad940380514555a933bde6
parent 06b8e2576f952e8f8b097ee906f662d2ac38e2e8
Author: Mattias Andrée <maandree@kth.se>
Date:   Wed,  3 May 2017 21:53:25 +0200

Minor rewrite of blind-single-colour.c

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

Diffstat:
Msrc/blind-single-colour.c | 22++++++----------------
1 file changed, 6 insertions(+), 16 deletions(-)

diff --git a/src/blind-single-colour.c b/src/blind-single-colour.c @@ -13,7 +13,7 @@ typedef double pixel_t[4]; int main(int argc, char *argv[]) { - struct stream stream; + struct stream stream = { .width = 0, .height = 0, .frames = 1 }; double X, Y, Z, alpha = 1; size_t x, y, n; pixel_t buf[BUFSIZ / 4]; @@ -21,10 +21,6 @@ main(int argc, char *argv[]) int inf = 0; char *arg; - stream.width = 0; - stream.height = 0; - stream.frames = 1; - ARGBEGIN { case 'f': arg = UARGF(); @@ -71,18 +67,12 @@ main(int argc, char *argv[]) buf[x][2] = Z; buf[x][3] = alpha; } - while (inf || stream.frames--) { - for (y = stream.height; y--;) { - for (x = stream.width; x;) { - x -= n = MIN(ELEMENTSOF(buf), x); - for (n *= sizeof(*buf); n; n -= (size_t)r) { - r = write(STDOUT_FILENO, buf, n); - if (r < 0) + while (inf || stream.frames--) + for (y = stream.height; y--;) + for (x = stream.width * sizeof(*buf); x;) + for (x -= n = MIN(sizeof(buf), x); n; n -= (size_t)r) + if ((r = write(STDOUT_FILENO, buf, n)) < 0) eprintf("write <stdout>:"); - } - } - } - } return 0; }