blind-vector-projection.c - blind - suckless command-line video editing utility | |
git clone git://git.suckless.org/blind | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
blind-vector-projection.c (1697B) | |
--- | |
1 /* See LICENSE file for copyright and license details. */ | |
2 #ifndef TYPE | |
3 #include "common.h" | |
4 | |
5 USAGE("[-r | -s] plane-stream") | |
6 | |
7 static int level = 1; | |
8 | |
9 #define FILE "blind-vector-projection.c" | |
10 #include "define-functions.h" | |
11 | |
12 int | |
13 main(int argc, char *argv[]) | |
14 { | |
15 struct stream left, right; | |
16 void (*process)(struct stream *left, struct stream *right, size_… | |
17 | |
18 ARGBEGIN { | |
19 case 'r': | |
20 if (level == 0) | |
21 usage(); | |
22 level = 2; | |
23 break; | |
24 case 's': | |
25 if (level == 2) | |
26 usage(); | |
27 level = 0; | |
28 break; | |
29 default: | |
30 usage(); | |
31 } ARGEND; | |
32 | |
33 if (argc != 1) | |
34 usage(); | |
35 | |
36 eopen_stream(&left, NULL); | |
37 eopen_stream(&right, argv[0]); | |
38 | |
39 SELECT_PROCESS_FUNCTION(&left); | |
40 CHECK_ALPHA_CHAN(&left); | |
41 CHECK_N_CHAN(&left, 4, 4); | |
42 | |
43 fprint_stream_head(stdout, &left); | |
44 efflush(stdout, "<stdout>"); | |
45 process_two_streams(&left, &right, STDOUT_FILENO, "<stdout>", pr… | |
46 return 0; | |
47 } | |
48 | |
49 #else | |
50 | |
51 static void | |
52 PROCESS(struct stream *left, struct stream *right, size_t n) | |
53 { | |
54 size_t i; | |
55 TYPE *lx, *ly, *lz, *la, rx, ry, rz, ra, x, y, z, a, norm; | |
56 for (i = 0; i < n; i += 4 * sizeof(TYPE)) { | |
57 lx = ((TYPE *)(left->buf + i)) + 0, rx = ((TYPE *)(right… | |
58 ly = ((TYPE *)(left->buf + i)) + 1, ry = ((TYPE *)(right… | |
59 lz = ((TYPE *)(left->buf + i)) + 2, rz = ((TYPE *)(right… | |
60 la = ((TYPE *)(left->buf + i)) + 3, ra = ((TYPE *)(right… | |
61 norm = rx * rx + ry * ry + rz * rz + ra * ra; | |
62 norm = sqrt(norm); | |
63 x = y = z = a = *lx * rx + *ly * ry + *lz * rz + *la * r… | |
64 if (level) { | |
65 x *= rx; | |
66 y *= ry; | |
67 z *= rz; | |
68 a *= rz; | |
69 if (level > 1) { | |
70 x = *lx - x; | |
71 y = *ly - y; | |
72 z = *lz - z; | |
73 a = *la - a; | |
74 } | |
75 } | |
76 *lx = x; | |
77 *ly = y; | |
78 *lz = z; | |
79 *la = a; | |
80 } | |
81 } | |
82 | |
83 #endif |