1 #ifndef __OVERLAYSAMPLE_H__
2 #define __OVERLAYSAMPLE_H__
3 #include "overlayframe.h"
5 #define XSAMPLE(FN, temp_type, type, max, components, ofs, round) { \
6 float temp[oh*components]; \
7 temp_type opcty = fade * max + round, trnsp = max - opcty; \
8 type **output_rows = (type**)voutput->get_rows() + o1i; \
9 type **input_rows = (type**)vinput->get_rows(); \
11 for(int i = pkg->out_col1; i < pkg->out_col2; i++) { \
12 type *input = input_rows[i - engine->col_out1 + engine->row_in]; \
13 float *tempp = temp; \
14 if( !k ) { /* direct copy case */ \
15 type *ip = input + i1i * components; \
16 for( int j=oh; --j>=0; ) { \
18 *tempp++ = *ip++ - ofs; \
19 *tempp++ = *ip++ - ofs; \
20 if( components == 4 ) *tempp++ = *ip++; \
23 else { /* resample */ \
24 for( int j=0; j<oh; ++j ) { \
25 float racc=0.f, gacc=0.f, bacc=0.f, aacc=0.f; \
26 int ki = lookup_sk[j], x = lookup_sx0[j]; \
27 type *ip = input + x * components; \
28 while(x < lookup_sx1[j]) { \
29 float kv = k[abs(ki >> INDEX_FRACTION)]; \
30 /* handle fractional pixels on edges of input */ \
31 if(x == i1i) kv *= i1f; \
32 if(++x == i2i) kv *= i2f; \
34 gacc += kv * (*ip++ - ofs); \
35 bacc += kv * (*ip++ - ofs); \
36 if( components == 4 ) { aacc += kv * *ip++; } \
39 float wacc = lookup_wacc[j]; \
40 *tempp++ = racc * wacc; \
41 *tempp++ = gacc * wacc; \
42 *tempp++ = bacc * wacc; \
43 if( components == 4 ) { *tempp++ = aacc * wacc; } \
47 /* handle fractional pixels on edges of output */ \
48 temp[0] *= o1f; temp[1] *= o1f; temp[2] *= o1f; \
49 if( components == 4 ) temp[3] *= o1f; \
50 tempp = temp + (oh-1)*components; \
51 tempp[0] *= o2f; tempp[1] *= o2f; tempp[2] *= o2f; \
52 if( components == 4 ) tempp[3] *= o2f; \
55 for( int j=0; j<oh; ++j ) { \
56 type *output = output_rows[j] + i * components; \
57 if( components == 4 ) { \
58 temp_type r, g, b, a; \
59 ALPHA4_BLEND(FN, temp_type, tempp, output, max, 0, ofs, round); \
60 ALPHA4_STORE(output, ofs, max); \
64 ALPHA3_BLEND(FN, temp_type, tempp, output, max, 0, ofs, round); \
65 ALPHA3_STORE(output, ofs, max); \
67 tempp += components; \