• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • File List
  • Globals

libavutil/libm.h

Go to the documentation of this file.
00001 /*
00002  * This file is part of FFmpeg.
00003  *
00004  * FFmpeg 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  * FFmpeg 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 FFmpeg; 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_CBRTF
00032 #undef cbrtf
00033 #define cbrtf(x) powf(x, 1.0/3.0)
00034 #endif /* HAVE_CBRTF */
00035 
00036 #if !HAVE_EXP2
00037 #undef exp2
00038 #define exp2(x) exp((x) * 0.693147180559945)
00039 #endif /* HAVE_EXP2 */
00040 
00041 #if !HAVE_EXP2F
00042 #undef exp2f
00043 #define exp2f(x) ((float)exp2(x))
00044 #endif /* HAVE_EXP2F */
00045 
00046 #if !HAVE_LLRINT
00047 #undef llrint
00048 #define llrint(x) ((long long)rint(x))
00049 #endif /* HAVE_LLRINT */
00050 
00051 #if !HAVE_LLRINTF
00052 #undef llrintf
00053 #define llrintf(x) ((long long)rint(x))
00054 #endif /* HAVE_LLRINT */
00055 
00056 #if !HAVE_LOG2
00057 #undef log2
00058 #define log2(x) (log(x) * 1.44269504088896340736)
00059 #endif /* HAVE_LOG2 */
00060 
00061 #if !HAVE_LOG2F
00062 #undef log2f
00063 #define log2f(x) ((float)log2(x))
00064 #endif /* HAVE_LOG2F */
00065 
00066 #if !HAVE_LRINT
00067 static av_always_inline av_const long int lrint(double x)
00068 {
00069     return rint(x);
00070 }
00071 #endif /* HAVE_LRINT */
00072 
00073 #if !HAVE_LRINTF
00074 static av_always_inline av_const long int lrintf(float x)
00075 {
00076     return (int)(rint(x));
00077 }
00078 #endif /* HAVE_LRINTF */
00079 
00080 #if !HAVE_ROUND
00081 static av_always_inline av_const double round(double x)
00082 {
00083     return (x > 0) ? floor(x + 0.5) : ceil(x - 0.5);
00084 }
00085 #endif /* HAVE_ROUND */
00086 
00087 #if !HAVE_ROUNDF
00088 static av_always_inline av_const float roundf(float x)
00089 {
00090     return (x > 0) ? floor(x + 0.5) : ceil(x - 0.5);
00091 }
00092 #endif /* HAVE_ROUNDF */
00093 
00094 #if !HAVE_TRUNC
00095 static av_always_inline av_const double trunc(double x)
00096 {
00097     return (x > 0) ? floor(x) : ceil(x);
00098 }
00099 #endif /* HAVE_TRUNC */
00100 
00101 #if !HAVE_TRUNCF
00102 static av_always_inline av_const float truncf(float x)
00103 {
00104     return (x > 0) ? floor(x) : ceil(x);
00105 }
00106 #endif /* HAVE_TRUNCF */
00107 
00108 #endif /* AVUTIL_LIBM_H */
Generated on Fri Feb 1 2013 14:34:56 for FFmpeg by doxygen 1.7.1