namespace imgproc\r
{\r
template<typename T, int N> struct TypeVec {};\r
- template<> struct TypeVec<uchar, 1> { typedef uchar1 vec_t; };\r
- template<> struct TypeVec<uchar, 2> { typedef uchar2 vec_t; };\r
template<> struct TypeVec<uchar, 3> { typedef uchar3 vec_t; };\r
template<> struct TypeVec<uchar, 4> { typedef uchar4 vec_t; };\r
- template<> struct TypeVec<unsigned short, 1> { typedef ushort1 vec_t; };\r
- template<> struct TypeVec<unsigned short, 2> { typedef ushort2 vec_t; };\r
template<> struct TypeVec<unsigned short, 3> { typedef ushort3 vec_t; };\r
template<> struct TypeVec<unsigned short, 4> { typedef ushort4 vec_t; };\r
- template<> struct TypeVec<float, 1> { typedef float1 vec_t; };\r
- template<> struct TypeVec<float, 2> { typedef float2 vec_t; };\r
template<> struct TypeVec<float, 3> { typedef float3 vec_t; };\r
template<> struct TypeVec<float, 4> { typedef float4 vec_t; };\r
\r
template<typename T> struct ColorChannel {};\r
-\r
template<> struct ColorChannel<uchar>\r
{\r
typedef float worktype_f;\r
static __device__ unsigned char max() { return UCHAR_MAX; }\r
static __device__ unsigned char half() { return (unsigned char)(max()/2 + 1); }\r
};\r
-\r
template<> struct ColorChannel<unsigned short>\r
{\r
typedef float worktype_f;\r
static __device__ unsigned short max() { return USHRT_MAX; }\r
static __device__ unsigned short half() { return (unsigned short)(max()/2 + 1); }\r
};\r
-\r
template<> struct ColorChannel<float>\r
{\r
typedef float worktype_f;\r
\r
if (y < rows && x < cols)\r
{\r
- src_t src = *(const src_t*)(src_ + y * src_step + x * SRCCN);\r
+ src_t src = *(const src_t*)(src_ + y * src_step + x * SRCCN * sizeof(T));\r
dst_t dst;\r
\r
dst.x = ((const T*)(&src))[bidx];\r
dst.z = ((const T*)(&src))[bidx ^ 2];\r
setAlpha(dst, getAlpha<T>(src));\r
\r
- *(dst_t*)(dst_ + y * dst_step + x * DSTCN) = dst;\r
+ *(dst_t*)(dst_ + y * dst_step + x * DSTCN * sizeof(T)) = dst;\r
}\r
}\r
}\r
\r
if (y < rows && x < cols)\r
{\r
- src_t src = *(const src_t*)(src_ + y * src_step + x * SRCCN);\r
+ src_t src = *(const src_t*)(src_ + y * src_step + x * SRCCN * sizeof(T));\r
dst_t dst;\r
\r
RGB2YCrCbConverter<T>::cvt(((const T*)(&src)), dst, bidx);\r
\r
- *(dst_t*)(dst_ + y * dst_step + x * 3) = dst;\r
+ *(dst_t*)(dst_ + y * dst_step + x * 3 * sizeof(T)) = dst;\r
}\r
}\r
\r
\r
if (y < rows && x < cols)\r
{\r
- src_t src = *(const src_t*)(src_ + y * src_step + x * 3);\r
+ src_t src = *(const src_t*)(src_ + y * src_step + x * 3 * sizeof(T));\r
dst_t dst;\r
\r
YCrCb2RGBConvertor<T>::cvt(src, ((T*)(&dst)), bidx);\r
setAlpha(dst, ColorChannel<T>::max());\r
\r
- *(dst_t*)(dst_ + y * dst_step + x * DSTCN) = dst;\r
+ *(dst_t*)(dst_ + y * dst_step + x * DSTCN * sizeof(T)) = dst;\r
}\r
}\r
}\r