annotate arm/intmath.h @ 980:f08c66310125 libavutil

ARM: intmath.h cosmetics
author mru
date Wed, 07 Jul 2010 17:27:48 +0000
parents 4d9ad0ed07d0
children d004c9e2aa40
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
816
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
1 /*
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
2 * Copyright (c) 2010 Mans Rullgard <mans@mansr.com>
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
3 *
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
4 * This file is part of FFmpeg.
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
5 *
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
6 * FFmpeg is free software; you can redistribute it and/or
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
7 * modify it under the terms of the GNU Lesser General Public
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
8 * License as published by the Free Software Foundation; either
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
9 * version 2.1 of the License, or (at your option) any later version.
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
10 *
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
11 * FFmpeg is distributed in the hope that it will be useful,
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
14 * Lesser General Public License for more details.
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
15 *
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
16 * You should have received a copy of the GNU Lesser General Public
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
17 * License along with FFmpeg; if not, write to the Free Software
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
19 */
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
20
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
21 #ifndef AVUTIL_ARM_INTMATH_H
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
22 #define AVUTIL_ARM_INTMATH_H
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
23
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
24 #include "config.h"
873
4d9ad0ed07d0 Replace many includes of libavutil/common.h with what is actually needed
mru
parents: 816
diff changeset
25 #include "libavutil/attributes.h"
816
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
26
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
27 #if HAVE_INLINE_ASM
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
28
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
29 #if HAVE_ARMV6
980
f08c66310125 ARM: intmath.h cosmetics
mru
parents: 873
diff changeset
30
f08c66310125 ARM: intmath.h cosmetics
mru
parents: 873
diff changeset
31 #define FASTDIV FASTDIV
816
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
32 static inline av_const int FASTDIV(int a, int b)
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
33 {
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
34 int r, t;
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
35 __asm__ volatile("cmp %3, #2 \n\t"
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
36 "ldr %1, [%4, %3, lsl #2] \n\t"
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
37 "lsrle %0, %2, #1 \n\t"
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
38 "smmulgt %0, %1, %2 \n\t"
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
39 : "=&r"(r), "=&r"(t) : "r"(a), "r"(b), "r"(ff_inverse));
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
40 return r;
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
41 }
980
f08c66310125 ARM: intmath.h cosmetics
mru
parents: 873
diff changeset
42
f08c66310125 ARM: intmath.h cosmetics
mru
parents: 873
diff changeset
43 #else /* HAVE_ARMV6 */
f08c66310125 ARM: intmath.h cosmetics
mru
parents: 873
diff changeset
44
f08c66310125 ARM: intmath.h cosmetics
mru
parents: 873
diff changeset
45 #define FASTDIV FASTDIV
816
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
46 static inline av_const int FASTDIV(int a, int b)
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
47 {
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
48 int r, t;
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
49 __asm__ volatile("umull %1, %0, %2, %3"
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
50 : "=&r"(r), "=&r"(t) : "r"(a), "r"(ff_inverse[b]));
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
51 return r;
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
52 }
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
53
980
f08c66310125 ARM: intmath.h cosmetics
mru
parents: 873
diff changeset
54 #endif /* HAVE_ARMV6 */
816
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
55
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
56 #endif /* HAVE_INLINE_ASM */
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
57
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
58 #endif /* AVUTIL_ARM_INTMATH_H */