annotate intmath.h @ 816:d87093e4b925 libavutil

Move FASTDIV macro to intmath.h
author mru
date Tue, 19 Jan 2010 23:25:36 +0000
parents 36cc11e07d9b
children 41db9ae634fe
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
807
36cc11e07d9b Optimise av_log2 with clz when available
mru
parents:
diff changeset
1 /*
36cc11e07d9b Optimise av_log2 with clz when available
mru
parents:
diff changeset
2 * Copyright (c) 2010 Mans Rullgard <mans@mansr.com>
36cc11e07d9b Optimise av_log2 with clz when available
mru
parents:
diff changeset
3 *
36cc11e07d9b Optimise av_log2 with clz when available
mru
parents:
diff changeset
4 * This file is part of FFmpeg.
36cc11e07d9b Optimise av_log2 with clz when available
mru
parents:
diff changeset
5 *
36cc11e07d9b Optimise av_log2 with clz when available
mru
parents:
diff changeset
6 * FFmpeg is free software; you can redistribute it and/or
36cc11e07d9b Optimise av_log2 with clz when available
mru
parents:
diff changeset
7 * modify it under the terms of the GNU Lesser General Public
36cc11e07d9b Optimise av_log2 with clz when available
mru
parents:
diff changeset
8 * License as published by the Free Software Foundation; either
36cc11e07d9b Optimise av_log2 with clz when available
mru
parents:
diff changeset
9 * version 2.1 of the License, or (at your option) any later version.
36cc11e07d9b Optimise av_log2 with clz when available
mru
parents:
diff changeset
10 *
36cc11e07d9b Optimise av_log2 with clz when available
mru
parents:
diff changeset
11 * FFmpeg is distributed in the hope that it will be useful,
36cc11e07d9b Optimise av_log2 with clz when available
mru
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
36cc11e07d9b Optimise av_log2 with clz when available
mru
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
36cc11e07d9b Optimise av_log2 with clz when available
mru
parents:
diff changeset
14 * Lesser General Public License for more details.
36cc11e07d9b Optimise av_log2 with clz when available
mru
parents:
diff changeset
15 *
36cc11e07d9b Optimise av_log2 with clz when available
mru
parents:
diff changeset
16 * You should have received a copy of the GNU Lesser General Public
36cc11e07d9b Optimise av_log2 with clz when available
mru
parents:
diff changeset
17 * License along with FFmpeg; if not, write to the Free Software
36cc11e07d9b Optimise av_log2 with clz when available
mru
parents:
diff changeset
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
36cc11e07d9b Optimise av_log2 with clz when available
mru
parents:
diff changeset
19 */
36cc11e07d9b Optimise av_log2 with clz when available
mru
parents:
diff changeset
20
36cc11e07d9b Optimise av_log2 with clz when available
mru
parents:
diff changeset
21 #ifndef AVUTIL_INTMATH_H
36cc11e07d9b Optimise av_log2 with clz when available
mru
parents:
diff changeset
22 #define AVUTIL_INTMATH_H
36cc11e07d9b Optimise av_log2 with clz when available
mru
parents:
diff changeset
23
36cc11e07d9b Optimise av_log2 with clz when available
mru
parents:
diff changeset
24 #include "config.h"
36cc11e07d9b Optimise av_log2 with clz when available
mru
parents:
diff changeset
25 #include "common.h"
36cc11e07d9b Optimise av_log2 with clz when available
mru
parents:
diff changeset
26
816
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents: 807
diff changeset
27 extern const uint32_t ff_inverse[257];
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents: 807
diff changeset
28
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents: 807
diff changeset
29 #if ARCH_ARM
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents: 807
diff changeset
30 # include "arm/intmath.h"
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents: 807
diff changeset
31 #elif ARCH_X86
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents: 807
diff changeset
32 # include "x86/intmath.h"
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents: 807
diff changeset
33 #endif
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents: 807
diff changeset
34
807
36cc11e07d9b Optimise av_log2 with clz when available
mru
parents:
diff changeset
35 #if HAVE_FAST_CLZ && AV_GCC_VERSION_AT_LEAST(3,4)
36cc11e07d9b Optimise av_log2 with clz when available
mru
parents:
diff changeset
36
36cc11e07d9b Optimise av_log2 with clz when available
mru
parents:
diff changeset
37 #ifndef av_log2
36cc11e07d9b Optimise av_log2 with clz when available
mru
parents:
diff changeset
38
36cc11e07d9b Optimise av_log2 with clz when available
mru
parents:
diff changeset
39 #define av_log2(x) (31 - __builtin_clz((x)|1))
36cc11e07d9b Optimise av_log2 with clz when available
mru
parents:
diff changeset
40
36cc11e07d9b Optimise av_log2 with clz when available
mru
parents:
diff changeset
41 #ifndef av_log2_16bit
36cc11e07d9b Optimise av_log2 with clz when available
mru
parents:
diff changeset
42 #define av_log2_16bit av_log2
36cc11e07d9b Optimise av_log2 with clz when available
mru
parents:
diff changeset
43 #endif
36cc11e07d9b Optimise av_log2 with clz when available
mru
parents:
diff changeset
44
36cc11e07d9b Optimise av_log2 with clz when available
mru
parents:
diff changeset
45 #endif /* av_log2 */
36cc11e07d9b Optimise av_log2 with clz when available
mru
parents:
diff changeset
46
36cc11e07d9b Optimise av_log2 with clz when available
mru
parents:
diff changeset
47 #endif /* AV_GCC_VERSION_AT_LEAST(3,4) */
36cc11e07d9b Optimise av_log2 with clz when available
mru
parents:
diff changeset
48
816
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents: 807
diff changeset
49 #ifndef FASTDIV
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents: 807
diff changeset
50
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents: 807
diff changeset
51 #if CONFIG_FASTDIV
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents: 807
diff changeset
52 # define FASTDIV(a,b) ((uint32_t)((((uint64_t)a) * ff_inverse[b]) >> 32))
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents: 807
diff changeset
53 #else
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents: 807
diff changeset
54 # define FASTDIV(a,b) ((a) / (b))
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents: 807
diff changeset
55 #endif
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents: 807
diff changeset
56
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents: 807
diff changeset
57 #endif /* FASTDIV */
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents: 807
diff changeset
58
807
36cc11e07d9b Optimise av_log2 with clz when available
mru
parents:
diff changeset
59 #endif /* AVUTIL_INTMATH_H */