blind-split-chan: add -c - blind - suckless command-line video editing utility | |
git clone git://git.suckless.org/blind | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit f70ffc7f6e6331a56be4a52882c432133e40bd01 | |
parent 509cd22048a070317e43a53c5c733f61d01e20a4 | |
Author: Mattias Andrée <[email protected]> | |
Date: Fri, 21 Jul 2017 17:15:09 +0200 | |
blind-split-chan: add -c | |
Signed-off-by: Mattias Andrée <[email protected]> | |
Diffstat: | |
M man/blind-split-chans.1 | 10 ++++++++++ | |
M src/blind-split-chans.c | 52 +++++++++++++++++++++++------… | |
2 files changed, 49 insertions(+), 13 deletions(-) | |
--- | |
diff --git a/man/blind-split-chans.1 b/man/blind-split-chans.1 | |
@@ -3,6 +3,7 @@ | |
blind-split-chans - Split colour channels into separate videos | |
.SH SYNOPSIS | |
.B blind-split-chans | |
+[-c] | |
.I X-file | |
.I Y-file | |
.I Z-file | |
@@ -37,6 +38,15 @@ in | |
.IR Y-file , | |
and | |
.IR Z-file . | |
+.SH OPTIONS | |
+.TP | |
+.B -c | |
+Set the values to zero in all channels | |
+except for channels matching their file. If | |
+.I alpha-file | |
+is omitted, the alpha values are still | |
+stored in the alpha channel of the other | |
+files. | |
.SH SEE ALSO | |
.BR blind (7), | |
.BR blind-arithm (1), | |
diff --git a/src/blind-split-chans.c b/src/blind-split-chans.c | |
@@ -1,17 +1,27 @@ | |
/* See LICENSE file for copyright and license details. */ | |
#include "common.h" | |
-USAGE("X-file Y-file Z-file [alpha-file]") | |
+USAGE("[-c] X-file Y-file Z-file [alpha-file]") | |
int | |
main(int argc, char *argv[]) | |
{ | |
struct stream stream; | |
- char xbuf[BUFSIZ], ybuf[BUFSIZ], zbuf[BUFSIZ], abuf[BUFSIZ]; | |
+ char xbuf[sizeof(stream.buf)], ybuf[sizeof(xbuf)], zbuf[sizeof(xbuf)],… | |
int xfd, yfd, zfd, afd = -1; | |
- size_t i, n, ptr; | |
+ size_t i, n, ptr, cs; | |
+ int all_channels = 1; | |
- UNOFLAGS(argc != 3 && argc != 4); | |
+ ARGBEGIN { | |
+ case 'c': | |
+ all_channels = 0; | |
+ break; | |
+ default: | |
+ usage(); | |
+ } ARGEND; | |
+ | |
+ if (argc != 3 && argc != 4) | |
+ usage(); | |
eopen_stream(&stream, NULL); | |
@@ -30,20 +40,36 @@ main(int argc, char *argv[]) | |
if (afd >= 0 && DPRINTF_HEAD(afd, stream.frames, stream.width, stream.… | |
eprintf("dprintf %s:", argv[3]); | |
- n = (stream.n_chan - (afd < 0)) * stream.chan_size; | |
+ if (!all_channels) { | |
+ memset(xbuf, 0, sizeof(xbuf)); | |
+ memset(ybuf, 0, sizeof(ybuf)); | |
+ memset(zbuf, 0, sizeof(zbuf)); | |
+ memset(abuf, 0, sizeof(abuf)); | |
+ } | |
+ | |
+ cs = stream.chan_size; | |
+ n = (stream.n_chan - (afd < 0)) * cs; | |
do { | |
for (ptr = 0; ptr + stream.pixel_size <= stream.ptr; ptr += st… | |
- for (i = 0; i < n; i += stream.chan_size) { | |
- memcpy(xbuf + ptr + i, stream.buf + ptr + 0 * … | |
- memcpy(ybuf + ptr + i, stream.buf + ptr + 1 * … | |
- memcpy(zbuf + ptr + i, stream.buf + ptr + 2 * … | |
+ if (all_channels) { | |
+ for (i = 0; i < n; i += cs) { | |
+ memcpy(xbuf + ptr + i, stream.buf + pt… | |
+ memcpy(ybuf + ptr + i, stream.buf + pt… | |
+ memcpy(zbuf + ptr + i, stream.buf + pt… | |
+ if (afd >= 0) | |
+ memcpy(abuf + ptr + i, stream.… | |
+ } | |
+ } else { | |
+ memcpy(xbuf + ptr + 0 * cs, stream.buf + ptr +… | |
+ memcpy(ybuf + ptr + 1 * cs, stream.buf + ptr +… | |
+ memcpy(zbuf + ptr + 2 * cs, stream.buf + ptr +… | |
if (afd >= 0) | |
- memcpy(abuf + ptr + i, stream.buf + pt… | |
+ memcpy(abuf + ptr + 3 * cs, stream.buf… | |
} | |
if (afd < 0) { | |
- memcpy(xbuf + ptr + n, stream.buf + ptr + 3 * … | |
- memcpy(ybuf + ptr + n, stream.buf + ptr + 3 * … | |
- memcpy(zbuf + ptr + n, stream.buf + ptr + 3 * … | |
+ memcpy(xbuf + ptr + n, stream.buf + ptr + 3 * … | |
+ memcpy(ybuf + ptr + n, stream.buf + ptr + 3 * … | |
+ memcpy(zbuf + ptr + n, stream.buf + ptr + 3 * … | |
} | |
} | |
ewriteall(xfd, xbuf, ptr, argv[0]); |