| blind-coordinate-field.c - blind - suckless command-line video editing utility | |
| git clone git://git.suckless.org/blind | |
| Log | |
| Files | |
| Refs | |
| README | |
| LICENSE | |
| --- | |
| blind-coordinate-field.c (1446B) | |
| --- | |
| 1 /* See LICENSE file for copyright and license details. */ | |
| 2 #ifndef TYPE | |
| 3 #include "common.h" | |
| 4 | |
| 5 USAGE("[-f frames | -f 'inf'] [-F pixel-format] -w width -h height") | |
| 6 | |
| 7 static struct stream stream = { .width = 0, .height = 0, .frames = 1 }; | |
| 8 static int inf = 0; | |
| 9 | |
| 10 #define FILE "blind-coordinate-field.c" | |
| 11 #include "define-functions.h" | |
| 12 | |
| 13 int | |
| 14 main(int argc, char *argv[]) | |
| 15 { | |
| 16 char *arg; | |
| 17 const char *pixfmt = "xyza"; | |
| 18 void (*process)(void); | |
| 19 | |
| 20 ARGBEGIN { | |
| 21 case 'f': | |
| 22 arg = UARGF(); | |
| 23 if (!strcmp(arg, "inf")) | |
| 24 inf = 1, stream.frames = 0; | |
| 25 else | |
| 26 stream.frames = etozu_flag('f', arg, 1, SIZE_MAX… | |
| 27 break; | |
| 28 case 'F': | |
| 29 pixfmt = UARGF(); | |
| 30 break; | |
| 31 case 'w': | |
| 32 stream.width = etozu_flag('w', UARGF(), 1, SIZE_MAX); | |
| 33 break; | |
| 34 case 'h': | |
| 35 stream.height = etozu_flag('h', UARGF(), 1, SIZE_MAX); | |
| 36 break; | |
| 37 default: | |
| 38 usage(); | |
| 39 } ARGEND; | |
| 40 | |
| 41 if (!stream.width || !stream.height || argc) | |
| 42 usage(); | |
| 43 | |
| 44 if (inf) | |
| 45 einf_check_fd(STDOUT_FILENO, "<stdout>"); | |
| 46 | |
| 47 eset_pixel_format(&stream, pixfmt); | |
| 48 SELECT_PROCESS_FUNCTION(&stream); | |
| 49 CHECK_N_CHAN(&stream, 4, 4); | |
| 50 | |
| 51 fprint_stream_head(stdout, &stream); | |
| 52 efflush(stdout, "<stdout>"); | |
| 53 process(); | |
| 54 return 0; | |
| 55 } | |
| 56 | |
| 57 #else | |
| 58 | |
| 59 static void | |
| 60 PROCESS(void) | |
| 61 { | |
| 62 TYPE buf[4] = {0, 0, 0, 0}; | |
| 63 size_t x, y; | |
| 64 while (inf || stream.frames--) { | |
| 65 for (y = 0; y < stream.height; y++) { | |
| 66 buf[1] = (TYPE)y; | |
| 67 for (x = 0; x < stream.width; x++) { | |
| 68 buf[0] = (TYPE)x; | |
| 69 ewrite(STDOUT_FILENO, buf, sizeof(buf), … | |
| 70 } | |
| 71 } | |
| 72 } | |
| 73 } | |
| 74 | |
| 75 #endif |