Libav 0.7.1
|
00001 /* 00002 * This file is part of Libav. 00003 * 00004 * Libav is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU Lesser General Public 00006 * License as published by the Free Software Foundation; either 00007 * version 2.1 of the License, or (at your option) any later version. 00008 * 00009 * Libav is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 * Lesser General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU Lesser General Public 00015 * License along with Libav; if not, write to the Free Software 00016 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 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 00031 #if !HAVE_EXP2 00032 #undef exp2 00033 #define exp2(x) exp((x) * 0.693147180559945) 00034 #endif /* HAVE_EXP2 */ 00035 00036 #if !HAVE_EXP2F 00037 #undef exp2f 00038 #define exp2f(x) ((float)exp2(x)) 00039 #endif /* HAVE_EXP2F */ 00040 00041 #if !HAVE_LLRINT 00042 #undef llrint 00043 #define llrint(x) ((long long)rint(x)) 00044 #endif /* HAVE_LLRINT */ 00045 00046 #if !HAVE_LLRINTF 00047 #undef llrintf 00048 #define llrintf(x) ((long long)rint(x)) 00049 #endif /* HAVE_LLRINT */ 00050 00051 #if !HAVE_LOG2 00052 #undef log2 00053 #define log2(x) (log(x) * 1.44269504088896340736) 00054 #endif /* HAVE_LOG2 */ 00055 00056 #if !HAVE_LOG2F 00057 #undef log2f 00058 #define log2f(x) ((float)log2(x)) 00059 #endif /* HAVE_LOG2F */ 00060 00061 #if !HAVE_LRINT 00062 static av_always_inline av_const long int lrint(double x) 00063 { 00064 return rint(x); 00065 } 00066 #endif /* HAVE_LRINT */ 00067 00068 #if !HAVE_LRINTF 00069 static av_always_inline av_const long int lrintf(float x) 00070 { 00071 return (int)(rint(x)); 00072 } 00073 #endif /* HAVE_LRINTF */ 00074 00075 #if !HAVE_ROUND 00076 static av_always_inline av_const double round(double x) 00077 { 00078 return (x > 0) ? floor(x + 0.5) : ceil(x - 0.5); 00079 } 00080 #endif /* HAVE_ROUND */ 00081 00082 #if !HAVE_ROUNDF 00083 static av_always_inline av_const float roundf(float x) 00084 { 00085 return (x > 0) ? floor(x + 0.5) : ceil(x - 0.5); 00086 } 00087 #endif /* HAVE_ROUNDF */ 00088 00089 #if !HAVE_TRUNC 00090 static av_always_inline av_const double trunc(double x) 00091 { 00092 return (x > 0) ? floor(x) : ceil(x); 00093 } 00094 #endif /* HAVE_TRUNC */ 00095 00096 #if !HAVE_TRUNCF 00097 static av_always_inline av_const float truncf(float x) 00098 { 00099 return (x > 0) ? floor(x) : ceil(x); 00100 } 00101 #endif /* HAVE_TRUNCF */ 00102 00103 #endif /* AVUTIL_LIBM_H */