fixed short and float reading/writing in gpu::cvtColor
authorVladislav Vinogradov <no@email>
Tue, 28 Sep 2010 09:10:25 +0000 (09:10 +0000)
committerVladislav Vinogradov <no@email>
Tue, 28 Sep 2010 09:10:25 +0000 (09:10 +0000)
modules/gpu/src/cuda/color.cu

index d8c03aa..274bb67 100644 (file)
@@ -52,35 +52,26 @@ using namespace cv::gpu;
 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
@@ -124,7 +115,7 @@ namespace imgproc
 \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
@@ -132,7 +123,7 @@ namespace imgproc
             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
@@ -817,12 +808,12 @@ namespace imgproc
 \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
@@ -865,13 +856,13 @@ namespace imgproc
 \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