annotate libm.h @ 958:f789d66969a4 libavutil

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