2 // For Open Source Computer Vision Library
4 // Copyright (C) 2010-2012, Institute Of Software Chinese Academy Of Science, all rights reserved.
5 // Copyright (C) 2010-2012, Advanced Micro Devices, Inc., all rights reserved.
6 // Third party copyrights are property of their respective owners.
9 // Niko Li, newlife20080214@gmail.com
10 // Rock Li, Rock.li@amd.com
11 // Redistribution and use in source and binary forms, with or without modification,
12 // are permitted provided that the following conditions are met:
14 // * Redistribution's of source code must retain the above copyright notice,
15 // this list of conditions and the following disclaimer.
17 // * Redistribution's in binary form must reproduce the above copyright notice,
18 // this list of conditions and the following disclaimer in the documentation
19 // and/or other materials provided with the distribution.
21 // * The name of the copyright holders may not be used to endorse or promote products
22 // derived from this software without specific prior written permission.
24 // This software is provided by the copyright holders and contributors as is and
25 // any express or implied warranties, including, but not limited to, the implied
26 // warranties of merchantability and fitness for a particular purpose are disclaimed.
27 // In no event shall the Intel Corporation or contributors be liable for any direct,
28 // indirect, incidental, special, exemplary, or consequential damages
29 // (including, but not limited to, procurement of substitute goods or services;
30 // loss of use, data, or profits; or business interruption) however caused
31 // and on any theory of liability, whether in contract, strict liability,
32 // or tort (including negligence or otherwise) arising in any way out of
33 // the use of this software, even if advised of the possibility of such damage.
37 __kernel void LUT(__global const uchar * srcptr, int src_step, int src_offset,
38 __global const uchar * lutptr, int lut_step, int lut_offset,
39 __global uchar * dstptr, int dst_step, int dst_offset, int rows, int cols)
41 int x = get_global_id(0);
42 int y = get_global_id(1);
44 if (x < cols && y < rows)
46 int src_index = mad24(y, src_step, mad24(x, (int)sizeof(srcT) * dcn, src_offset));
47 int dst_index = mad24(y, dst_step, mad24(x, (int)sizeof(dstT) * dcn, dst_offset));
49 __global const srcT * src = (__global const srcT *)(srcptr + src_index);
50 __global const dstT * lut = (__global const dstT *)(lutptr + lut_offset);
51 __global dstT * dst = (__global dstT *)(dstptr + dst_index);
55 for (int cn = 0; cn < dcn; ++cn)
56 dst[cn] = lut[src[cn]];
59 for (int cn = 0; cn < dcn; ++cn)
60 dst[cn] = lut[mad24(src[cn], dcn, cn)];