diff --git a/modules/imgproc/src/color.cpp b/modules/imgproc/src/color.cpp index 5686204de..e0ed0fa13 100644 --- a/modules/imgproc/src/color.cpp +++ b/modules/imgproc/src/color.cpp @@ -157,46 +157,38 @@ template<> struct ColorChannel ///////////////////////////// Top-level template function //////////////////////////////// template -class CvtColorLoop_Invoker : - public ParallelLoopBody +class CvtColorLoop_Invoker : public ParallelLoopBody { typedef typename Cvt::channel_type _Tp; public: - + CvtColorLoop_Invoker(const Mat& _src, Mat& _dst, const Cvt& _cvt) : ParallelLoopBody(), src(_src), dst(_dst), cvt(_cvt) { } - + virtual void operator()(const Range& range) const { - int i = range.start; - const uchar* yS = src.data + src.step * i; - uchar* yD = dst.data + dst.step * i; + const uchar* yS = src.ptr(range.start); + uchar* yD = dst.ptr(range.start); - for ( ; i < range.end; ++i, yS += src.step, yD += dst.step ) + for( int i = range.start; i < range.end; ++i, yS += src.step, yD += dst.step ) cvt((const _Tp*)yS, (_Tp*)yD, src.cols); } - + private: - const Mat src; - Mat dst; - const Cvt cvt; - + const Mat& src; + Mat& dst; + const Cvt& cvt; + CvtColorLoop_Invoker(const CvtColorLoop_Invoker&); const CvtColorLoop_Invoker& operator= (const CvtColorLoop_Invoker&); }; -template +template void CvtColorLoop(const Mat& src, Mat& dst, const Cvt& cvt) { - Range range(0, src.rows); - CvtColorLoop_Invoker invoker(src, dst, cvt); -#if defined(_MSC_VER) || defined(__APPLE__) - parallel_for_(range, invoker); -#else - invoker(range); -#endif + parallel_for_(Range(0, src.rows), CvtColorLoop_Invoker(src, dst, cvt)); } ////////////////// Various 3/4-channel to 3/4-channel RGB transformations ///////////////// @@ -2172,7 +2164,7 @@ static void Bayer2RGB_VNG_8u( const Mat& srcmat, Mat& dstmat, int code ) bool haveSSE = cv::checkHardwareSupport(CV_CPU_SSE2); #define _mm_absdiff_epu16(a,b) _mm_adds_epu16(_mm_subs_epu16(a, b), _mm_subs_epu16(b, a)) #endif - + for( int y = 2; y < size.height - 4; y++ ) { uchar* dstrow = dst + dststep*y + 6; @@ -2659,7 +2651,7 @@ static void Bayer2RGB_VNG_8u( const Mat& srcmat, Mat& dstmat, int code ) x2 = _mm_merge_epi16(t0, x0); uchar R[8], G[8], B[8]; - + // Make sure there is no sign bit in the 16 bit values so they can saturate correctly x1 = _mm_and_si128(x1, smask); x2 = _mm_and_si128(x2, smask); @@ -3180,7 +3172,7 @@ struct RGBA2mRGBA _Tp v1 = *src++; _Tp v2 = *src++; _Tp v3 = *src++; - + *dst++ = (v0 * v3 + half_val) / max_val; *dst++ = (v1 * v3 + half_val) / max_val; *dst++ = (v2 * v3 + half_val) / max_val; @@ -3205,7 +3197,7 @@ struct mRGBA2RGBA _Tp v2 = *src++; _Tp v3 = *src++; _Tp v3_half = v3 / 2; - + *dst++ = (v3==0)? 0 : (v0 * max_val + v3_half) / v3; *dst++ = (v3==0)? 0 : (v1 * max_val + v3_half) / v3; *dst++ = (v3==0)? 0 : (v2 * max_val + v3_half) / v3; @@ -3568,7 +3560,7 @@ void cv::cvtColor( InputArray _src, OutputArray _dst, int code, int dcn ) case CV_BayerBG2BGR: case CV_BayerGB2BGR: case CV_BayerRG2BGR: case CV_BayerGR2BGR: case CV_BayerBG2BGR_VNG: case CV_BayerGB2BGR_VNG: case CV_BayerRG2BGR_VNG: case CV_BayerGR2BGR_VNG: { - if (dcn <= 0) + if (dcn <= 0) dcn = 3; CV_Assert( scn == 1 && dcn == 3 );