r1009: Move the dependencies to newer package names
[cinelerra_cv/mob.git] / cinelerra / gen-feather-h
blobacca349831c18a09b92737e1bbe8cb60ec372d5e
1 #!/usr/bin/perl
4 $MAXN = 30;
6 $N = 3;
8 print "/* Only for odd N */\n";
10 print "#define DO_FEATHER_MAX_N " . $MAXN . "\n\n";
12 while ($N < $MAXN) {
13 my $i;
15 print "#define DO_FEATHER_" . $N . '(type, int_type, max, N); \
16 { \
17 int offset = N / 2; \
18 int frame_w = input->get_w(); \
19 int frame_h = input->get_h(); \
20 int start_in = start_out - offset; \
21 int end_in = end_out + offset; \
22 type **in_rows = (type**)input->get_rows(); \
23 type **out_rows = (type**)output->get_rows(); \
24 int i,j; \
25 int_type tmp1, tmp2; \
28 print " int_type ";
29 for ($i = 0; $i < $N - 2; $i++)
30 { print "SR" . $i . ", "; }
31 print "SR" . $i . "; \\\n";
32 print " int_type *SC0 = new int_type[(frame_w + offset * 2) * ". ($N - 1) . "]; \\\n";
33 print " memset(SC0, 0, sizeof(int_type) * (frame_w + offset * 2) * " . ($N - 1) . "); \\\n";
34 print ' for (i = start_in; i < end_in; i++) \
35 { \
36 type *in_row; \
37 if (i < 0) \
38 in_row = in_rows[0]; \
39 else if (i >= frame_h) \
40 in_row = in_rows[frame_h - 1]; \
41 else \
42 in_row = in_rows[i]; \
45 print "\t\t";
46 for ($i = 0; $i < $N - 1; $i++)
47 { print "SR" . $i . " = "; }
48 print "0; \\\n";
49 # print ' if (i >= start_out && i <= end_out) \';
50 print ' { \
51 type *out_row; \
52 if (i >= start_out + offset && i<= end_out + offset) \
53 out_row = out_rows[i - offset]; \
54 else \
55 out_row = 0; \
57 $KERNEL =' int_type *SC = SC0; \
58 for (j = 0; j < frame_w + offset * 2; j++) \
59 { \
60 if (j < offset) \
61 tmp1 = in_row[0]; \
62 else if (j >= frame_w + offset) \
63 tmp1 = in_row[frame_w - 1]; \
64 else \
65 tmp1 = in_row[j - offset]; \
66 ';
68 # row machine
69 $t1 = "tmp2";
70 $t2 = "tmp1";
71 for ($i = 0; $i < $N - 1; $i++)
73 $KERNEL .= "\t\t\t\t" . $t1 . " = SR" . $i . " + " . $t2 . "; \\\n";
74 $KERNEL .= "\t\t\t\tSR" . $i . " = " . $t2 . "; \\\n";
75 if ($t1 eq "tmp1")
77 $t1 = "tmp2";
78 $t2 = "tmp1";
79 } else
81 $t1 = "tmp1";
82 $t2 = "tmp2";
85 # column machine
86 for ($i = 0; $i < $N - 2; $i++)
88 $KERNEL .= "\t\t\t\t" . $t1 . " = SC[" . $i . "] + " . $t2 . "; \\\n";
89 $KERNEL .= "\t\t\t\tSC[" . $i . "] = " . $t2 . "; \\\n";
90 if ($t1 eq "tmp1")
92 $t1 = "tmp2";
93 $t2 = "tmp1";
94 } else
96 $t1 = "tmp1";
97 $t2 = "tmp2";
101 print $KERNEL;
103 # output
104 $POWER = ($N - 1) * 2;
105 $HALF_N2 = 2 ** ($POWER - 1);
106 if ($HALF_N2 >= 134217728)
108 # $HALF_N2 = "(uint64_t)" . $HALF_N2 . "L";
109 $HALF_N2 = "((uint64_t)1 <<" . ($POWER - 1) . ")";
111 print "\t\t\t\tif (j >= offset * 2) \\\n";
113 print "\t\t\t\t\tif (out_row) out_row[j - offset * 2] = (" . $HALF_N2 . " + SC[" . $i . "] + " . $t2 . ") >> " . $POWER . "; \\\n";
114 print "\t\t\t\tSC[" . $i . "] = " . $t2 . "; \\\n";
115 print "\t\t\t\tSC += " . ($N -1) . ";\\\n";
116 print "\t\t\t} \\\n";
118 #print "\t\t} else { /* just fill in the SCs, no ouput... */ \\\n";
120 # print $KERNEL;
121 # print "\t\t\t\tSC[" . $i . "] = " . $t2 . " ;\\\n";
122 # print "\t\t\t\tSC += " . ($N -1) . ";\\\n";
123 # print "\t\t\t} \\\n";
125 $N += 2;
127 print "\t\t} \\\n";
128 print "\t} \\\n";
129 print "\tdelete [] SC0; \\\n";
130 print "}\n";
138 print '
139 /* THIS WORKS ONLY FOR ODD N >= 3 */
140 #define DO_FEATHER_N(type, int_type, max, N) \
146 print ' switch(input->get_color_model()) \
150 $bits = 0;
152 while ($bits < 16) {
153 $bits += 8;
155 printf " case BC_A". $bits .": \\\n";
157 if ($bits == 8) {
158 $type = "unsigned char";
159 } else
161 $type = "uint16_t";
163 print ' switch (N) \
167 $N = 3;
169 while ($N < $MAXN) {
170 $POWER = ($N - 1) * 2;
171 if ($POWER + $bits <= 16)
173 $int_type = "uint16_t";
174 } elsif ($POWER + $bits <= 32)
176 $int_type = "uint32_t";
177 } elsif ($POWER + $bits <= 64)
179 $int_type = "uint64_t";
181 else {
182 $N += 2;
183 $N = $MAXN;
185 if ($N < $MAXN)
187 print "\t\t\t\tcase " . $N . ": \\\n";
188 print "\t\t\t\t\tDO_FEATHER_" . $N . "($type, $int_type, max, " . $N . "); \\\n";
189 print "\t\t\t\t\treturn 1; \\\n";
191 print "\t\t\t\t\tbreak; \\\n";
193 $N += 2;
195 print "\t\t\t\tdefault: \\\n\t\t\t\t\treturn 0; \\\n";
196 print "\t\t\t} \\\n";
200 print ' } \
201 return 0; \