| blind-repeat-tessellation.c - blind - suckless command-line video editing utili… | |
| git clone git://git.suckless.org/blind | |
| Log | |
| Files | |
| Refs | |
| README | |
| LICENSE | |
| --- | |
| blind-repeat-tessellation.c (1151B) | |
| --- | |
| 1 /* See LICENSE file for copyright and license details. */ | |
| 2 #include "common.h" | |
| 3 | |
| 4 USAGE("-w width -h height") | |
| 5 | |
| 6 int | |
| 7 main(int argc, char *argv[]) | |
| 8 { | |
| 9 struct stream stream; | |
| 10 size_t width = 0; | |
| 11 size_t height = 0; | |
| 12 size_t x, y, p, w; | |
| 13 char *buf; | |
| 14 | |
| 15 ARGBEGIN { | |
| 16 case 'w': | |
| 17 width = etozu_flag('w', UARGF(), 1, SIZE_MAX); | |
| 18 break; | |
| 19 case 'h': | |
| 20 height = etozu_flag('h', UARGF(), 1, SIZE_MAX); | |
| 21 break; | |
| 22 default: | |
| 23 usage(); | |
| 24 } ARGEND; | |
| 25 | |
| 26 if (!width || !height || argc) | |
| 27 usage(); | |
| 28 | |
| 29 eopen_stream(&stream, NULL); | |
| 30 echeck_dimensions(&stream, WIDTH | HEIGHT, NULL); | |
| 31 x = stream.width, stream.width = width; | |
| 32 y = stream.height, stream.height = height; | |
| 33 fprint_stream_head(stdout, &stream); | |
| 34 efflush(stdout, "<stdout>"); | |
| 35 stream.width = x; | |
| 36 stream.height = y; | |
| 37 buf = emalloc(stream.frame_size); | |
| 38 | |
| 39 w = width % stream.width; | |
| 40 while (eread_frame(&stream, buf)) { | |
| 41 for (y = 0; y < height; y++) { | |
| 42 p = (y % stream.height) * stream.row_size; | |
| 43 for (x = 0; x < width / stream.width; x++) | |
| 44 ewriteall(STDOUT_FILENO, buf + p, stream… | |
| 45 if (w) | |
| 46 ewriteall(STDOUT_FILENO, buf + p, w * st… | |
| 47 } | |
| 48 } | |
| 49 | |
| 50 free(buf); | |
| 51 return 0; | |
| 52 } |