Mercurial > libavutil.hg
annotate internal.h @ 90:b916c714f77b libavutil
Fix FSF postal address.
author | diego |
---|---|
date | Wed, 26 Jul 2006 01:12:26 +0000 |
parents | 59433f391f2d |
children | e5409bf748df |
rev | line source |
---|---|
0
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
1 /** |
80
624fc3ad183a
Split common.h in two parts, purely internal stuff (internal.h) and things
reimar
parents:
75
diff
changeset
|
2 * @file internal.h |
0
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
3 * common internal api header. |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
4 */ |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
5 |
80
624fc3ad183a
Split common.h in two parts, purely internal stuff (internal.h) and things
reimar
parents:
75
diff
changeset
|
6 #ifndef INTERNAL_H |
624fc3ad183a
Split common.h in two parts, purely internal stuff (internal.h) and things
reimar
parents:
75
diff
changeset
|
7 #define INTERNAL_H |
0
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
8 |
57
4d00c7c7d07d
Make ffmpeg better support pic - from Diego Petten <flameeyes@gentoo.org>
lu_zero
parents:
55
diff
changeset
|
9 #if ( defined(__PIC__) || defined(__pic__) ) && ! defined(PIC) |
4d00c7c7d07d
Make ffmpeg better support pic - from Diego Petten <flameeyes@gentoo.org>
lu_zero
parents:
55
diff
changeset
|
10 # define PIC |
4d00c7c7d07d
Make ffmpeg better support pic - from Diego Petten <flameeyes@gentoo.org>
lu_zero
parents:
55
diff
changeset
|
11 #endif |
4d00c7c7d07d
Make ffmpeg better support pic - from Diego Petten <flameeyes@gentoo.org>
lu_zero
parents:
55
diff
changeset
|
12 |
0
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
13 # ifndef ENODATA |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
14 # define ENODATA 61 |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
15 # endif |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
16 |
89
59433f391f2d
do not include bswap.h in common.h for external programs, since the former
reimar
parents:
80
diff
changeset
|
17 #include "bswap.h" |
59433f391f2d
do not include bswap.h in common.h for external programs, since the former
reimar
parents:
80
diff
changeset
|
18 |
0
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
19 #include <stddef.h> |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
20 #ifndef offsetof |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
21 # define offsetof(T,F) ((unsigned int)((char *)&((T *)0)->F)) |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
22 #endif |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
23 |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
24 #define AVOPTION_CODEC_BOOL(name, help, field) \ |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
25 { name, help, offsetof(AVCodecContext, field), FF_OPT_TYPE_BOOL } |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
26 #define AVOPTION_CODEC_DOUBLE(name, help, field, minv, maxv, defval) \ |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
27 { name, help, offsetof(AVCodecContext, field), FF_OPT_TYPE_DOUBLE, minv, maxv, defval } |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
28 #define AVOPTION_CODEC_FLAG(name, help, field, flag, defval) \ |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
29 { name, help, offsetof(AVCodecContext, field), FF_OPT_TYPE_FLAG, flag, 0, defval } |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
30 #define AVOPTION_CODEC_INT(name, help, field, minv, maxv, defval) \ |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
31 { name, help, offsetof(AVCodecContext, field), FF_OPT_TYPE_INT, minv, maxv, defval } |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
32 #define AVOPTION_CODEC_STRING(name, help, field, str, val) \ |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
33 { name, help, offsetof(AVCodecContext, field), FF_OPT_TYPE_STRING, .defval = val, .defstr = str } |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
34 #define AVOPTION_CODEC_RCOVERRIDE(name, help, field) \ |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
35 { name, help, offsetof(AVCodecContext, field), FF_OPT_TYPE_RCOVERRIDE, .defval = 0, .defstr = NULL } |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
36 #define AVOPTION_SUB(ptr) { .name = NULL, .help = (const char*)ptr } |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
37 #define AVOPTION_END() AVOPTION_SUB(NULL) |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
38 |
74 | 39 #ifdef __MINGW32__ |
75 | 40 # ifdef _DEBUG |
41 # define DEBUG | |
42 # endif | |
0
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
43 |
75 | 44 # define snprintf _snprintf |
45 # define vsnprintf _vsnprintf | |
19 | 46 |
75 | 47 # ifdef CONFIG_WINCE |
48 # define perror(a) | |
49 # endif | |
19 | 50 |
66
c619660c74ab
CONFIG_WIN32 implies MinGW and Cygwin and possibly more, so use just
diego
parents:
65
diff
changeset
|
51 /* __MINGW32__ end */ |
0
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
52 #elif defined (CONFIG_OS2) |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
53 /* OS/2 EMX */ |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
54 |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
55 #include <float.h> |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
56 |
73 | 57 #endif /* !__MINGW32__ && CONFIG_OS2 */ |
0
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
58 |
73 | 59 # ifdef USE_FASTMEMCPY |
60 # include "fastmemcpy.h" | |
61 # endif | |
0
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
62 |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
63 // Use rip-relative addressing if compiling PIC code on x86-64. |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
64 # if defined(__MINGW32__) || defined(__CYGWIN__) || \ |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
65 defined(__OS2__) || (defined (__OpenBSD__) && !defined(__ELF__)) |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
66 # if defined(ARCH_X86_64) && defined(PIC) |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
67 # define MANGLE(a) "_" #a"(%%rip)" |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
68 # else |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
69 # define MANGLE(a) "_" #a |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
70 # endif |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
71 # else |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
72 # if defined(ARCH_X86_64) && defined(PIC) |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
73 # define MANGLE(a) #a"(%%rip)" |
31
7b1170d0da89
Proper mangling information for symbols in OS X Mach-O shared objects.
diego
parents:
22
diff
changeset
|
74 # elif defined(CONFIG_DARWIN) |
7b1170d0da89
Proper mangling information for symbols in OS X Mach-O shared objects.
diego
parents:
22
diff
changeset
|
75 # define MANGLE(a) "_" #a |
0
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
76 # else |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
77 # define MANGLE(a) #a |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
78 # endif |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
79 # endif |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
80 |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
81 /* debug stuff */ |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
82 |
44
96a4efa91a4d
make sure NDEBUG is not defined already before defining it
gpoirier
parents:
39
diff
changeset
|
83 # if !defined(DEBUG) && !defined(NDEBUG) |
0
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
84 # define NDEBUG |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
85 # endif |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
86 # include <assert.h> |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
87 |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
88 /* dprintf macros */ |
65 | 89 # ifdef DEBUG |
90 # define dprintf(fmt,...) av_log(NULL, AV_LOG_DEBUG, fmt, __VA_ARGS__) | |
91 # else | |
92 # define dprintf(fmt,...) | |
93 # endif | |
0
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
94 |
19 | 95 # ifdef CONFIG_WINCE |
96 # define abort() | |
97 # endif | |
0
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
98 |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
99 # define av_abort() do { av_log(NULL, AV_LOG_ERROR, "Abort at %s:%d\n", __FILE__, __LINE__); abort(); } while (0) |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
100 |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
101 extern const uint32_t inverse[256]; |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
102 |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
103 #if defined(ARCH_X86) || defined(ARCH_X86_64) |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
104 # define FASTDIV(a,b) \ |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
105 ({\ |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
106 int ret,dmy;\ |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
107 asm volatile(\ |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
108 "mull %3"\ |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
109 :"=d"(ret),"=a"(dmy)\ |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
110 :"1"(a),"g"(inverse[b])\ |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
111 );\ |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
112 ret;\ |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
113 }) |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
114 #elif defined(CONFIG_FASTDIV) |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
115 # define FASTDIV(a,b) ((uint32_t)((((uint64_t)a)*inverse[b])>>32)) |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
116 #else |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
117 # define FASTDIV(a,b) ((a)/(b)) |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
118 #endif |
12 | 119 |
0
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
120 /* math */ |
22
3b56407b3f96
On MinGW it is not possible to build shared and static libraries at once.
diego
parents:
19
diff
changeset
|
121 extern FF_IMPORT_ATTR const uint8_t ff_sqrt_tab[128]; |
0
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
122 |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
123 static inline int ff_sqrt(int a) |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
124 { |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
125 int ret=0; |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
126 int s; |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
127 int ret_sq=0; |
12 | 128 |
0
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
129 if(a<128) return ff_sqrt_tab[a]; |
12 | 130 |
0
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
131 for(s=15; s>=0; s--){ |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
132 int b= ret_sq + (1<<(s*2)) + (ret<<s)*2; |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
133 if(b<=a){ |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
134 ret_sq=b; |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
135 ret+= 1<<s; |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
136 } |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
137 } |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
138 return ret; |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
139 } |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
140 |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
141 #if defined(ARCH_X86) || defined(ARCH_X86_64) |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
142 #define MASK_ABS(mask, level)\ |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
143 asm volatile(\ |
13 | 144 "cdq \n\t"\ |
145 "xorl %1, %0 \n\t"\ | |
146 "subl %1, %0 \n\t"\ | |
147 : "+a" (level), "=&d" (mask)\ | |
148 ); | |
0
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
149 #else |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
150 #define MASK_ABS(mask, level)\ |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
151 mask= level>>31;\ |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
152 level= (level^mask)-mask; |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
153 #endif |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
154 |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
155 #if __CPU__ >= 686 && !defined(RUNTIME_CPUDETECT) |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
156 #define COPY3_IF_LT(x,y,a,b,c,d)\ |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
157 asm volatile (\ |
13 | 158 "cmpl %0, %3 \n\t"\ |
159 "cmovl %3, %0 \n\t"\ | |
160 "cmovl %4, %1 \n\t"\ | |
161 "cmovl %5, %2 \n\t"\ | |
0
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
162 : "+r" (x), "+r" (a), "+r" (c)\ |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
163 : "r" (y), "r" (b), "r" (d)\ |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
164 ); |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
165 #else |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
166 #define COPY3_IF_LT(x,y,a,b,c,d)\ |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
167 if((y)<(x)){\ |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
168 (x)=(y);\ |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
169 (a)=(b);\ |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
170 (c)=(d);\ |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
171 } |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
172 #endif |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
173 |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
174 /* avoid usage of various functions */ |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
175 #define malloc please_use_av_malloc |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
176 #define free please_use_av_free |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
177 #define realloc please_use_av_realloc |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
178 #define time time_is_forbidden_due_to_security_issues |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
179 #define rand rand_is_forbidden_due_to_state_trashing |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
180 #define srand srand_is_forbidden_due_to_state_trashing |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
181 #define sprintf sprintf_is_forbidden_due_to_security_issues_use_snprintf |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
182 #define strcat strcat_is_forbidden_due_to_security_issues_use_pstrcat |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
183 #if !(defined(LIBAVFORMAT_BUILD) || defined(_FRAMEHOOK_H)) |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
184 #define printf please_use_av_log |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
185 #define fprintf please_use_av_log |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
186 #endif |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
187 |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
188 #define CHECKED_ALLOCZ(p, size)\ |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
189 {\ |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
190 p= av_mallocz(size);\ |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
191 if(p==NULL && (size)!=0){\ |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
192 perror("malloc");\ |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
193 goto fail;\ |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
194 }\ |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
195 } |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
196 |
4
26a00aee5eac
Move lrintf implementation from libavcodec/dsputil.h to libavutil/common.h
diego
parents:
3
diff
changeset
|
197 #ifndef HAVE_LRINTF |
26a00aee5eac
Move lrintf implementation from libavcodec/dsputil.h to libavutil/common.h
diego
parents:
3
diff
changeset
|
198 /* XXX: add ISOC specific test to avoid specific BSD testing. */ |
26a00aee5eac
Move lrintf implementation from libavcodec/dsputil.h to libavutil/common.h
diego
parents:
3
diff
changeset
|
199 /* better than nothing implementation. */ |
26a00aee5eac
Move lrintf implementation from libavcodec/dsputil.h to libavutil/common.h
diego
parents:
3
diff
changeset
|
200 /* btw, rintf() is existing on fbsd too -- alex */ |
26a00aee5eac
Move lrintf implementation from libavcodec/dsputil.h to libavutil/common.h
diego
parents:
3
diff
changeset
|
201 static always_inline long int lrintf(float x) |
26a00aee5eac
Move lrintf implementation from libavcodec/dsputil.h to libavutil/common.h
diego
parents:
3
diff
changeset
|
202 { |
66
c619660c74ab
CONFIG_WIN32 implies MinGW and Cygwin and possibly more, so use just
diego
parents:
65
diff
changeset
|
203 #ifdef __MINGW32__ |
4
26a00aee5eac
Move lrintf implementation from libavcodec/dsputil.h to libavutil/common.h
diego
parents:
3
diff
changeset
|
204 # ifdef ARCH_X86 |
26a00aee5eac
Move lrintf implementation from libavcodec/dsputil.h to libavutil/common.h
diego
parents:
3
diff
changeset
|
205 int32_t i; |
26a00aee5eac
Move lrintf implementation from libavcodec/dsputil.h to libavutil/common.h
diego
parents:
3
diff
changeset
|
206 asm volatile( |
26a00aee5eac
Move lrintf implementation from libavcodec/dsputil.h to libavutil/common.h
diego
parents:
3
diff
changeset
|
207 "fistpl %0\n\t" |
26a00aee5eac
Move lrintf implementation from libavcodec/dsputil.h to libavutil/common.h
diego
parents:
3
diff
changeset
|
208 : "=m" (i) : "t" (x) : "st" |
26a00aee5eac
Move lrintf implementation from libavcodec/dsputil.h to libavutil/common.h
diego
parents:
3
diff
changeset
|
209 ); |
26a00aee5eac
Move lrintf implementation from libavcodec/dsputil.h to libavutil/common.h
diego
parents:
3
diff
changeset
|
210 return i; |
26a00aee5eac
Move lrintf implementation from libavcodec/dsputil.h to libavutil/common.h
diego
parents:
3
diff
changeset
|
211 # else |
26a00aee5eac
Move lrintf implementation from libavcodec/dsputil.h to libavutil/common.h
diego
parents:
3
diff
changeset
|
212 /* XXX: incorrect, but make it compile */ |
26a00aee5eac
Move lrintf implementation from libavcodec/dsputil.h to libavutil/common.h
diego
parents:
3
diff
changeset
|
213 return (int)(x + (x < 0 ? -0.5 : 0.5)); |
26a00aee5eac
Move lrintf implementation from libavcodec/dsputil.h to libavutil/common.h
diego
parents:
3
diff
changeset
|
214 # endif /* ARCH_X86 */ |
26a00aee5eac
Move lrintf implementation from libavcodec/dsputil.h to libavutil/common.h
diego
parents:
3
diff
changeset
|
215 #else |
26a00aee5eac
Move lrintf implementation from libavcodec/dsputil.h to libavutil/common.h
diego
parents:
3
diff
changeset
|
216 return (int)(rint(x)); |
66
c619660c74ab
CONFIG_WIN32 implies MinGW and Cygwin and possibly more, so use just
diego
parents:
65
diff
changeset
|
217 #endif /* __MINGW32__ */ |
4
26a00aee5eac
Move lrintf implementation from libavcodec/dsputil.h to libavutil/common.h
diego
parents:
3
diff
changeset
|
218 } |
26a00aee5eac
Move lrintf implementation from libavcodec/dsputil.h to libavutil/common.h
diego
parents:
3
diff
changeset
|
219 #endif /* HAVE_LRINTF */ |
26a00aee5eac
Move lrintf implementation from libavcodec/dsputil.h to libavutil/common.h
diego
parents:
3
diff
changeset
|
220 |
80
624fc3ad183a
Split common.h in two parts, purely internal stuff (internal.h) and things
reimar
parents:
75
diff
changeset
|
221 #endif /* INTERNAL_H */ |