blind

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

commit eebc4d5fb9cf6d78cbdba7a5aa9be713ddf9959c
parent a79568e8ab6bd516bef02e87855c23526356f20a
Author: Mattias Andrée <maandree@kth.se>
Date:   Wed, 26 Jul 2017 18:01:15 +0200

blind{-make,}-kernel: apply identity kernel instead of null kernel to non-selected channels

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

Diffstat:
Mman/blind-kernel.1 | 16++++++++--------
Mman/blind-make-kernel.1 | 16++++++++--------
Msrc/blind-kernel.c | 25+++++++++++++------------
Msrc/blind-make-kernel.c | 25+++++++++++++------------
4 files changed, 42 insertions(+), 40 deletions(-)

diff --git a/man/blind-kernel.1 b/man/blind-kernel.1 @@ -169,20 +169,20 @@ or .SH OPTIONS .TP .B -a -Apply the values to the alpha channel, set the -values for all unselected channels to zero. +Apply the values to the alpha channel, apply an +identity kernel to all unselected channels. .TP .B -x -Apply the values to the X channel, set the values -for all unselected channels to zero. +Apply the values to the X channel, apply an +identity kernel to all unselected channels. .TP .B -y -Apply the values to the Y channel, set the values -for all unselected channels to zero. +Apply the values to the Y channel, apply an +identity kernel to all unselected channels. .TP .B -z -Apply the values to the Z channel, set the values -for all unselected channels to zero. +Apply the values to the Z channel, apply an +identity kernel to all unselected channels. .SH NOTES .B blind-make-kernel Create a single frame, to that it can be stored to diff --git a/man/blind-make-kernel.1 b/man/blind-make-kernel.1 @@ -42,8 +42,8 @@ is used to delimit cells. .SH OPTIONS .TP .B -a -Apply the values to the alpha channel, set the -values for all unselected channels to zero. +Apply the values to the alpha channel, apply an +identity kernel to all unselected channels. .TP .BR -d \ \fIdenominator\fP Divide the matrix by @@ -60,16 +60,16 @@ before .BR -d . .TP .B -x -Apply the values to the X channel, set the values -for all unselected channels to zero. +Apply the values to the X channel, apply an +identity kernel to all unselected channels. .TP .B -y -Apply the values to the Y channel, set the values -for all unselected channels to zero. +Apply the values to the Y channel, apply an +identity kernel to all unselected channels. .TP .B -z -Apply the values to the Z channel, set the values -for all unselected channels to zero. +Apply the values to the Z channel, apply an +identity kernel to all unselected channels. .SH NOTES .B blind-make-kernel Create a single frame, to that it can be stored to diff --git a/src/blind-kernel.c b/src/blind-kernel.c @@ -290,23 +290,23 @@ usage: int main(int argc, char *argv[]) { - int null_x = 1, null_y = 1, null_z = 1, null_a = 1; + int id_x = 1, id_y = 1, id_z = 1, id_a = 1; size_t rows, cols, y, x, n; const double *kernel, *kern; - double *buffer, *buf, *free_this; + double *buffer, *buf, *free_this, id_val; ARGBEGIN { case 'x': - null_x = 0; + id_x = 0; break; case 'y': - null_y = 0; + id_y = 0; break; case 'z': - null_z = 0; + id_z = 0; break; case 'a': - null_a = 0; + id_a = 0; break; default: usage(); @@ -315,8 +315,8 @@ main(int argc, char *argv[]) if (!argc) usage(); - if (null_x && null_y && null_z && null_a) - null_x = null_y = null_z = null_a = 0; + if (id_x && id_y && id_z && id_a) + id_x = id_y = id_z = id_a = 0; if (0); #define X(FUNC, NAME)\ @@ -337,10 +337,11 @@ main(int argc, char *argv[]) for (y = 0; y < rows; y++) { buf = buffer; for (x = 0; x < cols; x++) { - buf[0] = null_x ? 0.0 : *kern; - buf[1] = null_y ? 0.0 : *kern; - buf[2] = null_z ? 0.0 : *kern; - buf[3] = null_a ? 0.0 : *kern; + id_val = (x == cols / 2 && y == rows / 2) ? 1. : 0.; + buf[0] = id_x ? id_val : *kern; + buf[1] = id_y ? id_val : *kern; + buf[2] = id_z ? id_val : *kern; + buf[3] = id_a ? id_val : *kern; buf += 4; kern++; } diff --git a/src/blind-make-kernel.c b/src/blind-make-kernel.c @@ -82,10 +82,10 @@ main(int argc, char *argv[]) { int normalise = 0; double denominator = 1; - int null_x = 1, null_y = 1, null_z = 1, null_a = 1; + int id_x = 1, id_y = 1, id_z = 1, id_a = 1; size_t rows, cols, y, x, n; double *kernel, *kern, sum = 0, value; - double *buffer, *buf; + double *buffer, *buf, id_val; ARGBEGIN { case 'd': @@ -95,23 +95,23 @@ main(int argc, char *argv[]) normalise = 1; break; case 'x': - null_x = 0; + id_x = 0; break; case 'y': - null_y = 0; + id_y = 0; break; case 'z': - null_z = 0; + id_z = 0; break; case 'a': - null_a = 0; + id_a = 0; break; default: usage(); } ARGEND; - if (null_x && null_y && null_z && null_a) - null_x = null_y = null_z = null_a = 0; + if (id_x && id_y && id_z && id_a) + id_x = id_y = id_z = id_a = 0; if (argc) kernel = read_matrix_cmdline(argv, &rows, &cols); @@ -136,11 +136,12 @@ main(int argc, char *argv[]) for (y = 0; y < rows; y++) { buf = buffer; for (x = 0; x < cols; x++) { + id_val = (x == cols / 2 && y == rows / 2) ? 1. : 0.; value = *kern++ / denominator; - buf[0] = null_x ? 0.0 : value; - buf[1] = null_y ? 0.0 : value; - buf[2] = null_z ? 0.0 : value; - buf[3] = null_a ? 0.0 : value; + buf[0] = id_x ? id_val : value; + buf[1] = id_y ? id_val : value; + buf[2] = id_z ? id_val : value; + buf[3] = id_a ? id_val : value; buf += 4; } ewriteall(STDOUT_FILENO, buffer, n, "<stdout>");