15 const int x = (blockIdx.x * blockDim.x) + threadIdx.x;
16 const int y = (blockIdx.y * blockDim.y) + threadIdx.y;
24 uchar3 *src_px = (uchar3 *) (src + y * srcPitch) + x;
25 uchar4 *dst_px = (uchar4 *) (dst + y * dstPitch) + x;
27 const uchar3 px = *src_px;
29 *dst_px = make_uchar4(px.x, px.y, px.z, 0);
40 const int x = (blockIdx.x * blockDim.x) + threadIdx.x;
41 const int y = (blockIdx.y * blockDim.y) + threadIdx.y;
49 uchar4 *src_px = (uchar4 *) (src + y * srcPitch) + x;
50 uchar3 *dst_px = (uchar3 *) (dst + y * dstPitch) + x;
52 const uchar4 px = *src_px;
54 *dst_px = make_uchar3(px.x, px.y, px.z);
57#define max(a, b) (((a) > (b))? (a): (b))
58#define min(a, b) (((a) < (b))? (a): (b))
68 const int x = (blockIdx.x * blockDim.x) + threadIdx.x;
69 const int y = (blockIdx.y * blockDim.y) + threadIdx.y;
77 const int uyvy_block = x / 2;
79 uchar4 *src_px = (uchar4 *) (src + y * srcPitch) + uyvy_block;
80 uchar4 *dst_px = (uchar4 *) (dst + y * dstPitch) + x;
82 const uchar4 block = *src_px;
86 int luma = (x % 2) ? block.w : block.y;
88 int r =
min(
max(1.164f*(luma - 16) + 1.793f*(v - 128), 0), 255);
89 int g =
min(
max(1.164f*(luma - 16) - 0.534f*(v - 128) - 0.213f*(u - 128), 0), 255);
90 int b =
min(
max(1.164f*(luma - 16) + 2.115f*(u - 128), 0), 255);
92 *dst_px = make_uchar4(r, g, b, 0);
103 const int x = (blockIdx.x * blockDim.x) + threadIdx.x;
104 const int y = (blockIdx.y * blockDim.y) + threadIdx.y;
106 const int uyvy_block = x;
107 const int src_x = x * 2;
109 if(src_x + 1 >= width)
115 uchar4 *src_px_1 = (uchar4 *) (src + y * srcPitch) + src_x;
116 uchar4 *src_px_2 = (uchar4 *) (src + y * srcPitch) + src_x + 1;
117 uchar4 *dst_px = (uchar4 *) (dst + y * dstPitch) + uyvy_block;
119 int y1 = 11993 * src_px_1->x + 40239 * src_px_1->y + 4063 * src_px_1->z + (1<<20);
120 int u = -6619 * src_px_1->x -22151 * src_px_1->y + 28770 * src_px_1->z;
121 int v = 28770 * src_px_1->x - 26149 * src_px_1->y - 2621 * src_px_1->z;
123 int y2 = 11993 * src_px_2->x + 40239 * src_px_2->y + 4063 * src_px_2->z + (1<<20);
124 u += -6619 * src_px_2->x -22151 * src_px_2->y + 28770 * src_px_2->z;
125 v += 28770 * src_px_2->x - 26149 * src_px_2->y - 2621 * src_px_2->z;
130 *dst_px = make_uchar4(
min(
max(u, 0), (1<<24)-1) >> 16,
131 min(
max(y1, 0), (1<<24)-1) >> 16,
132 min(
max(v, 0), (1<<24)-1) >> 16,
133 min(
max(y2, 0), (1<<24)-1) >> 16);
143 CUstream_st *stream){
145 dim3 blockSize(32,32);
146 dim3 numBlocks((width + blockSize.x - 1) / blockSize.x,
147 (height + blockSize.y - 1) / blockSize.y);
158 CUstream_st *stream){
160 dim3 blockSize(32,32);
161 dim3 numBlocks((width + blockSize.x - 1) / blockSize.x,
162 (height + blockSize.y - 1) / blockSize.y);
173 CUstream_st *stream){
175 dim3 blockSize(32,32);
176 dim3 numBlocks((width / 2 + blockSize.x - 1) / blockSize.x,
177 (height + blockSize.y - 1) / blockSize.y);
188 CUstream_st *stream){
190 dim3 blockSize(32,32);
191 dim3 numBlocks((width + blockSize.x - 1) / blockSize.x,
192 (height + blockSize.y - 1) / blockSize.y);
__global__ void kern_RGBAtoUYVY(unsigned char *dst, size_t dstPitch, unsigned char *src, size_t srcPitch, size_t width, size_t height)
void cuda_RGBA_to_UYVY(unsigned char *dst, size_t dstPitch, unsigned char *src, size_t srcPitch, size_t width, size_t height, CUstream_st *stream)
__global__ void kern_RGBAtoRGB(unsigned char *dst, size_t dstPitch, unsigned char *src, size_t srcPitch, size_t width, size_t height)
void cuda_UYVY_to_RGBA(unsigned char *dst, size_t dstPitch, unsigned char *src, size_t srcPitch, size_t width, size_t height, CUstream_st *stream)
void cuda_RGBA_to_RGB(unsigned char *dst, size_t dstPitch, unsigned char *src, size_t srcPitch, size_t width, size_t height, CUstream_st *stream)
__global__ void kern_RGBtoRGBA(unsigned char *dst, size_t dstPitch, unsigned char *src, size_t srcPitch, size_t width, size_t height)
void cuda_RGB_to_RGBA(unsigned char *dst, size_t dstPitch, unsigned char *src, size_t srcPitch, size_t width, size_t height, CUstream_st *stream)
__global__ void kern_UYVYtoRGBA(unsigned char *dst, size_t dstPitch, unsigned char *src, size_t srcPitch, size_t width, size_t height)