Created
April 13, 2017 16:24
-
-
Save zxmarcos/56f5f4199dff9728e2908818a28e062b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__kernel void teste2(__global __read_only uchar * srcptr, int src_step, int src_offset, | |
__global uchar * dstptr, int dst_step, int dst_offset, int rows, int cols, | |
float focal) | |
{ | |
int du = get_global_id(0); | |
int dv = get_global_id(1); | |
if (du < cols && dv < rows) { | |
du = du - (0.5 * cols) + 1; | |
dv = dv - (0.5 * rows) + 1; | |
const float f = du / focal; | |
float x = focal * tan(f); | |
float y = dv * sqrt(1 + pow(tan(f), 2)); | |
x = x + (0.5 * cols) - 1; | |
y = y + (0.5 * rows) - 1; | |
if (x >= 0 && x < cols && y >= 0 && y < rows) { | |
int i = get_global_id(0); | |
int j = get_global_id(1); | |
#if 0 | |
int dst_index = mad24(j, dst_step, mad24(i, sizeof(uchar)*3, dst_offset)); | |
int src_index = mad24(y, src_step, mad24(x, sizeof(uchar)*3, src_offset)); | |
__global uchar *dst = (__global uchar *)(dstptr + dst_index); | |
__global __read_only uchar *src = (__global __read_only uchar *)(srcptr + src_index); | |
dst[0] = src[0]; | |
dst[1] = src[1]; | |
dst[2] = src[2]; | |
#else | |
int dst_index = mad24(j, dst_step, mad24(i, sizeof(uchar3), dst_offset)); | |
int src_index = mad24(y, src_step, mad24(x, sizeof(uchar3), src_offset)); | |
__global uchar3 *dst = (__global uchar3 *)(dstptr + dst_index); | |
__global __read_only uchar3 *src = (__global __read_only uchar3 *)(srcptr + src_index); | |
dst[0] = src[0]; | |
#endif | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment