1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-30 15:53:03 +04:00

Enables support of IPP 9.0.0;

HAVE_IPP_ICV_ONLY will be undefined if OpenCV was linked against ICV packet from IPP9 or greater. ICV9+ packets will be aligned with IPP in OpenCV APIs
This will ease code management between IPP and ICV
This commit is contained in:
Pavel Vlasov
2015-09-25 17:56:19 +03:00
parent 14b006e808
commit 62854dcc0d
9 changed files with 352 additions and 69 deletions
+52 -9
View File
@@ -1180,7 +1180,7 @@ class IPPCalcHistInvoker :
public ParallelLoopBody
{
public:
IPPCalcHistInvoker(const Mat & _src, Mat & _hist, AutoBuffer<Ipp32s> & _levels, Ipp32s _histSize, Ipp32s _low, Ipp32s _high, bool * _ok) :
IPPCalcHistInvoker(const Mat & _src, Mat & _hist, AutoBuffer<Ipp32f> & _levels, Ipp32s _histSize, Ipp32f _low, Ipp32f _high, bool * _ok) :
ParallelLoopBody(), src(&_src), hist(&_hist), levels(&_levels), histSize(_histSize), low(_low), high(_high), ok(_ok)
{
*ok = true;
@@ -1189,12 +1189,54 @@ public:
virtual void operator() (const Range & range) const
{
Mat phist(hist->size(), hist->type(), Scalar::all(0));
#if IPP_VERSION_X100 >= 900
IppiSize roi = {src->cols, range.end - range.start};
int bufferSize = 0;
int specSize = 0;
IppiHistogramSpec *pSpec = NULL;
Ipp8u *pBuffer = NULL;
IppStatus status = ippiHistogramEven_8u_C1R(
src->ptr(range.start), (int)src->step, ippiSize(src->cols, range.end - range.start),
phist.ptr<Ipp32s>(), (Ipp32s *)*levels, histSize, low, high);
if(ippiHistogramGetBufferSize(ipp8u, roi, &histSize, 1, 1, &specSize, &bufferSize) < 0)
{
*ok = false;
return;
}
if (status < 0)
pBuffer = (Ipp8u*)ippMalloc(bufferSize);
if(!pBuffer && bufferSize)
{
*ok = false;
return;
}
pSpec = (IppiHistogramSpec*)ippMalloc(specSize);
if(!pSpec && specSize)
{
if(pBuffer) ippFree(pBuffer);
*ok = false;
return;
}
if(ippiHistogramUniformInit(ipp8u, (Ipp32f*)&low, (Ipp32f*)&high, (Ipp32s*)&histSize, 1, pSpec) < 0)
{
if(pSpec) ippFree(pSpec);
if(pBuffer) ippFree(pBuffer);
*ok = false;
return;
}
IppStatus status = ippiHistogram_8u_C1R(src->ptr(range.start), (int)src->step, ippiSize(src->cols, range.end - range.start),
phist.ptr<Ipp32u>(), pSpec, pBuffer);
if(pSpec) ippFree(pSpec);
if(pBuffer) ippFree(pBuffer);
#else
CV_SUPPRESS_DEPRECATED_START
IppStatus status = ippiHistogramEven_8u_C1R(src->ptr(range.start), (int)src->step, ippiSize(src->cols, range.end - range.start),
phist.ptr<Ipp32s>(), (Ipp32s*)(Ipp32f*)*levels, histSize, (Ipp32s)low, (Ipp32s)high);
CV_SUPPRESS_DEPRECATED_END
#endif
if(status < 0)
{
*ok = false;
return;
@@ -1207,8 +1249,9 @@ public:
private:
const Mat * src;
Mat * hist;
AutoBuffer<Ipp32s> * levels;
Ipp32s histSize, low, high;
AutoBuffer<Ipp32f> * levels;
Ipp32s histSize;
Ipp32f low, high;
bool * ok;
const IPPCalcHistInvoker & operator = (const IPPCalcHistInvoker & );
@@ -1239,7 +1282,7 @@ static bool ipp_calchist(const Mat* images, int nimages, const int* channels,
!accumulate && uniform)
{
ihist.setTo(Scalar::all(0));
AutoBuffer<Ipp32s> levels(histSize[0] + 1);
AutoBuffer<Ipp32f> levels(histSize[0] + 1);
bool ok = true;
const Mat & src = images[0];
@@ -1247,7 +1290,7 @@ static bool ipp_calchist(const Mat* images, int nimages, const int* channels,
#ifdef HAVE_CONCURRENCY
nstripes = 1;
#endif
IPPCalcHistInvoker invoker(src, ihist, levels, histSize[0] + 1, (Ipp32s)ranges[0][0], (Ipp32s)ranges[0][1], &ok);
IPPCalcHistInvoker invoker(src, ihist, levels, histSize[0] + 1, ranges[0][0], ranges[0][1], &ok);
Range range(0, src.rows);
parallel_for_(range, invoker, nstripes);