36 #ifdef SAMPLING_POLICY_TOP_LEFT 37 const float4 in_x_coords = (float4)(coord.s0, 1 + coord.s0, 2 + coord.s0, 3 + coord.s0);
38 const float4 new_x = in_x_coords * (float4)(scale.s0);
39 const float4 new_y = (float4)(coord.s1 * scale.s1);
40 return (float8)(new_x.s0, new_y.s0, new_x.s1, new_y.s1, new_x.s2, new_y.s2, new_x.s3, new_y.s3);
41 #elif SAMPLING_POLICY_CENTER 42 const float4 in_x_coords = (float4)(coord.s0, 1 + coord.s0, 2 + coord.s0, 3 + coord.s0);
43 const float4 new_x = (in_x_coords + ((float4)(0.5f))) * (float4)(scale.s0);
44 const float4 new_y = (float4)((coord.s1 + 0.5f) * scale.s1);
45 return (float8)(new_x.s0, new_y.s0, new_x.s1, new_y.s1, new_x.s2, new_y.s2, new_x.s3, new_y.s3);
47 #error("Unsupported sampling policy"); 60 const float4 in_x_coords = (float4)(coord.s0, 1 + coord.s0, 2 + coord.s0, 3 + coord.s0);
61 #ifdef SAMPLING_POLICY_TOP_LEFT 62 const float4 new_x = in_x_coords * (float4)(scale.s0);
63 const float4 new_y = (float4)(coord.s1 * scale.s1);
64 return (float8)(new_x.s0, new_y.s0, new_x.s1, new_y.s1, new_x.s2, new_y.s2, new_x.s3, new_y.s3);
65 #elif SAMPLING_POLICY_CENTER 66 const float4 new_x = (in_x_coords + ((float4)(0.5f))) * (float4)(scale.s0) - (float4)(0.5f);
67 const float4 new_y = (float4)((coord.s1 + 0.5f) * scale.s1 - 0.5f);
68 return (float8)(new_x.s0, new_y.s0, new_x.s1, new_y.s1, new_x.s2, new_y.s2, new_x.s3, new_y.s3);
70 #error("Unsupported sampling policy"); 105 const float2 r = (float2)(scale_x, scale_y);
108 transformed =
round(transformed);
109 #endif // ALIGN_CORNERS 111 vstore4(
read_texels4(&in, convert_int8(tc)), 0, (__global DATA_TYPE *)out.
ptr);
145 const float2 r = (float2)(scale_x, scale_y);
#define CONVERT_TO_IMAGE_STRUCT(name)
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 ...
#define IMAGE_DECLARATION(name)
__kernel void scale_nearest_neighbour_nchw(__global uchar *in_ptr, uint in_stride_x, uint in_step_x, uint in_stride_y, uint in_step_y, uint in_offset_first_element_in_bytes, __global uchar *out_ptr, uint out_stride_x, uint out_step_x, uint out_stride_y, uint out_step_y, uint out_offset_first_element_in_bytes, const float input_width, const float input_height, const float scale_x, const float scale_y)
Performs an affine transformation on an image interpolating with the NEAREAST NEIGHBOUR method...
const float8 transform_bilinear(const float2 coord, const float2 scale)
Transforms four 2D coordinates.
const float8 transform_nearest(const float2 coord, const float2 scale)
Transforms four 2D coordinates.
#define CONVERT_TO_IMAGE_STRUCT_NO_STEP(name)
__kernel void scale_bilinear_nchw(__global uchar *in_ptr, uint in_stride_x, uint in_step_x, uint in_stride_y, uint in_step_y, uint in_offset_first_element_in_bytes, __global uchar *out_ptr, uint out_stride_x, uint out_step_x, uint out_stride_y, uint out_step_y, uint out_offset_first_element_in_bytes, const float input_width, const float input_height, const float scale_x, const float scale_y)
Performs an affine transformation on an image interpolating with the BILINEAR method.
Structure to hold Image information.
int round(float x, RoundingPolicy rounding_policy)
Return a rounded value of x.
__global uchar * ptr
Pointer to the starting postion of the buffer.
const size_t input_height
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 float2 get_current_coords()
Returns the current thread coordinates.