36 const float4 clamped_x =
clamp(coords.even, 0.0f - border_size, width - 1 + border_size);
37 const float4 clamped_y =
clamp(coords.odd, 0.0f - border_size, height - 1 + border_size);
38 return (float8)(clamped_x.s0, clamped_y.s0, clamped_x.s1, clamped_y.s1, clamped_x.s2, clamped_y.s2, clamped_x.s3, clamped_y.s3);
48 inline const float8
clamp_to_border(float8 coords,
const float width,
const float height)
60 return (
VEC_DATA_TYPE(DATA_TYPE, 4))(*((__global DATA_TYPE *)
offset(in, coords.s0, coords.s1)),
61 *((__global DATA_TYPE *)
offset(in, coords.s2, coords.s3)),
62 *((__global DATA_TYPE *)
offset(in, coords.s4, coords.s5)),
63 *((__global DATA_TYPE *)
offset(in, coords.s6, coords.s7)));
77 return (float8)( coord.s0, coord.s1, coord.s0 + 1, coord.s1, coord.s0, coord.s1 + 1, coord.s0 + 1, coord.s1 + 1);
93 const float8 fc = floor(coords);
94 const float16 c1 = (float16)(
97 const float16 c2 = (float16)(
102 const float16
t = (float16)(
104 * ((__global DATA_TYPE *)
offset(in, c1.s0, c1.s1)), *((__global DATA_TYPE *)
offset(in, c1.s2, c1.s3)),
105 *((__global DATA_TYPE *)
offset(in, c1.s4, c1.s5)), *((__global DATA_TYPE *)
offset(in, c1.s6, c1.s7)),
106 *((__global DATA_TYPE *)
offset(in, c1.s8, c1.s9)), *((__global DATA_TYPE *)
offset(in, c1.sa, c1.sb)),
107 *((__global DATA_TYPE *)
offset(in, c1.sc, c1.sd)), *((__global DATA_TYPE *)
offset(in, c1.se, c1.sf)),
108 *((__global DATA_TYPE *)
offset(in, c2.s0, c2.s1)), *((__global DATA_TYPE *)
offset(in, c2.s2, c2.s3)),
109 *((__global DATA_TYPE *)
offset(in, c2.s4, c2.s5)), *((__global DATA_TYPE *)
offset(in, c2.s6, c2.s7)),
110 *((__global DATA_TYPE *)
offset(in, c2.s8, c2.s9)), *((__global DATA_TYPE *)
offset(in, c2.sa, c2.sb)),
111 *((__global DATA_TYPE *)
offset(in, c2.sc, c2.sd)), *((__global DATA_TYPE *)
offset(in, c2.se, c2.sf)));
112 const float8 a = coords - fc;
113 const float8
b = ((float8)(1.f)) - a;
114 const float4 fr = (float4)(
115 ((t.s0 * b.s0 * b.s1) + (t.s1 * a.s0 * b.s1) + (t.s2 * b.s0 * a.s1) + (t.s3 * a.s0 * a.s1)),
116 ((t.s4 * b.s2 * b.s3) + (t.s5 * a.s2 * b.s3) + (t.s6 * b.s2 * a.s3) + (t.s7 * a.s2 * a.s3)),
117 ((t.s8 * b.s4 * b.s5) + (t.s9 * a.s4 * b.s5) + (t.sa * b.s4 * a.s5) + (t.sb * a.s4 * a.s5)),
118 ((t.sc * b.s6 * b.s7) + (t.sd * a.s6 * b.s7) + (t.se * b.s6 * a.s7) + (t.sf * a.s6 * a.s7)));
__global uchar * offset(const Image *img, int x, int y)
Get the pointer position of a Image.
const float8 clamp_to_border(float8 coords, const float width, const float height)
Clamps the given coordinates to the borders.
const DATA_TYPE4 bilinear_interpolate_with_border(const Image *in, const float8 coords, const float width, const float height, const float border_size)
Computes the bilinear interpolation for each set of coordinates in the vector coords and returns the ...
DataType clamp(const DataType &n, const DataType &lower=std::numeric_limits< RangeType >::lowest(), const DataType &upper=std::numeric_limits< RangeType >::max())
Performs clamping among a lower and upper value.
const float8 get_neighbour_coords(const float2 coord)
Given a texel coordinates this function will return the following array of coordinates: [ P...
Structure to hold Image information.
const DATA_TYPE4 read_texels4(const Image *in, const int8 coords)
Reads four texels from the input image.
const float8 clamp_to_border_with_size(float8 coords, const float width, const float height, const float border_size)
Clamps the given coordinates to the borders according to the border size.
const DATA_TYPE4 bilinear_interpolate(const Image *in, const float8 coords, const float width, const float height)
Computes the bilinear interpolation for each set of coordinates in the vector coords and returns the ...
#define VEC_DATA_TYPE(type, size)