Skip to content

Commit 12ea847

Browse files
terfendailvpisarev
authored andcommitted
bitexact gaussianblur implementation (opencv#10345)
* Bit-exact implementation of GaussianBlur smoothing * Added universal intrinsics based implementation for bit-exact CV_8U GaussianBlur smoothing. * Added parallel_for to evaluation of bit-exact GaussianBlur * Added custom implementations for 3x3 and 5x5 bit-exact GaussianBlur
1 parent 87db636 commit 12ea847

File tree

3 files changed

+1604
-10
lines changed

3 files changed

+1604
-10
lines changed

modules/imgproc/src/fixedpoint.inl.hpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ class fixedpoint64
7676
// int64_t nval = (int64_t)val + val2.val + nfrac >> 32;
7777
// return nval > MAXINT32 ? beConv(MAXINT32, MAXINT32) : beConv((int32_t)(nval), 0);
7878
// }
79+
CV_ALWAYS_INLINE fixedpoint64 operator >> (int n) const { return fixedpoint64(val >> n); }
80+
CV_ALWAYS_INLINE fixedpoint64 operator << (int n) const { return fixedpoint64(val << n); }
7981
template <typename ET>
8082
CV_ALWAYS_INLINE operator ET() const { return cv::saturate_cast<ET>((int64_t)fixedround((uint64_t)val) >> fixedShift); }
8183
CV_ALWAYS_INLINE operator double() const { return (double)val / (1LL << fixedShift); }
@@ -129,6 +131,8 @@ class ufixedpoint64
129131
// int64_t nval = (int64_t)val + val2.val + nfrac >> 32;
130132
// return nval > MAXINT32 ? beConv(MAXINT32, MAXINT32) : beConv((int32_t)(nval), 0);
131133
// }
134+
CV_ALWAYS_INLINE ufixedpoint64 operator >> (int n) const { return ufixedpoint64(val >> n); }
135+
CV_ALWAYS_INLINE ufixedpoint64 operator << (int n) const { return ufixedpoint64(val << n); }
132136
template <typename ET>
133137
CV_ALWAYS_INLINE operator ET() const { return cv::saturate_cast<ET>(fixedround(val) >> fixedShift); }
134138
CV_ALWAYS_INLINE operator double() const { return (double)val / (1LL << fixedShift); }
@@ -170,6 +174,8 @@ class fixedpoint32
170174
// int32_t nval = (int32_t)val + val2.val + nfrac >> 32;
171175
// return nval > MAXINT32 ? beConv(MAXINT32, MAXINT32) : beConv((int32_t)(nval), 0);
172176
// }
177+
CV_ALWAYS_INLINE fixedpoint32 operator >> (int n) const { return fixedpoint32(val >> n); }
178+
CV_ALWAYS_INLINE fixedpoint32 operator << (int n) const { return fixedpoint32(val << n); }
173179
template <typename ET>
174180
CV_ALWAYS_INLINE operator ET() const { return cv::saturate_cast<ET>((int32_t)fixedround((uint32_t)val) >> fixedShift); }
175181
CV_ALWAYS_INLINE operator double() const { return (double)val / (1 << fixedShift); }
@@ -209,6 +215,8 @@ class ufixedpoint32
209215
// int32_t nval = (int32_t)val + val2.val + nfrac >> 32;
210216
// return nval > MAXINT32 ? beConv(MAXINT32, MAXINT32) : beConv((int32_t)(nval), 0);
211217
// }
218+
CV_ALWAYS_INLINE ufixedpoint32 operator >> (int n) const { return ufixedpoint32(val >> n); }
219+
CV_ALWAYS_INLINE ufixedpoint32 operator << (int n) const { return ufixedpoint32(val << n); }
212220
template <typename ET>
213221
CV_ALWAYS_INLINE operator ET() const { return cv::saturate_cast<ET>(fixedround(val) >> fixedShift); }
214222
CV_ALWAYS_INLINE operator double() const { return (double)val / (1 << fixedShift); }
@@ -241,6 +249,8 @@ class fixedpoint16
241249
CV_ALWAYS_INLINE fixedpoint32 operator * (const fixedpoint16& val2) const { return (int32_t)val * (int32_t)(val2.val); }
242250
CV_ALWAYS_INLINE fixedpoint16 operator + (const fixedpoint16& val2) const { return fixedpoint16((int16_t)(val + val2.val)); }
243251
CV_ALWAYS_INLINE fixedpoint16 operator - (const fixedpoint16& val2) const { return fixedpoint16((int16_t)(val - val2.val)); }
252+
CV_ALWAYS_INLINE fixedpoint16 operator >> (int n) const { return fixedpoint16((int16_t)(val >> n)); }
253+
CV_ALWAYS_INLINE fixedpoint16 operator << (int n) const { return fixedpoint16((int16_t)(val << n)); }
244254
template <typename ET>
245255
CV_ALWAYS_INLINE operator ET() const { return cv::saturate_cast<ET>((int16_t)fixedround((uint16_t)val) >> fixedShift); }
246256
CV_ALWAYS_INLINE operator double() const { return (double)val / (1 << fixedShift); }
@@ -271,12 +281,8 @@ class ufixedpoint16
271281
CV_ALWAYS_INLINE ufixedpoint32 operator * (const ufixedpoint16& val2) const { return ((uint32_t)val * (uint32_t)(val2.val)); }
272282
CV_ALWAYS_INLINE ufixedpoint16 operator + (const ufixedpoint16& val2) const { return ufixedpoint16((uint16_t)(val + val2.val)); }
273283
CV_ALWAYS_INLINE ufixedpoint16 operator - (const ufixedpoint16& val2) const { return ufixedpoint16((uint16_t)(val - val2.val)); }
274-
// CV_ALWAYS_INLINE fixedpoint16 operator + (const fixedpoint16& val2) const
275-
// {
276-
// int16_t nfrac = (int32_t)frac + val2.frac;
277-
// int16_t nval = (int32_t)val + val2.val + nfrac >> 16;
278-
// return nval > MAXINT32 ? beConv(MAXINT16, MAXINT16) : beConv((int16_t)(nval), 0);
279-
// }
284+
CV_ALWAYS_INLINE ufixedpoint16 operator >> (int n) const { return ufixedpoint16((uint16_t)(val >> n)); }
285+
CV_ALWAYS_INLINE ufixedpoint16 operator << (int n) const { return ufixedpoint16((uint16_t)(val << n)); }
280286
template <typename ET>
281287
CV_ALWAYS_INLINE operator ET() const { return cv::saturate_cast<ET>(fixedround(val) >> fixedShift); }
282288
CV_ALWAYS_INLINE operator double() const { return (double)val / (1 << fixedShift); }

0 commit comments

Comments
 (0)