Mercurial > libavutil.hg
comparison internal.h @ 774:1896cda0ecfc libavutil
whitespace cosmetics, prettyprinting
author | diego |
---|---|
date | Tue, 01 Sep 2009 16:00:45 +0000 |
parents | 988be4b2fd0c |
children | dff358ec2041 |
comparison
equal
deleted
inserted
replaced
773:8848af31706f | 774:1896cda0ecfc |
---|---|
54 # define attribute_used | 54 # define attribute_used |
55 #endif | 55 #endif |
56 #endif | 56 #endif |
57 | 57 |
58 #ifndef INT16_MIN | 58 #ifndef INT16_MIN |
59 #define INT16_MIN (-0x7fff-1) | 59 #define INT16_MIN (-0x7fff - 1) |
60 #endif | 60 #endif |
61 | 61 |
62 #ifndef INT16_MAX | 62 #ifndef INT16_MAX |
63 #define INT16_MAX 0x7fff | 63 #define INT16_MAX 0x7fff |
64 #endif | 64 #endif |
65 | 65 |
66 #ifndef INT32_MIN | 66 #ifndef INT32_MIN |
67 #define INT32_MIN (-0x7fffffff-1) | 67 #define INT32_MIN (-0x7fffffff - 1) |
68 #endif | 68 #endif |
69 | 69 |
70 #ifndef INT32_MAX | 70 #ifndef INT32_MAX |
71 #define INT32_MAX 0x7fffffff | 71 #define INT32_MAX 0x7fffffff |
72 #endif | 72 #endif |
74 #ifndef UINT32_MAX | 74 #ifndef UINT32_MAX |
75 #define UINT32_MAX 0xffffffff | 75 #define UINT32_MAX 0xffffffff |
76 #endif | 76 #endif |
77 | 77 |
78 #ifndef INT64_MIN | 78 #ifndef INT64_MIN |
79 #define INT64_MIN (-0x7fffffffffffffffLL-1) | 79 #define INT64_MIN (-0x7fffffffffffffffLL - 1) |
80 #endif | 80 #endif |
81 | 81 |
82 #ifndef INT64_MAX | 82 #ifndef INT64_MAX |
83 #define INT64_MAX INT64_C(9223372036854775807) | 83 #define INT64_MAX INT64_C(9223372036854775807) |
84 #endif | 84 #endif |
94 #if ( defined(__PIC__) || defined(__pic__) ) && ! defined(PIC) | 94 #if ( defined(__PIC__) || defined(__pic__) ) && ! defined(PIC) |
95 # define PIC | 95 # define PIC |
96 #endif | 96 #endif |
97 | 97 |
98 #ifndef offsetof | 98 #ifndef offsetof |
99 # define offsetof(T,F) ((unsigned int)((char *)&((T *)0)->F)) | 99 # define offsetof(T, F) ((unsigned int)((char *)&((T *)0)->F)) |
100 #endif | 100 #endif |
101 | 101 |
102 /* Use to export labels from asm. */ | 102 /* Use to export labels from asm. */ |
103 #define LABEL_MANGLE(a) EXTERN_PREFIX #a | 103 #define LABEL_MANGLE(a) EXTERN_PREFIX #a |
104 | 104 |
127 extern const uint32_t ff_inverse[256]; | 127 extern const uint32_t ff_inverse[256]; |
128 | 128 |
129 #if ARCH_X86 | 129 #if ARCH_X86 |
130 # define FASTDIV(a,b) \ | 130 # define FASTDIV(a,b) \ |
131 ({\ | 131 ({\ |
132 int ret,dmy;\ | 132 int ret, dmy;\ |
133 __asm__ volatile(\ | 133 __asm__ volatile(\ |
134 "mull %3"\ | 134 "mull %3"\ |
135 :"=d"(ret),"=a"(dmy)\ | 135 :"=d"(ret), "=a"(dmy)\ |
136 :"1"(a),"g"(ff_inverse[b])\ | 136 :"1"(a), "g"(ff_inverse[b])\ |
137 );\ | 137 );\ |
138 ret;\ | 138 ret;\ |
139 }) | 139 }) |
140 #elif HAVE_ARMV6 && HAVE_INLINE_ASM | 140 #elif HAVE_ARMV6 && HAVE_INLINE_ASM |
141 static inline av_const int FASTDIV(int a, int b) | 141 static inline av_const int FASTDIV(int a, int b) |
150 } | 150 } |
151 #elif ARCH_ARM && HAVE_INLINE_ASM | 151 #elif ARCH_ARM && HAVE_INLINE_ASM |
152 static inline av_const int FASTDIV(int a, int b) | 152 static inline av_const int FASTDIV(int a, int b) |
153 { | 153 { |
154 int r, t; | 154 int r, t; |
155 __asm__ volatile ("umull %1, %0, %2, %3" | 155 __asm__ volatile("umull %1, %0, %2, %3" |
156 : "=&r"(r), "=&r"(t) : "r"(a), "r"(ff_inverse[b])); | 156 : "=&r"(r), "=&r"(t) : "r"(a), "r"(ff_inverse[b])); |
157 return r; | 157 return r; |
158 } | 158 } |
159 #elif CONFIG_FASTDIV | 159 #elif CONFIG_FASTDIV |
160 # define FASTDIV(a,b) ((uint32_t)((((uint64_t)a)*ff_inverse[b])>>32)) | 160 # define FASTDIV(a,b) ((uint32_t)((((uint64_t)a) * ff_inverse[b]) >> 32)) |
161 #else | 161 #else |
162 # define FASTDIV(a,b) ((a)/(b)) | 162 # define FASTDIV(a,b) ((a) / (b)) |
163 #endif | 163 #endif |
164 | 164 |
165 extern const uint8_t ff_sqrt_tab[256]; | 165 extern const uint8_t ff_sqrt_tab[256]; |
166 | 166 |
167 static inline av_const unsigned int ff_sqrt(unsigned int a) | 167 static inline av_const unsigned int ff_sqrt(unsigned int a) |
168 { | 168 { |
169 unsigned int b; | 169 unsigned int b; |
170 | 170 |
171 if(a<255) return (ff_sqrt_tab[a+1]-1)>>4; | 171 if (a < 255) return (ff_sqrt_tab[a + 1] - 1) >> 4; |
172 else if(a<(1<<12)) b= ff_sqrt_tab[a>>4 ]>>2; | 172 else if (a < (1 << 12)) b = ff_sqrt_tab[a >> 4] >> 2; |
173 #if !CONFIG_SMALL | 173 #if !CONFIG_SMALL |
174 else if(a<(1<<14)) b= ff_sqrt_tab[a>>6 ]>>1; | 174 else if (a < (1 << 14)) b = ff_sqrt_tab[a >> 6] >> 1; |
175 else if(a<(1<<16)) b= ff_sqrt_tab[a>>8 ] ; | 175 else if (a < (1 << 16)) b = ff_sqrt_tab[a >> 8] ; |
176 #endif | 176 #endif |
177 else{ | 177 else { |
178 int s= av_log2_16bit(a>>16)>>1; | 178 int s = av_log2_16bit(a >> 16) >> 1; |
179 unsigned int c= a>>(s+2); | 179 unsigned int c = a >> (s + 2); |
180 b= ff_sqrt_tab[c>>(s+8)]; | 180 b = ff_sqrt_tab[c >> (s + 8)]; |
181 b= FASTDIV(c,b) + (b<<s); | 181 b = FASTDIV(c,b) + (b << s); |
182 } | 182 } |
183 | 183 |
184 return b - (a<b*b); | 184 return b - (a < b * b); |
185 } | 185 } |
186 | 186 |
187 #if ARCH_X86 | 187 #if ARCH_X86 |
188 #define MASK_ABS(mask, level)\ | 188 #define MASK_ABS(mask, level)\ |
189 __asm__ volatile(\ | 189 __asm__ volatile(\ |
192 "subl %1, %0 \n\t"\ | 192 "subl %1, %0 \n\t"\ |
193 : "+a" (level), "=&d" (mask)\ | 193 : "+a" (level), "=&d" (mask)\ |
194 ); | 194 ); |
195 #else | 195 #else |
196 #define MASK_ABS(mask, level)\ | 196 #define MASK_ABS(mask, level)\ |
197 mask= level>>31;\ | 197 mask = level >> 31;\ |
198 level= (level^mask)-mask; | 198 level = (level ^ mask) - mask; |
199 #endif | 199 #endif |
200 | 200 |
201 #if HAVE_CMOV | 201 #if HAVE_CMOV |
202 #define COPY3_IF_LT(x,y,a,b,c,d)\ | 202 #define COPY3_IF_LT(x, y, a, b, c, d)\ |
203 __asm__ volatile (\ | 203 __asm__ volatile(\ |
204 "cmpl %0, %3 \n\t"\ | 204 "cmpl %0, %3 \n\t"\ |
205 "cmovl %3, %0 \n\t"\ | 205 "cmovl %3, %0 \n\t"\ |
206 "cmovl %4, %1 \n\t"\ | 206 "cmovl %4, %1 \n\t"\ |
207 "cmovl %5, %2 \n\t"\ | 207 "cmovl %5, %2 \n\t"\ |
208 : "+&r" (x), "+&r" (a), "+r" (c)\ | 208 : "+&r" (x), "+&r" (a), "+r" (c)\ |
209 : "r" (y), "r" (b), "r" (d)\ | 209 : "r" (y), "r" (b), "r" (d)\ |
210 ); | 210 ); |
211 #else | 211 #else |
212 #define COPY3_IF_LT(x,y,a,b,c,d)\ | 212 #define COPY3_IF_LT(x, y, a, b, c, d)\ |
213 if((y)<(x)){\ | 213 if ((y) < (x)) {\ |
214 (x)=(y);\ | 214 (x) = (y);\ |
215 (a)=(b);\ | 215 (a) = (b);\ |
216 (c)=(d);\ | 216 (c) = (d);\ |
217 } | 217 } |
218 #endif | 218 #endif |
219 | 219 |
220 /* avoid usage of dangerous/inappropriate system functions */ | 220 /* avoid usage of dangerous/inappropriate system functions */ |
221 #undef malloc | 221 #undef malloc |
249 #define perror please_use_av_log_instead_of_perror | 249 #define perror please_use_av_log_instead_of_perror |
250 #endif | 250 #endif |
251 | 251 |
252 #define CHECKED_ALLOC(p, size)\ | 252 #define CHECKED_ALLOC(p, size)\ |
253 {\ | 253 {\ |
254 p= av_malloc(size);\ | 254 p = av_malloc(size);\ |
255 if(p==NULL && (size)!=0){\ | 255 if (p == NULL && (size) != 0) {\ |
256 av_log(NULL, AV_LOG_ERROR, "Cannot allocate memory.");\ | 256 av_log(NULL, AV_LOG_ERROR, "Cannot allocate memory.");\ |
257 goto fail;\ | 257 goto fail;\ |
258 }\ | 258 }\ |
259 } | 259 } |
260 | 260 |
261 #define CHECKED_ALLOCZ(p, size)\ | 261 #define CHECKED_ALLOCZ(p, size)\ |
262 {\ | 262 {\ |
263 p= av_mallocz(size);\ | 263 p = av_mallocz(size);\ |
264 if(p==NULL && (size)!=0){\ | 264 if (p == NULL && (size) != 0) {\ |
265 av_log(NULL, AV_LOG_ERROR, "Cannot allocate memory.");\ | 265 av_log(NULL, AV_LOG_ERROR, "Cannot allocate memory.");\ |
266 goto fail;\ | 266 goto fail;\ |
267 }\ | 267 }\ |
268 } | 268 } |
269 | 269 |