summaryrefslogtreecommitdiff
path: root/libavutil/common.h
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-10-26 19:37:43 +0200
committerMichael Niedermayer <michaelni@gmx.at>2012-10-27 00:26:35 +0200
commitae52eb7fc74273a7472f93241943a0887f0db503 (patch)
tree05e739e793a0e96a15e1ded5bccd43a19bbb1ad1 /libavutil/common.h
parent5f0105b820fa7b5934bf677c96226d89f9e05b3a (diff)
lavu: add av_clip64()
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavutil/common.h')
-rw-r--r--libavutil/common.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/libavutil/common.h b/libavutil/common.h
index c2a54c4987..03a2354db4 100644
--- a/libavutil/common.h
+++ b/libavutil/common.h
@@ -103,6 +103,20 @@ static av_always_inline av_const int av_clip_c(int a, int amin, int amax)
}
/**
+ * Clip a signed 64bit integer value into the amin-amax range.
+ * @param a value to clip
+ * @param amin minimum value of the clip range
+ * @param amax maximum value of the clip range
+ * @return clipped value
+ */
+static av_always_inline av_const int64_t av_clip64_c(int64_t a, int64_t amin, int64_t amax)
+{
+ if (a < amin) return amin;
+ else if (a > amax) return amax;
+ else return a;
+}
+
+/**
* Clip a signed integer value into the 0-255 range.
* @param a value to clip
* @return clipped value
@@ -375,6 +389,9 @@ static av_always_inline av_const int av_popcount64_c(uint64_t x)
#ifndef av_clip
# define av_clip av_clip_c
#endif
+#ifndef av_clip64
+# define av_clip64 av_clip64_c
+#endif
#ifndef av_clip_uint8
# define av_clip_uint8 av_clip_uint8_c
#endif