X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=documentation%2Fwarp__perspective_8cl_source.xhtml;h=d7e0ef53995d30409892ef83d28c940cee9ed5b1;hb=b3a371bc429d2ba45e56baaf239d8200c2662a74;hp=530968de6f778797b8016273ea73ee712cdbe67b;hpb=46d5927c3461ec270de8b0fc087ac5dc2431488f;p=platform%2Fupstream%2Farmcl.git diff --git a/documentation/warp__perspective_8cl_source.xhtml b/documentation/warp__perspective_8cl_source.xhtml index 530968d..d7e0ef5 100644 --- a/documentation/warp__perspective_8cl_source.xhtml +++ b/documentation/warp__perspective_8cl_source.xhtml @@ -6,7 +6,7 @@ -ARM Compute Library: src/core/CL/cl_kernels/warp_perspective.cl Source File +Compute Library: src/core/CL/cl_kernels/warp_perspective.cl Source File @@ -39,8 +39,8 @@ -
ARM Compute Library -  17.05 +
Compute Library +  18.05
@@ -55,6 +55,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
-Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016, 2017 ARM Limited.
3  *
4  * SPDX-License-Identifier: MIT
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to
8  * deal in the Software without restriction, including without limitation the
9  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10  * sell copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in all
14  * copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22  * SOFTWARE.
23  */
24 #include "helpers.h"
25 #include "warp_helpers.h"
26 
28 inline const float16 build_perspective_mtx()
29 {
30  return (float16)(MAT0, MAT1, MAT2, MAT3, MAT4, MAT5, MAT6, MAT7, MAT8, 0, 0, 0, (float4)0);
31 }
32 
46 inline const float8 apply_perspective_transform(const float2 coord, const float16 mtx)
47 {
48  const float4 in_x_coords = (float4)(coord.s0, 1 + coord.s0, 2 + coord.s0, 3 + coord.s0);
49  // transform [z,z+1,z+2,z+3]
50  const float4 z = (float4)mad(in_x_coords, (float4)(mtx.s2), mad((float4)(coord.s1), (float4)(mtx.s5), (float4)(mtx.s8)));
51  // NOTE: Do not multiply x&y by 1.f/Z as this will result in loss of accuracy and mismatches with VX reference implementation
52  // transform [x,x+1,x+2,x+3]
53  const float4 new_x = (float4)mad(in_x_coords, (float4)(mtx.s0), mad((float4)(coord.s1), (float4)(mtx.s3), (float4)(mtx.s6))) / z;
54  // transform [y,y+1,y+2,y+3]
55  const float4 new_y = (float4)mad(in_x_coords, (float4)(mtx.s1), mad((float4)(coord.s1), (float4)(mtx.s4), (float4)(mtx.s7))) / z;
56  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);
57 }
58 
89  IMAGE_DECLARATION(out),
90  const int width,
91  const int height)
92 {
94  Image out = CONVERT_TO_IMAGE_STRUCT(out);
95  vstore4(read_texels4(&in, convert_int8(clamp_to_border(apply_perspective_transform(get_current_coords(), build_perspective_mtx()), width, height))), 0, out.ptr);
96 }
97 
120  IMAGE_DECLARATION(in),
121  IMAGE_DECLARATION(out),
122  const int width,
123  const int height)
124 {
126  Image out = CONVERT_TO_IMAGE_STRUCT(out);
127  vstore4(bilinear_interpolate(&in, clamp_to_border(apply_perspective_transform(get_current_coords(), build_perspective_mtx()), width, height), width, height), 0, out.ptr);
128 }
const float8 clamp_to_border(float8 coords, const float width, const float height)
Clamps the given coordinates to the borders.
Definition: warp_helpers.h:33
-
#define CONVERT_TO_IMAGE_STRUCT_NO_STEP(name)
Definition: helpers.h:76
+Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016, 2017 ARM Limited.
3  *
4  * SPDX-License-Identifier: MIT
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to
8  * deal in the Software without restriction, including without limitation the
9  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10  * sell copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in all
14  * copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22  * SOFTWARE.
23  */
24 #include "helpers.h"
25 #include "warp_helpers.h"
26 
28 inline const float16 build_perspective_mtx()
29 {
30  return (float16)(MAT0, MAT1, MAT2, MAT3, MAT4, MAT5, MAT6, MAT7, MAT8, 0, 0, 0, (float4)0);
31 }
32 
46 inline const float8 apply_perspective_transform(const float2 coord, const float16 mtx)
47 {
48  const float4 in_x_coords = (float4)(coord.s0, 1 + coord.s0, 2 + coord.s0, 3 + coord.s0);
49  // transform [z,z+1,z+2,z+3]
50  const float4 z = (float4)mad(in_x_coords, (float4)(mtx.s2), mad((float4)(coord.s1), (float4)(mtx.s5), (float4)(mtx.s8)));
51  // NOTE: Do not multiply x&y by 1.f/Z as this will result in loss of accuracy and mismatches with VX reference implementation
52  // transform [x,x+1,x+2,x+3]
53  const float4 new_x = (float4)mad(in_x_coords, (float4)(mtx.s0), mad((float4)(coord.s1), (float4)(mtx.s3), (float4)(mtx.s6))) / z;
54  // transform [y,y+1,y+2,y+3]
55  const float4 new_y = (float4)mad(in_x_coords, (float4)(mtx.s1), mad((float4)(coord.s1), (float4)(mtx.s4), (float4)(mtx.s7))) / z;
56  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);
57 }
58 
89  IMAGE_DECLARATION(out),
90  const int width,
91  const int height)
92 {
94  Image out = CONVERT_TO_IMAGE_STRUCT(out);
95  vstore4(read_texels4(&in, convert_int8_rtn(clamp_to_border(apply_perspective_transform(get_current_coords(), build_perspective_mtx()), width, height))), 0, out.ptr);
96 }
97 
120  IMAGE_DECLARATION(in),
121  IMAGE_DECLARATION(out),
122  const int width,
123  const int height)
124 {
126  Image out = CONVERT_TO_IMAGE_STRUCT(out);
128 }
const float8 clamp_to_border(float8 coords, const float width, const float height)
Clamps the given coordinates to the borders.
Definition: warp_helpers.h:48
+
#define CONVERT_TO_IMAGE_STRUCT_NO_STEP(name)
Definition: helpers.h:107
const float8 apply_perspective_transform(const float2 coord, const float16 mtx)
Transforms four 2D coordinates using the formula:
-
#define IMAGE_DECLARATION(name)
Definition: helpers.h:49
+
#define IMAGE_DECLARATION(name)
Definition: helpers.h:68
-
#define CONVERT_TO_IMAGE_STRUCT(name)
Definition: helpers.h:73
+
#define CONVERT_TO_IMAGE_STRUCT(name)
Definition: helpers.h:104
const float16 build_perspective_mtx()
Returns the perspective matrix.
-
Structure to hold Image information.
Definition: helpers.h:95
-
__global uchar * ptr
Pointer to the starting postion of the buffer.
Definition: helpers.h:97
+
Structure to hold Image information.
Definition: helpers.h:142
+
__global uchar * ptr
Pointer to the starting postion of the buffer.
Definition: helpers.h:144
-
const DATA_TYPE4 read_texels4(const Image *in, const int8 coords)
Reads four texels from the input image.
Definition: warp_helpers.h:45
-
const float2 get_current_coords()
Returns the current thread coordinates.
Definition: warp_helpers.h:54
+
const DATA_TYPE4 read_texels4(const Image *in, const int8 coords)
Reads four texels from the input image.
Definition: warp_helpers.h:58
+
const float2 get_current_coords()
Returns the current thread coordinates.
Definition: warp_helpers.h:67
__kernel void warp_perspective_nearest_neighbour(__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 int width, const int height)
Performs perspective transformation on an image interpolating with the NEAREAST NEIGHBOUR method...
__kernel void warp_perspective_bilinear(__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 int width, const int height)
Performs a perspective transform on an image interpolating with the BILINEAR method.
-
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 ...
Definition: warp_helpers.h:80
+
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 ...
Definition: warp_helpers.h:135