summaryrefslogtreecommitdiff
path: root/libavutil/common.h
diff options
context:
space:
mode:
authorRonald S. Bultje <rsbultje@gmail.com>2010-06-22 19:11:33 +0000
committerRonald S. Bultje <rsbultje@gmail.com>2010-06-22 19:11:33 +0000
commit45a1b86a0504c598b542b676f028e743bba7a2ba (patch)
treeaa82a6c1cceedc79a1245d234cdf99eda8c27691 /libavutil/common.h
parent890fe85f26ed18e34ff91cfdd916f555a2d3606a (diff)
Add av_clip_int8(), used in the upcoming VP8 decoder.
Originally committed as revision 23713 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavutil/common.h')
-rw-r--r--libavutil/common.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/libavutil/common.h b/libavutil/common.h
index ba67b4a559..ee4417558c 100644
--- a/libavutil/common.h
+++ b/libavutil/common.h
@@ -123,6 +123,17 @@ static inline av_const uint8_t av_clip_uint8(int a)
}
/**
+ * Clips a signed integer value into the -128,127 range.
+ * @param a value to clip
+ * @return clipped value
+ */
+static inline av_const int8_t av_clip_int8(int a)
+{
+ if ((a+0x80) & ~0xFF) return (a>>31) ^ 0x7F;
+ else return a;
+}
+
+/**
* Clips a signed integer value into the 0-65535 range.
* @param a value to clip
* @return clipped value