diff options
Diffstat (limited to 'libavutil')
-rw-r--r-- | libavutil/common.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/libavutil/common.h b/libavutil/common.h index ba67b4a..ee44175 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 |