@@ -2241,6 +2241,54 @@ static bool openvx_gaussianBlur(InputArray _src, OutputArray _dst, Size ksize,
2241
2241
#endif
2242
2242
2243
2243
#ifdef HAVE_IPP
2244
+ #define IPP_DISABLE_FILTERING_INMEM_PARTIAL 1 // IW 2017u2 has bug which doesn't allow use of partial inMem with tiling
2245
+ #define IPP_GAUSSIANBLUR_PARALLEL 1
2246
+
2247
+ #ifdef HAVE_IPP_IW
2248
+
2249
+ class ipp_gaussianBlurParallel : public ParallelLoopBody
2250
+ {
2251
+ public:
2252
+ ipp_gaussianBlurParallel (::ipp::IwiImage &src, ::ipp::IwiImage &dst, int kernelSize, float sigma, ::ipp::IwiBorderType &border, bool *pOk):
2253
+ m_src (src), m_dst(dst), m_kernelSize(kernelSize), m_sigma(sigma), m_border(border), m_pOk(pOk) {
2254
+ *m_pOk = true ;
2255
+ }
2256
+ ~ipp_gaussianBlurParallel ()
2257
+ {
2258
+ }
2259
+
2260
+ virtual void operator () (const Range& range) const
2261
+ {
2262
+ CV_INSTRUMENT_REGION_IPP ()
2263
+
2264
+ if (!*m_pOk)
2265
+ return ;
2266
+
2267
+ try
2268
+ {
2269
+ ::ipp::IwiRoi roi = ::ipp::IwiRect (0 , range.start , m_dst.m_size .width , range.end - range.start );
2270
+ CV_INSTRUMENT_FUN_IPP (::ipp::iwiFilterGaussian, &m_src, &m_dst, m_kernelSize, m_sigma, m_border, &roi);
2271
+ }
2272
+ catch (::ipp::IwException e)
2273
+ {
2274
+ *m_pOk = false ;
2275
+ return ;
2276
+ }
2277
+ }
2278
+ private:
2279
+ ::ipp::IwiImage &m_src;
2280
+ ::ipp::IwiImage &m_dst;
2281
+
2282
+ int m_kernelSize;
2283
+ float m_sigma;
2284
+ ::ipp::IwiBorderType &m_border;
2285
+
2286
+ volatile bool *m_pOk;
2287
+ const ipp_gaussianBlurParallel& operator = (const ipp_gaussianBlurParallel&);
2288
+ };
2289
+
2290
+ #endif
2291
+
2244
2292
static bool ipp_GaussianBlur (InputArray _src, OutputArray _dst, Size ksize,
2245
2293
double sigma1, double sigma2, int borderType )
2246
2294
{
@@ -2272,7 +2320,23 @@ static bool ipp_GaussianBlur(InputArray _src, OutputArray _dst, Size ksize,
2272
2320
if (!ippBorder.m_borderType )
2273
2321
return false ;
2274
2322
2275
- CV_INSTRUMENT_FUN_IPP (::ipp::iwiFilterGaussian, &iwSrc, &iwDst, ksize.width , (float )sigma1, ippBorder);
2323
+ const bool disableThreading = IPP_DISABLE_FILTERING_INMEM_PARTIAL &&
2324
+ ((ippBorder.m_borderFlags )&ippBorderInMem) && ((ippBorder.m_borderFlags )&ippBorderInMem) != ippBorderInMem;
2325
+ const int threads = ippiSuggestThreadsNum (iwDst, 2 );
2326
+ if (!disableThreading && IPP_GAUSSIANBLUR_PARALLEL && threads > 1 ) {
2327
+ bool ok;
2328
+ ipp_gaussianBlurParallel invoker (iwSrc, iwDst, ksize.width , (float ) sigma1, ippBorder, &ok);
2329
+
2330
+ if (!ok)
2331
+ return false ;
2332
+ const Range range (0 , (int ) iwDst.m_size .height );
2333
+ parallel_for_ (range, invoker, threads*4 );
2334
+
2335
+ if (!ok)
2336
+ return false ;
2337
+ } else {
2338
+ CV_INSTRUMENT_FUN_IPP (::ipp::iwiFilterGaussian, &iwSrc, &iwDst, ksize.width , (float ) sigma1, ippBorder);
2339
+ }
2276
2340
}
2277
2341
catch (::ipp::IwException ex)
2278
2342
{
@@ -4255,24 +4319,23 @@ static bool ipp_bilateralFilter(Mat &src, Mat &dst, int d, double sigmaColor, do
4255
4319
if (!ippBorder.m_borderType )
4256
4320
return false ;
4257
4321
4258
- // IW 2017u2 has bug which doesn't allow use of partial inMem with tiling
4259
- if ((((ippBorder.m_borderFlags )&ippBorderInMem) && ((ippBorder.m_borderFlags )&ippBorderInMem) != ippBorderInMem))
4260
- return false ;
4261
-
4262
- bool ok = true ;
4263
- int threads = ippiSuggestThreadsNum (iwDst, 2 );
4264
- Range range (0 , (int )iwDst.m_size .height );
4265
- ipp_bilateralFilterParallel invoker (iwSrc, iwDst, radius, valSquareSigma, posSquareSigma, ippBorder, &ok);
4266
- if (!ok)
4267
- return false ;
4322
+ const bool disableThreading = IPP_DISABLE_FILTERING_INMEM_PARTIAL &&
4323
+ ((ippBorder.m_borderFlags )&ippBorderInMem) && ((ippBorder.m_borderFlags )&ippBorderInMem) != ippBorderInMem;
4324
+ const int threads = ippiSuggestThreadsNum (iwDst, 2 );
4325
+ if (!disableThreading && IPP_BILATERAL_PARALLEL && threads > 1 ) {
4326
+ bool ok = true ;
4327
+ Range range (0 , (int )iwDst.m_size .height );
4328
+ ipp_bilateralFilterParallel invoker (iwSrc, iwDst, radius, valSquareSigma, posSquareSigma, ippBorder, &ok);
4329
+ if (!ok)
4330
+ return false ;
4268
4331
4269
- if (IPP_BILATERAL_PARALLEL && threads > 1 )
4270
4332
parallel_for_ (range, invoker, threads*4 );
4271
- else
4272
- invoker (range);
4273
4333
4274
- if (!ok)
4275
- return false ;
4334
+ if (!ok)
4335
+ return false ;
4336
+ } else {
4337
+ CV_INSTRUMENT_FUN_IPP (::ipp::iwiFilterBilateral, &iwSrc, &iwDst, radius, valSquareSigma, posSquareSigma, ippiFilterBilateralGauss, ippDistNormL1, ippBorder);
4338
+ }
4276
4339
}
4277
4340
catch (::ipp::IwException)
4278
4341
{
0 commit comments