2 * This program is free software; you can redistribute it and/or modify it
3 * under the terms of the GNU General Public License as published
4 * by the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
7 * This program is distributed in the hope that it will be useful, but
8 * WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10 * General Public License for more details.
12 * You should have received a copy of the GNU General Public
13 * License along with this program; if not, write to the Free Software
14 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19 #ifndef __OVERLAYSAMPLE_H__
20 #define __OVERLAYSAMPLE_H__
21 #include "overlayframe.h"
23 #define XSAMPLE(FN, temp_type, type, max, components, ofs, round) { \
24 float temp[oh*components]; \
25 temp_type opcty = fade * max + round, trnsp = max - opcty; \
26 type **output_rows = (type**)voutput->get_rows() + o1i; \
27 type **input_rows = (type**)vinput->get_rows(); \
29 for(int i = pkg->out_col1; i < pkg->out_col2; i++) { \
30 type *input = input_rows[i - engine->col_out1 + engine->row_in]; \
31 float *tempp = temp; \
32 if( !k ) { /* direct copy case */ \
33 type *ip = input + i1i * components; \
34 for( int j=oh; --j>=0; ) { \
36 *tempp++ = *ip++ - ofs; \
37 *tempp++ = *ip++ - ofs; \
38 if( components == 4 ) *tempp++ = *ip++; \
41 else { /* resample */ \
42 for( int j=0; j<oh; ++j ) { \
43 float racc=0.f, gacc=0.f, bacc=0.f, aacc=0.f; \
44 int ki = lookup_sk[j], x = lookup_sx0[j]; \
45 type *ip = input + x * components; \
46 while(x < lookup_sx1[j]) { \
47 float kv = k[abs(ki >> INDEX_FRACTION)]; \
48 /* handle fractional pixels on edges of input */ \
49 if(x == i1i) kv *= i1f; \
50 if(++x == i2i) kv *= i2f; \
52 gacc += kv * (*ip++ - ofs); \
53 bacc += kv * (*ip++ - ofs); \
54 if( components == 4 ) { aacc += kv * *ip++; } \
57 float wacc = lookup_wacc[j]; \
58 *tempp++ = racc * wacc; \
59 *tempp++ = gacc * wacc; \
60 *tempp++ = bacc * wacc; \
61 if( components == 4 ) { *tempp++ = aacc * wacc; } \
65 /* handle fractional pixels on edges of output */ \
66 temp[0] *= o1f; temp[1] *= o1f; temp[2] *= o1f; \
67 if( components == 4 ) temp[3] *= o1f; \
68 tempp = temp + (oh-1)*components; \
69 tempp[0] *= o2f; tempp[1] *= o2f; tempp[2] *= o2f; \
70 if( components == 4 ) tempp[3] *= o2f; \
73 for( int j=0; j<oh; ++j ) { \
74 type *output = output_rows[j] + i * components; \
75 if( components == 4 ) { \
76 temp_type r, g, b, a; \
77 ALPHA4_BLEND(FN, temp_type, tempp, output, max, 0, ofs, round); \
78 ALPHA4_STORE(output, ofs, max); \
82 ALPHA3_BLEND(FN, temp_type, tempp, output, max, 0, ofs, round); \
83 ALPHA3_STORE(output, ofs, max); \
85 tempp += components; \