- int x1 = tx1, x2 = tx2; \
- if( x1 < min_out_x ) x1 = min_out_x; \
- if( x2 > max_out_x ) x2 = max_out_x; \
- tx = xinc * x1 + m.values[0][1] * (y + pivot_offset_y) + m.values[0][2] \
- + pivot_offset_x * xinc; \
- ty = yinc * x1 + m.values[1][1] * (y + pivot_offset_y) + m.values[1][2] \
- + pivot_offset_x * yinc; \
- tw = winc * x1 + m.values[2][1] * (y + pivot_offset_y) + m.values[2][2] \
- + pivot_offset_x * winc; \
- type *out = out_row + x1 * comps; \
- for( int x=x1; x<x2; ++x ) { \
-/* Normalize homogeneous coords */ \
- if( tw == 0.0 ) { ttx = 0.0; tty = 0.0; } \
- else { ttx = tx / tw; tty = ty / tw; } \
- itx = (int)ttx; ity = (int)tty; \
-/* the fractional error */ \
- float dx = ttx - itx, dy = tty - ity; \
- if( dx < 0 ) dx += 1; \
- if( dy < 0 ) dy += 1; \
-/* row/col index */ \
- int cp = itx-1, c0 = itx+0, c1 = itx+1, c2 = itx+2; \
- int rp = ity-1, r0 = ity+0, r1 = ity+1, r2 = ity+2; \
- type *rpp, *r0p, *r1p, *r2p; \
- rpp = rp>=min_in_y && rp<max_in_y ? inp_rows[rp] : 0; \
- r0p = r0>=min_in_y && r0<max_in_y ? inp_rows[r0] : 0; \
- r1p = r1>=min_in_y && r1<max_in_y ? inp_rows[r1] : 0; \
- r2p = r2>=min_in_y && r2<max_in_y ? inp_rows[r2] : 0; \
- temp_type r, g, b, a; \
- r = (temp_type)(transform_cubic(dy, \
- CUBIC_ROW(rpp, 0x0), CUBIC_ROW(r0p, 0x0), \
- CUBIC_ROW(r1p, 0x0), CUBIC_ROW(r2p, 0x0)) \
- + round_factor); \
- if(rpp) ++rpp; if(r0p) ++r0p; if(r1p) ++r1p; if(r2p) ++r2p; \
- g = (temp_type)(transform_cubic(dy, \
- CUBIC_ROW(rpp, chroma_offset), CUBIC_ROW(r0p, chroma_offset), \
- CUBIC_ROW(r1p, chroma_offset), CUBIC_ROW(r2p, chroma_offset)) \
- + round_factor) + chroma_offset; \
- if(rpp) ++rpp; if(r0p) ++r0p; if(r1p) ++r1p; if(r2p) ++r2p; \
- b = (temp_type)(transform_cubic(dy, \
- CUBIC_ROW(rpp, chroma_offset), CUBIC_ROW(r0p, chroma_offset), \
- CUBIC_ROW(r1p, chroma_offset), CUBIC_ROW(r2p, chroma_offset)) \
- + round_factor) + chroma_offset; \
- if( components == 4 ) { \
- if(rpp) ++rpp; if(r0p) ++r0p; if(r1p) ++r1p; if(r2p) ++r2p; \
- a = (temp_type)(transform_cubic(dy, \
- CUBIC_ROW(rpp, 0x0), CUBIC_ROW(r0p, 0x0), \
- CUBIC_ROW(r1p, 0x0), CUBIC_ROW(r2p, 0x0)) \
- + round_factor); \
- } \
- if( sizeof(type) < 4 ) { \
- *out++ = CLIP(r, 0, max); \
- *out++ = CLIP(g, 0, max); \
- *out++ = CLIP(b, 0, max); \
- if( components == 4 ) *out++ = CLIP(a, 0, max); \
- } \
- else { \
- *out++ = r; \
- *out++ = g; \
- *out++ = b; \
- if( components == 4 ) *out++ = a; \
- } \
- \
-/* increment the transformed coordinates */ \
- tx += xinc; ty += yinc; tw += winc; \
- } \
- } \
-} break
-
-#define LINEAR_ROW(in_row, chroma_offset) ( !in_row ? 0 : transform_linear(dx, \
- c0>=min_in_x && c0<max_in_x ? in_row[c0*comps]-chroma_offset : 0, \
- c1>=min_in_x && c1<max_in_x ? in_row[c1*comps]-chroma_offset : 0) )
-
-#define DO_LINEAR(tag, components, type, temp_type, chroma_offset, max) \
-case tag: { \
- type **inp_rows = (type**)server->input->get_rows(); \
- type **out_rows = (type**)server->output->get_rows(); \
- int comps = components; \
- float round_factor = sizeof(type) < 4 ? 0.5 : 0; \