r1053: Add Russian translation.
[cinelerra_cv.git] / cinelerra / feather.h
blobd1fc00f6405910e881efa4c9402c3e44c2afe8e2
1 /* Only for odd N */
2 #define DO_FEATHER_MAX_N 30
4 #define DO_FEATHER_3(type, int_type, max, N); \
5 { \
6 int offset = N / 2; \
7 int frame_w = input->get_w(); \
8 int frame_h = input->get_h(); \
9 int start_in = start_out - offset; \
10 int end_in = end_out + offset; \
11 type **in_rows = (type**)input->get_rows(); \
12 type **out_rows = (type**)output->get_rows(); \
13 int i,j; \
14 int_type tmp1, tmp2; \
15 int_type SR0, SR1; \
16 int_type *SC0 = new int_type[(frame_w + offset * 2) * 2]; \
17 memset(SC0, 0, sizeof(int_type) * (frame_w + offset * 2) * 2); \
18 for (i = start_in; i < end_in; i++) \
19 { \
20 type *in_row; \
21 if (i < 0) \
22 in_row = in_rows[0]; \
23 else if (i >= frame_h) \
24 in_row = in_rows[frame_h - 1]; \
25 else \
26 in_row = in_rows[i]; \
27 SR0 = SR1 = 0; \
28 { \
29 type *out_row; \
30 if (i >= start_out + offset && i<= end_out + offset) \
31 out_row = out_rows[i - offset]; \
32 else \
33 out_row = 0; \
34 int_type *SC = SC0; \
35 for (j = 0; j < frame_w + offset * 2; j++) \
36 { \
37 if (j < offset) \
38 tmp1 = in_row[0]; \
39 else if (j >= frame_w + offset) \
40 tmp1 = in_row[frame_w - 1]; \
41 else \
42 tmp1 = in_row[j - offset]; \
43 tmp2 = SR0 + tmp1; \
44 SR0 = tmp1; \
45 tmp1 = SR1 + tmp2; \
46 SR1 = tmp2; \
47 tmp2 = SC[0] + tmp1; \
48 SC[0] = tmp1; \
49 if (j >= offset * 2) \
50 if (out_row) out_row[j - offset * 2] = (8 + SC[1] + tmp2) >> 4; \
51 SC[1] = tmp2; \
52 SC += 2;\
53 } \
54 } \
55 } \
56 delete [] SC0; \
58 #define DO_FEATHER_5(type, int_type, max, N); \
59 { \
60 int offset = N / 2; \
61 int frame_w = input->get_w(); \
62 int frame_h = input->get_h(); \
63 int start_in = start_out - offset; \
64 int end_in = end_out + offset; \
65 type **in_rows = (type**)input->get_rows(); \
66 type **out_rows = (type**)output->get_rows(); \
67 int i,j; \
68 int_type tmp1, tmp2; \
69 int_type SR0, SR1, SR2, SR3; \
70 int_type *SC0 = new int_type[(frame_w + offset * 2) * 4]; \
71 memset(SC0, 0, sizeof(int_type) * (frame_w + offset * 2) * 4); \
72 for (i = start_in; i < end_in; i++) \
73 { \
74 type *in_row; \
75 if (i < 0) \
76 in_row = in_rows[0]; \
77 else if (i >= frame_h) \
78 in_row = in_rows[frame_h - 1]; \
79 else \
80 in_row = in_rows[i]; \
81 SR0 = SR1 = SR2 = SR3 = 0; \
82 { \
83 type *out_row; \
84 if (i >= start_out + offset && i<= end_out + offset) \
85 out_row = out_rows[i - offset]; \
86 else \
87 out_row = 0; \
88 int_type *SC = SC0; \
89 for (j = 0; j < frame_w + offset * 2; j++) \
90 { \
91 if (j < offset) \
92 tmp1 = in_row[0]; \
93 else if (j >= frame_w + offset) \
94 tmp1 = in_row[frame_w - 1]; \
95 else \
96 tmp1 = in_row[j - offset]; \
97 tmp2 = SR0 + tmp1; \
98 SR0 = tmp1; \
99 tmp1 = SR1 + tmp2; \
100 SR1 = tmp2; \
101 tmp2 = SR2 + tmp1; \
102 SR2 = tmp1; \
103 tmp1 = SR3 + tmp2; \
104 SR3 = tmp2; \
105 tmp2 = SC[0] + tmp1; \
106 SC[0] = tmp1; \
107 tmp1 = SC[1] + tmp2; \
108 SC[1] = tmp2; \
109 tmp2 = SC[2] + tmp1; \
110 SC[2] = tmp1; \
111 if (j >= offset * 2) \
112 if (out_row) out_row[j - offset * 2] = (128 + SC[3] + tmp2) >> 8; \
113 SC[3] = tmp2; \
114 SC += 4;\
118 delete [] SC0; \
120 #define DO_FEATHER_7(type, int_type, max, N); \
122 int offset = N / 2; \
123 int frame_w = input->get_w(); \
124 int frame_h = input->get_h(); \
125 int start_in = start_out - offset; \
126 int end_in = end_out + offset; \
127 type **in_rows = (type**)input->get_rows(); \
128 type **out_rows = (type**)output->get_rows(); \
129 int i,j; \
130 int_type tmp1, tmp2; \
131 int_type SR0, SR1, SR2, SR3, SR4, SR5; \
132 int_type *SC0 = new int_type[(frame_w + offset * 2) * 6]; \
133 memset(SC0, 0, sizeof(int_type) * (frame_w + offset * 2) * 6); \
134 for (i = start_in; i < end_in; i++) \
136 type *in_row; \
137 if (i < 0) \
138 in_row = in_rows[0]; \
139 else if (i >= frame_h) \
140 in_row = in_rows[frame_h - 1]; \
141 else \
142 in_row = in_rows[i]; \
143 SR0 = SR1 = SR2 = SR3 = SR4 = SR5 = 0; \
145 type *out_row; \
146 if (i >= start_out + offset && i<= end_out + offset) \
147 out_row = out_rows[i - offset]; \
148 else \
149 out_row = 0; \
150 int_type *SC = SC0; \
151 for (j = 0; j < frame_w + offset * 2; j++) \
153 if (j < offset) \
154 tmp1 = in_row[0]; \
155 else if (j >= frame_w + offset) \
156 tmp1 = in_row[frame_w - 1]; \
157 else \
158 tmp1 = in_row[j - offset]; \
159 tmp2 = SR0 + tmp1; \
160 SR0 = tmp1; \
161 tmp1 = SR1 + tmp2; \
162 SR1 = tmp2; \
163 tmp2 = SR2 + tmp1; \
164 SR2 = tmp1; \
165 tmp1 = SR3 + tmp2; \
166 SR3 = tmp2; \
167 tmp2 = SR4 + tmp1; \
168 SR4 = tmp1; \
169 tmp1 = SR5 + tmp2; \
170 SR5 = tmp2; \
171 tmp2 = SC[0] + tmp1; \
172 SC[0] = tmp1; \
173 tmp1 = SC[1] + tmp2; \
174 SC[1] = tmp2; \
175 tmp2 = SC[2] + tmp1; \
176 SC[2] = tmp1; \
177 tmp1 = SC[3] + tmp2; \
178 SC[3] = tmp2; \
179 tmp2 = SC[4] + tmp1; \
180 SC[4] = tmp1; \
181 if (j >= offset * 2) \
182 if (out_row) out_row[j - offset * 2] = (2048 + SC[5] + tmp2) >> 12; \
183 SC[5] = tmp2; \
184 SC += 6;\
188 delete [] SC0; \
190 #define DO_FEATHER_9(type, int_type, max, N); \
192 int offset = N / 2; \
193 int frame_w = input->get_w(); \
194 int frame_h = input->get_h(); \
195 int start_in = start_out - offset; \
196 int end_in = end_out + offset; \
197 type **in_rows = (type**)input->get_rows(); \
198 type **out_rows = (type**)output->get_rows(); \
199 int i,j; \
200 int_type tmp1, tmp2; \
201 int_type SR0, SR1, SR2, SR3, SR4, SR5, SR6, SR7; \
202 int_type *SC0 = new int_type[(frame_w + offset * 2) * 8]; \
203 memset(SC0, 0, sizeof(int_type) * (frame_w + offset * 2) * 8); \
204 for (i = start_in; i < end_in; i++) \
206 type *in_row; \
207 if (i < 0) \
208 in_row = in_rows[0]; \
209 else if (i >= frame_h) \
210 in_row = in_rows[frame_h - 1]; \
211 else \
212 in_row = in_rows[i]; \
213 SR0 = SR1 = SR2 = SR3 = SR4 = SR5 = SR6 = SR7 = 0; \
215 type *out_row; \
216 if (i >= start_out + offset && i<= end_out + offset) \
217 out_row = out_rows[i - offset]; \
218 else \
219 out_row = 0; \
220 int_type *SC = SC0; \
221 for (j = 0; j < frame_w + offset * 2; j++) \
223 if (j < offset) \
224 tmp1 = in_row[0]; \
225 else if (j >= frame_w + offset) \
226 tmp1 = in_row[frame_w - 1]; \
227 else \
228 tmp1 = in_row[j - offset]; \
229 tmp2 = SR0 + tmp1; \
230 SR0 = tmp1; \
231 tmp1 = SR1 + tmp2; \
232 SR1 = tmp2; \
233 tmp2 = SR2 + tmp1; \
234 SR2 = tmp1; \
235 tmp1 = SR3 + tmp2; \
236 SR3 = tmp2; \
237 tmp2 = SR4 + tmp1; \
238 SR4 = tmp1; \
239 tmp1 = SR5 + tmp2; \
240 SR5 = tmp2; \
241 tmp2 = SR6 + tmp1; \
242 SR6 = tmp1; \
243 tmp1 = SR7 + tmp2; \
244 SR7 = tmp2; \
245 tmp2 = SC[0] + tmp1; \
246 SC[0] = tmp1; \
247 tmp1 = SC[1] + tmp2; \
248 SC[1] = tmp2; \
249 tmp2 = SC[2] + tmp1; \
250 SC[2] = tmp1; \
251 tmp1 = SC[3] + tmp2; \
252 SC[3] = tmp2; \
253 tmp2 = SC[4] + tmp1; \
254 SC[4] = tmp1; \
255 tmp1 = SC[5] + tmp2; \
256 SC[5] = tmp2; \
257 tmp2 = SC[6] + tmp1; \
258 SC[6] = tmp1; \
259 if (j >= offset * 2) \
260 if (out_row) out_row[j - offset * 2] = (32768 + SC[7] + tmp2) >> 16; \
261 SC[7] = tmp2; \
262 SC += 8;\
266 delete [] SC0; \
268 #define DO_FEATHER_11(type, int_type, max, N); \
270 int offset = N / 2; \
271 int frame_w = input->get_w(); \
272 int frame_h = input->get_h(); \
273 int start_in = start_out - offset; \
274 int end_in = end_out + offset; \
275 type **in_rows = (type**)input->get_rows(); \
276 type **out_rows = (type**)output->get_rows(); \
277 int i,j; \
278 int_type tmp1, tmp2; \
279 int_type SR0, SR1, SR2, SR3, SR4, SR5, SR6, SR7, SR8, SR9; \
280 int_type *SC0 = new int_type[(frame_w + offset * 2) * 10]; \
281 memset(SC0, 0, sizeof(int_type) * (frame_w + offset * 2) * 10); \
282 for (i = start_in; i < end_in; i++) \
284 type *in_row; \
285 if (i < 0) \
286 in_row = in_rows[0]; \
287 else if (i >= frame_h) \
288 in_row = in_rows[frame_h - 1]; \
289 else \
290 in_row = in_rows[i]; \
291 SR0 = SR1 = SR2 = SR3 = SR4 = SR5 = SR6 = SR7 = SR8 = SR9 = 0; \
293 type *out_row; \
294 if (i >= start_out + offset && i<= end_out + offset) \
295 out_row = out_rows[i - offset]; \
296 else \
297 out_row = 0; \
298 int_type *SC = SC0; \
299 for (j = 0; j < frame_w + offset * 2; j++) \
301 if (j < offset) \
302 tmp1 = in_row[0]; \
303 else if (j >= frame_w + offset) \
304 tmp1 = in_row[frame_w - 1]; \
305 else \
306 tmp1 = in_row[j - offset]; \
307 tmp2 = SR0 + tmp1; \
308 SR0 = tmp1; \
309 tmp1 = SR1 + tmp2; \
310 SR1 = tmp2; \
311 tmp2 = SR2 + tmp1; \
312 SR2 = tmp1; \
313 tmp1 = SR3 + tmp2; \
314 SR3 = tmp2; \
315 tmp2 = SR4 + tmp1; \
316 SR4 = tmp1; \
317 tmp1 = SR5 + tmp2; \
318 SR5 = tmp2; \
319 tmp2 = SR6 + tmp1; \
320 SR6 = tmp1; \
321 tmp1 = SR7 + tmp2; \
322 SR7 = tmp2; \
323 tmp2 = SR8 + tmp1; \
324 SR8 = tmp1; \
325 tmp1 = SR9 + tmp2; \
326 SR9 = tmp2; \
327 tmp2 = SC[0] + tmp1; \
328 SC[0] = tmp1; \
329 tmp1 = SC[1] + tmp2; \
330 SC[1] = tmp2; \
331 tmp2 = SC[2] + tmp1; \
332 SC[2] = tmp1; \
333 tmp1 = SC[3] + tmp2; \
334 SC[3] = tmp2; \
335 tmp2 = SC[4] + tmp1; \
336 SC[4] = tmp1; \
337 tmp1 = SC[5] + tmp2; \
338 SC[5] = tmp2; \
339 tmp2 = SC[6] + tmp1; \
340 SC[6] = tmp1; \
341 tmp1 = SC[7] + tmp2; \
342 SC[7] = tmp2; \
343 tmp2 = SC[8] + tmp1; \
344 SC[8] = tmp1; \
345 if (j >= offset * 2) \
346 if (out_row) out_row[j - offset * 2] = (524288 + SC[9] + tmp2) >> 20; \
347 SC[9] = tmp2; \
348 SC += 10;\
352 delete [] SC0; \
354 #define DO_FEATHER_13(type, int_type, max, N); \
356 int offset = N / 2; \
357 int frame_w = input->get_w(); \
358 int frame_h = input->get_h(); \
359 int start_in = start_out - offset; \
360 int end_in = end_out + offset; \
361 type **in_rows = (type**)input->get_rows(); \
362 type **out_rows = (type**)output->get_rows(); \
363 int i,j; \
364 int_type tmp1, tmp2; \
365 int_type SR0, SR1, SR2, SR3, SR4, SR5, SR6, SR7, SR8, SR9, SR10, SR11; \
366 int_type *SC0 = new int_type[(frame_w + offset * 2) * 12]; \
367 memset(SC0, 0, sizeof(int_type) * (frame_w + offset * 2) * 12); \
368 for (i = start_in; i < end_in; i++) \
370 type *in_row; \
371 if (i < 0) \
372 in_row = in_rows[0]; \
373 else if (i >= frame_h) \
374 in_row = in_rows[frame_h - 1]; \
375 else \
376 in_row = in_rows[i]; \
377 SR0 = SR1 = SR2 = SR3 = SR4 = SR5 = SR6 = SR7 = SR8 = SR9 = SR10 = SR11 = 0; \
379 type *out_row; \
380 if (i >= start_out + offset && i<= end_out + offset) \
381 out_row = out_rows[i - offset]; \
382 else \
383 out_row = 0; \
384 int_type *SC = SC0; \
385 for (j = 0; j < frame_w + offset * 2; j++) \
387 if (j < offset) \
388 tmp1 = in_row[0]; \
389 else if (j >= frame_w + offset) \
390 tmp1 = in_row[frame_w - 1]; \
391 else \
392 tmp1 = in_row[j - offset]; \
393 tmp2 = SR0 + tmp1; \
394 SR0 = tmp1; \
395 tmp1 = SR1 + tmp2; \
396 SR1 = tmp2; \
397 tmp2 = SR2 + tmp1; \
398 SR2 = tmp1; \
399 tmp1 = SR3 + tmp2; \
400 SR3 = tmp2; \
401 tmp2 = SR4 + tmp1; \
402 SR4 = tmp1; \
403 tmp1 = SR5 + tmp2; \
404 SR5 = tmp2; \
405 tmp2 = SR6 + tmp1; \
406 SR6 = tmp1; \
407 tmp1 = SR7 + tmp2; \
408 SR7 = tmp2; \
409 tmp2 = SR8 + tmp1; \
410 SR8 = tmp1; \
411 tmp1 = SR9 + tmp2; \
412 SR9 = tmp2; \
413 tmp2 = SR10 + tmp1; \
414 SR10 = tmp1; \
415 tmp1 = SR11 + tmp2; \
416 SR11 = tmp2; \
417 tmp2 = SC[0] + tmp1; \
418 SC[0] = tmp1; \
419 tmp1 = SC[1] + tmp2; \
420 SC[1] = tmp2; \
421 tmp2 = SC[2] + tmp1; \
422 SC[2] = tmp1; \
423 tmp1 = SC[3] + tmp2; \
424 SC[3] = tmp2; \
425 tmp2 = SC[4] + tmp1; \
426 SC[4] = tmp1; \
427 tmp1 = SC[5] + tmp2; \
428 SC[5] = tmp2; \
429 tmp2 = SC[6] + tmp1; \
430 SC[6] = tmp1; \
431 tmp1 = SC[7] + tmp2; \
432 SC[7] = tmp2; \
433 tmp2 = SC[8] + tmp1; \
434 SC[8] = tmp1; \
435 tmp1 = SC[9] + tmp2; \
436 SC[9] = tmp2; \
437 tmp2 = SC[10] + tmp1; \
438 SC[10] = tmp1; \
439 if (j >= offset * 2) \
440 if (out_row) out_row[j - offset * 2] = (8388608 + SC[11] + tmp2) >> 24; \
441 SC[11] = tmp2; \
442 SC += 12;\
446 delete [] SC0; \
448 #define DO_FEATHER_15(type, int_type, max, N); \
450 int offset = N / 2; \
451 int frame_w = input->get_w(); \
452 int frame_h = input->get_h(); \
453 int start_in = start_out - offset; \
454 int end_in = end_out + offset; \
455 type **in_rows = (type**)input->get_rows(); \
456 type **out_rows = (type**)output->get_rows(); \
457 int i,j; \
458 int_type tmp1, tmp2; \
459 int_type SR0, SR1, SR2, SR3, SR4, SR5, SR6, SR7, SR8, SR9, SR10, SR11, SR12, SR13; \
460 int_type *SC0 = new int_type[(frame_w + offset * 2) * 14]; \
461 memset(SC0, 0, sizeof(int_type) * (frame_w + offset * 2) * 14); \
462 for (i = start_in; i < end_in; i++) \
464 type *in_row; \
465 if (i < 0) \
466 in_row = in_rows[0]; \
467 else if (i >= frame_h) \
468 in_row = in_rows[frame_h - 1]; \
469 else \
470 in_row = in_rows[i]; \
471 SR0 = SR1 = SR2 = SR3 = SR4 = SR5 = SR6 = SR7 = SR8 = SR9 = SR10 = SR11 = SR12 = SR13 = 0; \
473 type *out_row; \
474 if (i >= start_out + offset && i<= end_out + offset) \
475 out_row = out_rows[i - offset]; \
476 else \
477 out_row = 0; \
478 int_type *SC = SC0; \
479 for (j = 0; j < frame_w + offset * 2; j++) \
481 if (j < offset) \
482 tmp1 = in_row[0]; \
483 else if (j >= frame_w + offset) \
484 tmp1 = in_row[frame_w - 1]; \
485 else \
486 tmp1 = in_row[j - offset]; \
487 tmp2 = SR0 + tmp1; \
488 SR0 = tmp1; \
489 tmp1 = SR1 + tmp2; \
490 SR1 = tmp2; \
491 tmp2 = SR2 + tmp1; \
492 SR2 = tmp1; \
493 tmp1 = SR3 + tmp2; \
494 SR3 = tmp2; \
495 tmp2 = SR4 + tmp1; \
496 SR4 = tmp1; \
497 tmp1 = SR5 + tmp2; \
498 SR5 = tmp2; \
499 tmp2 = SR6 + tmp1; \
500 SR6 = tmp1; \
501 tmp1 = SR7 + tmp2; \
502 SR7 = tmp2; \
503 tmp2 = SR8 + tmp1; \
504 SR8 = tmp1; \
505 tmp1 = SR9 + tmp2; \
506 SR9 = tmp2; \
507 tmp2 = SR10 + tmp1; \
508 SR10 = tmp1; \
509 tmp1 = SR11 + tmp2; \
510 SR11 = tmp2; \
511 tmp2 = SR12 + tmp1; \
512 SR12 = tmp1; \
513 tmp1 = SR13 + tmp2; \
514 SR13 = tmp2; \
515 tmp2 = SC[0] + tmp1; \
516 SC[0] = tmp1; \
517 tmp1 = SC[1] + tmp2; \
518 SC[1] = tmp2; \
519 tmp2 = SC[2] + tmp1; \
520 SC[2] = tmp1; \
521 tmp1 = SC[3] + tmp2; \
522 SC[3] = tmp2; \
523 tmp2 = SC[4] + tmp1; \
524 SC[4] = tmp1; \
525 tmp1 = SC[5] + tmp2; \
526 SC[5] = tmp2; \
527 tmp2 = SC[6] + tmp1; \
528 SC[6] = tmp1; \
529 tmp1 = SC[7] + tmp2; \
530 SC[7] = tmp2; \
531 tmp2 = SC[8] + tmp1; \
532 SC[8] = tmp1; \
533 tmp1 = SC[9] + tmp2; \
534 SC[9] = tmp2; \
535 tmp2 = SC[10] + tmp1; \
536 SC[10] = tmp1; \
537 tmp1 = SC[11] + tmp2; \
538 SC[11] = tmp2; \
539 tmp2 = SC[12] + tmp1; \
540 SC[12] = tmp1; \
541 if (j >= offset * 2) \
542 if (out_row) out_row[j - offset * 2] = (((uint64_t)1 <<27) + SC[13] + tmp2) >> 28; \
543 SC[13] = tmp2; \
544 SC += 14;\
548 delete [] SC0; \
550 #define DO_FEATHER_17(type, int_type, max, N); \
552 int offset = N / 2; \
553 int frame_w = input->get_w(); \
554 int frame_h = input->get_h(); \
555 int start_in = start_out - offset; \
556 int end_in = end_out + offset; \
557 type **in_rows = (type**)input->get_rows(); \
558 type **out_rows = (type**)output->get_rows(); \
559 int i,j; \
560 int_type tmp1, tmp2; \
561 int_type SR0, SR1, SR2, SR3, SR4, SR5, SR6, SR7, SR8, SR9, SR10, SR11, SR12, SR13, SR14, SR15; \
562 int_type *SC0 = new int_type[(frame_w + offset * 2) * 16]; \
563 memset(SC0, 0, sizeof(int_type) * (frame_w + offset * 2) * 16); \
564 for (i = start_in; i < end_in; i++) \
566 type *in_row; \
567 if (i < 0) \
568 in_row = in_rows[0]; \
569 else if (i >= frame_h) \
570 in_row = in_rows[frame_h - 1]; \
571 else \
572 in_row = in_rows[i]; \
573 SR0 = SR1 = SR2 = SR3 = SR4 = SR5 = SR6 = SR7 = SR8 = SR9 = SR10 = SR11 = SR12 = SR13 = SR14 = SR15 = 0; \
575 type *out_row; \
576 if (i >= start_out + offset && i<= end_out + offset) \
577 out_row = out_rows[i - offset]; \
578 else \
579 out_row = 0; \
580 int_type *SC = SC0; \
581 for (j = 0; j < frame_w + offset * 2; j++) \
583 if (j < offset) \
584 tmp1 = in_row[0]; \
585 else if (j >= frame_w + offset) \
586 tmp1 = in_row[frame_w - 1]; \
587 else \
588 tmp1 = in_row[j - offset]; \
589 tmp2 = SR0 + tmp1; \
590 SR0 = tmp1; \
591 tmp1 = SR1 + tmp2; \
592 SR1 = tmp2; \
593 tmp2 = SR2 + tmp1; \
594 SR2 = tmp1; \
595 tmp1 = SR3 + tmp2; \
596 SR3 = tmp2; \
597 tmp2 = SR4 + tmp1; \
598 SR4 = tmp1; \
599 tmp1 = SR5 + tmp2; \
600 SR5 = tmp2; \
601 tmp2 = SR6 + tmp1; \
602 SR6 = tmp1; \
603 tmp1 = SR7 + tmp2; \
604 SR7 = tmp2; \
605 tmp2 = SR8 + tmp1; \
606 SR8 = tmp1; \
607 tmp1 = SR9 + tmp2; \
608 SR9 = tmp2; \
609 tmp2 = SR10 + tmp1; \
610 SR10 = tmp1; \
611 tmp1 = SR11 + tmp2; \
612 SR11 = tmp2; \
613 tmp2 = SR12 + tmp1; \
614 SR12 = tmp1; \
615 tmp1 = SR13 + tmp2; \
616 SR13 = tmp2; \
617 tmp2 = SR14 + tmp1; \
618 SR14 = tmp1; \
619 tmp1 = SR15 + tmp2; \
620 SR15 = tmp2; \
621 tmp2 = SC[0] + tmp1; \
622 SC[0] = tmp1; \
623 tmp1 = SC[1] + tmp2; \
624 SC[1] = tmp2; \
625 tmp2 = SC[2] + tmp1; \
626 SC[2] = tmp1; \
627 tmp1 = SC[3] + tmp2; \
628 SC[3] = tmp2; \
629 tmp2 = SC[4] + tmp1; \
630 SC[4] = tmp1; \
631 tmp1 = SC[5] + tmp2; \
632 SC[5] = tmp2; \
633 tmp2 = SC[6] + tmp1; \
634 SC[6] = tmp1; \
635 tmp1 = SC[7] + tmp2; \
636 SC[7] = tmp2; \
637 tmp2 = SC[8] + tmp1; \
638 SC[8] = tmp1; \
639 tmp1 = SC[9] + tmp2; \
640 SC[9] = tmp2; \
641 tmp2 = SC[10] + tmp1; \
642 SC[10] = tmp1; \
643 tmp1 = SC[11] + tmp2; \
644 SC[11] = tmp2; \
645 tmp2 = SC[12] + tmp1; \
646 SC[12] = tmp1; \
647 tmp1 = SC[13] + tmp2; \
648 SC[13] = tmp2; \
649 tmp2 = SC[14] + tmp1; \
650 SC[14] = tmp1; \
651 if (j >= offset * 2) \
652 if (out_row) out_row[j - offset * 2] = (((uint64_t)1 <<31) + SC[15] + tmp2) >> 32; \
653 SC[15] = tmp2; \
654 SC += 16;\
658 delete [] SC0; \
660 #define DO_FEATHER_19(type, int_type, max, N); \
662 int offset = N / 2; \
663 int frame_w = input->get_w(); \
664 int frame_h = input->get_h(); \
665 int start_in = start_out - offset; \
666 int end_in = end_out + offset; \
667 type **in_rows = (type**)input->get_rows(); \
668 type **out_rows = (type**)output->get_rows(); \
669 int i,j; \
670 int_type tmp1, tmp2; \
671 int_type SR0, SR1, SR2, SR3, SR4, SR5, SR6, SR7, SR8, SR9, SR10, SR11, SR12, SR13, SR14, SR15, SR16, SR17; \
672 int_type *SC0 = new int_type[(frame_w + offset * 2) * 18]; \
673 memset(SC0, 0, sizeof(int_type) * (frame_w + offset * 2) * 18); \
674 for (i = start_in; i < end_in; i++) \
676 type *in_row; \
677 if (i < 0) \
678 in_row = in_rows[0]; \
679 else if (i >= frame_h) \
680 in_row = in_rows[frame_h - 1]; \
681 else \
682 in_row = in_rows[i]; \
683 SR0 = SR1 = SR2 = SR3 = SR4 = SR5 = SR6 = SR7 = SR8 = SR9 = SR10 = SR11 = SR12 = SR13 = SR14 = SR15 = SR16 = SR17 = 0; \
685 type *out_row; \
686 if (i >= start_out + offset && i<= end_out + offset) \
687 out_row = out_rows[i - offset]; \
688 else \
689 out_row = 0; \
690 int_type *SC = SC0; \
691 for (j = 0; j < frame_w + offset * 2; j++) \
693 if (j < offset) \
694 tmp1 = in_row[0]; \
695 else if (j >= frame_w + offset) \
696 tmp1 = in_row[frame_w - 1]; \
697 else \
698 tmp1 = in_row[j - offset]; \
699 tmp2 = SR0 + tmp1; \
700 SR0 = tmp1; \
701 tmp1 = SR1 + tmp2; \
702 SR1 = tmp2; \
703 tmp2 = SR2 + tmp1; \
704 SR2 = tmp1; \
705 tmp1 = SR3 + tmp2; \
706 SR3 = tmp2; \
707 tmp2 = SR4 + tmp1; \
708 SR4 = tmp1; \
709 tmp1 = SR5 + tmp2; \
710 SR5 = tmp2; \
711 tmp2 = SR6 + tmp1; \
712 SR6 = tmp1; \
713 tmp1 = SR7 + tmp2; \
714 SR7 = tmp2; \
715 tmp2 = SR8 + tmp1; \
716 SR8 = tmp1; \
717 tmp1 = SR9 + tmp2; \
718 SR9 = tmp2; \
719 tmp2 = SR10 + tmp1; \
720 SR10 = tmp1; \
721 tmp1 = SR11 + tmp2; \
722 SR11 = tmp2; \
723 tmp2 = SR12 + tmp1; \
724 SR12 = tmp1; \
725 tmp1 = SR13 + tmp2; \
726 SR13 = tmp2; \
727 tmp2 = SR14 + tmp1; \
728 SR14 = tmp1; \
729 tmp1 = SR15 + tmp2; \
730 SR15 = tmp2; \
731 tmp2 = SR16 + tmp1; \
732 SR16 = tmp1; \
733 tmp1 = SR17 + tmp2; \
734 SR17 = tmp2; \
735 tmp2 = SC[0] + tmp1; \
736 SC[0] = tmp1; \
737 tmp1 = SC[1] + tmp2; \
738 SC[1] = tmp2; \
739 tmp2 = SC[2] + tmp1; \
740 SC[2] = tmp1; \
741 tmp1 = SC[3] + tmp2; \
742 SC[3] = tmp2; \
743 tmp2 = SC[4] + tmp1; \
744 SC[4] = tmp1; \
745 tmp1 = SC[5] + tmp2; \
746 SC[5] = tmp2; \
747 tmp2 = SC[6] + tmp1; \
748 SC[6] = tmp1; \
749 tmp1 = SC[7] + tmp2; \
750 SC[7] = tmp2; \
751 tmp2 = SC[8] + tmp1; \
752 SC[8] = tmp1; \
753 tmp1 = SC[9] + tmp2; \
754 SC[9] = tmp2; \
755 tmp2 = SC[10] + tmp1; \
756 SC[10] = tmp1; \
757 tmp1 = SC[11] + tmp2; \
758 SC[11] = tmp2; \
759 tmp2 = SC[12] + tmp1; \
760 SC[12] = tmp1; \
761 tmp1 = SC[13] + tmp2; \
762 SC[13] = tmp2; \
763 tmp2 = SC[14] + tmp1; \
764 SC[14] = tmp1; \
765 tmp1 = SC[15] + tmp2; \
766 SC[15] = tmp2; \
767 tmp2 = SC[16] + tmp1; \
768 SC[16] = tmp1; \
769 if (j >= offset * 2) \
770 if (out_row) out_row[j - offset * 2] = (((uint64_t)1 <<35) + SC[17] + tmp2) >> 36; \
771 SC[17] = tmp2; \
772 SC += 18;\
776 delete [] SC0; \
778 #define DO_FEATHER_21(type, int_type, max, N); \
780 int offset = N / 2; \
781 int frame_w = input->get_w(); \
782 int frame_h = input->get_h(); \
783 int start_in = start_out - offset; \
784 int end_in = end_out + offset; \
785 type **in_rows = (type**)input->get_rows(); \
786 type **out_rows = (type**)output->get_rows(); \
787 int i,j; \
788 int_type tmp1, tmp2; \
789 int_type SR0, SR1, SR2, SR3, SR4, SR5, SR6, SR7, SR8, SR9, SR10, SR11, SR12, SR13, SR14, SR15, SR16, SR17, SR18, SR19; \
790 int_type *SC0 = new int_type[(frame_w + offset * 2) * 20]; \
791 memset(SC0, 0, sizeof(int_type) * (frame_w + offset * 2) * 20); \
792 for (i = start_in; i < end_in; i++) \
794 type *in_row; \
795 if (i < 0) \
796 in_row = in_rows[0]; \
797 else if (i >= frame_h) \
798 in_row = in_rows[frame_h - 1]; \
799 else \
800 in_row = in_rows[i]; \
801 SR0 = SR1 = SR2 = SR3 = SR4 = SR5 = SR6 = SR7 = SR8 = SR9 = SR10 = SR11 = SR12 = SR13 = SR14 = SR15 = SR16 = SR17 = SR18 = SR19 = 0; \
803 type *out_row; \
804 if (i >= start_out + offset && i<= end_out + offset) \
805 out_row = out_rows[i - offset]; \
806 else \
807 out_row = 0; \
808 int_type *SC = SC0; \
809 for (j = 0; j < frame_w + offset * 2; j++) \
811 if (j < offset) \
812 tmp1 = in_row[0]; \
813 else if (j >= frame_w + offset) \
814 tmp1 = in_row[frame_w - 1]; \
815 else \
816 tmp1 = in_row[j - offset]; \
817 tmp2 = SR0 + tmp1; \
818 SR0 = tmp1; \
819 tmp1 = SR1 + tmp2; \
820 SR1 = tmp2; \
821 tmp2 = SR2 + tmp1; \
822 SR2 = tmp1; \
823 tmp1 = SR3 + tmp2; \
824 SR3 = tmp2; \
825 tmp2 = SR4 + tmp1; \
826 SR4 = tmp1; \
827 tmp1 = SR5 + tmp2; \
828 SR5 = tmp2; \
829 tmp2 = SR6 + tmp1; \
830 SR6 = tmp1; \
831 tmp1 = SR7 + tmp2; \
832 SR7 = tmp2; \
833 tmp2 = SR8 + tmp1; \
834 SR8 = tmp1; \
835 tmp1 = SR9 + tmp2; \
836 SR9 = tmp2; \
837 tmp2 = SR10 + tmp1; \
838 SR10 = tmp1; \
839 tmp1 = SR11 + tmp2; \
840 SR11 = tmp2; \
841 tmp2 = SR12 + tmp1; \
842 SR12 = tmp1; \
843 tmp1 = SR13 + tmp2; \
844 SR13 = tmp2; \
845 tmp2 = SR14 + tmp1; \
846 SR14 = tmp1; \
847 tmp1 = SR15 + tmp2; \
848 SR15 = tmp2; \
849 tmp2 = SR16 + tmp1; \
850 SR16 = tmp1; \
851 tmp1 = SR17 + tmp2; \
852 SR17 = tmp2; \
853 tmp2 = SR18 + tmp1; \
854 SR18 = tmp1; \
855 tmp1 = SR19 + tmp2; \
856 SR19 = tmp2; \
857 tmp2 = SC[0] + tmp1; \
858 SC[0] = tmp1; \
859 tmp1 = SC[1] + tmp2; \
860 SC[1] = tmp2; \
861 tmp2 = SC[2] + tmp1; \
862 SC[2] = tmp1; \
863 tmp1 = SC[3] + tmp2; \
864 SC[3] = tmp2; \
865 tmp2 = SC[4] + tmp1; \
866 SC[4] = tmp1; \
867 tmp1 = SC[5] + tmp2; \
868 SC[5] = tmp2; \
869 tmp2 = SC[6] + tmp1; \
870 SC[6] = tmp1; \
871 tmp1 = SC[7] + tmp2; \
872 SC[7] = tmp2; \
873 tmp2 = SC[8] + tmp1; \
874 SC[8] = tmp1; \
875 tmp1 = SC[9] + tmp2; \
876 SC[9] = tmp2; \
877 tmp2 = SC[10] + tmp1; \
878 SC[10] = tmp1; \
879 tmp1 = SC[11] + tmp2; \
880 SC[11] = tmp2; \
881 tmp2 = SC[12] + tmp1; \
882 SC[12] = tmp1; \
883 tmp1 = SC[13] + tmp2; \
884 SC[13] = tmp2; \
885 tmp2 = SC[14] + tmp1; \
886 SC[14] = tmp1; \
887 tmp1 = SC[15] + tmp2; \
888 SC[15] = tmp2; \
889 tmp2 = SC[16] + tmp1; \
890 SC[16] = tmp1; \
891 tmp1 = SC[17] + tmp2; \
892 SC[17] = tmp2; \
893 tmp2 = SC[18] + tmp1; \
894 SC[18] = tmp1; \
895 if (j >= offset * 2) \
896 if (out_row) out_row[j - offset * 2] = (((uint64_t)1 <<39) + SC[19] + tmp2) >> 40; \
897 SC[19] = tmp2; \
898 SC += 20;\
902 delete [] SC0; \
904 #define DO_FEATHER_23(type, int_type, max, N); \
906 int offset = N / 2; \
907 int frame_w = input->get_w(); \
908 int frame_h = input->get_h(); \
909 int start_in = start_out - offset; \
910 int end_in = end_out + offset; \
911 type **in_rows = (type**)input->get_rows(); \
912 type **out_rows = (type**)output->get_rows(); \
913 int i,j; \
914 int_type tmp1, tmp2; \
915 int_type SR0, SR1, SR2, SR3, SR4, SR5, SR6, SR7, SR8, SR9, SR10, SR11, SR12, SR13, SR14, SR15, SR16, SR17, SR18, SR19, SR20, SR21; \
916 int_type *SC0 = new int_type[(frame_w + offset * 2) * 22]; \
917 memset(SC0, 0, sizeof(int_type) * (frame_w + offset * 2) * 22); \
918 for (i = start_in; i < end_in; i++) \
920 type *in_row; \
921 if (i < 0) \
922 in_row = in_rows[0]; \
923 else if (i >= frame_h) \
924 in_row = in_rows[frame_h - 1]; \
925 else \
926 in_row = in_rows[i]; \
927 SR0 = SR1 = SR2 = SR3 = SR4 = SR5 = SR6 = SR7 = SR8 = SR9 = SR10 = SR11 = SR12 = SR13 = SR14 = SR15 = SR16 = SR17 = SR18 = SR19 = SR20 = SR21 = 0; \
929 type *out_row; \
930 if (i >= start_out + offset && i<= end_out + offset) \
931 out_row = out_rows[i - offset]; \
932 else \
933 out_row = 0; \
934 int_type *SC = SC0; \
935 for (j = 0; j < frame_w + offset * 2; j++) \
937 if (j < offset) \
938 tmp1 = in_row[0]; \
939 else if (j >= frame_w + offset) \
940 tmp1 = in_row[frame_w - 1]; \
941 else \
942 tmp1 = in_row[j - offset]; \
943 tmp2 = SR0 + tmp1; \
944 SR0 = tmp1; \
945 tmp1 = SR1 + tmp2; \
946 SR1 = tmp2; \
947 tmp2 = SR2 + tmp1; \
948 SR2 = tmp1; \
949 tmp1 = SR3 + tmp2; \
950 SR3 = tmp2; \
951 tmp2 = SR4 + tmp1; \
952 SR4 = tmp1; \
953 tmp1 = SR5 + tmp2; \
954 SR5 = tmp2; \
955 tmp2 = SR6 + tmp1; \
956 SR6 = tmp1; \
957 tmp1 = SR7 + tmp2; \
958 SR7 = tmp2; \
959 tmp2 = SR8 + tmp1; \
960 SR8 = tmp1; \
961 tmp1 = SR9 + tmp2; \
962 SR9 = tmp2; \
963 tmp2 = SR10 + tmp1; \
964 SR10 = tmp1; \
965 tmp1 = SR11 + tmp2; \
966 SR11 = tmp2; \
967 tmp2 = SR12 + tmp1; \
968 SR12 = tmp1; \
969 tmp1 = SR13 + tmp2; \
970 SR13 = tmp2; \
971 tmp2 = SR14 + tmp1; \
972 SR14 = tmp1; \
973 tmp1 = SR15 + tmp2; \
974 SR15 = tmp2; \
975 tmp2 = SR16 + tmp1; \
976 SR16 = tmp1; \
977 tmp1 = SR17 + tmp2; \
978 SR17 = tmp2; \
979 tmp2 = SR18 + tmp1; \
980 SR18 = tmp1; \
981 tmp1 = SR19 + tmp2; \
982 SR19 = tmp2; \
983 tmp2 = SR20 + tmp1; \
984 SR20 = tmp1; \
985 tmp1 = SR21 + tmp2; \
986 SR21 = tmp2; \
987 tmp2 = SC[0] + tmp1; \
988 SC[0] = tmp1; \
989 tmp1 = SC[1] + tmp2; \
990 SC[1] = tmp2; \
991 tmp2 = SC[2] + tmp1; \
992 SC[2] = tmp1; \
993 tmp1 = SC[3] + tmp2; \
994 SC[3] = tmp2; \
995 tmp2 = SC[4] + tmp1; \
996 SC[4] = tmp1; \
997 tmp1 = SC[5] + tmp2; \
998 SC[5] = tmp2; \
999 tmp2 = SC[6] + tmp1; \
1000 SC[6] = tmp1; \
1001 tmp1 = SC[7] + tmp2; \
1002 SC[7] = tmp2; \
1003 tmp2 = SC[8] + tmp1; \
1004 SC[8] = tmp1; \
1005 tmp1 = SC[9] + tmp2; \
1006 SC[9] = tmp2; \
1007 tmp2 = SC[10] + tmp1; \
1008 SC[10] = tmp1; \
1009 tmp1 = SC[11] + tmp2; \
1010 SC[11] = tmp2; \
1011 tmp2 = SC[12] + tmp1; \
1012 SC[12] = tmp1; \
1013 tmp1 = SC[13] + tmp2; \
1014 SC[13] = tmp2; \
1015 tmp2 = SC[14] + tmp1; \
1016 SC[14] = tmp1; \
1017 tmp1 = SC[15] + tmp2; \
1018 SC[15] = tmp2; \
1019 tmp2 = SC[16] + tmp1; \
1020 SC[16] = tmp1; \
1021 tmp1 = SC[17] + tmp2; \
1022 SC[17] = tmp2; \
1023 tmp2 = SC[18] + tmp1; \
1024 SC[18] = tmp1; \
1025 tmp1 = SC[19] + tmp2; \
1026 SC[19] = tmp2; \
1027 tmp2 = SC[20] + tmp1; \
1028 SC[20] = tmp1; \
1029 if (j >= offset * 2) \
1030 if (out_row) out_row[j - offset * 2] = (((uint64_t)1 <<43) + SC[21] + tmp2) >> 44; \
1031 SC[21] = tmp2; \
1032 SC += 22;\
1036 delete [] SC0; \
1038 #define DO_FEATHER_25(type, int_type, max, N); \
1040 int offset = N / 2; \
1041 int frame_w = input->get_w(); \
1042 int frame_h = input->get_h(); \
1043 int start_in = start_out - offset; \
1044 int end_in = end_out + offset; \
1045 type **in_rows = (type**)input->get_rows(); \
1046 type **out_rows = (type**)output->get_rows(); \
1047 int i,j; \
1048 int_type tmp1, tmp2; \
1049 int_type SR0, SR1, SR2, SR3, SR4, SR5, SR6, SR7, SR8, SR9, SR10, SR11, SR12, SR13, SR14, SR15, SR16, SR17, SR18, SR19, SR20, SR21, SR22, SR23; \
1050 int_type *SC0 = new int_type[(frame_w + offset * 2) * 24]; \
1051 memset(SC0, 0, sizeof(int_type) * (frame_w + offset * 2) * 24); \
1052 for (i = start_in; i < end_in; i++) \
1054 type *in_row; \
1055 if (i < 0) \
1056 in_row = in_rows[0]; \
1057 else if (i >= frame_h) \
1058 in_row = in_rows[frame_h - 1]; \
1059 else \
1060 in_row = in_rows[i]; \
1061 SR0 = SR1 = SR2 = SR3 = SR4 = SR5 = SR6 = SR7 = SR8 = SR9 = SR10 = SR11 = SR12 = SR13 = SR14 = SR15 = SR16 = SR17 = SR18 = SR19 = SR20 = SR21 = SR22 = SR23 = 0; \
1063 type *out_row; \
1064 if (i >= start_out + offset && i<= end_out + offset) \
1065 out_row = out_rows[i - offset]; \
1066 else \
1067 out_row = 0; \
1068 int_type *SC = SC0; \
1069 for (j = 0; j < frame_w + offset * 2; j++) \
1071 if (j < offset) \
1072 tmp1 = in_row[0]; \
1073 else if (j >= frame_w + offset) \
1074 tmp1 = in_row[frame_w - 1]; \
1075 else \
1076 tmp1 = in_row[j - offset]; \
1077 tmp2 = SR0 + tmp1; \
1078 SR0 = tmp1; \
1079 tmp1 = SR1 + tmp2; \
1080 SR1 = tmp2; \
1081 tmp2 = SR2 + tmp1; \
1082 SR2 = tmp1; \
1083 tmp1 = SR3 + tmp2; \
1084 SR3 = tmp2; \
1085 tmp2 = SR4 + tmp1; \
1086 SR4 = tmp1; \
1087 tmp1 = SR5 + tmp2; \
1088 SR5 = tmp2; \
1089 tmp2 = SR6 + tmp1; \
1090 SR6 = tmp1; \
1091 tmp1 = SR7 + tmp2; \
1092 SR7 = tmp2; \
1093 tmp2 = SR8 + tmp1; \
1094 SR8 = tmp1; \
1095 tmp1 = SR9 + tmp2; \
1096 SR9 = tmp2; \
1097 tmp2 = SR10 + tmp1; \
1098 SR10 = tmp1; \
1099 tmp1 = SR11 + tmp2; \
1100 SR11 = tmp2; \
1101 tmp2 = SR12 + tmp1; \
1102 SR12 = tmp1; \
1103 tmp1 = SR13 + tmp2; \
1104 SR13 = tmp2; \
1105 tmp2 = SR14 + tmp1; \
1106 SR14 = tmp1; \
1107 tmp1 = SR15 + tmp2; \
1108 SR15 = tmp2; \
1109 tmp2 = SR16 + tmp1; \
1110 SR16 = tmp1; \
1111 tmp1 = SR17 + tmp2; \
1112 SR17 = tmp2; \
1113 tmp2 = SR18 + tmp1; \
1114 SR18 = tmp1; \
1115 tmp1 = SR19 + tmp2; \
1116 SR19 = tmp2; \
1117 tmp2 = SR20 + tmp1; \
1118 SR20 = tmp1; \
1119 tmp1 = SR21 + tmp2; \
1120 SR21 = tmp2; \
1121 tmp2 = SR22 + tmp1; \
1122 SR22 = tmp1; \
1123 tmp1 = SR23 + tmp2; \
1124 SR23 = tmp2; \
1125 tmp2 = SC[0] + tmp1; \
1126 SC[0] = tmp1; \
1127 tmp1 = SC[1] + tmp2; \
1128 SC[1] = tmp2; \
1129 tmp2 = SC[2] + tmp1; \
1130 SC[2] = tmp1; \
1131 tmp1 = SC[3] + tmp2; \
1132 SC[3] = tmp2; \
1133 tmp2 = SC[4] + tmp1; \
1134 SC[4] = tmp1; \
1135 tmp1 = SC[5] + tmp2; \
1136 SC[5] = tmp2; \
1137 tmp2 = SC[6] + tmp1; \
1138 SC[6] = tmp1; \
1139 tmp1 = SC[7] + tmp2; \
1140 SC[7] = tmp2; \
1141 tmp2 = SC[8] + tmp1; \
1142 SC[8] = tmp1; \
1143 tmp1 = SC[9] + tmp2; \
1144 SC[9] = tmp2; \
1145 tmp2 = SC[10] + tmp1; \
1146 SC[10] = tmp1; \
1147 tmp1 = SC[11] + tmp2; \
1148 SC[11] = tmp2; \
1149 tmp2 = SC[12] + tmp1; \
1150 SC[12] = tmp1; \
1151 tmp1 = SC[13] + tmp2; \
1152 SC[13] = tmp2; \
1153 tmp2 = SC[14] + tmp1; \
1154 SC[14] = tmp1; \
1155 tmp1 = SC[15] + tmp2; \
1156 SC[15] = tmp2; \
1157 tmp2 = SC[16] + tmp1; \
1158 SC[16] = tmp1; \
1159 tmp1 = SC[17] + tmp2; \
1160 SC[17] = tmp2; \
1161 tmp2 = SC[18] + tmp1; \
1162 SC[18] = tmp1; \
1163 tmp1 = SC[19] + tmp2; \
1164 SC[19] = tmp2; \
1165 tmp2 = SC[20] + tmp1; \
1166 SC[20] = tmp1; \
1167 tmp1 = SC[21] + tmp2; \
1168 SC[21] = tmp2; \
1169 tmp2 = SC[22] + tmp1; \
1170 SC[22] = tmp1; \
1171 if (j >= offset * 2) \
1172 if (out_row) out_row[j - offset * 2] = (((uint64_t)1 <<47) + SC[23] + tmp2) >> 48; \
1173 SC[23] = tmp2; \
1174 SC += 24;\
1178 delete [] SC0; \
1180 #define DO_FEATHER_27(type, int_type, max, N); \
1182 int offset = N / 2; \
1183 int frame_w = input->get_w(); \
1184 int frame_h = input->get_h(); \
1185 int start_in = start_out - offset; \
1186 int end_in = end_out + offset; \
1187 type **in_rows = (type**)input->get_rows(); \
1188 type **out_rows = (type**)output->get_rows(); \
1189 int i,j; \
1190 int_type tmp1, tmp2; \
1191 int_type SR0, SR1, SR2, SR3, SR4, SR5, SR6, SR7, SR8, SR9, SR10, SR11, SR12, SR13, SR14, SR15, SR16, SR17, SR18, SR19, SR20, SR21, SR22, SR23, SR24, SR25; \
1192 int_type *SC0 = new int_type[(frame_w + offset * 2) * 26]; \
1193 memset(SC0, 0, sizeof(int_type) * (frame_w + offset * 2) * 26); \
1194 for (i = start_in; i < end_in; i++) \
1196 type *in_row; \
1197 if (i < 0) \
1198 in_row = in_rows[0]; \
1199 else if (i >= frame_h) \
1200 in_row = in_rows[frame_h - 1]; \
1201 else \
1202 in_row = in_rows[i]; \
1203 SR0 = SR1 = SR2 = SR3 = SR4 = SR5 = SR6 = SR7 = SR8 = SR9 = SR10 = SR11 = SR12 = SR13 = SR14 = SR15 = SR16 = SR17 = SR18 = SR19 = SR20 = SR21 = SR22 = SR23 = SR24 = SR25 = 0; \
1205 type *out_row; \
1206 if (i >= start_out + offset && i<= end_out + offset) \
1207 out_row = out_rows[i - offset]; \
1208 else \
1209 out_row = 0; \
1210 int_type *SC = SC0; \
1211 for (j = 0; j < frame_w + offset * 2; j++) \
1213 if (j < offset) \
1214 tmp1 = in_row[0]; \
1215 else if (j >= frame_w + offset) \
1216 tmp1 = in_row[frame_w - 1]; \
1217 else \
1218 tmp1 = in_row[j - offset]; \
1219 tmp2 = SR0 + tmp1; \
1220 SR0 = tmp1; \
1221 tmp1 = SR1 + tmp2; \
1222 SR1 = tmp2; \
1223 tmp2 = SR2 + tmp1; \
1224 SR2 = tmp1; \
1225 tmp1 = SR3 + tmp2; \
1226 SR3 = tmp2; \
1227 tmp2 = SR4 + tmp1; \
1228 SR4 = tmp1; \
1229 tmp1 = SR5 + tmp2; \
1230 SR5 = tmp2; \
1231 tmp2 = SR6 + tmp1; \
1232 SR6 = tmp1; \
1233 tmp1 = SR7 + tmp2; \
1234 SR7 = tmp2; \
1235 tmp2 = SR8 + tmp1; \
1236 SR8 = tmp1; \
1237 tmp1 = SR9 + tmp2; \
1238 SR9 = tmp2; \
1239 tmp2 = SR10 + tmp1; \
1240 SR10 = tmp1; \
1241 tmp1 = SR11 + tmp2; \
1242 SR11 = tmp2; \
1243 tmp2 = SR12 + tmp1; \
1244 SR12 = tmp1; \
1245 tmp1 = SR13 + tmp2; \
1246 SR13 = tmp2; \
1247 tmp2 = SR14 + tmp1; \
1248 SR14 = tmp1; \
1249 tmp1 = SR15 + tmp2; \
1250 SR15 = tmp2; \
1251 tmp2 = SR16 + tmp1; \
1252 SR16 = tmp1; \
1253 tmp1 = SR17 + tmp2; \
1254 SR17 = tmp2; \
1255 tmp2 = SR18 + tmp1; \
1256 SR18 = tmp1; \
1257 tmp1 = SR19 + tmp2; \
1258 SR19 = tmp2; \
1259 tmp2 = SR20 + tmp1; \
1260 SR20 = tmp1; \
1261 tmp1 = SR21 + tmp2; \
1262 SR21 = tmp2; \
1263 tmp2 = SR22 + tmp1; \
1264 SR22 = tmp1; \
1265 tmp1 = SR23 + tmp2; \
1266 SR23 = tmp2; \
1267 tmp2 = SR24 + tmp1; \
1268 SR24 = tmp1; \
1269 tmp1 = SR25 + tmp2; \
1270 SR25 = tmp2; \
1271 tmp2 = SC[0] + tmp1; \
1272 SC[0] = tmp1; \
1273 tmp1 = SC[1] + tmp2; \
1274 SC[1] = tmp2; \
1275 tmp2 = SC[2] + tmp1; \
1276 SC[2] = tmp1; \
1277 tmp1 = SC[3] + tmp2; \
1278 SC[3] = tmp2; \
1279 tmp2 = SC[4] + tmp1; \
1280 SC[4] = tmp1; \
1281 tmp1 = SC[5] + tmp2; \
1282 SC[5] = tmp2; \
1283 tmp2 = SC[6] + tmp1; \
1284 SC[6] = tmp1; \
1285 tmp1 = SC[7] + tmp2; \
1286 SC[7] = tmp2; \
1287 tmp2 = SC[8] + tmp1; \
1288 SC[8] = tmp1; \
1289 tmp1 = SC[9] + tmp2; \
1290 SC[9] = tmp2; \
1291 tmp2 = SC[10] + tmp1; \
1292 SC[10] = tmp1; \
1293 tmp1 = SC[11] + tmp2; \
1294 SC[11] = tmp2; \
1295 tmp2 = SC[12] + tmp1; \
1296 SC[12] = tmp1; \
1297 tmp1 = SC[13] + tmp2; \
1298 SC[13] = tmp2; \
1299 tmp2 = SC[14] + tmp1; \
1300 SC[14] = tmp1; \
1301 tmp1 = SC[15] + tmp2; \
1302 SC[15] = tmp2; \
1303 tmp2 = SC[16] + tmp1; \
1304 SC[16] = tmp1; \
1305 tmp1 = SC[17] + tmp2; \
1306 SC[17] = tmp2; \
1307 tmp2 = SC[18] + tmp1; \
1308 SC[18] = tmp1; \
1309 tmp1 = SC[19] + tmp2; \
1310 SC[19] = tmp2; \
1311 tmp2 = SC[20] + tmp1; \
1312 SC[20] = tmp1; \
1313 tmp1 = SC[21] + tmp2; \
1314 SC[21] = tmp2; \
1315 tmp2 = SC[22] + tmp1; \
1316 SC[22] = tmp1; \
1317 tmp1 = SC[23] + tmp2; \
1318 SC[23] = tmp2; \
1319 tmp2 = SC[24] + tmp1; \
1320 SC[24] = tmp1; \
1321 if (j >= offset * 2) \
1322 if (out_row) out_row[j - offset * 2] = (((uint64_t)1 <<51) + SC[25] + tmp2) >> 52; \
1323 SC[25] = tmp2; \
1324 SC += 26;\
1328 delete [] SC0; \
1330 #define DO_FEATHER_29(type, int_type, max, N); \
1332 int offset = N / 2; \
1333 int frame_w = input->get_w(); \
1334 int frame_h = input->get_h(); \
1335 int start_in = start_out - offset; \
1336 int end_in = end_out + offset; \
1337 type **in_rows = (type**)input->get_rows(); \
1338 type **out_rows = (type**)output->get_rows(); \
1339 int i,j; \
1340 int_type tmp1, tmp2; \
1341 int_type SR0, SR1, SR2, SR3, SR4, SR5, SR6, SR7, SR8, SR9, SR10, SR11, SR12, SR13, SR14, SR15, SR16, SR17, SR18, SR19, SR20, SR21, SR22, SR23, SR24, SR25, SR26, SR27; \
1342 int_type *SC0 = new int_type[(frame_w + offset * 2) * 28]; \
1343 memset(SC0, 0, sizeof(int_type) * (frame_w + offset * 2) * 28); \
1344 for (i = start_in; i < end_in; i++) \
1346 type *in_row; \
1347 if (i < 0) \
1348 in_row = in_rows[0]; \
1349 else if (i >= frame_h) \
1350 in_row = in_rows[frame_h - 1]; \
1351 else \
1352 in_row = in_rows[i]; \
1353 SR0 = SR1 = SR2 = SR3 = SR4 = SR5 = SR6 = SR7 = SR8 = SR9 = SR10 = SR11 = SR12 = SR13 = SR14 = SR15 = SR16 = SR17 = SR18 = SR19 = SR20 = SR21 = SR22 = SR23 = SR24 = SR25 = SR26 = SR27 = 0; \
1355 type *out_row; \
1356 if (i >= start_out + offset && i<= end_out + offset) \
1357 out_row = out_rows[i - offset]; \
1358 else \
1359 out_row = 0; \
1360 int_type *SC = SC0; \
1361 for (j = 0; j < frame_w + offset * 2; j++) \
1363 if (j < offset) \
1364 tmp1 = in_row[0]; \
1365 else if (j >= frame_w + offset) \
1366 tmp1 = in_row[frame_w - 1]; \
1367 else \
1368 tmp1 = in_row[j - offset]; \
1369 tmp2 = SR0 + tmp1; \
1370 SR0 = tmp1; \
1371 tmp1 = SR1 + tmp2; \
1372 SR1 = tmp2; \
1373 tmp2 = SR2 + tmp1; \
1374 SR2 = tmp1; \
1375 tmp1 = SR3 + tmp2; \
1376 SR3 = tmp2; \
1377 tmp2 = SR4 + tmp1; \
1378 SR4 = tmp1; \
1379 tmp1 = SR5 + tmp2; \
1380 SR5 = tmp2; \
1381 tmp2 = SR6 + tmp1; \
1382 SR6 = tmp1; \
1383 tmp1 = SR7 + tmp2; \
1384 SR7 = tmp2; \
1385 tmp2 = SR8 + tmp1; \
1386 SR8 = tmp1; \
1387 tmp1 = SR9 + tmp2; \
1388 SR9 = tmp2; \
1389 tmp2 = SR10 + tmp1; \
1390 SR10 = tmp1; \
1391 tmp1 = SR11 + tmp2; \
1392 SR11 = tmp2; \
1393 tmp2 = SR12 + tmp1; \
1394 SR12 = tmp1; \
1395 tmp1 = SR13 + tmp2; \
1396 SR13 = tmp2; \
1397 tmp2 = SR14 + tmp1; \
1398 SR14 = tmp1; \
1399 tmp1 = SR15 + tmp2; \
1400 SR15 = tmp2; \
1401 tmp2 = SR16 + tmp1; \
1402 SR16 = tmp1; \
1403 tmp1 = SR17 + tmp2; \
1404 SR17 = tmp2; \
1405 tmp2 = SR18 + tmp1; \
1406 SR18 = tmp1; \
1407 tmp1 = SR19 + tmp2; \
1408 SR19 = tmp2; \
1409 tmp2 = SR20 + tmp1; \
1410 SR20 = tmp1; \
1411 tmp1 = SR21 + tmp2; \
1412 SR21 = tmp2; \
1413 tmp2 = SR22 + tmp1; \
1414 SR22 = tmp1; \
1415 tmp1 = SR23 + tmp2; \
1416 SR23 = tmp2; \
1417 tmp2 = SR24 + tmp1; \
1418 SR24 = tmp1; \
1419 tmp1 = SR25 + tmp2; \
1420 SR25 = tmp2; \
1421 tmp2 = SR26 + tmp1; \
1422 SR26 = tmp1; \
1423 tmp1 = SR27 + tmp2; \
1424 SR27 = tmp2; \
1425 tmp2 = SC[0] + tmp1; \
1426 SC[0] = tmp1; \
1427 tmp1 = SC[1] + tmp2; \
1428 SC[1] = tmp2; \
1429 tmp2 = SC[2] + tmp1; \
1430 SC[2] = tmp1; \
1431 tmp1 = SC[3] + tmp2; \
1432 SC[3] = tmp2; \
1433 tmp2 = SC[4] + tmp1; \
1434 SC[4] = tmp1; \
1435 tmp1 = SC[5] + tmp2; \
1436 SC[5] = tmp2; \
1437 tmp2 = SC[6] + tmp1; \
1438 SC[6] = tmp1; \
1439 tmp1 = SC[7] + tmp2; \
1440 SC[7] = tmp2; \
1441 tmp2 = SC[8] + tmp1; \
1442 SC[8] = tmp1; \
1443 tmp1 = SC[9] + tmp2; \
1444 SC[9] = tmp2; \
1445 tmp2 = SC[10] + tmp1; \
1446 SC[10] = tmp1; \
1447 tmp1 = SC[11] + tmp2; \
1448 SC[11] = tmp2; \
1449 tmp2 = SC[12] + tmp1; \
1450 SC[12] = tmp1; \
1451 tmp1 = SC[13] + tmp2; \
1452 SC[13] = tmp2; \
1453 tmp2 = SC[14] + tmp1; \
1454 SC[14] = tmp1; \
1455 tmp1 = SC[15] + tmp2; \
1456 SC[15] = tmp2; \
1457 tmp2 = SC[16] + tmp1; \
1458 SC[16] = tmp1; \
1459 tmp1 = SC[17] + tmp2; \
1460 SC[17] = tmp2; \
1461 tmp2 = SC[18] + tmp1; \
1462 SC[18] = tmp1; \
1463 tmp1 = SC[19] + tmp2; \
1464 SC[19] = tmp2; \
1465 tmp2 = SC[20] + tmp1; \
1466 SC[20] = tmp1; \
1467 tmp1 = SC[21] + tmp2; \
1468 SC[21] = tmp2; \
1469 tmp2 = SC[22] + tmp1; \
1470 SC[22] = tmp1; \
1471 tmp1 = SC[23] + tmp2; \
1472 SC[23] = tmp2; \
1473 tmp2 = SC[24] + tmp1; \
1474 SC[24] = tmp1; \
1475 tmp1 = SC[25] + tmp2; \
1476 SC[25] = tmp2; \
1477 tmp2 = SC[26] + tmp1; \
1478 SC[26] = tmp1; \
1479 if (j >= offset * 2) \
1480 if (out_row) out_row[j - offset * 2] = (((uint64_t)1 <<55) + SC[27] + tmp2) >> 56; \
1481 SC[27] = tmp2; \
1482 SC += 28;\
1486 delete [] SC0; \
1489 /* THIS WORKS ONLY FOR ODD N >= 3 */
1490 #define DO_FEATHER_N(type, int_type, max, N) \
1492 switch(input->get_color_model()) \
1494 case BC_A8: \
1495 switch (N) \
1497 case 3: \
1498 DO_FEATHER_3(unsigned char, uint16_t, max, 3); \
1499 return 1; \
1500 break; \
1501 case 5: \
1502 DO_FEATHER_5(unsigned char, uint16_t, max, 5); \
1503 return 1; \
1504 break; \
1505 case 7: \
1506 DO_FEATHER_7(unsigned char, uint32_t, max, 7); \
1507 return 1; \
1508 break; \
1509 case 9: \
1510 DO_FEATHER_9(unsigned char, uint32_t, max, 9); \
1511 return 1; \
1512 break; \
1513 case 11: \
1514 DO_FEATHER_11(unsigned char, uint32_t, max, 11); \
1515 return 1; \
1516 break; \
1517 case 13: \
1518 DO_FEATHER_13(unsigned char, uint32_t, max, 13); \
1519 return 1; \
1520 break; \
1521 case 15: \
1522 DO_FEATHER_15(unsigned char, uint64_t, max, 15); \
1523 return 1; \
1524 break; \
1525 case 17: \
1526 DO_FEATHER_17(unsigned char, uint64_t, max, 17); \
1527 return 1; \
1528 break; \
1529 case 19: \
1530 DO_FEATHER_19(unsigned char, uint64_t, max, 19); \
1531 return 1; \
1532 break; \
1533 case 21: \
1534 DO_FEATHER_21(unsigned char, uint64_t, max, 21); \
1535 return 1; \
1536 break; \
1537 case 23: \
1538 DO_FEATHER_23(unsigned char, uint64_t, max, 23); \
1539 return 1; \
1540 break; \
1541 case 25: \
1542 DO_FEATHER_25(unsigned char, uint64_t, max, 25); \
1543 return 1; \
1544 break; \
1545 case 27: \
1546 DO_FEATHER_27(unsigned char, uint64_t, max, 27); \
1547 return 1; \
1548 break; \
1549 case 29: \
1550 DO_FEATHER_29(unsigned char, uint64_t, max, 29); \
1551 return 1; \
1552 break; \
1553 default: \
1554 return 0; \
1556 case BC_A16: \
1557 switch (N) \
1559 case 3: \
1560 DO_FEATHER_3(uint16_t, uint32_t, max, 3); \
1561 return 1; \
1562 break; \
1563 case 5: \
1564 DO_FEATHER_5(uint16_t, uint32_t, max, 5); \
1565 return 1; \
1566 break; \
1567 case 7: \
1568 DO_FEATHER_7(uint16_t, uint32_t, max, 7); \
1569 return 1; \
1570 break; \
1571 case 9: \
1572 DO_FEATHER_9(uint16_t, uint32_t, max, 9); \
1573 return 1; \
1574 break; \
1575 case 11: \
1576 DO_FEATHER_11(uint16_t, uint64_t, max, 11); \
1577 return 1; \
1578 break; \
1579 case 13: \
1580 DO_FEATHER_13(uint16_t, uint64_t, max, 13); \
1581 return 1; \
1582 break; \
1583 case 15: \
1584 DO_FEATHER_15(uint16_t, uint64_t, max, 15); \
1585 return 1; \
1586 break; \
1587 case 17: \
1588 DO_FEATHER_17(uint16_t, uint64_t, max, 17); \
1589 return 1; \
1590 break; \
1591 case 19: \
1592 DO_FEATHER_19(uint16_t, uint64_t, max, 19); \
1593 return 1; \
1594 break; \
1595 case 21: \
1596 DO_FEATHER_21(uint16_t, uint64_t, max, 21); \
1597 return 1; \
1598 break; \
1599 case 23: \
1600 DO_FEATHER_23(uint16_t, uint64_t, max, 23); \
1601 return 1; \
1602 break; \
1603 case 25: \
1604 DO_FEATHER_25(uint16_t, uint64_t, max, 25); \
1605 return 1; \
1606 break; \
1607 default: \
1608 return 0; \
1611 return 0; \