Merge pull request #2663 from ilya-lavrenov:ipp_slow

This commit is contained in:
Alexander Alekhin 2014-05-14 12:30:04 +04:00 committed by OpenCV Buildbot
commit 46d672dcc3
9 changed files with 49 additions and 50 deletions

View File

@ -423,7 +423,7 @@ Mat& Mat::setTo(InputArray _value, InputArray _mask)
int cn = channels(), depth0 = depth(); int cn = channels(), depth0 = depth();
if (!mask.empty() && (dims <= 2 || (isContinuous() && mask.isContinuous())) && if (!mask.empty() && (dims <= 2 || (isContinuous() && mask.isContinuous())) &&
(depth0 == CV_8U || depth0 == CV_16U || depth0 == CV_16S || depth0 == CV_32S || depth0 == CV_32F) && (/*depth0 == CV_8U ||*/ depth0 == CV_16U || depth0 == CV_16S || depth0 == CV_32S || depth0 == CV_32F) &&
(cn == 1 || cn == 3 || cn == 4)) (cn == 1 || cn == 3 || cn == 4))
{ {
uchar _buf[32]; uchar _buf[32];
@ -442,9 +442,9 @@ Mat& Mat::setTo(InputArray _value, InputArray _mask)
if (cn == 1) if (cn == 1)
{ {
if (depth0 == CV_8U) /*if (depth0 == CV_8U)
status = ippiSet_8u_C1MR(*(Ipp8u *)buf, (Ipp8u *)data, dstep, roisize, mask.data, mstep); status = ippiSet_8u_C1MR(*(Ipp8u *)buf, (Ipp8u *)data, dstep, roisize, mask.data, mstep);
else if (depth0 == CV_16U) else*/ if (depth0 == CV_16U)
status = ippiSet_16u_C1MR(*(Ipp16u *)buf, (Ipp16u *)data, dstep, roisize, mask.data, mstep); status = ippiSet_16u_C1MR(*(Ipp16u *)buf, (Ipp16u *)data, dstep, roisize, mask.data, mstep);
else if (depth0 == CV_16S) else if (depth0 == CV_16S)
status = ippiSet_16s_C1MR(*(Ipp16s *)buf, (Ipp16s *)data, dstep, roisize, mask.data, mstep); status = ippiSet_16s_C1MR(*(Ipp16s *)buf, (Ipp16s *)data, dstep, roisize, mask.data, mstep);
@ -468,9 +468,9 @@ Mat& Mat::setTo(InputArray _value, InputArray _mask)
{ \ { \
if (cn == ippcn) \ if (cn == ippcn) \
{ \ { \
if (depth0 == CV_8U) \ /*if (depth0 == CV_8U) \
IPP_SET(8u, ippcn); \ IPP_SET(8u, ippcn); \
else if (depth0 == CV_16U) \ else*/ if (depth0 == CV_16U) \
IPP_SET(16u, ippcn); \ IPP_SET(16u, ippcn); \
else if (depth0 == CV_16S) \ else if (depth0 == CV_16S) \
IPP_SET(16s, ippcn); \ IPP_SET(16s, ippcn); \

View File

@ -237,7 +237,7 @@ float cubeRoot( float value )
static void Magnitude_32f(const float* x, const float* y, float* mag, int len) static void Magnitude_32f(const float* x, const float* y, float* mag, int len)
{ {
#if defined(HAVE_IPP) #if defined HAVE_IPP && 0
IppStatus status = ippsMagnitude_32f(x, y, mag, len); IppStatus status = ippsMagnitude_32f(x, y, mag, len);
if (status >= 0) if (status >= 0)
return; return;

View File

@ -2798,7 +2798,7 @@ dotProd_(const T* src1, const T* src2, int len)
static double dotProd_8u(const uchar* src1, const uchar* src2, int len) static double dotProd_8u(const uchar* src1, const uchar* src2, int len)
{ {
double r = 0; double r = 0;
#if ARITHM_USE_IPP #if ARITHM_USE_IPP && 0
if (0 <= ippiDotProd_8u64f_C1R(src1, (int)(len*sizeof(src1[0])), if (0 <= ippiDotProd_8u64f_C1R(src1, (int)(len*sizeof(src1[0])),
src2, (int)(len*sizeof(src2[0])), src2, (int)(len*sizeof(src2[0])),
ippiSize(len, 1), &r)) ippiSize(len, 1), &r))

View File

@ -3624,18 +3624,18 @@ static IppSortFunc getSortFunc(int depth, bool sortDescending)
{ {
if (!sortDescending) if (!sortDescending)
return depth == CV_8U ? (IppSortFunc)ippsSortAscend_8u_I : return depth == CV_8U ? (IppSortFunc)ippsSortAscend_8u_I :
depth == CV_16U ? (IppSortFunc)ippsSortAscend_16u_I : /*depth == CV_16U ? (IppSortFunc)ippsSortAscend_16u_I :
depth == CV_16S ? (IppSortFunc)ippsSortAscend_16s_I : depth == CV_16S ? (IppSortFunc)ippsSortAscend_16s_I :
depth == CV_32S ? (IppSortFunc)ippsSortAscend_32s_I : depth == CV_32S ? (IppSortFunc)ippsSortAscend_32s_I :
depth == CV_32F ? (IppSortFunc)ippsSortAscend_32f_I : depth == CV_32F ? (IppSortFunc)ippsSortAscend_32f_I :
depth == CV_64F ? (IppSortFunc)ippsSortAscend_64f_I : 0; depth == CV_64F ? (IppSortFunc)ippsSortAscend_64f_I :*/ 0;
else else
return depth == CV_8U ? (IppSortFunc)ippsSortDescend_8u_I : return depth == CV_8U ? (IppSortFunc)ippsSortDescend_8u_I :
depth == CV_16U ? (IppSortFunc)ippsSortDescend_16u_I : /*depth == CV_16U ? (IppSortFunc)ippsSortDescend_16u_I :
depth == CV_16S ? (IppSortFunc)ippsSortDescend_16s_I : depth == CV_16S ? (IppSortFunc)ippsSortDescend_16s_I :
depth == CV_32S ? (IppSortFunc)ippsSortDescend_32s_I : depth == CV_32S ? (IppSortFunc)ippsSortDescend_32s_I :
depth == CV_32F ? (IppSortFunc)ippsSortDescend_32f_I : depth == CV_32F ? (IppSortFunc)ippsSortDescend_32f_I :
depth == CV_64F ? (IppSortFunc)ippsSortDescend_64f_I : 0; depth == CV_64F ? (IppSortFunc)ippsSortDescend_64f_I :*/ 0;
} }
static IppFlipFunc getFlipFunc(int depth) static IppFlipFunc getFlipFunc(int depth)
@ -3643,9 +3643,9 @@ static IppFlipFunc getFlipFunc(int depth)
CV_SUPPRESS_DEPRECATED_START CV_SUPPRESS_DEPRECATED_START
return return
depth == CV_8U || depth == CV_8S ? (IppFlipFunc)ippsFlip_8u_I : depth == CV_8U || depth == CV_8S ? (IppFlipFunc)ippsFlip_8u_I :
depth == CV_16U || depth == CV_16S ? (IppFlipFunc)ippsFlip_16u_I : /*depth == CV_16U || depth == CV_16S ? (IppFlipFunc)ippsFlip_16u_I :
depth == CV_32S || depth == CV_32F ? (IppFlipFunc)ippsFlip_32f_I : depth == CV_32S || depth == CV_32F ? (IppFlipFunc)ippsFlip_32f_I :
depth == CV_64F ? (IppFlipFunc)ippsFlip_64f_I : 0; depth == CV_64F ? (IppFlipFunc)ippsFlip_64f_I : */0;
CV_SUPPRESS_DEPRECATED_END CV_SUPPRESS_DEPRECATED_END
} }
@ -3700,6 +3700,7 @@ template<typename T> static void sort_( const Mat& src, Mat& dst, int flags )
#endif #endif
{ {
#ifdef USE_IPP_SORT #ifdef USE_IPP_SORT
if (depth != CV_8U)
setIppErrorStatus(); setIppErrorStatus();
#endif #endif
std::sort( ptr, ptr + len ); std::sort( ptr, ptr + len );
@ -3732,7 +3733,7 @@ public:
const _Tp* arr; const _Tp* arr;
}; };
#ifdef USE_IPP_SORT #if defined USE_IPP_SORT && 0
typedef IppStatus (CV_STDCALL *IppSortIndexFunc)(void *, int *, int); typedef IppStatus (CV_STDCALL *IppSortIndexFunc)(void *, int *, int);
@ -3779,7 +3780,7 @@ template<typename T> static void sortIdx_( const Mat& src, Mat& dst, int flags )
bptr = (T*)buf; bptr = (T*)buf;
_iptr = (int*)ibuf; _iptr = (int*)ibuf;
#ifdef USE_IPP_SORT #if defined USE_IPP_SORT && 0
int depth = src.depth(); int depth = src.depth();
IppSortIndexFunc ippFunc = getSortIndexFunc(depth, sortDescending); IppSortIndexFunc ippFunc = getSortIndexFunc(depth, sortDescending);
IppFlipFunc ippFlipFunc = getFlipFunc(depth); IppFlipFunc ippFlipFunc = getFlipFunc(depth);
@ -3803,21 +3804,21 @@ template<typename T> static void sortIdx_( const Mat& src, Mat& dst, int flags )
for( j = 0; j < len; j++ ) for( j = 0; j < len; j++ )
iptr[j] = j; iptr[j] = j;
#ifdef USE_IPP_SORT #if defined USE_IPP_SORT && 0
if (sortRows || !ippFunc || ippFunc(ptr, iptr, len) < 0) if (sortRows || !ippFunc || ippFunc(ptr, iptr, len) < 0)
#endif #endif
{ {
#ifdef USE_IPP_SORT #if defined USE_IPP_SORT && 0
setIppErrorStatus(); setIppErrorStatus();
#endif #endif
std::sort( iptr, iptr + len, LessThanIdx<T>(ptr) ); std::sort( iptr, iptr + len, LessThanIdx<T>(ptr) );
if( sortDescending ) if( sortDescending )
{ {
#ifdef USE_IPP_SORT #if defined USE_IPP_SORT && 0
if (!ippFlipFunc || ippFlipFunc(iptr, len) < 0) if (!ippFlipFunc || ippFlipFunc(iptr, len) < 0)
#endif #endif
{ {
#ifdef USE_IPP_SORT #if defined USE_IPP_SORT && 0
setIppErrorStatus(); setIppErrorStatus();
#endif #endif
for( j = 0; j < len/2; j++ ) for( j = 0; j < len/2; j++ )

View File

@ -3977,22 +3977,20 @@ void cv::cvtColor( InputArray _src, OutputArray _dst, int code, int dcn )
setIppErrorStatus(); setIppErrorStatus();
} }
else else
#endif if (code == CV_LRGB2Lab && scn == 3 && depth == CV_8U) // slower than OpenCV
if (code == CV_LRGB2Lab && scn == 3 && depth == CV_8U)
{ {
if (CvtColorIPPLoop(src, dst, IPPReorderGeneralFunctor(ippiSwapChannelsC3RTab[depth], if (CvtColorIPPLoop(src, dst, IPPReorderGeneralFunctor(ippiSwapChannelsC3RTab[depth],
(ippiGeneralFunc)ippiBGRToLab_8u_C3R, 2, 1, 0, depth))) (ippiGeneralFunc)ippiBGRToLab_8u_C3R, 2, 1, 0, depth)))
return; return;
setIppErrorStatus(); setIppErrorStatus();
} }
else if (code == CV_LRGB2Lab && scn == 4 && depth == CV_8U) else if (code == CV_LRGB2Lab && scn == 4 && depth == CV_8U) // slower than OpenCV
{ {
if (CvtColorIPPLoop(src, dst, IPPReorderGeneralFunctor(ippiSwapChannelsC4C3RTab[depth], if (CvtColorIPPLoop(src, dst, IPPReorderGeneralFunctor(ippiSwapChannelsC4C3RTab[depth],
(ippiGeneralFunc)ippiBGRToLab_8u_C3R, 2, 1, 0, depth))) (ippiGeneralFunc)ippiBGRToLab_8u_C3R, 2, 1, 0, depth)))
return; return;
setIppErrorStatus(); setIppErrorStatus();
} }
#if 0
else if (code == CV_LRGB2Luv && scn == 3) else if (code == CV_LRGB2Luv && scn == 3)
{ {
if (CvtColorIPPLoop(src, dst, IPPGeneralFunctor(ippiRGBToLUVTab[depth]))) if (CvtColorIPPLoop(src, dst, IPPGeneralFunctor(ippiRGBToLUVTab[depth])))
@ -4054,7 +4052,7 @@ void cv::cvtColor( InputArray _src, OutputArray _dst, int code, int dcn )
_dst.create(sz, CV_MAKETYPE(depth, dcn)); _dst.create(sz, CV_MAKETYPE(depth, dcn));
dst = _dst.getMat(); dst = _dst.getMat();
#if defined(HAVE_IPP) && 0 #if defined HAVE_IPP && 0
if( code == CV_Lab2LBGR && dcn == 3 && depth == CV_8U) if( code == CV_Lab2LBGR && dcn == 3 && depth == CV_8U)
{ {
if( CvtColorIPPLoop(src, dst, IPPGeneralFunctor((ippiGeneralFunc)ippiLabToBGR_8u_C3R)) ) if( CvtColorIPPLoop(src, dst, IPPGeneralFunctor((ippiGeneralFunc)ippiLabToBGR_8u_C3R)) )

View File

@ -526,7 +526,7 @@ void cv::cornerHarris( InputArray _src, OutputArray _dst, int blockSize, int ksi
_dst.create( src.size(), CV_32FC1 ); _dst.create( src.size(), CV_32FC1 );
Mat dst = _dst.getMat(); Mat dst = _dst.getMat();
#if IPP_VERSION_X100 >= 801 #if IPP_VERSION_X100 >= 801 && 0
int type = src.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type); int type = src.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type);
int borderTypeNI = borderType & ~BORDER_ISOLATED; int borderTypeNI = borderType & ~BORDER_ISOLATED;
bool isolated = (borderType & BORDER_ISOLATED) != 0; bool isolated = (borderType & BORDER_ISOLATED) != 0;
@ -563,9 +563,7 @@ void cv::cornerHarris( InputArray _src, OutputArray _dst, int blockSize, int ksi
if (status >= 0) if (status >= 0)
return; return;
setIppErrorStatus();
} }
else
setIppErrorStatus(); setIppErrorStatus();
} }
#endif #endif

View File

@ -2086,9 +2086,7 @@ static bool ocl_resize( InputArray _src, OutputArray _dst, Size dsize,
k.create("resizeSampler", ocl::imgproc::resize_oclsrc, compileOpts); k.create("resizeSampler", ocl::imgproc::resize_oclsrc, compileOpts);
if (k.empty()) if (k.empty())
{
useSampler = false; useSampler = false;
}
else else
{ {
// Convert the input into an OpenCL image type, using normalized channel data types // Convert the input into an OpenCL image type, using normalized channel data types
@ -2397,6 +2395,12 @@ void cv::resize( InputArray _src, OutputArray _dst, Size dsize,
double scale_x = 1./inv_scale_x, scale_y = 1./inv_scale_y; double scale_x = 1./inv_scale_x, scale_y = 1./inv_scale_y;
int k, sx, sy, dx, dy; int k, sx, sy, dx, dy;
int iscale_x = saturate_cast<int>(scale_x);
int iscale_y = saturate_cast<int>(scale_y);
bool is_area_fast = std::abs(scale_x - iscale_x) < DBL_EPSILON &&
std::abs(scale_y - iscale_y) < DBL_EPSILON;
#if IPP_VERSION_X100 >= 701 #if IPP_VERSION_X100 >= 701
#define IPP_RESIZE_EPS 1e-10 #define IPP_RESIZE_EPS 1e-10
@ -2404,7 +2408,8 @@ void cv::resize( InputArray _src, OutputArray _dst, Size dsize,
double ey = fabs((double)dsize.height / src.rows - inv_scale_y) / inv_scale_y; double ey = fabs((double)dsize.height / src.rows - inv_scale_y) / inv_scale_y;
if ( ((ex < IPP_RESIZE_EPS && ey < IPP_RESIZE_EPS && depth != CV_64F) || (ex == 0 && ey == 0 && depth == CV_64F)) && if ( ((ex < IPP_RESIZE_EPS && ey < IPP_RESIZE_EPS && depth != CV_64F) || (ex == 0 && ey == 0 && depth == CV_64F)) &&
(interpolation == INTER_LINEAR || interpolation == INTER_CUBIC)) (interpolation == INTER_LINEAR || interpolation == INTER_CUBIC) &&
!(interpolation == INTER_LINEAR && is_area_fast && iscale_x == 2 && iscale_y == 2 && depth == CV_8U))
{ {
int mode = -1; int mode = -1;
if (interpolation == INTER_LINEAR && src.rows >= 2 && src.cols >= 2) if (interpolation == INTER_LINEAR && src.rows >= 2 && src.cols >= 2)
@ -2435,12 +2440,6 @@ void cv::resize( InputArray _src, OutputArray _dst, Size dsize,
} }
{ {
int iscale_x = saturate_cast<int>(scale_x);
int iscale_y = saturate_cast<int>(scale_y);
bool is_area_fast = std::abs(scale_x - iscale_x) < DBL_EPSILON &&
std::abs(scale_y - iscale_y) < DBL_EPSILON;
// in case of scale_x && scale_y is equal to 2 // in case of scale_x && scale_y is equal to 2
// INTER_AREA (fast) also is equal to INTER_LINEAR // INTER_AREA (fast) also is equal to INTER_LINEAR
if( interpolation == INTER_LINEAR && is_area_fast && iscale_x == 2 && iscale_y == 2 ) if( interpolation == INTER_LINEAR && is_area_fast && iscale_x == 2 && iscale_y == 2 )

View File

@ -462,7 +462,7 @@ cv::Moments cv::moments( InputArray _src, bool binary )
if( cn > 1 ) if( cn > 1 )
CV_Error( CV_StsBadArg, "Invalid image type (must be single-channel)" ); CV_Error( CV_StsBadArg, "Invalid image type (must be single-channel)" );
#if IPP_VERSION_X100 >= 801 #if IPP_VERSION_X100 >= 801 && 0
if (!binary) if (!binary)
{ {
IppiSize roi = { mat.cols, mat.rows }; IppiSize roi = { mat.cols, mat.rows };

View File

@ -508,7 +508,7 @@ void cv::pyrDown( InputArray _src, OutputArray _dst, const Size& _dsz, int borde
return; return;
#endif #endif
#if IPP_VERSION_X100 >= 801 #if IPP_VERSION_X100 >= 801 && 0
bool isolated = (borderType & BORDER_ISOLATED) != 0; bool isolated = (borderType & BORDER_ISOLATED) != 0;
int borderTypeNI = borderType & ~BORDER_ISOLATED; int borderTypeNI = borderType & ~BORDER_ISOLATED;
if (borderTypeNI == BORDER_DEFAULT && (!src.isSubmatrix() || isolated) && dsz == Size((src.cols + 1)/2, (src.rows + 1)/2)) if (borderTypeNI == BORDER_DEFAULT && (!src.isSubmatrix() || isolated) && dsz == Size((src.cols + 1)/2, (src.rows + 1)/2))
@ -577,7 +577,7 @@ void cv::pyrUp( InputArray _src, OutputArray _dst, const Size& _dsz, int borderT
return; return;
#endif #endif
#if IPP_VERSION_X100 >= 801 #if IPP_VERSION_X100 >= 801 && 0
bool isolated = (borderType & BORDER_ISOLATED) != 0; bool isolated = (borderType & BORDER_ISOLATED) != 0;
int borderTypeNI = borderType & ~BORDER_ISOLATED; int borderTypeNI = borderType & ~BORDER_ISOLATED;
if (borderTypeNI == BORDER_DEFAULT && (!src.isSubmatrix() || isolated) && dsz == Size(src.cols*2, src.rows*2)) if (borderTypeNI == BORDER_DEFAULT && (!src.isSubmatrix() || isolated) && dsz == Size(src.cols*2, src.rows*2))
@ -648,7 +648,7 @@ void cv::buildPyramid( InputArray _src, OutputArrayOfArrays _dst, int maxlevel,
int i=1; int i=1;
#if IPP_VERSION_X100 >= 801 #if IPP_VERSION_X100 >= 801 && 0
bool isolated = (borderType & BORDER_ISOLATED) != 0; bool isolated = (borderType & BORDER_ISOLATED) != 0;
int borderTypeNI = borderType & ~BORDER_ISOLATED; int borderTypeNI = borderType & ~BORDER_ISOLATED;
if (borderTypeNI == BORDER_DEFAULT && (!src.isSubmatrix() || isolated)) if (borderTypeNI == BORDER_DEFAULT && (!src.isSubmatrix() || isolated))
@ -668,17 +668,20 @@ void cv::buildPyramid( InputArray _src, OutputArrayOfArrays _dst, int maxlevel,
pyrInitAllocFunc = (ippiPyramidLayerDownInitAlloc) ippiPyramidLayerDownInitAlloc_8u_C1R; pyrInitAllocFunc = (ippiPyramidLayerDownInitAlloc) ippiPyramidLayerDownInitAlloc_8u_C1R;
pyrDownFunc = (ippiPyramidLayerDown) ippiPyramidLayerDown_8u_C1R; pyrDownFunc = (ippiPyramidLayerDown) ippiPyramidLayerDown_8u_C1R;
pyrFreeFunc = (ippiPyramidLayerDownFree) ippiPyramidLayerDownFree_8u_C1R; pyrFreeFunc = (ippiPyramidLayerDownFree) ippiPyramidLayerDownFree_8u_C1R;
} else if (type == CV_8UC3) }
else if (type == CV_8UC3)
{ {
pyrInitAllocFunc = (ippiPyramidLayerDownInitAlloc) ippiPyramidLayerDownInitAlloc_8u_C3R; pyrInitAllocFunc = (ippiPyramidLayerDownInitAlloc) ippiPyramidLayerDownInitAlloc_8u_C3R;
pyrDownFunc = (ippiPyramidLayerDown) ippiPyramidLayerDown_8u_C3R; pyrDownFunc = (ippiPyramidLayerDown) ippiPyramidLayerDown_8u_C3R;
pyrFreeFunc = (ippiPyramidLayerDownFree) ippiPyramidLayerDownFree_8u_C3R; pyrFreeFunc = (ippiPyramidLayerDownFree) ippiPyramidLayerDownFree_8u_C3R;
} else if (type == CV_32FC1) }
else if (type == CV_32FC1)
{ {
pyrInitAllocFunc = (ippiPyramidLayerDownInitAlloc) ippiPyramidLayerDownInitAlloc_32f_C1R; pyrInitAllocFunc = (ippiPyramidLayerDownInitAlloc) ippiPyramidLayerDownInitAlloc_32f_C1R;
pyrDownFunc = (ippiPyramidLayerDown) ippiPyramidLayerDown_32f_C1R; pyrDownFunc = (ippiPyramidLayerDown) ippiPyramidLayerDown_32f_C1R;
pyrFreeFunc = (ippiPyramidLayerDownFree) ippiPyramidLayerDownFree_32f_C1R; pyrFreeFunc = (ippiPyramidLayerDownFree) ippiPyramidLayerDownFree_32f_C1R;
} else if (type == CV_32FC3) }
else if (type == CV_32FC3)
{ {
pyrInitAllocFunc = (ippiPyramidLayerDownInitAlloc) ippiPyramidLayerDownInitAlloc_32f_C3R; pyrInitAllocFunc = (ippiPyramidLayerDownInitAlloc) ippiPyramidLayerDownInitAlloc_32f_C3R;
pyrDownFunc = (ippiPyramidLayerDown) ippiPyramidLayerDown_32f_C3R; pyrDownFunc = (ippiPyramidLayerDown) ippiPyramidLayerDown_32f_C3R;
@ -722,10 +725,10 @@ void cv::buildPyramid( InputArray _src, OutputArrayOfArrays _dst, int maxlevel,
} }
} }
pyrFreeFunc(gPyr->pState); pyrFreeFunc(gPyr->pState);
} else
{
setIppErrorStatus();
} }
else
setIppErrorStatus();
ippiPyramidFree(gPyr); ippiPyramidFree(gPyr);
} }
} }