diff options
author | Aurelien Jacobs <aurel@gnuage.org> | 2007-08-11 21:59:01 +0000 |
---|---|---|
committer | Aurelien Jacobs <aurel@gnuage.org> | 2007-08-11 21:59:01 +0000 |
commit | ddb8ebe7a19ea6178f9cf8857a55657d8f317559 (patch) | |
tree | d5dff067f43d5646bfc9c1f51a3b5489970a3aa7 /libavutil/common.h | |
parent | b9c684a2b874713d874a6cc5bb8e809b0aa703ff (diff) | |
download | ffmpeg-ddb8ebe7a19ea6178f9cf8857a55657d8f317559.tar.gz |
add a new av_clip_int16() function to libavutil
Originally committed as revision 10076 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavutil/common.h')
-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 bbade55bfa..9550403503 100644 --- a/libavutil/common.h +++ b/libavutil/common.h @@ -192,6 +192,17 @@ static inline uint8_t av_clip_uint8(int a) 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); |