diff common.h @ 373:c3b57cc542e0 libavutil

add a new av_clip_int16() function to libavutil
author aurel
date Sat, 11 Aug 2007 21:59:01 +0000
parents 317edea5d1a8
children d0f3bb6e367e
line wrap: on
line diff
--- a/common.h	Sat Aug 11 21:52:40 2007 +0000
+++ b/common.h	Sat Aug 11 21:59:01 2007 +0000
@@ -192,6 +192,17 @@
     else          return a;
 }
 
+/**
+ * clip a signed integer value into the -32768,32767 range
+ * @param a value to clip
+ * @return clipped value
+ */
+static inline int16_t av_clip_int16(int a)
+{
+    if ((a+32768) & ~65535) return (a>>31) ^ 32767;
+    else                    return a;
+}
+
 /* math */
 int64_t ff_gcd(int64_t a, int64_t b);