ipp_countNonZero build fix;
Removed IPP port for tiny arithm.cpp functions Additional warnings fix on various platforms. Build without OPENCL and GCC warnings fixed Fixed warnings, trailing spaces and removed unused secure_cpy. IPP code refactored. IPP code path implemented as separate static functions to simplify future work with IPP code and make it more readable.
This commit is contained in:

committed by
Pavel Vlasov

parent
b1a8e4f760
commit
a5a21019b2
@@ -1166,103 +1166,22 @@ static bool ocl_pyrUp( InputArray _src, OutputArray _dst, const Size& _dsz, int
|
||||
|
||||
}
|
||||
|
||||
void cv::pyrDown( InputArray _src, OutputArray _dst, const Size& _dsz, int borderType )
|
||||
#if defined(HAVE_IPP)
|
||||
namespace cv
|
||||
{
|
||||
CV_Assert(borderType != BORDER_CONSTANT);
|
||||
|
||||
CV_OCL_RUN(_src.dims() <= 2 && _dst.isUMat(),
|
||||
ocl_pyrDown(_src, _dst, _dsz, borderType))
|
||||
static bool ipp_pyrdown( InputArray _src, OutputArray _dst, const Size& _dsz, int borderType )
|
||||
{
|
||||
#if IPP_VERSION_X100 >= 801 && 0
|
||||
Size dsz = _dsz.area() == 0 ? Size((_src.cols() + 1)/2, (_src.rows() + 1)/2) : _dsz;
|
||||
bool isolated = (borderType & BORDER_ISOLATED) != 0;
|
||||
int borderTypeNI = borderType & ~BORDER_ISOLATED;
|
||||
|
||||
Mat src = _src.getMat();
|
||||
Size dsz = _dsz.area() == 0 ? Size((src.cols + 1)/2, (src.rows + 1)/2) : _dsz;
|
||||
_dst.create( dsz, src.type() );
|
||||
Mat dst = _dst.getMat();
|
||||
int depth = src.depth();
|
||||
|
||||
#ifdef HAVE_TEGRA_OPTIMIZATION
|
||||
if(borderType == BORDER_DEFAULT && tegra::useTegra() && tegra::pyrDown(src, dst))
|
||||
return;
|
||||
#endif
|
||||
|
||||
#if IPP_VERSION_X100 >= 801 && 0
|
||||
CV_IPP_CHECK()
|
||||
{
|
||||
bool isolated = (borderType & BORDER_ISOLATED) != 0;
|
||||
int borderTypeNI = borderType & ~BORDER_ISOLATED;
|
||||
if (borderTypeNI == BORDER_DEFAULT && (!src.isSubmatrix() || isolated) && dsz == Size((src.cols + 1)/2, (src.rows + 1)/2))
|
||||
{
|
||||
typedef IppStatus (CV_STDCALL * ippiPyrDown)(const void* pSrc, int srcStep, void* pDst, int dstStep, IppiSize srcRoi, Ipp8u* buffer);
|
||||
int type = src.type();
|
||||
CV_SUPPRESS_DEPRECATED_START
|
||||
ippiPyrDown pyrDownFunc = type == CV_8UC1 ? (ippiPyrDown) ippiPyrDown_Gauss5x5_8u_C1R :
|
||||
type == CV_8UC3 ? (ippiPyrDown) ippiPyrDown_Gauss5x5_8u_C3R :
|
||||
type == CV_32FC1 ? (ippiPyrDown) ippiPyrDown_Gauss5x5_32f_C1R :
|
||||
type == CV_32FC3 ? (ippiPyrDown) ippiPyrDown_Gauss5x5_32f_C3R : 0;
|
||||
CV_SUPPRESS_DEPRECATED_END
|
||||
|
||||
if (pyrDownFunc)
|
||||
{
|
||||
int bufferSize;
|
||||
IppiSize srcRoi = { src.cols, src.rows };
|
||||
IppDataType dataType = depth == CV_8U ? ipp8u : ipp32f;
|
||||
CV_SUPPRESS_DEPRECATED_START
|
||||
IppStatus ok = ippiPyrDownGetBufSize_Gauss5x5(srcRoi.width, dataType, src.channels(), &bufferSize);
|
||||
CV_SUPPRESS_DEPRECATED_END
|
||||
if (ok >= 0)
|
||||
{
|
||||
Ipp8u* buffer = ippsMalloc_8u(bufferSize);
|
||||
ok = pyrDownFunc(src.data, (int) src.step, dst.data, (int) dst.step, srcRoi, buffer);
|
||||
ippsFree(buffer);
|
||||
|
||||
if (ok >= 0)
|
||||
{
|
||||
CV_IMPL_ADD(CV_IMPL_IPP);
|
||||
return;
|
||||
}
|
||||
setIppErrorStatus();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
PyrFunc func = 0;
|
||||
if( depth == CV_8U )
|
||||
func = pyrDown_<FixPtCast<uchar, 8>, PyrDownVec_32s8u>;
|
||||
else if( depth == CV_16S )
|
||||
func = pyrDown_<FixPtCast<short, 8>, PyrDownVec_32s16s >;
|
||||
else if( depth == CV_16U )
|
||||
func = pyrDown_<FixPtCast<ushort, 8>, PyrDownVec_32s16u >;
|
||||
else if( depth == CV_32F )
|
||||
func = pyrDown_<FltCast<float, 8>, PyrDownVec_32f>;
|
||||
else if( depth == CV_64F )
|
||||
func = pyrDown_<FltCast<double, 8>, PyrDownNoVec<double, double> >;
|
||||
else
|
||||
CV_Error( CV_StsUnsupportedFormat, "" );
|
||||
|
||||
func( src, dst, borderType );
|
||||
}
|
||||
|
||||
void cv::pyrUp( InputArray _src, OutputArray _dst, const Size& _dsz, int borderType )
|
||||
{
|
||||
CV_Assert(borderType == BORDER_DEFAULT);
|
||||
|
||||
CV_OCL_RUN(_src.dims() <= 2 && _dst.isUMat(),
|
||||
ocl_pyrUp(_src, _dst, _dsz, borderType))
|
||||
|
||||
Mat src = _src.getMat();
|
||||
Size dsz = _dsz.area() == 0 ? Size(src.cols*2, src.rows*2) : _dsz;
|
||||
_dst.create( dsz, src.type() );
|
||||
Mat dst = _dst.getMat();
|
||||
int depth = src.depth();
|
||||
|
||||
#ifdef HAVE_TEGRA_OPTIMIZATION
|
||||
if(borderType == BORDER_DEFAULT && tegra::useTegra() && tegra::pyrUp(src, dst))
|
||||
return;
|
||||
#endif
|
||||
|
||||
#if IPP_VERSION_X100 >= 801 && 0
|
||||
CV_IPP_CHECK()
|
||||
{
|
||||
bool isolated = (borderType & BORDER_ISOLATED) != 0;
|
||||
int borderTypeNI = borderType & ~BORDER_ISOLATED;
|
||||
@@ -1294,14 +1213,149 @@ void cv::pyrUp( InputArray _src, OutputArray _dst, const Size& _dsz, int borderT
|
||||
if (ok >= 0)
|
||||
{
|
||||
CV_IMPL_ADD(CV_IMPL_IPP);
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
setIppErrorStatus();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
CV_UNUSED(_src); CV_UNUSED(_dst); CV_UNUSED(_dsz); CV_UNUSED(borderType);
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void cv::pyrDown( InputArray _src, OutputArray _dst, const Size& _dsz, int borderType )
|
||||
{
|
||||
CV_Assert(borderType != BORDER_CONSTANT);
|
||||
|
||||
CV_OCL_RUN(_src.dims() <= 2 && _dst.isUMat(),
|
||||
ocl_pyrDown(_src, _dst, _dsz, borderType))
|
||||
|
||||
Mat src = _src.getMat();
|
||||
Size dsz = _dsz.area() == 0 ? Size((src.cols + 1)/2, (src.rows + 1)/2) : _dsz;
|
||||
_dst.create( dsz, src.type() );
|
||||
Mat dst = _dst.getMat();
|
||||
int depth = src.depth();
|
||||
|
||||
#ifdef HAVE_TEGRA_OPTIMIZATION
|
||||
if(borderType == BORDER_DEFAULT && tegra::useTegra() && tegra::pyrDown(src, dst))
|
||||
return;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_IPP
|
||||
bool isolated = (borderType & BORDER_ISOLATED) != 0;
|
||||
int borderTypeNI = borderType & ~BORDER_ISOLATED;
|
||||
#endif
|
||||
CV_IPP_RUN(borderTypeNI == BORDER_DEFAULT && (!_src.isSubmatrix() || isolated) && dsz == Size((_src.cols() + 1)/2, (_src.rows() + 1)/2),
|
||||
ipp_pyrdown( _src, _dst, _dsz, borderType));
|
||||
|
||||
|
||||
PyrFunc func = 0;
|
||||
if( depth == CV_8U )
|
||||
func = pyrDown_<FixPtCast<uchar, 8>, PyrDownVec_32s8u>;
|
||||
else if( depth == CV_16S )
|
||||
func = pyrDown_<FixPtCast<short, 8>, PyrDownVec_32s16s >;
|
||||
else if( depth == CV_16U )
|
||||
func = pyrDown_<FixPtCast<ushort, 8>, PyrDownVec_32s16u >;
|
||||
else if( depth == CV_32F )
|
||||
func = pyrDown_<FltCast<float, 8>, PyrDownVec_32f>;
|
||||
else if( depth == CV_64F )
|
||||
func = pyrDown_<FltCast<double, 8>, PyrDownNoVec<double, double> >;
|
||||
else
|
||||
CV_Error( CV_StsUnsupportedFormat, "" );
|
||||
|
||||
func( src, dst, borderType );
|
||||
}
|
||||
|
||||
|
||||
#if defined(HAVE_IPP)
|
||||
namespace cv
|
||||
{
|
||||
static bool ipp_pyrup( InputArray _src, OutputArray _dst, const Size& _dsz, int borderType )
|
||||
{
|
||||
#if IPP_VERSION_X100 >= 801 && 0
|
||||
Size sz = _src.dims() <= 2 ? _src.size() : Size();
|
||||
Size dsz = _dsz.area() == 0 ? Size(_src.cols()*2, _src.rows()*2) : _dsz;
|
||||
|
||||
Mat src = _src.getMat();
|
||||
_dst.create( dsz, src.type() );
|
||||
Mat dst = _dst.getMat();
|
||||
int depth = src.depth();
|
||||
|
||||
{
|
||||
bool isolated = (borderType & BORDER_ISOLATED) != 0;
|
||||
int borderTypeNI = borderType & ~BORDER_ISOLATED;
|
||||
if (borderTypeNI == BORDER_DEFAULT && (!src.isSubmatrix() || isolated) && dsz == Size(src.cols*2, src.rows*2))
|
||||
{
|
||||
typedef IppStatus (CV_STDCALL * ippiPyrUp)(const void* pSrc, int srcStep, void* pDst, int dstStep, IppiSize srcRoi, Ipp8u* buffer);
|
||||
int type = src.type();
|
||||
CV_SUPPRESS_DEPRECATED_START
|
||||
ippiPyrUp pyrUpFunc = type == CV_8UC1 ? (ippiPyrUp) ippiPyrUp_Gauss5x5_8u_C1R :
|
||||
type == CV_8UC3 ? (ippiPyrUp) ippiPyrUp_Gauss5x5_8u_C3R :
|
||||
type == CV_32FC1 ? (ippiPyrUp) ippiPyrUp_Gauss5x5_32f_C1R :
|
||||
type == CV_32FC3 ? (ippiPyrUp) ippiPyrUp_Gauss5x5_32f_C3R : 0;
|
||||
CV_SUPPRESS_DEPRECATED_END
|
||||
|
||||
if (pyrUpFunc)
|
||||
{
|
||||
int bufferSize;
|
||||
IppiSize srcRoi = { src.cols, src.rows };
|
||||
IppDataType dataType = depth == CV_8U ? ipp8u : ipp32f;
|
||||
CV_SUPPRESS_DEPRECATED_START
|
||||
IppStatus ok = ippiPyrUpGetBufSize_Gauss5x5(srcRoi.width, dataType, src.channels(), &bufferSize);
|
||||
CV_SUPPRESS_DEPRECATED_END
|
||||
if (ok >= 0)
|
||||
{
|
||||
Ipp8u* buffer = ippsMalloc_8u(bufferSize);
|
||||
ok = pyrUpFunc(src.data, (int) src.step, dst.data, (int) dst.step, srcRoi, buffer);
|
||||
ippsFree(buffer);
|
||||
|
||||
if (ok >= 0)
|
||||
{
|
||||
CV_IMPL_ADD(CV_IMPL_IPP);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
CV_UNUSED(_src); CV_UNUSED(_dst); CV_UNUSED(_dsz); CV_UNUSED(borderType);
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void cv::pyrUp( InputArray _src, OutputArray _dst, const Size& _dsz, int borderType )
|
||||
{
|
||||
CV_Assert(borderType == BORDER_DEFAULT);
|
||||
|
||||
CV_OCL_RUN(_src.dims() <= 2 && _dst.isUMat(),
|
||||
ocl_pyrUp(_src, _dst, _dsz, borderType))
|
||||
|
||||
|
||||
Mat src = _src.getMat();
|
||||
Size dsz = _dsz.area() == 0 ? Size(src.cols*2, src.rows*2) : _dsz;
|
||||
_dst.create( dsz, src.type() );
|
||||
Mat dst = _dst.getMat();
|
||||
int depth = src.depth();
|
||||
|
||||
#ifdef HAVE_TEGRA_OPTIMIZATION
|
||||
if(borderType == BORDER_DEFAULT && tegra::useTegra() && tegra::pyrUp(src, dst))
|
||||
return;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_IPP
|
||||
bool isolated = (borderType & BORDER_ISOLATED) != 0;
|
||||
int borderTypeNI = borderType & ~BORDER_ISOLATED;
|
||||
#endif
|
||||
CV_IPP_RUN(borderTypeNI == BORDER_DEFAULT && (!_src.isSubmatrix() || isolated) && dsz == Size(_src.cols()*2, _src.rows()*2),
|
||||
ipp_pyrup( _src, _dst, _dsz, borderType));
|
||||
|
||||
|
||||
PyrFunc func = 0;
|
||||
if( depth == CV_8U )
|
||||
@@ -1320,28 +1374,19 @@ void cv::pyrUp( InputArray _src, OutputArray _dst, const Size& _dsz, int borderT
|
||||
func( src, dst, borderType );
|
||||
}
|
||||
|
||||
void cv::buildPyramid( InputArray _src, OutputArrayOfArrays _dst, int maxlevel, int borderType )
|
||||
|
||||
#if 0 //#ifdef HAVE_IPP
|
||||
namespace cv
|
||||
{
|
||||
CV_Assert(borderType != BORDER_CONSTANT);
|
||||
|
||||
if (_src.dims() <= 2 && _dst.isUMatVector())
|
||||
{
|
||||
UMat src = _src.getUMat();
|
||||
_dst.create( maxlevel + 1, 1, 0 );
|
||||
_dst.getUMatRef(0) = src;
|
||||
for( int i = 1; i <= maxlevel; i++ )
|
||||
pyrDown( _dst.getUMatRef(i-1), _dst.getUMatRef(i), Size(), borderType );
|
||||
return;
|
||||
}
|
||||
|
||||
static bool ipp_buildpyramid( InputArray _src, OutputArrayOfArrays _dst, int maxlevel, int borderType )
|
||||
{
|
||||
#if IPP_VERSION_X100 >= 801 && 0
|
||||
Mat src = _src.getMat();
|
||||
_dst.create( maxlevel + 1, 1, 0 );
|
||||
_dst.getMatRef(0) = src;
|
||||
|
||||
int i=1;
|
||||
|
||||
#if IPP_VERSION_X100 >= 801 && 0
|
||||
CV_IPP_CHECK()
|
||||
{
|
||||
bool isolated = (borderType & BORDER_ISOLATED) != 0;
|
||||
int borderTypeNI = borderType & ~BORDER_ISOLATED;
|
||||
@@ -1414,8 +1459,8 @@ void cv::buildPyramid( InputArray _src, OutputArrayOfArrays _dst, int maxlevel,
|
||||
|
||||
if (ok < 0)
|
||||
{
|
||||
setIppErrorStatus();
|
||||
break;
|
||||
pyrFreeFunc(gPyr->pState);
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1425,13 +1470,52 @@ void cv::buildPyramid( InputArray _src, OutputArrayOfArrays _dst, int maxlevel,
|
||||
pyrFreeFunc(gPyr->pState);
|
||||
}
|
||||
else
|
||||
setIppErrorStatus();
|
||||
|
||||
{
|
||||
ippiPyramidFree(gPyr);
|
||||
return false;
|
||||
}
|
||||
ippiPyramidFree(gPyr);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
#else
|
||||
CV_UNUSED(_src); CV_UNUSED(_dst); CV_UNUSED(maxlevel); CV_UNUSED(borderType);
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void cv::buildPyramid( InputArray _src, OutputArrayOfArrays _dst, int maxlevel, int borderType )
|
||||
{
|
||||
CV_Assert(borderType != BORDER_CONSTANT);
|
||||
|
||||
if (_src.dims() <= 2 && _dst.isUMatVector())
|
||||
{
|
||||
UMat src = _src.getUMat();
|
||||
_dst.create( maxlevel + 1, 1, 0 );
|
||||
_dst.getUMatRef(0) = src;
|
||||
for( int i = 1; i <= maxlevel; i++ )
|
||||
pyrDown( _dst.getUMatRef(i-1), _dst.getUMatRef(i), Size(), borderType );
|
||||
return;
|
||||
}
|
||||
|
||||
Mat src = _src.getMat();
|
||||
_dst.create( maxlevel + 1, 1, 0 );
|
||||
_dst.getMatRef(0) = src;
|
||||
|
||||
int i=1;
|
||||
|
||||
#if (IPP_VERSION_X100 >= 801 && 0)
|
||||
bool isolated = (borderType & BORDER_ISOLATED) != 0;
|
||||
int borderTypeNI = borderType & ~BORDER_ISOLATED;
|
||||
CV_IPP_RUN(((IPP_VERSION_X100 >= 801 && 0) && (borderTypeNI == BORDER_DEFAULT && (!_src.isSubmatrix() || isolated))),
|
||||
ipp_buildpyramid( _src, _dst, maxlevel, borderType));
|
||||
#endif
|
||||
|
||||
|
||||
for( ; i <= maxlevel; i++ )
|
||||
pyrDown( _dst.getMatRef(i-1), _dst.getMatRef(i), Size(), borderType );
|
||||
}
|
||||
|
Reference in New Issue
Block a user