Introduction
Introduction Statistics Contact Development Disclaimer Help
blind-time-blur.c - blind - suckless command-line video editing utility
git clone git://git.suckless.org/blind
Log
Files
Refs
README
LICENSE
---
blind-time-blur.c (1617B)
---
1 /* See LICENSE file for copyright and license details. */
2 #ifndef TYPE
3 #include "common.h"
4
5 USAGE("alpha-stream")
6
7 static int first = 1;
8
9 #define FILE "blind-time-blur.c"
10 #include "define-functions.h"
11
12 int
13 main(int argc, char *argv[])
14 {
15 struct stream colour, alpha;
16 void (*process)(char *restrict output, char *restrict cbuf, char…
17 struct stream *colour, struct stream *alpha);
18
19 ARGBEGIN {
20 default:
21 usage();
22 } ARGEND;
23
24 if (argc != 1)
25 usage();
26
27 eopen_stream(&colour, NULL);
28 eopen_stream(&alpha, argv[0]);
29
30 SELECT_PROCESS_FUNCTION(&colour);
31 CHECK_CHANS(&colour, == 3, == 1);
32 CHECK_N_CHAN(&colour, 4, 4);
33
34 echeck_compat(&colour, &alpha);
35 fprint_stream_head(stdout, &colour);
36 efflush(stdout, "<stdout>");
37 process_each_frame_two_streams(&colour, &alpha, STDOUT_FILENO, "…
38 return 0;
39 }
40
41 #else
42
43 static void
44 PROCESS(char *output, char *restrict cbuf, char *restrict abuf,
45 struct stream *colour, struct stream *alpha)
46 {
47 typedef TYPE pixel_t[4];
48 pixel_t *restrict clr = (pixel_t *)cbuf;
49 pixel_t *restrict alf = (pixel_t *)abuf;
50 pixel_t *img = (pixel_t *)output;
51 size_t i, n = colour->width * colour->height;
52 TYPE a1, a2;
53
54 if (first) {
55 memcpy(output, cbuf, colour->frame_size);
56 first = 0;
57 return;
58 }
59
60 for (i = 0; i < n; i++, clr++, alf++, img++) {
61 a1 = (*img)[3];
62 a2 = (*clr)[3] * (*alf)[1] * (*alf)[3];
63 a1 *= (1 - a2);
64 (*img)[0] = (*img)[0] * a1 + (*clr)[0] * a2;
65 (*img)[1] = (*img)[1] * a1 + (*clr)[1] * a2;
66 (*img)[2] = (*img)[2] * a1 + (*clr)[2] * a2;
67 (*img)[3] = a1 + a2;
68 }
69
70 (void) colour;
71 (void) alpha;
72
73 }
74
75 #endif
You are viewing proxied material from suckless.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.