Revision 75fb5c24
libavutil/arm/intmath.h | ||
---|---|---|
1 |
/* |
|
2 |
* Copyright (c) 2010 Mans Rullgard <mans@mansr.com> |
|
3 |
* |
|
4 |
* This file is part of FFmpeg. |
|
5 |
* |
|
6 |
* FFmpeg is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU Lesser General Public |
|
8 |
* License as published by the Free Software Foundation; either |
|
9 |
* version 2.1 of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* FFmpeg is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
14 |
* Lesser General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU Lesser General Public |
|
17 |
* License along with FFmpeg; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
19 |
*/ |
|
20 |
|
|
21 |
#ifndef AVUTIL_ARM_INTMATH_H |
|
22 |
#define AVUTIL_ARM_INTMATH_H |
|
23 |
|
|
24 |
#include "config.h" |
|
25 |
#include "libavutil/common.h" |
|
26 |
|
|
27 |
#if HAVE_INLINE_ASM |
|
28 |
|
|
29 |
#if HAVE_ARMV6 |
|
30 |
static inline av_const int FASTDIV(int a, int b) |
|
31 |
{ |
|
32 |
int r, t; |
|
33 |
__asm__ volatile("cmp %3, #2 \n\t" |
|
34 |
"ldr %1, [%4, %3, lsl #2] \n\t" |
|
35 |
"lsrle %0, %2, #1 \n\t" |
|
36 |
"smmulgt %0, %1, %2 \n\t" |
|
37 |
: "=&r"(r), "=&r"(t) : "r"(a), "r"(b), "r"(ff_inverse)); |
|
38 |
return r; |
|
39 |
} |
|
40 |
#else |
|
41 |
static inline av_const int FASTDIV(int a, int b) |
|
42 |
{ |
|
43 |
int r, t; |
|
44 |
__asm__ volatile("umull %1, %0, %2, %3" |
|
45 |
: "=&r"(r), "=&r"(t) : "r"(a), "r"(ff_inverse[b])); |
|
46 |
return r; |
|
47 |
} |
|
48 |
#endif |
|
49 |
|
|
50 |
#define FASTDIV FASTDIV |
|
51 |
|
|
52 |
#endif /* HAVE_INLINE_ASM */ |
|
53 |
|
|
54 |
#endif /* AVUTIL_ARM_INTMATH_H */ |
libavutil/internal.h | ||
---|---|---|
120 | 120 |
|
121 | 121 |
/* math */ |
122 | 122 |
|
123 |
extern const uint32_t ff_inverse[257]; |
|
124 |
|
|
125 |
#if ARCH_X86 |
|
126 |
# define FASTDIV(a,b) \ |
|
127 |
({\ |
|
128 |
int ret, dmy;\ |
|
129 |
__asm__ volatile(\ |
|
130 |
"mull %3"\ |
|
131 |
:"=d"(ret), "=a"(dmy)\ |
|
132 |
:"1"(a), "g"(ff_inverse[b])\ |
|
133 |
);\ |
|
134 |
ret;\ |
|
135 |
}) |
|
136 |
#elif HAVE_ARMV6 && HAVE_INLINE_ASM |
|
137 |
static inline av_const int FASTDIV(int a, int b) |
|
138 |
{ |
|
139 |
int r, t; |
|
140 |
__asm__ volatile("cmp %3, #2 \n\t" |
|
141 |
"ldr %1, [%4, %3, lsl #2] \n\t" |
|
142 |
"lsrle %0, %2, #1 \n\t" |
|
143 |
"smmulgt %0, %1, %2 \n\t" |
|
144 |
: "=&r"(r), "=&r"(t) : "r"(a), "r"(b), "r"(ff_inverse)); |
|
145 |
return r; |
|
146 |
} |
|
147 |
#elif ARCH_ARM && HAVE_INLINE_ASM |
|
148 |
static inline av_const int FASTDIV(int a, int b) |
|
149 |
{ |
|
150 |
int r, t; |
|
151 |
__asm__ volatile("umull %1, %0, %2, %3" |
|
152 |
: "=&r"(r), "=&r"(t) : "r"(a), "r"(ff_inverse[b])); |
|
153 |
return r; |
|
154 |
} |
|
155 |
#elif CONFIG_FASTDIV |
|
156 |
# define FASTDIV(a,b) ((uint32_t)((((uint64_t)a) * ff_inverse[b]) >> 32)) |
|
157 |
#else |
|
158 |
# define FASTDIV(a,b) ((a) / (b)) |
|
159 |
#endif |
|
160 |
|
|
161 | 123 |
extern const uint8_t ff_sqrt_tab[256]; |
162 | 124 |
|
163 | 125 |
static inline av_const unsigned int ff_sqrt(unsigned int a) |
libavutil/intmath.h | ||
---|---|---|
24 | 24 |
#include "config.h" |
25 | 25 |
#include "common.h" |
26 | 26 |
|
27 |
extern const uint32_t ff_inverse[257]; |
|
28 |
|
|
29 |
#if ARCH_ARM |
|
30 |
# include "arm/intmath.h" |
|
31 |
#elif ARCH_X86 |
|
32 |
# include "x86/intmath.h" |
|
33 |
#endif |
|
34 |
|
|
27 | 35 |
#if HAVE_FAST_CLZ && AV_GCC_VERSION_AT_LEAST(3,4) |
28 | 36 |
|
29 | 37 |
#ifndef av_log2 |
... | ... | |
38 | 46 |
|
39 | 47 |
#endif /* AV_GCC_VERSION_AT_LEAST(3,4) */ |
40 | 48 |
|
49 |
#ifndef FASTDIV |
|
50 |
|
|
51 |
#if CONFIG_FASTDIV |
|
52 |
# define FASTDIV(a,b) ((uint32_t)((((uint64_t)a) * ff_inverse[b]) >> 32)) |
|
53 |
#else |
|
54 |
# define FASTDIV(a,b) ((a) / (b)) |
|
55 |
#endif |
|
56 |
|
|
57 |
#endif /* FASTDIV */ |
|
58 |
|
|
41 | 59 |
#endif /* AVUTIL_INTMATH_H */ |
libavutil/x86/intmath.h | ||
---|---|---|
1 |
/* |
|
2 |
* Copyright (c) 2010 Mans Rullgard <mans@mansr.com> |
|
3 |
* |
|
4 |
* This file is part of FFmpeg. |
|
5 |
* |
|
6 |
* FFmpeg is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU Lesser General Public |
|
8 |
* License as published by the Free Software Foundation; either |
|
9 |
* version 2.1 of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* FFmpeg is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
14 |
* Lesser General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU Lesser General Public |
|
17 |
* License along with FFmpeg; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
19 |
*/ |
|
20 |
|
|
21 |
#ifndef AVUTIL_X86_INTMATH_H |
|
22 |
#define AVUTIL_X86_INTMATH_H |
|
23 |
|
|
24 |
#include "libavutil/common.h" |
|
25 |
|
|
26 |
#define FASTDIV(a,b) \ |
|
27 |
({\ |
|
28 |
int ret, dmy;\ |
|
29 |
__asm__ volatile(\ |
|
30 |
"mull %3"\ |
|
31 |
:"=d"(ret), "=a"(dmy)\ |
|
32 |
:"1"(a), "g"(ff_inverse[b])\ |
|
33 |
);\ |
|
34 |
ret;\ |
|
35 |
}) |
|
36 |
|
|
37 |
#endif /* AVUTIL_X86_INTMATH_H */ |
Also available in: Unified diff