From: Vladislav Vinogradov Date: Mon, 26 Aug 2013 06:25:04 +0000 (+0400) Subject: switched to new device layer in bitwize operations X-Git-Tag: accepted/tizen/6.0/unified/20201030.111113~3715^2~24 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b11cccaaca8d5c355742321be79ec1774dec9156;p=platform%2Fupstream%2Fopencv.git switched to new device layer in bitwize operations --- diff --git a/modules/cudaarithm/src/cuda/bitwise_mat.cu b/modules/cudaarithm/src/cuda/bitwise_mat.cu index 7a90cf3..e67d002 100644 --- a/modules/cudaarithm/src/cuda/bitwise_mat.cu +++ b/modules/cudaarithm/src/cuda/bitwise_mat.cu @@ -40,87 +40,124 @@ // //M*/ -#if !defined CUDA_DISABLER +#include "opencv2/opencv_modules.hpp" -#include "opencv2/core/cuda/common.hpp" -#include "opencv2/core/cuda/functional.hpp" -#include "opencv2/core/cuda/transform.hpp" -#include "opencv2/core/cuda/saturate_cast.hpp" -#include "opencv2/core/cuda/simd_functions.hpp" +#ifndef HAVE_OPENCV_CUDEV -#include "arithm_func_traits.hpp" +#error "opencv_cudev is required" -using namespace cv::cuda; -using namespace cv::cuda::device; +#else -namespace cv { namespace cuda { namespace device -{ - template struct TransformFunctorTraits< bit_not > : arithm::ArithmFuncTraits - { - }; +#include "opencv2/cudaarithm.hpp" +#include "opencv2/cudev.hpp" - template struct TransformFunctorTraits< bit_and > : arithm::ArithmFuncTraits - { - }; +using namespace cv::cudev; - template struct TransformFunctorTraits< bit_or > : arithm::ArithmFuncTraits - { - }; +void bitMat(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, const GpuMat& mask, double, Stream& stream, int op); - template struct TransformFunctorTraits< bit_xor > : arithm::ArithmFuncTraits - { - }; -}}} +////////////////////////////////////////////////////////////////////////////// +/// bitwise_not -namespace arithm +namespace { - template void bitMatNot(PtrStepSzb src, PtrStepSzb dst, PtrStepb mask, cudaStream_t stream) + template + void bitMatNot(const GpuMat& src, GpuMat& dst, const GpuMat& mask, Stream& stream) { + GlobPtrSz vsrc = globPtr((T*) src.data, src.step, src.rows, src.cols * src.channels()); + GlobPtrSz vdst = globPtr((T*) dst.data, dst.step, src.rows, src.cols * src.channels()); + if (mask.data) - device::transform((PtrStepSz) src, (PtrStepSz) dst, bit_not(), mask, stream); + gridTransformUnary(vsrc, vdst, bit_not(), singleMaskChannels(globPtr(mask), src.channels()), stream); else - device::transform((PtrStepSz) src, (PtrStepSz) dst, bit_not(), WithOutMask(), stream); + gridTransformUnary(vsrc, vdst, bit_not(), stream); } +} - template void bitMatAnd(PtrStepSzb src1, PtrStepSzb src2, PtrStepSzb dst, PtrStepb mask, cudaStream_t stream) +void cv::cuda::bitwise_not(InputArray _src, OutputArray _dst, InputArray _mask, Stream& stream) +{ + GpuMat src = _src.getGpuMat(); + GpuMat mask = _mask.getGpuMat(); + + const int depth = src.depth(); + + CV_DbgAssert( depth <= CV_32F ); + CV_DbgAssert( mask.empty() || (mask.type() == CV_8UC1 && mask.size() == src.size()) ); + + _dst.create(src.size(), src.type()); + GpuMat dst = _dst.getGpuMat(); + + if (depth == CV_32F || depth == CV_32S) { - if (mask.data) - device::transform((PtrStepSz) src1, (PtrStepSz) src2, (PtrStepSz) dst, bit_and(), mask, stream); - else - device::transform((PtrStepSz) src1, (PtrStepSz) src2, (PtrStepSz) dst, bit_and(), WithOutMask(), stream); + bitMatNot(src, dst, mask, stream); } - - template void bitMatOr(PtrStepSzb src1, PtrStepSzb src2, PtrStepSzb dst, PtrStepb mask, cudaStream_t stream) + else if (depth == CV_16S || depth == CV_16U) { - if (mask.data) - device::transform((PtrStepSz) src1, (PtrStepSz) src2, (PtrStepSz) dst, bit_or(), mask, stream); - else - device::transform((PtrStepSz) src1, (PtrStepSz) src2, (PtrStepSz) dst, bit_or(), WithOutMask(), stream); + bitMatNot(src, dst, mask, stream); } + else + { + bitMatNot(src, dst, mask, stream); + } +} - template void bitMatXor(PtrStepSzb src1, PtrStepSzb src2, PtrStepSzb dst, PtrStepb mask, cudaStream_t stream) +////////////////////////////////////////////////////////////////////////////// +/// Binary bitwise logical operations + +namespace +{ + template