comparison internal.h @ 871:0d85cdd07648 libavutil

Move libm replacements to new header libm.h ffmpeg.c uses lrintf(), which is missing on some systems. Previously it picked up the replacement via libavutil/internal.h due to HAVE_AV_CONFIG_H being erroneously defined. Moving these replacements to a separate header enables ffmpeg.c to use them without being exposed to internal interfaces. This use of a non-public header is justified by the header in question not being part of the internal interface either. It should rather be considered as part of the build system, which is shared between the libraries and the applications. This header cannot be installed since the tested conditions depend on the compiler.
author mru
date Tue, 09 Mar 2010 15:10:23 +0000
parents 41db9ae634fe
children 4d9ad0ed07d0
comparison
equal deleted inserted replaced
870:3790c30fc3ad 871:0d85cdd07648
190 av_log(ctx, AV_LOG_ERROR, "Cannot allocate memory.\n");\ 190 av_log(ctx, AV_LOG_ERROR, "Cannot allocate memory.\n");\
191 goto label;\ 191 goto label;\
192 }\ 192 }\
193 } 193 }
194 194
195 #if !HAVE_EXP2 195 #include "libm.h"
196 #undef exp2
197 #define exp2(x) exp((x) * 0.693147180559945)
198 #endif /* HAVE_EXP2 */
199
200 #if !HAVE_EXP2F
201 #undef exp2f
202 #define exp2f(x) ((float)exp2(x))
203 #endif /* HAVE_EXP2F */
204
205 #if !HAVE_LLRINT
206 #undef llrint
207 #define llrint(x) ((long long)rint(x))
208 #endif /* HAVE_LLRINT */
209
210 #if !HAVE_LOG2
211 #undef log2
212 #define log2(x) (log(x) * 1.44269504088896340736)
213 #endif /* HAVE_LOG2 */
214
215 #if !HAVE_LOG2F
216 #undef log2f
217 #define log2f(x) ((float)log2(x))
218 #endif /* HAVE_LOG2F */
219
220 #if !HAVE_LRINT
221 static av_always_inline av_const long int lrint(double x)
222 {
223 return rint(x);
224 }
225 #endif /* HAVE_LRINT */
226
227 #if !HAVE_LRINTF
228 static av_always_inline av_const long int lrintf(float x)
229 {
230 return (int)(rint(x));
231 }
232 #endif /* HAVE_LRINTF */
233
234 #if !HAVE_ROUND
235 static av_always_inline av_const double round(double x)
236 {
237 return (x > 0) ? floor(x + 0.5) : ceil(x - 0.5);
238 }
239 #endif /* HAVE_ROUND */
240
241 #if !HAVE_ROUNDF
242 static av_always_inline av_const float roundf(float x)
243 {
244 return (x > 0) ? floor(x + 0.5) : ceil(x - 0.5);
245 }
246 #endif /* HAVE_ROUNDF */
247
248 #if !HAVE_TRUNCF
249 static av_always_inline av_const float truncf(float x)
250 {
251 return (x > 0) ? floor(x) : ceil(x);
252 }
253 #endif /* HAVE_TRUNCF */
254 196
255 /** 197 /**
256 * Returns NULL if CONFIG_SMALL is true, otherwise the argument 198 * Returns NULL if CONFIG_SMALL is true, otherwise the argument
257 * without modification. Used to disable the definition of strings 199 * without modification. Used to disable the definition of strings
258 * (for example AVCodec long_names). 200 * (for example AVCodec long_names).