changeset 950:7362675c3e0a libavutil

Add av_clip_int8(), used in the upcoming VP8 decoder.
author rbultje
date Tue, 22 Jun 2010 19:11:33 +0000
parents be4cc14c16c2
children 1cf2ecdd1127
files common.h
diffstat 1 files changed, 11 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/common.h	Tue Jun 22 15:02:09 2010 +0000
+++ b/common.h	Tue Jun 22 19:11:33 2010 +0000
@@ -123,6 +123,17 @@
 }
 
 /**
+ * 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