OLD | NEW |
1 /* | 1 /* |
2 * copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at> | 2 * copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at> |
3 * | 3 * |
4 * This file is part of FFmpeg. | 4 * This file is part of FFmpeg. |
5 * | 5 * |
6 * FFmpeg is free software; you can redistribute it and/or | 6 * FFmpeg is free software; you can redistribute it and/or |
7 * modify it under the terms of the GNU Lesser General Public | 7 * modify it under the terms of the GNU Lesser General Public |
8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
9 * version 2.1 of the License, or (at your option) any later version. | 9 * version 2.1 of the License, or (at your option) any later version. |
10 * | 10 * |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 | 49 |
50 #ifndef attribute_used | 50 #ifndef attribute_used |
51 #if AV_GCC_VERSION_AT_LEAST(3,1) | 51 #if AV_GCC_VERSION_AT_LEAST(3,1) |
52 # define attribute_used __attribute__((used)) | 52 # define attribute_used __attribute__((used)) |
53 #else | 53 #else |
54 # define attribute_used | 54 # define attribute_used |
55 #endif | 55 #endif |
56 #endif | 56 #endif |
57 | 57 |
58 #ifndef av_alias | 58 #ifndef av_alias |
59 #if HAVE_ATTRIBUTE_MAY_ALIAS | 59 #if HAVE_ATTRIBUTE_MAY_ALIAS && (!defined(__ICC) || __ICC > 1110) && AV_GCC_VERS
ION_AT_LEAST(3,3) |
60 # define av_alias __attribute__((may_alias)) | 60 # define av_alias __attribute__((may_alias)) |
61 #else | 61 #else |
62 # define av_alias | 62 # define av_alias |
63 #endif | 63 #endif |
64 #endif | 64 #endif |
65 | 65 |
66 #ifndef INT16_MIN | 66 #ifndef INT16_MIN |
67 #define INT16_MIN (-0x7fff - 1) | 67 #define INT16_MIN (-0x7fff - 1) |
68 #endif | 68 #endif |
69 | 69 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 #ifdef DEBUG | 121 #ifdef DEBUG |
122 # define dprintf(pctx, ...) av_log(pctx, AV_LOG_DEBUG, __VA_ARGS__) | 122 # define dprintf(pctx, ...) av_log(pctx, AV_LOG_DEBUG, __VA_ARGS__) |
123 #else | 123 #else |
124 # define dprintf(pctx, ...) | 124 # define dprintf(pctx, ...) |
125 #endif | 125 #endif |
126 | 126 |
127 #define av_abort() do { av_log(NULL, AV_LOG_ERROR, "Abort at %s:%d\n", __FI
LE__, __LINE__); abort(); } while (0) | 127 #define av_abort() do { av_log(NULL, AV_LOG_ERROR, "Abort at %s:%d\n", __FI
LE__, __LINE__); abort(); } while (0) |
128 | 128 |
129 /* math */ | 129 /* math */ |
130 | 130 |
131 extern const uint8_t ff_sqrt_tab[256]; | |
132 | |
133 static inline av_const unsigned int ff_sqrt(unsigned int a) | |
134 { | |
135 unsigned int b; | |
136 | |
137 if (a < 255) return (ff_sqrt_tab[a + 1] - 1) >> 4; | |
138 else if (a < (1 << 12)) b = ff_sqrt_tab[a >> 4] >> 2; | |
139 #if !CONFIG_SMALL | |
140 else if (a < (1 << 14)) b = ff_sqrt_tab[a >> 6] >> 1; | |
141 else if (a < (1 << 16)) b = ff_sqrt_tab[a >> 8] ; | |
142 #endif | |
143 else { | |
144 int s = av_log2_16bit(a >> 16) >> 1; | |
145 unsigned int c = a >> (s + 2); | |
146 b = ff_sqrt_tab[c >> (s + 8)]; | |
147 b = FASTDIV(c,b) + (b << s); | |
148 } | |
149 | |
150 return b - (a < b * b); | |
151 } | |
152 | |
153 #if ARCH_X86 | 131 #if ARCH_X86 |
154 #define MASK_ABS(mask, level)\ | 132 #define MASK_ABS(mask, level)\ |
155 __asm__ volatile(\ | 133 __asm__ volatile(\ |
156 "cltd \n\t"\ | 134 "cltd \n\t"\ |
157 "xorl %1, %0 \n\t"\ | 135 "xorl %1, %0 \n\t"\ |
158 "subl %1, %0 \n\t"\ | 136 "subl %1, %0 \n\t"\ |
159 : "+a" (level), "=&d" (mask)\ | 137 : "+a" (level), "=&d" (mask)\ |
160 ); | 138 ); |
161 #else | 139 #else |
162 #define MASK_ABS(mask, level)\ | 140 #define MASK_ABS(mask, level)\ |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 }\ | 192 }\ |
215 } | 193 } |
216 | 194 |
217 #if !HAVE_EXP2 | 195 #if !HAVE_EXP2 |
218 #undef exp2 | 196 #undef exp2 |
219 #define exp2(x) exp((x) * 0.693147180559945) | 197 #define exp2(x) exp((x) * 0.693147180559945) |
220 #endif /* HAVE_EXP2 */ | 198 #endif /* HAVE_EXP2 */ |
221 | 199 |
222 #if !HAVE_EXP2F | 200 #if !HAVE_EXP2F |
223 #undef exp2f | 201 #undef exp2f |
224 #define exp2f(x) exp2(x) | 202 #define exp2f(x) ((float)exp2(x)) |
225 #endif /* HAVE_EXP2F */ | 203 #endif /* HAVE_EXP2F */ |
226 | 204 |
227 #if !HAVE_LLRINT | 205 #if !HAVE_LLRINT |
228 static av_always_inline av_const long long llrint(double x) | 206 #undef llrint |
229 { | 207 #define llrint(x) ((long long)rint(x)) |
230 return rint(x); | |
231 } | |
232 #endif /* HAVE_LLRINT */ | 208 #endif /* HAVE_LLRINT */ |
233 | 209 |
234 #if !HAVE_LOG2 | 210 #if !HAVE_LOG2 |
235 #undef log2 | 211 #undef log2 |
236 #define log2(x) (log(x) * 1.44269504088896340736) | 212 #define log2(x) (log(x) * 1.44269504088896340736) |
237 #endif /* HAVE_LOG2 */ | 213 #endif /* HAVE_LOG2 */ |
238 | 214 |
239 #if !HAVE_LOG2F | 215 #if !HAVE_LOG2F |
240 #undef log2f | 216 #undef log2f |
241 #define log2f(x) log2(x) | 217 #define log2f(x) ((float)log2(x)) |
242 #endif /* HAVE_LOG2F */ | 218 #endif /* HAVE_LOG2F */ |
243 | 219 |
244 #if !HAVE_LRINT | 220 #if !HAVE_LRINT |
245 static av_always_inline av_const long int lrint(double x) | 221 static av_always_inline av_const long int lrint(double x) |
246 { | 222 { |
247 return rint(x); | 223 return rint(x); |
248 } | 224 } |
249 #endif /* HAVE_LRINT */ | 225 #endif /* HAVE_LRINT */ |
250 | 226 |
251 #if !HAVE_LRINTF | 227 #if !HAVE_LRINTF |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 # define NULL_IF_CONFIG_SMALL(x) x | 263 # define NULL_IF_CONFIG_SMALL(x) x |
288 #endif | 264 #endif |
289 | 265 |
290 #if HAVE_THREADS | 266 #if HAVE_THREADS |
291 # define ONLY_IF_THREADS_ENABLED(x) x | 267 # define ONLY_IF_THREADS_ENABLED(x) x |
292 #else | 268 #else |
293 # define ONLY_IF_THREADS_ENABLED(x) NULL | 269 # define ONLY_IF_THREADS_ENABLED(x) NULL |
294 #endif | 270 #endif |
295 | 271 |
296 #endif /* AVUTIL_INTERNAL_H */ | 272 #endif /* AVUTIL_INTERNAL_H */ |
OLD | NEW |