Revision eb3755a5 libavutil/common.h
libavutil/common.h | ||
---|---|---|
64 | 64 |
|
65 | 65 |
extern const uint8_t av_reverse[256]; |
66 | 66 |
|
67 |
static inline av_const int av_log2_c(unsigned int v) |
|
67 |
static av_always_inline av_const int av_log2_c(unsigned int v)
|
|
68 | 68 |
{ |
69 | 69 |
int n = 0; |
70 | 70 |
if (v & 0xffff0000) { |
... | ... | |
80 | 80 |
return n; |
81 | 81 |
} |
82 | 82 |
|
83 |
static inline av_const int av_log2_16bit_c(unsigned int v) |
|
83 |
static av_always_inline av_const int av_log2_16bit_c(unsigned int v)
|
|
84 | 84 |
{ |
85 | 85 |
int n = 0; |
86 | 86 |
if (v & 0xff00) { |
... | ... | |
107 | 107 |
* @param amax maximum value of the clip range |
108 | 108 |
* @return clipped value |
109 | 109 |
*/ |
110 |
static inline av_const int av_clip_c(int a, int amin, int amax) |
|
110 |
static av_always_inline av_const int av_clip_c(int a, int amin, int amax)
|
|
111 | 111 |
{ |
112 | 112 |
if (a < amin) return amin; |
113 | 113 |
else if (a > amax) return amax; |
... | ... | |
119 | 119 |
* @param a value to clip |
120 | 120 |
* @return clipped value |
121 | 121 |
*/ |
122 |
static inline av_const uint8_t av_clip_uint8_c(int a) |
|
122 |
static av_always_inline av_const uint8_t av_clip_uint8_c(int a)
|
|
123 | 123 |
{ |
124 | 124 |
if (a&(~0xFF)) return (-a)>>31; |
125 | 125 |
else return a; |
... | ... | |
130 | 130 |
* @param a value to clip |
131 | 131 |
* @return clipped value |
132 | 132 |
*/ |
133 |
static inline av_const int8_t av_clip_int8_c(int a) |
|
133 |
static av_always_inline av_const int8_t av_clip_int8_c(int a)
|
|
134 | 134 |
{ |
135 | 135 |
if ((a+0x80) & ~0xFF) return (a>>31) ^ 0x7F; |
136 | 136 |
else return a; |
... | ... | |
141 | 141 |
* @param a value to clip |
142 | 142 |
* @return clipped value |
143 | 143 |
*/ |
144 |
static inline av_const uint16_t av_clip_uint16_c(int a) |
|
144 |
static av_always_inline av_const uint16_t av_clip_uint16_c(int a)
|
|
145 | 145 |
{ |
146 | 146 |
if (a&(~0xFFFF)) return (-a)>>31; |
147 | 147 |
else return a; |
... | ... | |
152 | 152 |
* @param a value to clip |
153 | 153 |
* @return clipped value |
154 | 154 |
*/ |
155 |
static inline av_const int16_t av_clip_int16_c(int a) |
|
155 |
static av_always_inline av_const int16_t av_clip_int16_c(int a)
|
|
156 | 156 |
{ |
157 | 157 |
if ((a+0x8000) & ~0xFFFF) return (a>>31) ^ 0x7FFF; |
158 | 158 |
else return a; |
... | ... | |
163 | 163 |
* @param a value to clip |
164 | 164 |
* @return clipped value |
165 | 165 |
*/ |
166 |
static inline av_const int32_t av_clipl_int32_c(int64_t a) |
|
166 |
static av_always_inline av_const int32_t av_clipl_int32_c(int64_t a)
|
|
167 | 167 |
{ |
168 | 168 |
if ((a+0x80000000u) & ~UINT64_C(0xFFFFFFFF)) return (a>>63) ^ 0x7FFFFFFF; |
169 | 169 |
else return a; |
... | ... | |
176 | 176 |
* @param amax maximum value of the clip range |
177 | 177 |
* @return clipped value |
178 | 178 |
*/ |
179 |
static inline av_const float av_clipf_c(float a, float amin, float amax) |
|
179 |
static av_always_inline av_const float av_clipf_c(float a, float amin, float amax)
|
|
180 | 180 |
{ |
181 | 181 |
if (a < amin) return amin; |
182 | 182 |
else if (a > amax) return amax; |
... | ... | |
187 | 187 |
* @param x value used to compute ceil(log2(x)) |
188 | 188 |
* @return computed ceiling of log2(x) |
189 | 189 |
*/ |
190 |
static inline av_const int av_ceil_log2_c(int x) |
|
190 |
static av_always_inline av_const int av_ceil_log2_c(int x)
|
|
191 | 191 |
{ |
192 | 192 |
return av_log2((x - 1) << 1); |
193 | 193 |
} |
... | ... | |
197 | 197 |
* @param x value to count bits of |
198 | 198 |
* @return the number of bits set to one in x |
199 | 199 |
*/ |
200 |
static inline av_const int av_popcount_c(uint32_t x) |
|
200 |
static av_always_inline av_const int av_popcount_c(uint32_t x)
|
|
201 | 201 |
{ |
202 | 202 |
x -= (x >> 1) & 0x55555555; |
203 | 203 |
x = (x & 0x33333333) + ((x >> 2) & 0x33333333); |
Also available in: Unified diff