blind

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

commit e650c912ba86c84cdad466674a0ca0c4ebadef9c
parent b4a50a1ad6ab7d8a674ce54cde9778986badd333
Author: Mattias Andrée <maandree@kth.se>
Date:   Fri, 14 Jul 2017 20:57:45 +0200

Fix blind-invert-matrix and increase percision of blind-to-text

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

Diffstat:
TODO | 5+++++
man/blind-invert-matrix.1 | 5+++++
man/blind-matrix-shear.1 | 4+++-
src/blind-invert-matrix.c | 12+++++++-----
src/blind-to-text.c | 4++--
5 files changed, 22 insertions(+), 8 deletions(-)

diff --git a/TODO b/TODO @@ -1,3 +1,8 @@ +HIGH PRIORITY: + blind-cat-rows and blind-cat-cols randomly produces incorrect results + + + blind-transform affine transformation by matrix multiplication, -t for tiling, -s for improve quality on downscaling (pixels' neighbours must not change). blind-primary-key replace a primary with transparency, -g for greyscaled images. diff --git a/man/blind-invert-matrix.1 b/man/blind-invert-matrix.1 @@ -21,6 +21,11 @@ resuling augment is printed. .B -e Apply optimisation that assumes all channels are identical. +.SH NOTES +.B blind-invert-matrix +fails if it encounters a non-invertable +matrix, however, this is not always the +case. .SH SEE ALSO .BR blind (7), .BR blind-multiply-matrices (1), diff --git a/man/blind-matrix-shear.1 b/man/blind-matrix-shear.1 @@ -43,7 +43,9 @@ The description assumes the Y-axis grows downwards. Horizontal shearing and vertical shearing is not mutually commutative, this tool performs the shearing at the same time rather than after each -other. +other. When shearing both horizontally and +vertically, the transformation matrix is not +necessarily invertable. .SH SEE ALSO .BR blind (7), .BR blind-from-text (1), diff --git a/src/blind-invert-matrix.c b/src/blind-invert-matrix.c @@ -18,7 +18,7 @@ static int equal = 0; typedef TYPE pixel_t[4];\ size_t rn = stream->height, r1, r2, c;\ size_t cn = stream->width > rn ? stream->width : 2 * rn;\ - pixel_t *matrix = buf, *p1, *p2 = NULL;\ + pixel_t *matrix = buf, *p1, *p2;\ TYPE t;\ \ for (r1 = 0; r1 < rn; r1++) {\ @@ -29,7 +29,7 @@ static int equal = 0; if (p2[r1][0])\ break;\ }\ - if (r2 == rn)\ + if (r2 >= rn)\ eprintf("matrix is not invertable\n");\ for (c = 0; c < cn; c++)\ t = p1[c][0], p1[c][0] = p2[c][0], p2[c][0] = t;\ @@ -82,9 +82,11 @@ main(int argc, char *argv[]) efflush(stdout, "<stdout>"); if (!strcmp(stream.pixfmt, "xyza")) { + one = alloca(4 * sizeof(double)); *(double *)one = 1; process = process_lf; } else if (!strcmp(stream.pixfmt, "xyza f")) { + one = alloca(4 * sizeof(float)); *(float *)one = 1; process = process_f; } else { @@ -105,7 +107,7 @@ main(int argc, char *argv[]) for (y = stream.height; y--;) { memmove(buf + y * row_size, buf + y * stream.row_size, stream.row_size); memset(buf + y * row_size + stream.row_size, 0, stream.row_size); - memcpy(buf + y * row_size + y * stream.pixel_size, one, stream.pixel_size); + memcpy(buf + y * row_size + stream.row_size + y * stream.pixel_size, one, stream.pixel_size); } } if (equal) { @@ -113,7 +115,7 @@ main(int argc, char *argv[]) for (y = 0; y < stream.height; y++) { for (x = 0; x < stream.width; x++) { p = buf + y * row_size + x * stream.pixel_size; - memcpy(p + chan_size, p, chan_size); + memcpy(p, p + chan_size, chan_size); memcpy(p + 2 * chan_size, p, 2 * chan_size); } } @@ -124,7 +126,7 @@ main(int argc, char *argv[]) process(&stream, buf + 3 * chan_size); } for (y = 0; y < stream.height; y++) - ewriteall(STDOUT_FILENO, buf + y * row_size + stream.row_size, stream.row_size, "<stdout>"); + ewriteall(STDOUT_FILENO, buf + y * row_size + stream.col_size, row_size - stream.col_size, "<stdout>"); } free(buf); diff --git a/src/blind-to-text.c b/src/blind-to-text.c @@ -16,8 +16,8 @@ USAGE("") (CAST)(((TYPE *)(stream->buf + i))[3]));\ } while (0) -static void process_xyza (struct stream *stream, size_t n) {PROCESS(double, double, "lf");} -static void process_xyzaf(struct stream *stream, size_t n) {PROCESS(float, double, "lf");} +static void process_xyza (struct stream *stream, size_t n) {PROCESS(double, double, ".25lf");} +static void process_xyzaf(struct stream *stream, size_t n) {PROCESS(float, double, ".25lf");} int main(int argc, char *argv[])