summaryrefslogtreecommitdiff
path: root/third_party/libopenjpeg20/opj_intmath.h
diff options
context:
space:
mode:
authorNicolas Pena <npm@chromium.org>2017-10-23 10:30:46 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-10-23 22:40:23 +0000
commit826480cf599f61fe0366ab2bd5803dd53c9d0562 (patch)
treed42bca4255a2ecf484b8498b08c6132dbcffe86a /third_party/libopenjpeg20/opj_intmath.h
parentebdba614b9683ddd1d50e8960639bc54c9d4bb7a (diff)
downloadpdfium-826480cf599f61fe0366ab2bd5803dd53c9d0562.tar.xz
Upgrade LibopenJPEG to 2.3chromium/3249
Bug: Change-Id: I4c968a4e5f41037d80e5dc64a1297cd2cbda31b1 Reviewed-on: https://pdfium-review.googlesource.com/16350 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Nicolás Peña Moreno <npm@chromium.org>
Diffstat (limited to 'third_party/libopenjpeg20/opj_intmath.h')
-rw-r--r--third_party/libopenjpeg20/opj_intmath.h31
1 files changed, 31 insertions, 0 deletions
diff --git a/third_party/libopenjpeg20/opj_intmath.h b/third_party/libopenjpeg20/opj_intmath.h
index cf97c15b12..ad13597661 100644
--- a/third_party/libopenjpeg20/opj_intmath.h
+++ b/third_party/libopenjpeg20/opj_intmath.h
@@ -96,6 +96,15 @@ static INLINE OPJ_UINT32 opj_uint_adds(OPJ_UINT32 a, OPJ_UINT32 b)
}
/**
+ Get the saturated difference of two unsigned integers
+ @return Returns saturated sum of a-b
+ */
+static INLINE OPJ_UINT32 opj_uint_subs(OPJ_UINT32 a, OPJ_UINT32 b)
+{
+ return (a >= b) ? a - b : 0;
+}
+
+/**
Clamp an integer inside an interval
@return
<ul>
@@ -115,6 +124,28 @@ static INLINE OPJ_INT32 opj_int_clamp(OPJ_INT32 a, OPJ_INT32 min,
}
return a;
}
+
+/**
+Clamp an integer inside an interval
+@return
+<ul>
+<li>Returns a if (min < a < max)
+<li>Returns max if (a > max)
+<li>Returns min if (a < min)
+</ul>
+*/
+static INLINE OPJ_INT64 opj_int64_clamp(OPJ_INT64 a, OPJ_INT64 min,
+ OPJ_INT64 max)
+{
+ if (a < min) {
+ return min;
+ }
+ if (a > max) {
+ return max;
+ }
+ return a;
+}
+
/**
@return Get absolute value of integer
*/