8 print "/* Only for odd N */\n";
10 print "#define DO_FEATHER_MAX_N " . $MAXN . "\n\n";
15 print "#define DO_FEATHER_" . $N . '(type, int_type, max, N); \
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(); \
25 int_type tmp1, tmp2; \
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++) \
38 in_row = in_rows[0]; \
39 else if (i >= frame_h) \
40 in_row = in_rows[frame_h - 1]; \
42 in_row = in_rows[i]; \
46 for ($i = 0; $i < $N - 1; $i++)
47 { print "SR" . $i . " = "; }
49 # print ' if (i >= start_out && i <= end_out) \';
52 if (i >= start_out + offset && i<= end_out + offset) \
53 out_row = out_rows[i - offset]; \
57 $KERNEL =' int_type *SC = SC0; \
58 for (j = 0; j < frame_w + offset * 2; j++) \
62 else if (j >= frame_w + offset) \
63 tmp1 = in_row[frame_w - 1]; \
65 tmp1 = in_row[j - offset]; \
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";
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";
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";
121 # print "\t\t\t\tSC[" . $i . "] = " . $t2 . " ;\\\n";
122 # print "\t\t\t\tSC += " . ($N -1) . ";\\\n";
123 # print "\t\t\t} \\\n";
129 print "\tdelete [] SC0; \\\n";
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()) \
155 printf " case BC_A". $bits .": \\\n";
158 $type = "unsigned char";
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";
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";
195 print "\t\t\t\tdefault: \\\n\t\t\t\t\treturn 0; \\\n";
196 print "\t\t\t} \\\n";