blind-to-text.c - 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
       ---
       blind-to-text.c (1036B)
       ---
            1 /* See LICENSE file for copyright and license details. */
            2 #ifndef TYPE
            3 #define INCLUDE_UINT16
            4 #include "common.h"
            5 
            6 USAGE("[-% format]")
            7 
            8 const char *fmt = NULL;
            9 
           10 #define FILE "blind-to-text.c"
           11 #include "define-functions.h"
           12 
           13 int
           14 main(int argc, char *argv[])
           15 {
           16         struct stream stream;
           17         void (*process)(struct stream *stream, size_t n);
           18 
           19         ARGBEGIN {
           20         case '%':
           21                 fmt = UARGF();
           22                 break;
           23         default:
           24                 usage();
           25         } ARGEND;
           26 
           27         if (argc)
           28                 usage();
           29 
           30         eopen_stream(&stream, NULL);
           31         fmt = select_print_format("%! %! %! %!\n", stream.encoding, fmt);
           32         SELECT_PROCESS_FUNCTION(&stream);
           33         printf("%zu %zu %zu %s\n", stream.frames, stream.width, stream.height, stream.pixfmt);
           34         process_stream(&stream, process);
           35         efshut(stdout, "<stdout>");
           36         return 0;
           37 }
           38 
           39 #else
           40 
           41 static void
           42 PROCESS(struct stream *stream, size_t n)
           43 {
           44         size_t i;
           45         TYPE *p = (TYPE *)(stream->buf);
           46         for (i = 0, n /= stream->chan_size; i < n; i += 4) {
           47                 printf(fmt, (PRINT_CAST)(p[i + 0]), (PRINT_CAST)(p[i + 1]),
           48                             (PRINT_CAST)(p[i + 2]), (PRINT_CAST)(p[i + 3]));
           49         }
           50 }
           51 
           52 #endif