Mercurial > libavutil.hg
comparison common.h @ 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 | e34e8d654ded |
comparison
equal
deleted
inserted
replaced
949:be4cc14c16c2 | 950:7362675c3e0a |
---|---|
121 if (a&(~0xFF)) return (-a)>>31; | 121 if (a&(~0xFF)) return (-a)>>31; |
122 else return a; | 122 else return a; |
123 } | 123 } |
124 | 124 |
125 /** | 125 /** |
126 * Clips a signed integer value into the -128,127 range. | |
127 * @param a value to clip | |
128 * @return clipped value | |
129 */ | |
130 static inline av_const int8_t av_clip_int8(int a) | |
131 { | |
132 if ((a+0x80) & ~0xFF) return (a>>31) ^ 0x7F; | |
133 else return a; | |
134 } | |
135 | |
136 /** | |
126 * Clips a signed integer value into the 0-65535 range. | 137 * Clips a signed integer value into the 0-65535 range. |
127 * @param a value to clip | 138 * @param a value to clip |
128 * @return clipped value | 139 * @return clipped value |
129 */ | 140 */ |
130 static inline av_const uint16_t av_clip_uint16(int a) | 141 static inline av_const uint16_t av_clip_uint16(int a) |