00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00024 #ifndef AVUTIL_LIBM_H
00025 #define AVUTIL_LIBM_H
00026 
00027 #include <math.h>
00028 #include "config.h"
00029 #include "attributes.h"
00030 #include "intfloat.h"
00031 
00032 #if HAVE_MIPSFPU && HAVE_INLINE_ASM
00033 #include "libavutil/mips/libm_mips.h"
00034 #endif 
00035 
00036 #if !HAVE_CBRTF
00037 static av_always_inline float cbrtf(float x)
00038 {
00039     return x < 0 ? -powf(-x, 1.0 / 3.0) : powf(x, 1.0 / 3.0);
00040 }
00041 #endif
00042 
00043 #if !HAVE_EXP2
00044 #undef exp2
00045 #define exp2(x) exp((x) * 0.693147180559945)
00046 #endif 
00047 
00048 #if !HAVE_EXP2F
00049 #undef exp2f
00050 #define exp2f(x) ((float)exp2(x))
00051 #endif 
00052 
00053 #if !HAVE_ISINF
00054 static av_always_inline av_const int isinf(float x)
00055 {
00056     uint32_t v = av_float2int(x);
00057     if ((v & 0x7f800000) != 0x7f800000)
00058         return 0;
00059     return !(v & 0x007fffff);
00060 }
00061 #endif 
00062 
00063 #if !HAVE_ISNAN
00064 static av_always_inline av_const int isnan(float x)
00065 {
00066     uint32_t v = av_float2int(x);
00067     if ((v & 0x7f800000) != 0x7f800000)
00068         return 0;
00069     return v & 0x007fffff;
00070 }
00071 #endif 
00072 
00073 #if !HAVE_LLRINT
00074 #undef llrint
00075 #define llrint(x) ((long long)rint(x))
00076 #endif 
00077 
00078 #if !HAVE_LLRINTF
00079 #undef llrintf
00080 #define llrintf(x) ((long long)rint(x))
00081 #endif 
00082 
00083 #if !HAVE_LOG2
00084 #undef log2
00085 #define log2(x) (log(x) * 1.44269504088896340736)
00086 #endif 
00087 
00088 #if !HAVE_LOG2F
00089 #undef log2f
00090 #define log2f(x) ((float)log2(x))
00091 #endif 
00092 
00093 #if !HAVE_RINT
00094 static inline double rint(double x)
00095 {
00096     return x >= 0 ? floor(x + 0.5) : ceil(x - 0.5);
00097 }
00098 #endif 
00099 
00100 #if !HAVE_LRINT
00101 static av_always_inline av_const long int lrint(double x)
00102 {
00103     return rint(x);
00104 }
00105 #endif 
00106 
00107 #if !HAVE_LRINTF
00108 static av_always_inline av_const long int lrintf(float x)
00109 {
00110     return (int)(rint(x));
00111 }
00112 #endif 
00113 
00114 #if !HAVE_ROUND
00115 static av_always_inline av_const double round(double x)
00116 {
00117     return (x > 0) ? floor(x + 0.5) : ceil(x - 0.5);
00118 }
00119 #endif 
00120 
00121 #if !HAVE_ROUNDF
00122 static av_always_inline av_const float roundf(float x)
00123 {
00124     return (x > 0) ? floor(x + 0.5) : ceil(x - 0.5);
00125 }
00126 #endif 
00127 
00128 #if !HAVE_TRUNC
00129 static av_always_inline av_const double trunc(double x)
00130 {
00131     return (x > 0) ? floor(x) : ceil(x);
00132 }
00133 #endif 
00134 
00135 #if !HAVE_TRUNCF
00136 static av_always_inline av_const float truncf(float x)
00137 {
00138     return (x > 0) ? floor(x) : ceil(x);
00139 }
00140 #endif 
00141 
00142 #endif