Skip to content

Commit 544eb4b

Browse files
committed
IPP: update minMaxIdx, disable some AVX optimizations with mask
1 parent d9e0923 commit 544eb4b

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

modules/core/src/stat.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2530,6 +2530,12 @@ static bool ipp_minMaxIdx(Mat &src, double* _minVal, double* _maxVal, int* _minI
25302530
return false;
25312531
#endif
25322532

2533+
// cv::minMaxIdx problem with index positions on AVX
2534+
#if IPP_VERSION_X100 < 201810
2535+
if(!mask.empty() && _maxIdx && ipp::getIppFeatures()&ippCPUID_AVX)
2536+
return false;
2537+
#endif
2538+
25332539
IppStatus status;
25342540
IppDataType dataType = ippiGetDataType(src.depth());
25352541
float minVal = 0;
@@ -2561,15 +2567,16 @@ static bool ipp_minMaxIdx(Mat &src, double* _minVal, double* _maxVal, int* _minI
25612567
size.width *= src.channels();
25622568

25632569
status = ippMinMaxFun(src.ptr(), (int)src.step, size, dataType, pMinVal, pMaxVal, pMinIdx, pMaxIdx, (Ipp8u*)mask.ptr(), (int)mask.step);
2564-
if(status < 0 || status == ippStsNoOperation)
2570+
if(status < 0)
25652571
return false;
25662572
if(_minVal)
25672573
*_minVal = minVal;
25682574
if(_maxVal)
25692575
*_maxVal = maxVal;
25702576
if(_minIdx)
25712577
{
2572-
if(!mask.empty() && !minIdx.y && !minIdx.x)
2578+
// Should be just ippStsNoOperation check, but there is a bug in the function so we need additional checks
2579+
if(status == ippStsNoOperation && !mask.empty() && !pMinIdx->x && !pMinIdx->y)
25732580
{
25742581
_minIdx[0] = -1;
25752582
_minIdx[1] = -1;
@@ -2582,7 +2589,8 @@ static bool ipp_minMaxIdx(Mat &src, double* _minVal, double* _maxVal, int* _minI
25822589
}
25832590
if(_maxIdx)
25842591
{
2585-
if(!mask.empty() && !maxIdx.y && !maxIdx.x)
2592+
// Should be just ippStsNoOperation check, but there is a bug in the function so we need additional checks
2593+
if(status == ippStsNoOperation && !mask.empty() && !pMaxIdx->x && !pMaxIdx->y)
25862594
{
25872595
_maxIdx[0] = -1;
25882596
_maxIdx[1] = -1;

0 commit comments

Comments
 (0)