From a2dd9061156fd267ced0364e40e0cffa43f1e093 Mon Sep 17 00:00:00 2001 From: Ingo Weyrich Date: Wed, 11 Dec 2019 13:00:09 +0100 Subject: [PATCH] flush denormals to zeros for mask blur, #5560 --- rtengine/rt_algo.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/rtengine/rt_algo.cc b/rtengine/rt_algo.cc index b02e75461..79a7c3679 100644 --- a/rtengine/rt_algo.cc +++ b/rtengine/rt_algo.cc @@ -473,8 +473,18 @@ void buildBlendMask(const float* const * luminance, float **blend, int W, int H, } } +#ifdef __SSE2__ + // flush denormals to zero for gaussian blur to avoid performance penalty if there are a lot of zero values in the mask + const auto oldMode = _MM_GET_FLUSH_ZERO_MODE(); + _MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON); +#endif + // blur blend mask to smooth transitions gaussianBlur(blend, blend, W, H, 2.0); + +#ifdef __SSE2__ + _MM_SET_FLUSH_ZERO_MODE(oldMode); +#endif } } }