# HG changeset patch # User rbultje # Date 1277233893 0 # Node ID 7362675c3e0a96cddf8614301b9d7cb48adc8603 # Parent be4cc14c16c2704eab0c906403496b0ee1136193 Add av_clip_int8(), used in the upcoming VP8 decoder. diff -r be4cc14c16c2 -r 7362675c3e0a common.h --- 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