Introduction
Introduction Statistics Contact Development Disclaimer Help
blind-primary-key - blind - suckless command-line video editing utility
git clone git://git.suckless.org/blind
Log
Files
Refs
README
LICENSE
---
blind-primary-key (3235B)
---
1 #!/usr/bin/env bash
2
3 set -e
4
5 if printf '%s\n' "$0" | grep / >/dev/null 2>/dev/null; then
6 export PATH="$(printf '%s\n' "$0" | tr '/\n' '\n/' | sed \$d | tr '/…
7 fi
8
9 pid=$$
10 o='0 0 0 0'
11 E='1 1 1 1'
12
13 x=x; y=y; z=z
14 ciexyy=0
15 zflag=
16 grey=0
17 keep=0
18
19 usage () {
20 xyy="-z x1 y1 x2 y2 x3 y3 [white-x white-y]"
21 xyz="X1 Y1 Z1 X2 Y2 Z2 X3 Y3 Z3 [white-X white-Y white-Z]"
22 printf 'usage: %s [-1 | -2 | -3] [-gk] [%s | %s]\n' "$0" "$xyy" …
23 exit 1
24 }
25
26 while ! test $# = 0; do
27 if test "$1" = --; then
28 shift 1
29 break
30 elif test "$(printf '%s\n' "$1" | sed 's/^\(.\).*$/\1/')" = -; t…
31 arg="$(printf '%s\n' "$1" | sed 's/^.//')"
32 shift 1
33 while test -n "$arg"; do
34 flag="$(printf '%s\n' "$arg" | sed 's/^\(.\).*$/…
35 arg="$(printf '%s\n' "$arg" | sed 's/^.//')"
36 if test "$flag" = 1; then
37 x=x; y=y; z=z
38 elif test "$flag" = 2; then
39 x=y; y=z; z=x
40 elif test "$flag" = 3; then
41 x=z; y=x; z=y
42 elif test "$flag" = g; then
43 grey=1
44 elif test "$flag" = k; then
45 keep=1
46 elif test "$flag" = z; then
47 ciexyy=1
48 else
49 usage
50 fi
51 done
52 else
53 break
54 fi
55 done
56
57 a=$(( ( 3 - $ciexyy ) * 3 ))
58 b=$(( ( 3 - $ciexyy ) * 4 ))
59 if test $# != 0 && test $# != $a && test $# != $b; then
60 usage
61 elif test $ciexyy = 1 && test $# = 0; then
62 usage
63 fi
64
65 read frames width height pixfmt < <(blind-read-head)
66
67 if test $# = 0; then
68 convert () { cat; }
69 unconvert () { cat; }
70 else
71 if test $ciexyy = 1; then
72 zflag=-z
73 fi
74 convert () {
75 blind-affine-colour -al \
76 <(blind-colour-matrix -F "$pixfmt" $zflag -- "$@…
77 blind-tee \
78 >(blind-invert-matrix -e | \blin…
79 blind-repeat inf -)
80 }
81 unconvert () {
82 blind-affine-colour -al \
83 <(blind-from-named -a blind-${pid}-invmat \
84 blind-arithm -xyz max <(blind-single-col…
85 blind-repeat inf -)
86 }
87 fi
88
89 if test $keep = 0; then
90 primary () { blind-from-named -a blind-${pid}-$x "$@"; }
91 keep_primary () { "$@"; }
92 else
93 primary () {
94 blind-from-named -a blind-${pid}-$x \
95 blind-tee >(blind-to-named -a blind-${pid}-k) | \
96 "$@"
97 }
98 keep_primary () {
99 if test $x = x; then
100 X=; Y=y; Z=z
101 elif test $x = y; then
102 X=x; Y=; Z=z
103 else
104 X=x; Y=y; Z=
105 fi
106 blind-from-named -f 7 -a blind-${pid}-k \
107 blind-arithm -a$X$Y$Z add /dev/fd/7 | \
108 "$@"
109 }
110 fi
111
112 if test $grey = 0; then
113 finalise () { unconvert; }
114 else
115 finalise () {
116 unconvert | blind-set-saturation <(blind-single-colour -…
117 }
118 fi
119
120 (blind-write-head $frames $width $height "$pixfmt" ; cat) | \
121 convert "$@" | \
122 blind-split-chans -c \
123 >(blind-to-named -a blind-${pid}-x) \
124 >(blind-to-named -a blind-${pid}-y) \
125 >(blind-to-named -a blind-${pid}-z) \
126 - | \
127 blind-arithm mul \
128 <(blind-single-colour -f inf -w $width -h $height 0 0 0 …
129 blind-arithm sub \
130 <(primary blind-affine-colour -l \
131 <(printf '%s %s %s %s\n' \
132 1 4 4 xyza \
133 $o $o $o $o \
134 $o $o $o $o \
135 $o $o $o $o \
136 $E $E $E $o | \
137 blind-from-text | \
138 blind-repeat inf -))) | \
139 keep_primary \
140 blind-from-named -f 8 -a blind-${pid}-$y blind-arithm add /dev/f…
141 blind-from-named -f 9 -a blind-${pid}-$z blind-arithm add /dev/f…
142 finalise
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.