Revision 335ee1aa

View differences:

ffmpeg.c
40 40
#include "libavutil/fifo.h"
41 41
#include "libavutil/pixdesc.h"
42 42
#include "libavutil/avstring.h"
43
#include "libavutil/libm.h"
43 44
#include "libavformat/os_support.h"
44 45

  
45 46
#if HAVE_SYS_RESOURCE_H
libavutil/internal.h
192 192
    }\
193 193
}
194 194

  
195
#if !HAVE_EXP2
196
#undef exp2
197
#define exp2(x) exp((x) * 0.693147180559945)
198
#endif /* HAVE_EXP2 */
199

  
200
#if !HAVE_EXP2F
201
#undef exp2f
202
#define exp2f(x) ((float)exp2(x))
203
#endif /* HAVE_EXP2F */
204

  
205
#if !HAVE_LLRINT
206
#undef llrint
207
#define llrint(x) ((long long)rint(x))
208
#endif /* HAVE_LLRINT */
209

  
210
#if !HAVE_LOG2
211
#undef log2
212
#define log2(x) (log(x) * 1.44269504088896340736)
213
#endif /* HAVE_LOG2 */
214

  
215
#if !HAVE_LOG2F
216
#undef log2f
217
#define log2f(x) ((float)log2(x))
218
#endif /* HAVE_LOG2F */
219

  
220
#if !HAVE_LRINT
221
static av_always_inline av_const long int lrint(double x)
222
{
223
    return rint(x);
224
}
225
#endif /* HAVE_LRINT */
226

  
227
#if !HAVE_LRINTF
228
static av_always_inline av_const long int lrintf(float x)
229
{
230
    return (int)(rint(x));
231
}
232
#endif /* HAVE_LRINTF */
233

  
234
#if !HAVE_ROUND
235
static av_always_inline av_const double round(double x)
236
{
237
    return (x > 0) ? floor(x + 0.5) : ceil(x - 0.5);
238
}
239
#endif /* HAVE_ROUND */
240

  
241
#if !HAVE_ROUNDF
242
static av_always_inline av_const float roundf(float x)
243
{
244
    return (x > 0) ? floor(x + 0.5) : ceil(x - 0.5);
245
}
246
#endif /* HAVE_ROUNDF */
247

  
248
#if !HAVE_TRUNCF
249
static av_always_inline av_const float truncf(float x)
250
{
251
    return (x > 0) ? floor(x) : ceil(x);
252
}
253
#endif /* HAVE_TRUNCF */
195
#include "libm.h"
254 196

  
255 197
/**
256 198
 * Returns NULL if CONFIG_SMALL is true, otherwise the argument
libavutil/libm.h
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
/**
20
 * @file libavutil/libm.h
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"
29

  
30
#if !HAVE_EXP2
31
#undef exp2
32
#define exp2(x) exp((x) * 0.693147180559945)
33
#endif /* HAVE_EXP2 */
34

  
35
#if !HAVE_EXP2F
36
#undef exp2f
37
#define exp2f(x) ((float)exp2(x))
38
#endif /* HAVE_EXP2F */
39

  
40
#if !HAVE_LLRINT
41
#undef llrint
42
#define llrint(x) ((long long)rint(x))
43
#endif /* HAVE_LLRINT */
44

  
45
#if !HAVE_LOG2
46
#undef log2
47
#define log2(x) (log(x) * 1.44269504088896340736)
48
#endif /* HAVE_LOG2 */
49

  
50
#if !HAVE_LOG2F
51
#undef log2f
52
#define log2f(x) ((float)log2(x))
53
#endif /* HAVE_LOG2F */
54

  
55
#if !HAVE_LRINT
56
static av_always_inline av_const long int lrint(double x)
57
{
58
    return rint(x);
59
}
60
#endif /* HAVE_LRINT */
61

  
62
#if !HAVE_LRINTF
63
static av_always_inline av_const long int lrintf(float x)
64
{
65
    return (int)(rint(x));
66
}
67
#endif /* HAVE_LRINTF */
68

  
69
#if !HAVE_ROUND
70
static av_always_inline av_const double round(double x)
71
{
72
    return (x > 0) ? floor(x + 0.5) : ceil(x - 0.5);
73
}
74
#endif /* HAVE_ROUND */
75

  
76
#if !HAVE_ROUNDF
77
static av_always_inline av_const float roundf(float x)
78
{
79
    return (x > 0) ? floor(x + 0.5) : ceil(x - 0.5);
80
}
81
#endif /* HAVE_ROUNDF */
82

  
83
#if !HAVE_TRUNCF
84
static av_always_inline av_const float truncf(float x)
85
{
86
    return (x > 0) ? floor(x) : ceil(x);
87
}
88
#endif /* HAVE_TRUNCF */
89

  
90
#endif /* AVUTIL_LIBM_H */

Also available in: Unified diff