Mercurial > libavutil.hg
annotate libm.h @ 908:de9d2bfb3ceb libavutil
Fix broken 32-bit clipping, and write numbers in hex instead of decimal so
they are easier to understand. Also give the add a 'u' postfix to silence
a pre-c99 compiler warning.
| author | rbultje |
|---|---|
| date | Mon, 26 Apr 2010 13:36:17 +0000 |
| parents | 4ce17228fc5e |
| children |
| rev | line source |
|---|---|
| 871 | 1 /* |
| 2 * This file is part of FFmpeg. | |
| 3 * | |
| 4 * FFmpeg is free software; you can redistribute it and/or | |
| 5 * modify it under the terms of the GNU Lesser General Public | |
| 6 * License as published by the Free Software Foundation; either | |
| 7 * version 2.1 of the License, or (at your option) any later version. | |
| 8 * | |
| 9 * FFmpeg is distributed in the hope that it will be useful, | |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 12 * Lesser General Public License for more details. | |
| 13 * | |
| 14 * You should have received a copy of the GNU Lesser General Public | |
| 15 * License along with FFmpeg; if not, write to the Free Software | |
| 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
| 17 */ | |
| 18 | |
| 19 /** | |
|
899
0795a743bda1
Remove explicit filename from Doxygen @file commands.
diego
parents:
872
diff
changeset
|
20 * @file |
| 871 | 21 * Replacements for frequently missing libm functions |
| 22 */ | |
| 23 | |
| 24 #ifndef AVUTIL_LIBM_H | |
| 25 #define AVUTIL_LIBM_H | |
| 26 | |
| 27 #include <math.h> | |
| 28 #include "config.h" | |
| 872 | 29 #include "attributes.h" |
| 871 | 30 |
| 31 #if !HAVE_EXP2 | |
| 32 #undef exp2 | |
| 33 #define exp2(x) exp((x) * 0.693147180559945) | |
| 34 #endif /* HAVE_EXP2 */ | |
| 35 | |
| 36 #if !HAVE_EXP2F | |
| 37 #undef exp2f | |
| 38 #define exp2f(x) ((float)exp2(x)) | |
| 39 #endif /* HAVE_EXP2F */ | |
| 40 | |
| 41 #if !HAVE_LLRINT | |
| 42 #undef llrint | |
| 43 #define llrint(x) ((long long)rint(x)) | |
| 44 #endif /* HAVE_LLRINT */ | |
| 45 | |
| 906 | 46 #if !HAVE_LLRINTF |
| 47 #undef llrintf | |
| 48 #define llrintf(x) ((long long)rint(x)) | |
| 49 #endif /* HAVE_LLRINT */ | |
| 50 | |
| 871 | 51 #if !HAVE_LOG2 |
| 52 #undef log2 | |
| 53 #define log2(x) (log(x) * 1.44269504088896340736) | |
| 54 #endif /* HAVE_LOG2 */ | |
| 55 | |
| 56 #if !HAVE_LOG2F | |
| 57 #undef log2f | |
| 58 #define log2f(x) ((float)log2(x)) | |
| 59 #endif /* HAVE_LOG2F */ | |
| 60 | |
| 61 #if !HAVE_LRINT | |
| 62 static av_always_inline av_const long int lrint(double x) | |
| 63 { | |
| 64 return rint(x); | |
| 65 } | |
| 66 #endif /* HAVE_LRINT */ | |
| 67 | |
| 68 #if !HAVE_LRINTF | |
| 69 static av_always_inline av_const long int lrintf(float x) | |
| 70 { | |
| 71 return (int)(rint(x)); | |
| 72 } | |
| 73 #endif /* HAVE_LRINTF */ | |
| 74 | |
| 75 #if !HAVE_ROUND | |
| 76 static av_always_inline av_const double round(double x) | |
| 77 { | |
| 78 return (x > 0) ? floor(x + 0.5) : ceil(x - 0.5); | |
| 79 } | |
| 80 #endif /* HAVE_ROUND */ | |
| 81 | |
| 82 #if !HAVE_ROUNDF | |
| 83 static av_always_inline av_const float roundf(float x) | |
| 84 { | |
| 85 return (x > 0) ? floor(x + 0.5) : ceil(x - 0.5); | |
| 86 } | |
| 87 #endif /* HAVE_ROUNDF */ | |
| 88 | |
| 89 #if !HAVE_TRUNCF | |
| 90 static av_always_inline av_const float truncf(float x) | |
| 91 { | |
| 92 return (x > 0) ? floor(x) : ceil(x); | |
| 93 } | |
| 94 #endif /* HAVE_TRUNCF */ | |
| 95 | |
| 96 #endif /* AVUTIL_LIBM_H */ |
