diff --git a/modules/core/src/arithm.cpp b/modules/core/src/arithm.cpp index 813e3c59c8..421fe0fa7d 100644 --- a/modules/core/src/arithm.cpp +++ b/modules/core/src/arithm.cpp @@ -48,13 +48,17 @@ #include "precomp.hpp" +#ifdef HAVE_IPP +#include "ippversion.h" +#endif + namespace cv { #if CV_SSE2 enum { ARITHM_SIMD = CV_CPU_SSE2 }; - + template struct VBinOp8 { int operator()(const uchar* src1, const uchar* src2, uchar* dst, int len) const @@ -193,7 +197,7 @@ struct _VAbsDiff32f }; struct _VAnd8u { __m128i operator()(const __m128i& a, const __m128i& b) const { return _mm_and_si128(a,b); }}; -struct _VOr8u { __m128i operator()(const __m128i& a, const __m128i& b) const { return _mm_or_si128(a,b); }}; +struct _VOr8u { __m128i operator()(const __m128i& a, const __m128i& b) const { return _mm_or_si128(a,b); }}; struct _VXor8u { __m128i operator()(const __m128i& a, const __m128i& b) const { return _mm_xor_si128(a,b); }}; typedef VBinOp8<_VAdd8u> VAdd8u; @@ -228,8 +232,8 @@ typedef VBinOp8<_VXor8u> VXor8u; #else -enum { ARITHM_SIMD = CV_CPU_NONE }; - +enum { ARITHM_SIMD = CV_CPU_NONE }; + typedef NoVec VAdd8u; typedef NoVec VSub8u; typedef NoVec VMin8u; @@ -262,6 +266,65 @@ typedef NoVec VXor8u; #endif + +#if defined (HAVE_IPP) && (IPP_VERSION_MAJOR >= 7) +struct ippAdd8u +{ + int operator()(const Ipp8u* src1, const Ipp8u* src2, Ipp8u* dst, int len) const + { + ippsAdd_8u_Sfs(src1,src2,dst,len,0); + return len; + } +}; + +struct ippAdd16u +{ + int operator()(const Ipp16u* src1, const Ipp16u* src2, Ipp16u* dst, int len) const + { + ippsAdd_16u_Sfs(src1,src2,dst,len,0); + return len; + } +}; + +struct ippAdd16s +{ + int operator()(const Ipp16s* src1, const Ipp16s* src2, Ipp16s* dst, int len) const + { + ippsAdd_16s_Sfs(src1,src2,dst,len,0); + return len; + } +}; + +struct ippAdd32s +{ + int operator()(const Ipp32s* src1, const Ipp32s* src2, Ipp32s* dst, int len) const + { + ippsAdd_32s_Sfs(src1,src2,dst,len,0); + return len; + } +}; + +struct ippAdd32f +{ + int operator()(const Ipp32f* src1, const Ipp32f* src2, Ipp32f* dst, int len) const + { + ippsAdd_32f(src1,src2,dst,len); + return len; + } +}; + +struct ippAdd64f +{ + int operator()(const Ipp64f* src1, const Ipp64f* src2, Ipp64f* dst, int len) const + { + ippsAdd_64f(src1,src2,dst,len); + return len; + } +}; + +#endif + + /****************************************************************************************\ * logical operations * \****************************************************************************************/ @@ -399,45 +462,45 @@ bitwiseSOp_( const Mat& srcmat, Mat& dstmat, const Scalar& _scalar ) } } - + static void binaryOp( const Mat& src1, const Mat& src2, Mat& dst, BinaryFunc func, int dsttype=-1 ) { if( dsttype == -1 ) dsttype = src1.type(); CV_Assert( src1.type() == src2.type() && func != 0 ); - + if( src1.dims > 2 || src2.dims > 2 ) { dst.create(src1.dims, src1.size, dsttype); const Mat* arrays[] = { &src1, &src2, &dst, 0 }; Mat planes[3]; NAryMatIterator it(arrays, planes); - + for( int i = 0; i < it.nplanes; i++, ++it ) func(it.planes[0], it.planes[1], it.planes[2]); return; } - + CV_Assert( src1.size() == src2.size() ); dst.create( src1.size(), dsttype ); func( src1, src2, dst ); } - + static void binaryMaskOp( const Mat& src1, const Mat& src2, Mat& dst, const Mat& mask, BinaryFunc func ) { CV_Assert( src1.type() == src2.type() && func != 0 ); - + if( src1.dims > 2 || src2.dims > 2 ) { dst.create(src1.dims, src1.size, src1.type()); const Mat* arrays[] = { &src1, &src2, &dst, &mask, 0 }; Mat planes[4]; NAryMatIterator it(arrays, planes); - + if( !mask.data ) for( int i = 0; i < it.nplanes; i++, ++it ) func(it.planes[0], it.planes[1], it.planes[2]); @@ -448,7 +511,7 @@ binaryMaskOp( const Mat& src1, const Mat& src2, Mat& dst, func); return; } - + CV_Assert( src1.size() == src2.size() ); dst.create( src1.size(), src1.type() ); @@ -482,14 +545,14 @@ binarySMaskOp( const Mat& src1, const Scalar& s, Mat& dst, const Mat& mask, BinarySFuncCn func ) { CV_Assert( func != 0 ); - + if( src1.dims > 2 ) { dst.create(src1.dims, src1.size, src1.type()); const Mat* arrays[] = { &src1, &dst, &mask, 0 }; Mat planes[3]; NAryMatIterator it(arrays, planes); - + if( !mask.data ) for( int i = 0; i < it.nplanes; i++, ++it ) func(it.planes[0], it.planes[1], s); @@ -499,7 +562,7 @@ binarySMaskOp( const Mat& src1, const Scalar& s, Mat& dst, it.planes[2], func); return; } - + dst.create( src1.size(), src1.type() ); if( !mask.data ) @@ -569,12 +632,12 @@ void bitwise_not(const Mat& src, Mat& dst) const Mat* arrays[] = { &src, &dst, 0 }; Mat planes[4]; NAryMatIterator it(arrays, planes); - + for( int i = 0; i < it.nplanes; i++, ++it ) bitwise_not(it.planes[0], it.planes[1]); return; } - + const uchar* sptr = src.data; dst.create( src.size(), src.type() ); uchar* dptr = dst.data; @@ -622,22 +685,37 @@ template<> inline uchar OpSub::operator ()(uchar a, uchar b) const static BinaryFunc addTab[] = { - binaryOpC1_,VAdd8u>, 0, - binaryOpC1_,VAdd16u>, - binaryOpC1_,VAdd16s>, - binaryOpC1_,NoVec>, - binaryOpC1_,VAdd32f>, - binaryOpC1_,NoVec>, 0 +#if defined (HAVE_IPP) && (IPP_VERSION_MAJOR >= 7) + binaryOpC1_, ippAdd8u>, + 0, + binaryOpC1_, ippAdd16u>, + binaryOpC1_, ippAdd16s>, + binaryOpC1_, ippAdd32s>, + binaryOpC1_, ippAdd32f>, + binaryOpC1_, ippAdd64f>, + 0 +#else + binaryOpC1_, VAdd8u>, + 0, + binaryOpC1_, VAdd16u>, + binaryOpC1_, VAdd16s>, + binaryOpC1_, NoVec>, + binaryOpC1_, VAdd32f>, + binaryOpC1_, NoVec>, + 0 +#endif }; static BinaryFunc subTab[] = { - binaryOpC1_,VSub8u>, 0, - binaryOpC1_,VSub16u>, - binaryOpC1_,VSub16s>, - binaryOpC1_,NoVec>, - binaryOpC1_,VSub32f>, - binaryOpC1_,NoVec>, 0 + binaryOpC1_, VSub8u>, + 0, + binaryOpC1_, VSub16u>, + binaryOpC1_, VSub16s>, + binaryOpC1_, NoVec>, + binaryOpC1_, VSub32f>, + binaryOpC1_, NoVec>, + 0 }; void add( const Mat& src1, const Mat& src2, Mat& dst ) @@ -645,19 +723,19 @@ void add( const Mat& src1, const Mat& src2, Mat& dst ) int type = src1.type(); BinaryFunc func = addTab[CV_MAT_DEPTH(type)]; CV_Assert( type == src2.type() && func != 0 ); - + if( src1.dims > 2 || src2.dims > 2 ) { dst.create(src1.dims, src1.size, src1.type()); const Mat* arrays[] = {&src1, &src2, &dst, 0}; Mat planes[3]; NAryMatIterator it(arrays, planes); - + for( int i = 0; i < it.nplanes; i++, ++it ) func( it.planes[0], it.planes[1], it.planes[2] ); return; } - + Size size = src1.size(); CV_Assert( size == src2.size() ); dst.create( size, type ); @@ -669,19 +747,19 @@ void subtract( const Mat& src1, const Mat& src2, Mat& dst ) int type = src1.type(); BinaryFunc func = subTab[CV_MAT_DEPTH(type)]; CV_Assert( type == src2.type() && func != 0 ); - + if( src1.dims > 2 || src2.dims > 2 ) { dst.create(src1.dims, src1.size, src1.type()); const Mat* arrays[] = {&src1, &src2, &dst, 0}; Mat planes[3]; NAryMatIterator it(arrays, planes); - + for( int i = 0; i < it.nplanes; i++, ++it ) func( it.planes[0], it.planes[1], it.planes[2] ); return; } - + Size size = src1.size(); CV_Assert( size == src2.size() ); dst.create( size, type ); @@ -707,12 +785,14 @@ void add(const Mat& src1, const Scalar& s, Mat& dst, const Mat& mask) { static BinarySFuncCn addSTab[] = { - binarySOpCn_ >, 0, + binarySOpCn_ >, + 0, binarySOpCn_ >, binarySOpCn_ >, binarySOpCn_ >, binarySOpCn_ >, - binarySOpCn_ >, 0 + binarySOpCn_ >, + 0 }; int depth = src1.depth(); binarySMaskOp(src1, s, dst, mask, addSTab[depth]); @@ -722,12 +802,14 @@ void subtract(const Scalar& s, const Mat& src1, Mat& dst, const Mat& mask) { static BinarySFuncCn rsubSTab[] = { - binarySOpCn_ >, 0, + binarySOpCn_ >, + 0, binarySOpCn_ >, binarySOpCn_ >, binarySOpCn_ >, binarySOpCn_ >, - binarySOpCn_ >, 0 + binarySOpCn_ >, + 0 }; int depth = src1.depth(); binarySMaskOp(src1, s, dst, mask, rsubSTab[depth]); @@ -755,13 +837,17 @@ mul_( const Mat& srcmat1, const Mat& srcmat2, Mat& dstmat, double _scale ) int i; for( i = 0; i <= size.width - 4; i += 4 ) { - T t0 = saturate_cast(src1[i] * src2[i]); - T t1 = saturate_cast(src1[i+1] * src2[i+1]); - dst[i] = t0; dst[i+1] = t1; + T t0; + T t1; + t0 = saturate_cast(src1[i ] * src2[i ]); + t1 = saturate_cast(src1[i+1] * src2[i+1]); + dst[i ] = t0; + dst[i+1] = t1; t0 = saturate_cast(src1[i+2] * src2[i+2]); t1 = saturate_cast(src1[i+3] * src2[i+3]); - dst[i+2] = t0; dst[i+3] = t1; + dst[i+2] = t0; + dst[i+3] = t1; } for( ; i < size.width; i++ ) @@ -798,25 +884,31 @@ void multiply(const Mat& src1, const Mat& src2, Mat& dst, double scale) { static MulDivFunc tab[] = { - mul_, 0, mul_, mul_, - mul_, mul_, mul_, 0 + mul_, + 0, + mul_, + mul_, + mul_, + mul_, + mul_, + 0 }; MulDivFunc func = tab[src1.depth()]; CV_Assert( src1.type() == src2.type() && func != 0 ); - + if( src1.dims > 2 || src2.dims > 2 ) { dst.create(src1.dims, src1.size, src1.type()); const Mat* arrays[] = {&src1, &src2, &dst, 0}; Mat planes[3]; NAryMatIterator it(arrays, planes); - + for( int i = 0; i < it.nplanes; i++, ++it ) func( it.planes[0], it.planes[1], it.planes[2], scale ); return; } - + CV_Assert( src1.size() == src2.size() ); dst.create( src1.size(), src1.type() ); func( src1, src2, dst, scale ); @@ -883,19 +975,19 @@ void divide(const Mat& src1, const Mat& src2, Mat& dst, double scale) MulDivFunc func = tab[src1.depth()]; CV_Assert( src1.size() == src2.size() && src1.type() == src2.type() && func != 0 ); - + if( src1.dims > 2 || src2.dims > 2 ) { dst.create(src1.dims, src1.size, src1.type()); const Mat* arrays[] = {&src1, &src2, &dst, 0}; Mat planes[3]; NAryMatIterator it(arrays, planes); - + for( int i = 0; i < it.nplanes; i++, ++it ) func( it.planes[0], it.planes[1], it.planes[2], scale ); return; } - + CV_Assert( src1.size() == src2.size() ); dst.create( src1.size(), src1.type() ); func( src1, src2, dst, scale ); @@ -954,25 +1046,31 @@ void divide(double scale, const Mat& src, Mat& dst) { static RecipFunc tab[] = { - recip_, 0, recip_, recip_, - recip_, recip_, recip_, 0 + recip_, + 0, + recip_, + recip_, + recip_, + recip_, + recip_, + 0 }; RecipFunc func = tab[src.depth()]; CV_Assert( func != 0 ); - + if( src.dims > 2 ) { dst.create(src.dims, src.size, src.type()); const Mat* arrays[] = {&src, &dst, 0}; Mat planes[2]; NAryMatIterator it(arrays, planes); - + for( int i = 0; i < it.nplanes; i++, ++it ) func( scale, it.planes[0], it.planes[1] ); return; } - + dst.create( src.size(), src.type() ); func( scale, src, dst ); } @@ -1122,27 +1220,33 @@ typedef void (*AddWeightedFunc)( const Mat& src1, double alpha, const Mat& src2, void addWeighted( const Mat& src1, double alpha, const Mat& src2, double beta, double gamma, Mat& dst ) { - static AddWeightedFunc tab[]= + static AddWeightedFunc tab[] = { - addWeighted8u, 0, addWeighted_, addWeighted_, - addWeighted_, addWeighted_, addWeighted_, 0 + addWeighted8u, + 0, + addWeighted_, + addWeighted_, + addWeighted_, + addWeighted_, + addWeighted_, + 0 }; AddWeightedFunc func = tab[src1.depth()]; CV_Assert( src1.type() == src2.type() && func != 0 ); - + if( src1.dims > 2 || src2.dims > 2 ) { dst.create(src1.dims, src1.size, src1.type()); const Mat* arrays[] = {&src1, &src2, &dst, 0}; Mat planes[3]; NAryMatIterator it(arrays, planes); - + for( int i = 0; i < it.nplanes; i++, ++it ) func( it.planes[0], alpha, it.planes[1], beta, gamma, it.planes[2] ); return; } - + CV_Assert( src1.size() == src2.size() ); dst.create( src1.size(), src1.type() ); func( src1, alpha, src2, beta, gamma, dst ); @@ -1176,12 +1280,14 @@ void absdiff( const Mat& src1, const Mat& src2, Mat& dst ) { static BinaryFunc tab[] = { - binaryOpC1_,VAbsDiff8u>, 0, + binaryOpC1_,VAbsDiff8u>, + 0, binaryOpC1_,VAbsDiff16u>, binaryOpC1_,VAbsDiff16s>, binaryOpC1_,NoVec>, binaryOpC1_,VAbsDiff32f>, - binaryOpC1_,NoVec>, 0 + binaryOpC1_,NoVec>, + 0 }; binaryOp(src1, src2, dst, tab[src1.depth()]); @@ -1192,24 +1298,26 @@ void absdiff( const Mat& src1, const Scalar& s, Mat& dst ) { static BinarySFuncCn tab[] = { - binarySOpCn_ >, 0, + binarySOpCn_ >, + 0, binarySOpCn_ >, binarySOpCn_ >, binarySOpCn_ >, binarySOpCn_ >, - binarySOpCn_ >, 0 + binarySOpCn_ >, + 0 }; BinarySFuncCn func = tab[src1.depth()]; CV_Assert(src1.channels() <= 4 && func != 0); - + if( src1.dims > 2 ) { dst.create(src1.dims, src1.size, src1.type()); const Mat* arrays[] = {&src1, &dst, 0}; Mat planes[3]; NAryMatIterator it(arrays, planes); - + for( int i = 0; i < it.nplanes; i++, ++it ) func( it.planes[0], it.planes[1], s ); return; @@ -1315,33 +1423,41 @@ void inRange(const Mat& src, const Mat& lowerb, { static InRangeFunc tab[] = { - inRange_ >, 0, + inRange_ >, + 0, inRange_ >, inRange_ >, inRange_ >, inRange_ >, - inRange_ >, 0, + inRange_ >, + 0, - inRange_ >, 0, + inRange_ >, + 0, inRange_ >, inRange_ >, inRange_ >, inRange_ >, - inRange_ >, 0, + inRange_ >, + 0, - inRange_ >, 0, + inRange_ >, + 0, inRange_ >, inRange_ >, inRange_ >, inRange_ >, - inRange_ >, 0, + inRange_ >, + 0, - inRange_ >, 0, + inRange_ >, + 0, inRange_ >, inRange_ >, inRange_ >, inRange_ >, - inRange_ >, 0 + inRange_ >, + 0 }; CV_Assert( src.type() == lowerb.type() && src.type() == upperb.type() && src.channels() <= 4 ); @@ -1355,12 +1471,12 @@ void inRange(const Mat& src, const Mat& lowerb, const Mat* arrays[] = {&src, &lowerb, &upperb, &dst, 0}; Mat planes[4]; NAryMatIterator it(arrays, planes); - + for( int i = 0; i < it.nplanes; i++, ++it ) func( it.planes[0], it.planes[1], it.planes[2], it.planes[3] ); return; } - + CV_Assert( src.size() == lowerb.size() && src.size() == upperb.size() ); dst.create(src.size(), CV_8U); func( src, lowerb, upperb, dst ); @@ -1371,47 +1487,55 @@ void inRange(const Mat& src, const Scalar& lowerb, { static InRangeSFunc tab[] = { - inRangeS_ >, 0, + inRangeS_ >, + 0, inRangeS_ >, inRangeS_ >, inRangeS_ >, inRangeS_ >, - inRangeS_ >, 0, + inRangeS_ >, + 0, - inRangeS_ >, 0, + inRangeS_ >, + 0, inRangeS_ >, inRangeS_ >, inRangeS_ >, inRangeS_ >, - inRangeS_ >, 0, + inRangeS_ >, + 0, - inRangeS_ >, 0, + inRangeS_ >, + 0, inRangeS_ >, inRangeS_ >, inRangeS_ >, inRangeS_ >, - inRangeS_ >, 0, + inRangeS_ >, + 0, - inRangeS_ >, 0, + inRangeS_ >, + 0, inRangeS_ >, inRangeS_ >, inRangeS_ >, inRangeS_ >, - inRangeS_ >, 0 + inRangeS_ >, + 0 }; CV_Assert( src.channels() <= 4 ); InRangeSFunc func = tab[src.type()]; CV_Assert( func != 0 ); - + if( src.dims > 2 ) { dst.create(src.dims, src.size, CV_8U); const Mat* arrays[] = {&src, &dst, 0}; Mat planes[2]; NAryMatIterator it(arrays, planes); - + for( int i = 0; i < it.nplanes; i++, ++it ) func( it.planes[0], lowerb, upperb, it.planes[1] ); return; @@ -1453,19 +1577,27 @@ void compare( const Mat& src1, const Mat& src2, Mat& dst, int cmpOp ) { static BinaryFunc tab[][8] = { - {binaryOpC1_,VCmpGT8u>, 0, - binaryOpC1_,NoVec>, - binaryOpC1_,NoVec>, - binaryOpC1_,NoVec>, - binaryOpC1_,NoVec>, - binaryOpC1_,NoVec>, 0}, - - {binaryOpC1_,VCmpEQ8u>, 0, - binaryOpC1_,NoVec>, - binaryOpC1_,NoVec>, // same function as for ushort's - binaryOpC1_,NoVec>, - binaryOpC1_,NoVec>, - binaryOpC1_,NoVec>, 0}, + { + binaryOpC1_,VCmpGT8u>, + 0, + binaryOpC1_,NoVec>, + binaryOpC1_,NoVec>, + binaryOpC1_,NoVec>, + binaryOpC1_,NoVec>, + binaryOpC1_,NoVec>, + 0 + }, + + { + binaryOpC1_,VCmpEQ8u>, + 0, + binaryOpC1_,NoVec>, + binaryOpC1_,NoVec>, // same function as for ushort's + binaryOpC1_,NoVec>, + binaryOpC1_,NoVec>, + binaryOpC1_,NoVec>, + 0 + }, }; CV_Assert(src1.channels() == 1); @@ -1479,20 +1611,25 @@ void compare( const Mat& src1, const Mat& src2, Mat& dst, int cmpOp ) case CMP_GT: case CMP_EQ: break; + case CMP_GE: std::swap( psrc1, psrc2 ); invflag = true; break; + case CMP_LT: std::swap( psrc1, psrc2 ); break; + case CMP_LE: invflag = true; break; + case CMP_NE: cmpOp = CMP_EQ; invflag = true; break; + default: CV_Error(CV_StsBadArg, "Unknown comparison method"); } @@ -1508,26 +1645,38 @@ void compare( const Mat& src1, double value, Mat& dst, int cmpOp ) { static BinarySFuncC1 tab[][8] = { - {binarySOpC1_ >, 0, - binarySOpC1_ >, - binarySOpC1_ >, - binarySOpC1_ >, - binarySOpC1_ >, - binarySOpC1_ >, 0}, - - {binarySOpC1_ >, 0, - binarySOpC1_ >, - binarySOpC1_ >, - binarySOpC1_ >, - binarySOpC1_ >, - binarySOpC1_ >, 0}, - - {binarySOpC1_ >, 0, - binarySOpC1_ >, - binarySOpC1_ >, - binarySOpC1_ >, - binarySOpC1_ >, - binarySOpC1_ >, 0}, + { + binarySOpC1_ >, + 0, + binarySOpC1_ >, + binarySOpC1_ >, + binarySOpC1_ >, + binarySOpC1_ >, + binarySOpC1_ >, + 0 + }, + + { + binarySOpC1_ >, + 0, + binarySOpC1_ >, + binarySOpC1_ >, + binarySOpC1_ >, + binarySOpC1_ >, + binarySOpC1_ >, + 0 + }, + + { + binarySOpC1_ >, + 0, + binarySOpC1_ >, + binarySOpC1_ >, + binarySOpC1_ >, + binarySOpC1_ >, + binarySOpC1_ >, + 0 + }, }; int depth = src1.depth(); @@ -1539,32 +1688,36 @@ void compare( const Mat& src1, double value, Mat& dst, int cmpOp ) case CMP_EQ: case CMP_GE: break; + case CMP_LT: invflag = true; cmpOp = CMP_GE; break; + case CMP_LE: invflag = true; cmpOp = CMP_GT; break; + case CMP_NE: invflag = true; cmpOp = CMP_EQ; break; + default: CV_Error(CV_StsBadArg, "Unknown comparison method"); } BinarySFuncC1 func = tab[cmpOp == CMP_EQ ? 0 : cmpOp == CMP_GT ? 1 : 2][depth]; CV_Assert( func != 0 ); - + if( src1.dims > 2 ) { dst.create(src1.dims, src1.size, CV_8UC(src1.channels())); const Mat* arrays[] = {&src1, &dst, 0}; Mat planes[2]; NAryMatIterator it(arrays, planes); - + for( int i = 0; i < it.nplanes; i++, ++it ) { func( it.planes[0], it.planes[1], value ); @@ -1573,7 +1726,7 @@ void compare( const Mat& src1, double value, Mat& dst, int cmpOp ) } return; } - + dst.create(src1.rows, src1.cols, CV_8UC(src1.channels())); func( src1, dst, value ); if( invflag ) @@ -1607,9 +1760,14 @@ void min( const Mat& src1, const Mat& src2, Mat& dst ) { static BinaryFunc tab[] = { - binaryOpC1_,VMin8u>, 0, binaryOpC1_,VMin16u>, - binaryOpC1_,VMin16s>, binaryOpC1_,NoVec>, - binaryOpC1_,VMin32f>, binaryOpC1_,NoVec>, 0 + binaryOpC1_,VMin8u>, + 0, + binaryOpC1_,VMin16u>, + binaryOpC1_,VMin16s>, + binaryOpC1_,NoVec>, + binaryOpC1_,VMin32f>, + binaryOpC1_,NoVec>, + 0 }; binaryOp(src1, src2, dst, tab[src1.depth()]); @@ -1619,9 +1777,14 @@ void max( const Mat& src1, const Mat& src2, Mat& dst ) { static BinaryFunc tab[] = { - binaryOpC1_,VMax8u>, 0, binaryOpC1_,VMax16u>, - binaryOpC1_,VMax16s>, binaryOpC1_,NoVec>, - binaryOpC1_,VMax32f>, binaryOpC1_,NoVec>, 0 + binaryOpC1_,VMax8u>, + 0, + binaryOpC1_,VMax16u>, + binaryOpC1_,VMax16s>, + binaryOpC1_,NoVec>, + binaryOpC1_,VMax32f>, + binaryOpC1_,NoVec>, + 0 }; binaryOp(src1, src2, dst, tab[src1.depth()]); @@ -1631,30 +1794,33 @@ void min( const Mat& src1, double value, Mat& dst ) { static BinarySFuncC1 tab[] = { - binarySOpC1_ >, 0, + binarySOpC1_ >, + 0, binarySOpC1_ >, binarySOpC1_ >, binarySOpC1_ >, binarySOpC1_ >, - binarySOpC1_ >, 0 + binarySOpC1_ >, + 0 }; BinarySFuncC1 func = tab[src1.depth()]; CV_Assert(func != 0); - + if( src1.dims > 2 ) { dst.create(src1.dims, src1.size, src1.type()); const Mat* arrays[] = {&src1, &dst, 0}; Mat planes[2]; NAryMatIterator it(arrays, planes); - + for( int i = 0; i < it.nplanes; i++, ++it ) func( it.planes[0], it.planes[1], value ); return; } - + dst.create(src1.size(), src1.type()); + return func( src1, dst, value ); } @@ -1662,34 +1828,37 @@ void max( const Mat& src1, double value, Mat& dst ) { static BinarySFuncC1 tab[] = { - binarySOpC1_ >, 0, + binarySOpC1_ >, + 0, binarySOpC1_ >, binarySOpC1_ >, binarySOpC1_ >, binarySOpC1_ >, - binarySOpC1_ >, 0 + binarySOpC1_ >, + 0 }; BinarySFuncC1 func = tab[src1.depth()]; CV_Assert(func != 0); - + if( src1.dims > 2 ) { dst.create(src1.dims, src1.size, src1.type()); const Mat* arrays[] = {&src1, &dst, 0}; Mat planes[2]; NAryMatIterator it(arrays, planes); - + for( int i = 0; i < it.nplanes; i++, ++it ) func( it.planes[0], it.planes[1], value ); return; } - + dst.create(src1.size(), src1.type()); + return func( src1, dst, value ); } -} +} // namespace cv /****************************************************************************************\ * Earlier API: cvAdd etc. * @@ -1715,6 +1884,7 @@ cvAnd( const CvArr* srcarr1, const CvArr* srcarr2, CvArr* dstarr, const CvArr* m cv::bitwise_and( src1, src2, dst, mask ); } + CV_IMPL void cvOr( const CvArr* srcarr1, const CvArr* srcarr2, CvArr* dstarr, const CvArr* maskarr ) { @@ -1771,6 +1941,7 @@ cvXorS( const CvArr* srcarr, CvScalar s, CvArr* dstarr, const CvArr* maskarr ) cv::bitwise_xor( src, s, dst, mask ); } + CV_IMPL void cvAdd( const CvArr* srcarr1, const CvArr* srcarr2, CvArr* dstarr, const CvArr* maskarr ) { cv::Mat src1 = cv::cvarrToMat(srcarr1), src2 = cv::cvarrToMat(srcarr2), @@ -1781,6 +1952,7 @@ CV_IMPL void cvAdd( const CvArr* srcarr1, const CvArr* srcarr2, CvArr* dstarr, c cv::add( src1, src2, dst, mask ); } + CV_IMPL void cvSub( const CvArr* srcarr1, const CvArr* srcarr2, CvArr* dstarr, const CvArr* maskarr ) { cv::Mat src1 = cv::cvarrToMat(srcarr1), src2 = cv::cvarrToMat(srcarr2), @@ -1791,6 +1963,7 @@ CV_IMPL void cvSub( const CvArr* srcarr1, const CvArr* srcarr2, CvArr* dstarr, c cv::subtract( src1, src2, dst, mask ); } + CV_IMPL void cvAddS( const CvArr* srcarr1, CvScalar value, CvArr* dstarr, const CvArr* maskarr ) { cv::Mat src1 = cv::cvarrToMat(srcarr1), @@ -1801,6 +1974,7 @@ CV_IMPL void cvAddS( const CvArr* srcarr1, CvScalar value, CvArr* dstarr, const cv::add( src1, value, dst, mask ); } + CV_IMPL void cvSubRS( const CvArr* srcarr1, CvScalar value, CvArr* dstarr, const CvArr* maskarr ) { cv::Mat src1 = cv::cvarrToMat(srcarr1), @@ -1811,6 +1985,7 @@ CV_IMPL void cvSubRS( const CvArr* srcarr1, CvScalar value, CvArr* dstarr, const cv::subtract( value, src1, dst, mask ); } + CV_IMPL void cvMul( const CvArr* srcarr1, const CvArr* srcarr2, CvArr* dstarr, double scale ) { @@ -1820,6 +1995,7 @@ CV_IMPL void cvMul( const CvArr* srcarr1, const CvArr* srcarr2, cv::multiply( src1, src2, dst, scale ); } + CV_IMPL void cvDiv( const CvArr* srcarr1, const CvArr* srcarr2, CvArr* dstarr, double scale ) { @@ -1865,6 +2041,7 @@ cvAbsDiffS( const CvArr* srcarr1, CvArr* dstarr, CvScalar scalar ) cv::absdiff( src1, scalar, dst ); } + CV_IMPL void cvInRange( const void* srcarr1, const void* srcarr2, const void* srcarr3, void* dstarr ) @@ -1875,6 +2052,7 @@ cvInRange( const void* srcarr1, const void* srcarr2, cv::inRange( src1, cv::cvarrToMat(srcarr2), cv::cvarrToMat(srcarr3), dst ); } + CV_IMPL void cvInRangeS( const void* srcarr1, CvScalar lowerb, CvScalar upperb, void* dstarr ) { @@ -1924,6 +2102,7 @@ cvMax( const void* srcarr1, const void* srcarr2, void* dstarr ) cv::max( src1, cv::cvarrToMat(srcarr2), dst ); } + CV_IMPL void cvMinS( const void* srcarr1, double value, void* dstarr ) { diff --git a/tests/cxts/cxts.cpp b/tests/cxts/cxts.cpp index 7d64be17e4..387e6a6ca1 100644 --- a/tests/cxts/cxts.cpp +++ b/tests/cxts/cxts.cpp @@ -1787,6 +1787,9 @@ void CvTS::print_summary_header( int streams ) { char csv_header[256], *ptr = csv_header; int i; +#ifdef HAVE_IPP + const IppLibraryVersion* ippver = ippGetLibVersion(); +#endif printf( streams, "Engine: %s\n", version ); time_t t1; @@ -1801,7 +1804,11 @@ void CvTS::print_summary_header( int streams ) printf( streams, "Tested Libraries: %s\n", lib_verinfo ); printf( streams, "Optimized Low-level Plugin\'s: %s\n", plugins ); printf( streams, "=================================================\n"); - +#ifdef HAVE_IPP + printf( streams, "Built with Intel(R) IPP\n" ); + printf( streams, " %s {%d.%d.%d.%d %s}\n", ippver->Version, ippver->major, ippver->minor, ippver->majorBuild, ippver->build, ippver->BuildDate ); + printf( streams, "=================================================\n"); +#endif sprintf( ptr, "funcName,dataType,channels,size," ); ptr += strlen(ptr);