Add blind-repeat-tessellation - blind - suckless command-line video editing utility
 (HTM) git clone git://git.suckless.org/blind
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 6f4d55793f88540d1b1abd7410e43da83993ad6a
 (DIR) parent e7f1780c5c05840ec3eca54b83d76c2658bf5de8
 (HTM) Author: Mattias Andrée <maandree@kth.se>
       Date:   Tue, 11 Jul 2017 23:27:46 +0200
       
       Add blind-repeat-tessellation
       
       Signed-off-by: Mattias Andrée <maandree@kth.se>
       
       Diffstat:
         M Makefile                            |       1 +
         M README                              |       3 +++
         A man/blind-repeat-tessellation.1     |      34 +++++++++++++++++++++++++++++++
         M man/blind.7                         |       3 +++
         A src/blind-repeat-tessellation.c     |      52 +++++++++++++++++++++++++++++++
       
       5 files changed, 93 insertions(+), 0 deletions(-)
       ---
 (DIR) diff --git a/Makefile b/Makefile
       @@ -44,6 +44,7 @@ BIN =\
                blind-radial-gradient\
                blind-read-head\
                blind-repeat\
       +        blind-repeat-tessellation\
                blind-reverse\
                blind-rewrite-head\
                blind-round-wave\
 (DIR) diff --git a/README b/README
       @@ -132,6 +132,9 @@ UTILITIES
               blind-repeat(1)
                      Repeat a video
        
       +       blind-repeat-tessellation(1)
       +              Repeat a video horizontally and veritically to a specific size
       +
               blind-reverse(1)
                      Reverse a video
        
 (DIR) diff --git a/man/blind-repeat-tessellation.1 b/man/blind-repeat-tessellation.1
       @@ -0,0 +1,34 @@
       +.TH BLIND-REPEAT-TESSELLATION 1 blind
       +.SH NAME
       +blind-repeat-tessellation - Repeat a video horizontally and veritically to a specific size
       +.SH SYNOPSIS
       +.B blind-repeat-tessellation
       +-w
       +.I width
       +-h
       +.I height
       +.SH DESCRIPTION
       +.B blind-repeat-tessellation
       +reads a video from stdin and prints it, repeated both
       +horizontally and vertically, to stdout.
       +.SH OPTIONS
       +.TP
       +.BR -w " "\fIwidth\fP
       +The width of the output video shall be exactly
       +.I width
       +pixels.
       +.TP
       +.BR -h " "\fIheight\fP
       +The height of the output video shall be exactly
       +.I height
       +pixels.
       +.SH REQUIREMENTS
       +.B blind-repeat-tessellation
       +requires enough free memory to load one full frame of
       +the video from stdin into memory. A frame requires 32
       +bytes per pixel it contains.
       +.SH SEE ALSO
       +.BR blind (7)
       +.SH AUTHORS
       +Mattias Andrée
       +.RI < maandree@kth.se >
 (DIR) diff --git a/man/blind.7 b/man/blind.7
       @@ -148,6 +148,9 @@ Reads the head from a video
        .BR blind-repeat (1)
        Repeat a video
        .TP
       +.BR blind-repeat-tessellation (1)
       +Repeat a video horizontally and veritically to a specific size
       +.TP
        .BR blind-reverse (1)
        Reverse a video
        .TP
 (DIR) diff --git a/src/blind-repeat-tessellation.c b/src/blind-repeat-tessellation.c
       @@ -0,0 +1,52 @@
       +/* See LICENSE file for copyright and license details. */
       +#include "common.h"
       +
       +USAGE("-w width -h height")
       +
       +int
       +main(int argc, char *argv[])
       +{
       +        struct stream stream;
       +        size_t width = 0;
       +        size_t height = 0;
       +        size_t x, y, p, w;
       +        char *buf;
       +
       +        ARGBEGIN {
       +        case 'w':
       +                width = etozu_flag('w', UARGF(), 1, SIZE_MAX);
       +                break;
       +        case 'h':
       +                height = etozu_flag('h', UARGF(), 1, SIZE_MAX);
       +                break;
       +        default:
       +                usage();
       +        } ARGEND;
       +
       +        if (!width || !height || argc)
       +                usage();
       +
       +        eopen_stream(&stream, NULL);
       +        echeck_dimensions(&stream, WIDTH | HEIGHT, NULL);
       +        x = stream.width,  stream.width = width;
       +        y = stream.height, stream.height = height;
       +        fprint_stream_head(stdout, &stream);
       +        efflush(stdout, "<stdout>");
       +        stream.width  = x;
       +        stream.height = y;
       +        buf = emalloc(stream.frame_size);
       +
       +        w = width % stream.width;
       +        while (eread_frame(&stream, buf)) {
       +                for (y = 0; y < height; y++) {
       +                        p = (y % stream.height) * stream.row_size;
       +                        for (x = 0; x < width / stream.width; x++)
       +                                ewriteall(STDOUT_FILENO, buf + p, stream.row_size, "<stdout>");
       +                        if (w)
       +                                ewriteall(STDOUT_FILENO, buf + p, w * stream.pixel_size, "<stdout>");
       +                }
       +        }
       +
       +        free(buf);
       +        return 0;
       +}