diff options
Diffstat (limited to 'apps/codecs/libcook/libavutil')
-rw-r--r-- | apps/codecs/libcook/libavutil/bswap.h | 8 | ||||
-rw-r--r-- | apps/codecs/libcook/libavutil/common.h | 286 | ||||
-rw-r--r-- | apps/codecs/libcook/libavutil/internal.h | 328 | ||||
-rw-r--r-- | apps/codecs/libcook/libavutil/mem.c | 158 | ||||
-rw-r--r-- | apps/codecs/libcook/libavutil/mem.h | 104 |
5 files changed, 4 insertions, 880 deletions
diff --git a/apps/codecs/libcook/libavutil/bswap.h b/apps/codecs/libcook/libavutil/bswap.h index 9175cb24a5..443cd1c3f9 100644 --- a/apps/codecs/libcook/libavutil/bswap.h +++ b/apps/codecs/libcook/libavutil/bswap.h | |||
@@ -28,7 +28,7 @@ | |||
28 | 28 | ||
29 | #include <stdint.h> | 29 | #include <stdint.h> |
30 | //#include "ffmpeg_config.h" | 30 | //#include "ffmpeg_config.h" |
31 | #include "common.h" | 31 | //#include "common.h" |
32 | 32 | ||
33 | #if ARCH_ARM | 33 | #if ARCH_ARM |
34 | # include "arm/bswap.h" | 34 | # include "arm/bswap.h" |
@@ -41,7 +41,7 @@ | |||
41 | #endif | 41 | #endif |
42 | 42 | ||
43 | #ifndef bswap_16 | 43 | #ifndef bswap_16 |
44 | static av_always_inline av_const uint16_t bswap_16(uint16_t x) | 44 | static inline uint16_t bswap_16(uint16_t x) |
45 | { | 45 | { |
46 | x= (x>>8) | (x<<8); | 46 | x= (x>>8) | (x<<8); |
47 | return x; | 47 | return x; |
@@ -49,7 +49,7 @@ static av_always_inline av_const uint16_t bswap_16(uint16_t x) | |||
49 | #endif | 49 | #endif |
50 | 50 | ||
51 | #ifndef bswap_32 | 51 | #ifndef bswap_32 |
52 | static av_always_inline av_const uint32_t bswap_32(uint32_t x) | 52 | static inline uint32_t bswap_32(uint32_t x) |
53 | { | 53 | { |
54 | x= ((x<<8)&0xFF00FF00) | ((x>>8)&0x00FF00FF); | 54 | x= ((x<<8)&0xFF00FF00) | ((x>>8)&0x00FF00FF); |
55 | x= (x>>16) | (x<<16); | 55 | x= (x>>16) | (x<<16); |
@@ -58,7 +58,7 @@ static av_always_inline av_const uint32_t bswap_32(uint32_t x) | |||
58 | #endif | 58 | #endif |
59 | 59 | ||
60 | #ifndef bswap_64 | 60 | #ifndef bswap_64 |
61 | static inline uint64_t av_const bswap_64(uint64_t x) | 61 | static inline uint64_t bswap_64(uint64_t x) |
62 | { | 62 | { |
63 | #if 0 | 63 | #if 0 |
64 | x= ((x<< 8)&0xFF00FF00FF00FF00ULL) | ((x>> 8)&0x00FF00FF00FF00FFULL); | 64 | x= ((x<< 8)&0xFF00FF00FF00FF00ULL) | ((x>> 8)&0x00FF00FF00FF00FFULL); |
diff --git a/apps/codecs/libcook/libavutil/common.h b/apps/codecs/libcook/libavutil/common.h deleted file mode 100644 index 949f093d35..0000000000 --- a/apps/codecs/libcook/libavutil/common.h +++ /dev/null | |||
@@ -1,286 +0,0 @@ | |||
1 | /* | ||
2 | * copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at> | ||
3 | * | ||
4 | * This file is part of FFmpeg. | ||
5 | * | ||
6 | * FFmpeg is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU Lesser General Public | ||
8 | * License as published by the Free Software Foundation; either | ||
9 | * version 2.1 of the License, or (at your option) any later version. | ||
10 | * | ||
11 | * FFmpeg is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
14 | * Lesser General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU Lesser General Public | ||
17 | * License along with FFmpeg; if not, write to the Free Software | ||
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @file libavutil/common.h | ||
23 | * common internal and external API header | ||
24 | */ | ||
25 | |||
26 | #ifndef AVUTIL_COMMON_H | ||
27 | #define AVUTIL_COMMON_H | ||
28 | |||
29 | #include <ctype.h> | ||
30 | #include <errno.h> | ||
31 | #include <inttypes.h> | ||
32 | #include <limits.h> | ||
33 | #include <math.h> | ||
34 | #include <stdio.h> | ||
35 | #include <stdlib.h> | ||
36 | #include <string.h> | ||
37 | |||
38 | #ifdef __GNUC__ | ||
39 | # define AV_GCC_VERSION_AT_LEAST(x,y) (__GNUC__ > x || __GNUC__ == x && __GNUC_MINOR__ >= y) | ||
40 | #else | ||
41 | # define AV_GCC_VERSION_AT_LEAST(x,y) 0 | ||
42 | #endif | ||
43 | |||
44 | #ifndef av_always_inline | ||
45 | #if AV_GCC_VERSION_AT_LEAST(3,1) | ||
46 | # define av_always_inline __attribute__((always_inline)) inline | ||
47 | #else | ||
48 | # define av_always_inline inline | ||
49 | #endif | ||
50 | #endif | ||
51 | |||
52 | #ifndef av_noinline | ||
53 | #if AV_GCC_VERSION_AT_LEAST(3,1) | ||
54 | # define av_noinline __attribute__((noinline)) | ||
55 | #else | ||
56 | # define av_noinline | ||
57 | #endif | ||
58 | #endif | ||
59 | |||
60 | #ifndef av_pure | ||
61 | #if AV_GCC_VERSION_AT_LEAST(3,1) | ||
62 | # define av_pure __attribute__((pure)) | ||
63 | #else | ||
64 | # define av_pure | ||
65 | #endif | ||
66 | #endif | ||
67 | |||
68 | #ifndef av_const | ||
69 | #if AV_GCC_VERSION_AT_LEAST(2,6) | ||
70 | # define av_const __attribute__((const)) | ||
71 | #else | ||
72 | # define av_const | ||
73 | #endif | ||
74 | #endif | ||
75 | |||
76 | #ifndef av_cold | ||
77 | #if (!defined(__ICC) || __ICC > 1100) && AV_GCC_VERSION_AT_LEAST(4,3) | ||
78 | # define av_cold __attribute__((cold)) | ||
79 | #else | ||
80 | # define av_cold | ||
81 | #endif | ||
82 | #endif | ||
83 | |||
84 | #ifndef av_flatten | ||
85 | #if AV_GCC_VERSION_AT_LEAST(4,1) | ||
86 | # define av_flatten __attribute__((flatten)) | ||
87 | #else | ||
88 | # define av_flatten | ||
89 | #endif | ||
90 | #endif | ||
91 | |||
92 | #ifndef attribute_deprecated | ||
93 | #if AV_GCC_VERSION_AT_LEAST(3,1) | ||
94 | # define attribute_deprecated __attribute__((deprecated)) | ||
95 | #else | ||
96 | # define attribute_deprecated | ||
97 | #endif | ||
98 | #endif | ||
99 | |||
100 | #ifndef av_unused | ||
101 | #if defined(__GNUC__) | ||
102 | # define av_unused __attribute__((unused)) | ||
103 | #else | ||
104 | # define av_unused | ||
105 | #endif | ||
106 | #endif | ||
107 | |||
108 | #ifndef av_uninit | ||
109 | #if defined(__GNUC__) && !defined(__ICC) | ||
110 | # define av_uninit(x) x=x | ||
111 | #else | ||
112 | # define av_uninit(x) x | ||
113 | #endif | ||
114 | #endif | ||
115 | |||
116 | //rounded division & shift | ||
117 | #define RSHIFT(a,b) ((a) > 0 ? ((a) + ((1<<(b))>>1))>>(b) : ((a) + ((1<<(b))>>1)-1)>>(b)) | ||
118 | /* assume b>0 */ | ||
119 | #define ROUNDED_DIV(a,b) (((a)>0 ? (a) + ((b)>>1) : (a) - ((b)>>1))/(b)) | ||
120 | #define FFABS(a) ((a) >= 0 ? (a) : (-(a))) | ||
121 | #define FFSIGN(a) ((a) > 0 ? 1 : -1) | ||
122 | |||
123 | #define FFMAX(a,b) ((a) > (b) ? (a) : (b)) | ||
124 | #define FFMAX3(a,b,c) FFMAX(FFMAX(a,b),c) | ||
125 | #define FFMIN(a,b) ((a) > (b) ? (b) : (a)) | ||
126 | #define FFMIN3(a,b,c) FFMIN(FFMIN(a,b),c) | ||
127 | |||
128 | #define FFSWAP(type,a,b) do{type SWAP_tmp= b; b= a; a= SWAP_tmp;}while(0) | ||
129 | #define FF_ARRAY_ELEMS(a) (sizeof(a) / sizeof((a)[0])) | ||
130 | |||
131 | /* misc math functions */ | ||
132 | extern const uint8_t ff_log2_tab[256]; | ||
133 | |||
134 | static inline av_const int av_log2(unsigned int v) | ||
135 | { | ||
136 | int n = 0; | ||
137 | if (v & 0xffff0000) { | ||
138 | v >>= 16; | ||
139 | n += 16; | ||
140 | } | ||
141 | if (v & 0xff00) { | ||
142 | v >>= 8; | ||
143 | n += 8; | ||
144 | } | ||
145 | n += ff_log2_tab[v]; | ||
146 | |||
147 | return n; | ||
148 | } | ||
149 | |||
150 | static inline av_const int av_log2_16bit(unsigned int v) | ||
151 | { | ||
152 | int n = 0; | ||
153 | if (v & 0xff00) { | ||
154 | v >>= 8; | ||
155 | n += 8; | ||
156 | } | ||
157 | n += ff_log2_tab[v]; | ||
158 | |||
159 | return n; | ||
160 | } | ||
161 | |||
162 | /** | ||
163 | * Clips a signed integer value into the amin-amax range. | ||
164 | * @param a value to clip | ||
165 | * @param amin minimum value of the clip range | ||
166 | * @param amax maximum value of the clip range | ||
167 | * @return clipped value | ||
168 | */ | ||
169 | static inline av_const int av_clip(int a, int amin, int amax) | ||
170 | { | ||
171 | if (a < amin) return amin; | ||
172 | else if (a > amax) return amax; | ||
173 | else return a; | ||
174 | } | ||
175 | |||
176 | /** | ||
177 | * Clips a signed integer value into the 0-255 range. | ||
178 | * @param a value to clip | ||
179 | * @return clipped value | ||
180 | */ | ||
181 | static inline av_const uint8_t av_clip_uint8(int a) | ||
182 | { | ||
183 | if (a&(~255)) return (-a)>>31; | ||
184 | else return a; | ||
185 | } | ||
186 | |||
187 | /** | ||
188 | * Clips a signed integer value into the -32768,32767 range. | ||
189 | * @param a value to clip | ||
190 | * @return clipped value | ||
191 | */ | ||
192 | static inline av_const int16_t av_clip_int16(int a) | ||
193 | { | ||
194 | if ((a+32768) & ~65535) return (a>>31) ^ 32767; | ||
195 | else return a; | ||
196 | } | ||
197 | |||
198 | /** | ||
199 | * Clips a float value into the amin-amax range. | ||
200 | * @param a value to clip | ||
201 | * @param amin minimum value of the clip range | ||
202 | * @param amax maximum value of the clip range | ||
203 | * @return clipped value | ||
204 | */ | ||
205 | static inline av_const float av_clipf(float a, float amin, float amax) | ||
206 | { | ||
207 | if (a < amin) return amin; | ||
208 | else if (a > amax) return amax; | ||
209 | else return a; | ||
210 | } | ||
211 | |||
212 | #define MKTAG(a,b,c,d) (a | (b << 8) | (c << 16) | (d << 24)) | ||
213 | #define MKBETAG(a,b,c,d) (d | (c << 8) | (b << 16) | (a << 24)) | ||
214 | |||
215 | /*! | ||
216 | * \def GET_UTF8(val, GET_BYTE, ERROR) | ||
217 | * Converts a UTF-8 character (up to 4 bytes long) to its 32-bit UCS-4 encoded form | ||
218 | * \param val is the output and should be of type uint32_t. It holds the converted | ||
219 | * UCS-4 character and should be a left value. | ||
220 | * \param GET_BYTE gets UTF-8 encoded bytes from any proper source. It can be | ||
221 | * a function or a statement whose return value or evaluated value is of type | ||
222 | * uint8_t. It will be executed up to 4 times for values in the valid UTF-8 range, | ||
223 | * and up to 7 times in the general case. | ||
224 | * \param ERROR action that should be taken when an invalid UTF-8 byte is returned | ||
225 | * from GET_BYTE. It should be a statement that jumps out of the macro, | ||
226 | * like exit(), goto, return, break, or continue. | ||
227 | */ | ||
228 | #define GET_UTF8(val, GET_BYTE, ERROR)\ | ||
229 | val= GET_BYTE;\ | ||
230 | {\ | ||
231 | int ones= 7 - av_log2(val ^ 255);\ | ||
232 | if(ones==1)\ | ||
233 | ERROR\ | ||
234 | val&= 127>>ones;\ | ||
235 | while(--ones > 0){\ | ||
236 | int tmp= GET_BYTE - 128;\ | ||
237 | if(tmp>>6)\ | ||
238 | ERROR\ | ||
239 | val= (val<<6) + tmp;\ | ||
240 | }\ | ||
241 | } | ||
242 | |||
243 | /*! | ||
244 | * \def PUT_UTF8(val, tmp, PUT_BYTE) | ||
245 | * Converts a 32-bit Unicode character to its UTF-8 encoded form (up to 4 bytes long). | ||
246 | * \param val is an input-only argument and should be of type uint32_t. It holds | ||
247 | * a UCS-4 encoded Unicode character that is to be converted to UTF-8. If | ||
248 | * val is given as a function it is executed only once. | ||
249 | * \param tmp is a temporary variable and should be of type uint8_t. It | ||
250 | * represents an intermediate value during conversion that is to be | ||
251 | * output by PUT_BYTE. | ||
252 | * \param PUT_BYTE writes the converted UTF-8 bytes to any proper destination. | ||
253 | * It could be a function or a statement, and uses tmp as the input byte. | ||
254 | * For example, PUT_BYTE could be "*output++ = tmp;" PUT_BYTE will be | ||
255 | * executed up to 4 times for values in the valid UTF-8 range and up to | ||
256 | * 7 times in the general case, depending on the length of the converted | ||
257 | * Unicode character. | ||
258 | */ | ||
259 | #define PUT_UTF8(val, tmp, PUT_BYTE)\ | ||
260 | {\ | ||
261 | int bytes, shift;\ | ||
262 | uint32_t in = val;\ | ||
263 | if (in < 0x80) {\ | ||
264 | tmp = in;\ | ||
265 | PUT_BYTE\ | ||
266 | } else {\ | ||
267 | bytes = (av_log2(in) + 4) / 5;\ | ||
268 | shift = (bytes - 1) * 6;\ | ||
269 | tmp = (256 - (256 >> bytes)) | (in >> shift);\ | ||
270 | PUT_BYTE\ | ||
271 | while (shift >= 6) {\ | ||
272 | shift -= 6;\ | ||
273 | tmp = 0x80 | ((in >> shift) & 0x3f);\ | ||
274 | PUT_BYTE\ | ||
275 | }\ | ||
276 | }\ | ||
277 | } | ||
278 | |||
279 | #include "mem.h" | ||
280 | |||
281 | //#ifdef HAVE_AV_CONFIG_H | ||
282 | //# include "ffmpeg_config.h" | ||
283 | # include "internal.h" | ||
284 | //#endif /* HAVE_AV_CONFIG_H */ | ||
285 | |||
286 | #endif /* AVUTIL_COMMON_H */ | ||
diff --git a/apps/codecs/libcook/libavutil/internal.h b/apps/codecs/libcook/libavutil/internal.h deleted file mode 100644 index c28b6f9a5e..0000000000 --- a/apps/codecs/libcook/libavutil/internal.h +++ /dev/null | |||
@@ -1,328 +0,0 @@ | |||
1 | /* | ||
2 | * copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at> | ||
3 | * | ||
4 | * This file is part of FFmpeg. | ||
5 | * | ||
6 | * FFmpeg is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU Lesser General Public | ||
8 | * License as published by the Free Software Foundation; either | ||
9 | * version 2.1 of the License, or (at your option) any later version. | ||
10 | * | ||
11 | * FFmpeg is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
14 | * Lesser General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU Lesser General Public | ||
17 | * License along with FFmpeg; if not, write to the Free Software | ||
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @file libavutil/internal.h | ||
23 | * common internal API header | ||
24 | */ | ||
25 | |||
26 | #ifndef AVUTIL_INTERNAL_H | ||
27 | #define AVUTIL_INTERNAL_H | ||
28 | |||
29 | #if !defined(DEBUG) && !defined(NDEBUG) | ||
30 | # define NDEBUG | ||
31 | #endif | ||
32 | |||
33 | #include <limits.h> | ||
34 | #include <stdint.h> | ||
35 | #include <stddef.h> | ||
36 | #include <assert.h> | ||
37 | //#include "ffmpeg_config.h" | ||
38 | #include "common.h" | ||
39 | #include "mem.h" | ||
40 | //#include "timer.h" | ||
41 | |||
42 | #ifndef attribute_align_arg | ||
43 | #if (!defined(__ICC) || __ICC > 1100) && AV_GCC_VERSION_AT_LEAST(4,2) | ||
44 | # define attribute_align_arg __attribute__((force_align_arg_pointer)) | ||
45 | #else | ||
46 | # define attribute_align_arg | ||
47 | #endif | ||
48 | #endif | ||
49 | |||
50 | #ifndef attribute_used | ||
51 | #if AV_GCC_VERSION_AT_LEAST(3,1) | ||
52 | # define attribute_used __attribute__((used)) | ||
53 | #else | ||
54 | # define attribute_used | ||
55 | #endif | ||
56 | #endif | ||
57 | |||
58 | #ifndef INT16_MIN | ||
59 | #define INT16_MIN (-0x7fff-1) | ||
60 | #endif | ||
61 | |||
62 | #ifndef INT16_MAX | ||
63 | #define INT16_MAX 0x7fff | ||
64 | #endif | ||
65 | |||
66 | #ifndef INT32_MIN | ||
67 | #define INT32_MIN (-0x7fffffff-1) | ||
68 | #endif | ||
69 | |||
70 | #ifndef INT32_MAX | ||
71 | #define INT32_MAX 0x7fffffff | ||
72 | #endif | ||
73 | |||
74 | #ifndef UINT32_MAX | ||
75 | #define UINT32_MAX 0xffffffff | ||
76 | #endif | ||
77 | |||
78 | #ifndef INT64_MIN | ||
79 | #define INT64_MIN (-0x7fffffffffffffffLL-1) | ||
80 | #endif | ||
81 | |||
82 | #ifndef INT64_MAX | ||
83 | #define INT64_MAX INT64_C(9223372036854775807) | ||
84 | #endif | ||
85 | |||
86 | #ifndef UINT64_MAX | ||
87 | #define UINT64_MAX UINT64_C(0xFFFFFFFFFFFFFFFF) | ||
88 | #endif | ||
89 | |||
90 | #ifndef INT_BIT | ||
91 | # define INT_BIT (CHAR_BIT * sizeof(int)) | ||
92 | #endif | ||
93 | |||
94 | #if ( defined(__PIC__) || defined(__pic__) ) && ! defined(PIC) | ||
95 | # define PIC | ||
96 | #endif | ||
97 | |||
98 | #ifndef offsetof | ||
99 | # define offsetof(T,F) ((unsigned int)((char *)&((T *)0)->F)) | ||
100 | #endif | ||
101 | |||
102 | // Use rip-relative addressing if compiling PIC code on x86-64. | ||
103 | #if ARCH_X86_64 && defined(PIC) | ||
104 | # define LOCAL_MANGLE(a) #a "(%%rip)" | ||
105 | #else | ||
106 | # define LOCAL_MANGLE(a) #a | ||
107 | #endif | ||
108 | |||
109 | #define MANGLE(a) EXTERN_PREFIX LOCAL_MANGLE(a) | ||
110 | |||
111 | /* debug stuff */ | ||
112 | |||
113 | /* dprintf macros */ | ||
114 | #ifdef DEBUG | ||
115 | # define dprintf(pctx, ...) av_log(pctx, AV_LOG_DEBUG, __VA_ARGS__) | ||
116 | #else | ||
117 | # define dprintf(pctx, ...) | ||
118 | #endif | ||
119 | |||
120 | #define av_abort() do { av_log(NULL, AV_LOG_ERROR, "Abort at %s:%d\n", __FILE__, __LINE__); abort(); } while (0) | ||
121 | |||
122 | /* math */ | ||
123 | |||
124 | extern const uint32_t ff_inverse[256]; | ||
125 | |||
126 | #if ARCH_X86 | ||
127 | # define FASTDIV(a,b) \ | ||
128 | ({\ | ||
129 | int ret,dmy;\ | ||
130 | __asm__ volatile(\ | ||
131 | "mull %3"\ | ||
132 | :"=d"(ret),"=a"(dmy)\ | ||
133 | :"1"(a),"g"(ff_inverse[b])\ | ||
134 | );\ | ||
135 | ret;\ | ||
136 | }) | ||
137 | #elif HAVE_ARMV6 && HAVE_INLINE_ASM | ||
138 | static inline av_const int FASTDIV(int a, int b) | ||
139 | { | ||
140 | int r, t; | ||
141 | __asm__ volatile("cmp %3, #2 \n\t" | ||
142 | "ldr %1, [%4, %3, lsl #2] \n\t" | ||
143 | "lsrle %0, %2, #1 \n\t" | ||
144 | "smmulgt %0, %1, %2 \n\t" | ||
145 | : "=&r"(r), "=&r"(t) : "r"(a), "r"(b), "r"(ff_inverse)); | ||
146 | return r; | ||
147 | } | ||
148 | #elif ARCH_ARM && HAVE_INLINE_ASM | ||
149 | static inline av_const int FASTDIV(int a, int b) | ||
150 | { | ||
151 | int r, t; | ||
152 | __asm__ volatile ("umull %1, %0, %2, %3" | ||
153 | : "=&r"(r), "=&r"(t) : "r"(a), "r"(ff_inverse[b])); | ||
154 | return r; | ||
155 | } | ||
156 | #elif CONFIG_FASTDIV | ||
157 | # define FASTDIV(a,b) ((uint32_t)((((uint64_t)a)*ff_inverse[b])>>32)) | ||
158 | #else | ||
159 | # define FASTDIV(a,b) ((a)/(b)) | ||
160 | #endif | ||
161 | |||
162 | extern const uint8_t ff_sqrt_tab[256]; | ||
163 | |||
164 | static inline av_const unsigned int ff_sqrt(unsigned int a) | ||
165 | { | ||
166 | unsigned int b; | ||
167 | |||
168 | if(a<255) return (ff_sqrt_tab[a+1]-1)>>4; | ||
169 | else if(a<(1<<12)) b= ff_sqrt_tab[a>>4 ]>>2; | ||
170 | #if !CONFIG_SMALL | ||
171 | else if(a<(1<<14)) b= ff_sqrt_tab[a>>6 ]>>1; | ||
172 | else if(a<(1<<16)) b= ff_sqrt_tab[a>>8 ] ; | ||
173 | #endif | ||
174 | else{ | ||
175 | int s= av_log2_16bit(a>>16)>>1; | ||
176 | unsigned int c= a>>(s+2); | ||
177 | b= ff_sqrt_tab[c>>(s+8)]; | ||
178 | b= FASTDIV(c,b) + (b<<s); | ||
179 | } | ||
180 | |||
181 | return b - (a<b*b); | ||
182 | } | ||
183 | |||
184 | #if ARCH_X86 | ||
185 | #define MASK_ABS(mask, level)\ | ||
186 | __asm__ volatile(\ | ||
187 | "cltd \n\t"\ | ||
188 | "xorl %1, %0 \n\t"\ | ||
189 | "subl %1, %0 \n\t"\ | ||
190 | : "+a" (level), "=&d" (mask)\ | ||
191 | ); | ||
192 | #else | ||
193 | #define MASK_ABS(mask, level)\ | ||
194 | mask= level>>31;\ | ||
195 | level= (level^mask)-mask; | ||
196 | #endif | ||
197 | |||
198 | #if HAVE_CMOV | ||
199 | #define COPY3_IF_LT(x,y,a,b,c,d)\ | ||
200 | __asm__ volatile (\ | ||
201 | "cmpl %0, %3 \n\t"\ | ||
202 | "cmovl %3, %0 \n\t"\ | ||
203 | "cmovl %4, %1 \n\t"\ | ||
204 | "cmovl %5, %2 \n\t"\ | ||
205 | : "+&r" (x), "+&r" (a), "+r" (c)\ | ||
206 | : "r" (y), "r" (b), "r" (d)\ | ||
207 | ); | ||
208 | #else | ||
209 | #define COPY3_IF_LT(x,y,a,b,c,d)\ | ||
210 | if((y)<(x)){\ | ||
211 | (x)=(y);\ | ||
212 | (a)=(b);\ | ||
213 | (c)=(d);\ | ||
214 | } | ||
215 | #endif | ||
216 | |||
217 | /* avoid usage of dangerous/inappropriate system functions */ | ||
218 | #undef malloc | ||
219 | #define malloc please_use_av_malloc | ||
220 | #undef free | ||
221 | #define free please_use_av_free | ||
222 | #undef realloc | ||
223 | #define realloc please_use_av_realloc | ||
224 | #undef time | ||
225 | #define time time_is_forbidden_due_to_security_issues | ||
226 | //#undef rand | ||
227 | //#define rand rand_is_forbidden_due_to_state_trashing_use_av_random | ||
228 | //#undef srand | ||
229 | //#define srand srand_is_forbidden_due_to_state_trashing_use_av_random_init | ||
230 | #undef random | ||
231 | #define random random_is_forbidden_due_to_state_trashing_use_av_random | ||
232 | #undef sprintf | ||
233 | #define sprintf sprintf_is_forbidden_due_to_security_issues_use_snprintf | ||
234 | #undef strcat | ||
235 | #define strcat strcat_is_forbidden_due_to_security_issues_use_av_strlcat | ||
236 | #undef exit | ||
237 | #define exit exit_is_forbidden | ||
238 | #ifndef LIBAVFORMAT_BUILD | ||
239 | //#undef printf | ||
240 | //#define printf please_use_av_log_instead_of_printf | ||
241 | #undef fprintf | ||
242 | #define fprintf please_use_av_log_instead_of_fprintf | ||
243 | #undef puts | ||
244 | #define puts please_use_av_log_instead_of_puts | ||
245 | #undef perror | ||
246 | #define perror please_use_av_log_instead_of_perror | ||
247 | #endif | ||
248 | |||
249 | #define CHECKED_ALLOCZ(p, size)\ | ||
250 | {\ | ||
251 | p= av_mallocz(size);\ | ||
252 | if(p==NULL && (size)!=0){\ | ||
253 | av_log(NULL, AV_LOG_ERROR, "Cannot allocate memory.");\ | ||
254 | goto fail;\ | ||
255 | }\ | ||
256 | } | ||
257 | |||
258 | #if defined(__ICC) || defined(__SUNPRO_C) | ||
259 | #define DECLARE_ALIGNED(n,t,v) t v __attribute__ ((aligned (n))) | ||
260 | #define DECLARE_ASM_CONST(n,t,v) const t __attribute__ ((aligned (n))) v | ||
261 | #elif defined(__GNUC__) | ||
262 | #define DECLARE_ALIGNED(n,t,v) t v __attribute__ ((aligned (n))) | ||
263 | #define DECLARE_ASM_CONST(n,t,v) static const t v attribute_used __attribute__ ((aligned (n))) | ||
264 | #elif defined(_MSC_VER) | ||
265 | #define DECLARE_ALIGNED(n,t,v) __declspec(align(n)) t v | ||
266 | #define DECLARE_ASM_CONST(n,t,v) __declspec(align(n)) static const t v | ||
267 | #elif HAVE_INLINE_ASM | ||
268 | #error The asm code needs alignment, but we do not know how to do it for this compiler. | ||
269 | #else | ||
270 | #define DECLARE_ALIGNED(n,t,v) t v | ||
271 | #define DECLARE_ASM_CONST(n,t,v) static const t v | ||
272 | #endif | ||
273 | |||
274 | |||
275 | #if !HAVE_LLRINT | ||
276 | static av_always_inline av_const long long llrint(double x) | ||
277 | { | ||
278 | return rint(x); | ||
279 | } | ||
280 | #endif /* HAVE_LLRINT */ | ||
281 | |||
282 | #if !HAVE_LRINT | ||
283 | static av_always_inline av_const long int lrint(double x) | ||
284 | { | ||
285 | return rint(x); | ||
286 | } | ||
287 | #endif /* HAVE_LRINT */ | ||
288 | |||
289 | #if !HAVE_LRINTF | ||
290 | static av_always_inline av_const long int lrintf(float x) | ||
291 | { | ||
292 | return (int)(rint(x)); | ||
293 | } | ||
294 | #endif /* HAVE_LRINTF */ | ||
295 | |||
296 | #if !HAVE_ROUND | ||
297 | static av_always_inline av_const double round(double x) | ||
298 | { | ||
299 | return (x > 0) ? floor(x + 0.5) : ceil(x - 0.5); | ||
300 | } | ||
301 | #endif /* HAVE_ROUND */ | ||
302 | |||
303 | #if !HAVE_ROUNDF | ||
304 | static av_always_inline av_const float roundf(float x) | ||
305 | { | ||
306 | return (x > 0) ? floor(x + 0.5) : ceil(x - 0.5); | ||
307 | } | ||
308 | #endif /* HAVE_ROUNDF */ | ||
309 | |||
310 | #if !HAVE_TRUNCF | ||
311 | static av_always_inline av_const float truncf(float x) | ||
312 | { | ||
313 | return (x > 0) ? floor(x) : ceil(x); | ||
314 | } | ||
315 | #endif /* HAVE_TRUNCF */ | ||
316 | |||
317 | /** | ||
318 | * Returns NULL if CONFIG_SMALL is true, otherwise the argument | ||
319 | * without modification. Used to disable the definition of strings | ||
320 | * (for example AVCodec long_names). | ||
321 | */ | ||
322 | #if CONFIG_SMALL | ||
323 | # define NULL_IF_CONFIG_SMALL(x) NULL | ||
324 | #else | ||
325 | # define NULL_IF_CONFIG_SMALL(x) x | ||
326 | #endif | ||
327 | |||
328 | #endif /* AVUTIL_INTERNAL_H */ | ||
diff --git a/apps/codecs/libcook/libavutil/mem.c b/apps/codecs/libcook/libavutil/mem.c deleted file mode 100644 index 7307df2384..0000000000 --- a/apps/codecs/libcook/libavutil/mem.c +++ /dev/null | |||
@@ -1,158 +0,0 @@ | |||
1 | /* | ||
2 | * default memory allocator for libavutil | ||
3 | * Copyright (c) 2002 Fabrice Bellard | ||
4 | * | ||
5 | * This file is part of FFmpeg. | ||
6 | * | ||
7 | * FFmpeg is free software; you can redistribute it and/or | ||
8 | * modify it under the terms of the GNU Lesser General Public | ||
9 | * License as published by the Free Software Foundation; either | ||
10 | * version 2.1 of the License, or (at your option) any later version. | ||
11 | * | ||
12 | * FFmpeg is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
15 | * Lesser General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU Lesser General Public | ||
18 | * License along with FFmpeg; if not, write to the Free Software | ||
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
20 | */ | ||
21 | |||
22 | /** | ||
23 | * @file libavutil/mem.c | ||
24 | * default memory allocator for libavutil | ||
25 | */ | ||
26 | |||
27 | |||
28 | #include <limits.h> | ||
29 | #include <stdlib.h> | ||
30 | #include <string.h> | ||
31 | #if HAVE_MALLOC_H | ||
32 | #include <malloc.h> | ||
33 | #endif | ||
34 | |||
35 | #include "mem.h" | ||
36 | |||
37 | /* here we can use OS-dependent allocation functions */ | ||
38 | #undef free | ||
39 | #undef malloc | ||
40 | #undef realloc | ||
41 | |||
42 | /* You can redefine av_malloc and av_free in your project to use your | ||
43 | memory allocator. You do not need to suppress this file because the | ||
44 | linker will do it automatically. */ | ||
45 | |||
46 | void *av_malloc(unsigned int size) | ||
47 | { | ||
48 | void *ptr = NULL; | ||
49 | #if CONFIG_MEMALIGN_HACK | ||
50 | long diff; | ||
51 | #endif | ||
52 | |||
53 | /* let's disallow possible ambiguous cases */ | ||
54 | if(size > (INT_MAX-16) ) | ||
55 | return NULL; | ||
56 | |||
57 | #if CONFIG_MEMALIGN_HACK | ||
58 | ptr = malloc(size+16); | ||
59 | if(!ptr) | ||
60 | return ptr; | ||
61 | diff= ((-(long)ptr - 1)&15) + 1; | ||
62 | ptr = (char*)ptr + diff; | ||
63 | ((char*)ptr)[-1]= diff; | ||
64 | #elif HAVE_POSIX_MEMALIGN | ||
65 | if (posix_memalign(&ptr,16,size)) | ||
66 | ptr = NULL; | ||
67 | #elif HAVE_MEMALIGN | ||
68 | ptr = memalign(16,size); | ||
69 | /* Why 64? | ||
70 | Indeed, we should align it: | ||
71 | on 4 for 386 | ||
72 | on 16 for 486 | ||
73 | on 32 for 586, PPro - K6-III | ||
74 | on 64 for K7 (maybe for P3 too). | ||
75 | Because L1 and L2 caches are aligned on those values. | ||
76 | But I don't want to code such logic here! | ||
77 | */ | ||
78 | /* Why 16? | ||
79 | Because some CPUs need alignment, for example SSE2 on P4, & most RISC CPUs | ||
80 | it will just trigger an exception and the unaligned load will be done in the | ||
81 | exception handler or it will just segfault (SSE2 on P4). | ||
82 | Why not larger? Because I did not see a difference in benchmarks ... | ||
83 | */ | ||
84 | /* benchmarks with P3 | ||
85 | memalign(64)+1 3071,3051,3032 | ||
86 | memalign(64)+2 3051,3032,3041 | ||
87 | memalign(64)+4 2911,2896,2915 | ||
88 | memalign(64)+8 2545,2554,2550 | ||
89 | memalign(64)+16 2543,2572,2563 | ||
90 | memalign(64)+32 2546,2545,2571 | ||
91 | memalign(64)+64 2570,2533,2558 | ||
92 | |||
93 | BTW, malloc seems to do 8-byte alignment by default here. | ||
94 | */ | ||
95 | #else | ||
96 | ptr = malloc(size); | ||
97 | #endif | ||
98 | return ptr; | ||
99 | } | ||
100 | |||
101 | void *av_realloc(void *ptr, unsigned int size) | ||
102 | { | ||
103 | #if CONFIG_MEMALIGN_HACK | ||
104 | int diff; | ||
105 | #endif | ||
106 | |||
107 | /* let's disallow possible ambiguous cases */ | ||
108 | if(size > (INT_MAX-16) ) | ||
109 | return NULL; | ||
110 | |||
111 | #if CONFIG_MEMALIGN_HACK | ||
112 | //FIXME this isn't aligned correctly, though it probably isn't needed | ||
113 | if(!ptr) return av_malloc(size); | ||
114 | diff= ((char*)ptr)[-1]; | ||
115 | return (char*)realloc((char*)ptr - diff, size + diff) + diff; | ||
116 | #else | ||
117 | return realloc(ptr, size); | ||
118 | #endif | ||
119 | } | ||
120 | |||
121 | void av_free(void *ptr) | ||
122 | { | ||
123 | /* XXX: this test should not be needed on most libcs */ | ||
124 | if (ptr) | ||
125 | #if CONFIG_MEMALIGN_HACK | ||
126 | free((char*)ptr - ((char*)ptr)[-1]); | ||
127 | #else | ||
128 | free(ptr); | ||
129 | #endif | ||
130 | } | ||
131 | |||
132 | void av_freep(void *arg) | ||
133 | { | ||
134 | void **ptr= (void**)arg; | ||
135 | av_free(*ptr); | ||
136 | *ptr = NULL; | ||
137 | } | ||
138 | |||
139 | void *av_mallocz(unsigned int size) | ||
140 | { | ||
141 | void *ptr = av_malloc(size); | ||
142 | if (ptr) | ||
143 | memset(ptr, 0, size); | ||
144 | return ptr; | ||
145 | } | ||
146 | |||
147 | char *av_strdup(const char *s) | ||
148 | { | ||
149 | char *ptr= NULL; | ||
150 | if(s){ | ||
151 | int len = strlen(s) + 1; | ||
152 | ptr = av_malloc(len); | ||
153 | if (ptr) | ||
154 | memcpy(ptr, s, len); | ||
155 | } | ||
156 | return ptr; | ||
157 | } | ||
158 | |||
diff --git a/apps/codecs/libcook/libavutil/mem.h b/apps/codecs/libcook/libavutil/mem.h deleted file mode 100644 index e50553aefe..0000000000 --- a/apps/codecs/libcook/libavutil/mem.h +++ /dev/null | |||
@@ -1,104 +0,0 @@ | |||
1 | /* | ||
2 | * copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at> | ||
3 | * | ||
4 | * This file is part of FFmpeg. | ||
5 | * | ||
6 | * FFmpeg is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU Lesser General Public | ||
8 | * License as published by the Free Software Foundation; either | ||
9 | * version 2.1 of the License, or (at your option) any later version. | ||
10 | * | ||
11 | * FFmpeg is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
14 | * Lesser General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU Lesser General Public | ||
17 | * License along with FFmpeg; if not, write to the Free Software | ||
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @file libavutil/mem.h | ||
23 | * memory handling functions | ||
24 | */ | ||
25 | |||
26 | #ifndef AVUTIL_MEM_H | ||
27 | #define AVUTIL_MEM_H | ||
28 | |||
29 | #include "common.h" | ||
30 | |||
31 | #if AV_GCC_VERSION_AT_LEAST(3,1) | ||
32 | #define av_malloc_attrib __attribute__((__malloc__)) | ||
33 | #else | ||
34 | #define av_malloc_attrib | ||
35 | #endif | ||
36 | |||
37 | #if (!defined(__ICC) || __ICC > 1100) && AV_GCC_VERSION_AT_LEAST(4,3) | ||
38 | #define av_alloc_size(n) __attribute__((alloc_size(n))) | ||
39 | #else | ||
40 | #define av_alloc_size(n) | ||
41 | #endif | ||
42 | |||
43 | /** | ||
44 | * Allocates a block of \p size bytes with alignment suitable for all | ||
45 | * memory accesses (including vectors if available on the CPU). | ||
46 | * @param size Size in bytes for the memory block to be allocated. | ||
47 | * @return Pointer to the allocated block, NULL if the block cannot | ||
48 | * be allocated. | ||
49 | * @see av_mallocz() | ||
50 | */ | ||
51 | void *av_malloc(unsigned int size) av_malloc_attrib av_alloc_size(1); | ||
52 | |||
53 | /** | ||
54 | * Allocates or reallocates a block of memory. | ||
55 | * If \p ptr is NULL and \p size > 0, allocates a new block. If \p | ||
56 | * size is zero, frees the memory block pointed to by \p ptr. | ||
57 | * @param size Size in bytes for the memory block to be allocated or | ||
58 | * reallocated. | ||
59 | * @param ptr Pointer to a memory block already allocated with | ||
60 | * av_malloc(z)() or av_realloc() or NULL. | ||
61 | * @return Pointer to a newly reallocated block or NULL if the block | ||
62 | * cannot be reallocated or the function is used to free the memory block. | ||
63 | * @see av_fast_realloc() | ||
64 | */ | ||
65 | void *av_realloc(void *ptr, unsigned int size) av_alloc_size(2); | ||
66 | |||
67 | /** | ||
68 | * Frees a memory block which has been allocated with av_malloc(z)() or | ||
69 | * av_realloc(). | ||
70 | * @param ptr Pointer to the memory block which should be freed. | ||
71 | * @note ptr = NULL is explicitly allowed. | ||
72 | * @note It is recommended that you use av_freep() instead. | ||
73 | * @see av_freep() | ||
74 | */ | ||
75 | void av_free(void *ptr); | ||
76 | |||
77 | /** | ||
78 | * Allocates a block of \p size bytes with alignment suitable for all | ||
79 | * memory accesses (including vectors if available on the CPU) and | ||
80 | * zeroes all the bytes of the block. | ||
81 | * @param size Size in bytes for the memory block to be allocated. | ||
82 | * @return Pointer to the allocated block, NULL if it cannot be allocated. | ||
83 | * @see av_malloc() | ||
84 | */ | ||
85 | void *av_mallocz(unsigned int size) av_malloc_attrib av_alloc_size(1); | ||
86 | |||
87 | /** | ||
88 | * Duplicates the string \p s. | ||
89 | * @param s string to be duplicated | ||
90 | * @return Pointer to a newly allocated string containing a | ||
91 | * copy of \p s or NULL if the string cannot be allocated. | ||
92 | */ | ||
93 | char *av_strdup(const char *s) av_malloc_attrib; | ||
94 | |||
95 | /** | ||
96 | * Frees a memory block which has been allocated with av_malloc(z)() or | ||
97 | * av_realloc() and set the pointer pointing to it to NULL. | ||
98 | * @param ptr Pointer to the pointer to the memory block which should | ||
99 | * be freed. | ||
100 | * @see av_free() | ||
101 | */ | ||
102 | void av_freep(void *ptr); | ||
103 | |||
104 | #endif /* AVUTIL_MEM_H */ | ||