annotate arm/intmath.h @ 1028:5dbb12a37c3d libavutil tip

Move av_set_options_string() from libavfilter to libavutil.
author stefano
date Mon, 27 Sep 2010 22:09:53 +0000
parents d004c9e2aa40
children
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
981
d004c9e2aa40 ARM: optimised integer clip functions
mru
parents: 980
diff changeset
24 #include <stdint.h>
d004c9e2aa40 ARM: optimised integer clip functions
mru
parents: 980
diff changeset
25
816
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
26 #include "config.h"
873
4d9ad0ed07d0 Replace many includes of libavutil/common.h with what is actually needed
mru
parents: 816
diff changeset
27 #include "libavutil/attributes.h"
816
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_INLINE_ASM
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
30
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
31 #if HAVE_ARMV6
980
f08c66310125 ARM: intmath.h cosmetics
mru
parents: 873
diff changeset
32
f08c66310125 ARM: intmath.h cosmetics
mru
parents: 873
diff changeset
33 #define FASTDIV FASTDIV
816
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
34 static inline av_const int FASTDIV(int a, int b)
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
35 {
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
36 int r, t;
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
37 __asm__ volatile("cmp %3, #2 \n\t"
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
38 "ldr %1, [%4, %3, lsl #2] \n\t"
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
39 "lsrle %0, %2, #1 \n\t"
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
40 "smmulgt %0, %1, %2 \n\t"
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
41 : "=&r"(r), "=&r"(t) : "r"(a), "r"(b), "r"(ff_inverse));
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
42 return r;
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
43 }
980
f08c66310125 ARM: intmath.h cosmetics
mru
parents: 873
diff changeset
44
981
d004c9e2aa40 ARM: optimised integer clip functions
mru
parents: 980
diff changeset
45 #define av_clip_uint8 av_clip_uint8_arm
d004c9e2aa40 ARM: optimised integer clip functions
mru
parents: 980
diff changeset
46 static inline av_const uint8_t av_clip_uint8_arm(int a)
d004c9e2aa40 ARM: optimised integer clip functions
mru
parents: 980
diff changeset
47 {
d004c9e2aa40 ARM: optimised integer clip functions
mru
parents: 980
diff changeset
48 unsigned x;
d004c9e2aa40 ARM: optimised integer clip functions
mru
parents: 980
diff changeset
49 __asm__ volatile ("usat %0, #8, %1" : "=r"(x) : "r"(a));
d004c9e2aa40 ARM: optimised integer clip functions
mru
parents: 980
diff changeset
50 return x;
d004c9e2aa40 ARM: optimised integer clip functions
mru
parents: 980
diff changeset
51 }
d004c9e2aa40 ARM: optimised integer clip functions
mru
parents: 980
diff changeset
52
d004c9e2aa40 ARM: optimised integer clip functions
mru
parents: 980
diff changeset
53 #define av_clip_int8 av_clip_int8_arm
d004c9e2aa40 ARM: optimised integer clip functions
mru
parents: 980
diff changeset
54 static inline av_const uint8_t av_clip_int8_arm(int a)
d004c9e2aa40 ARM: optimised integer clip functions
mru
parents: 980
diff changeset
55 {
d004c9e2aa40 ARM: optimised integer clip functions
mru
parents: 980
diff changeset
56 unsigned x;
d004c9e2aa40 ARM: optimised integer clip functions
mru
parents: 980
diff changeset
57 __asm__ volatile ("ssat %0, #8, %1" : "=r"(x) : "r"(a));
d004c9e2aa40 ARM: optimised integer clip functions
mru
parents: 980
diff changeset
58 return x;
d004c9e2aa40 ARM: optimised integer clip functions
mru
parents: 980
diff changeset
59 }
d004c9e2aa40 ARM: optimised integer clip functions
mru
parents: 980
diff changeset
60
d004c9e2aa40 ARM: optimised integer clip functions
mru
parents: 980
diff changeset
61 #define av_clip_uint16 av_clip_uint16_arm
d004c9e2aa40 ARM: optimised integer clip functions
mru
parents: 980
diff changeset
62 static inline av_const uint16_t av_clip_uint16_arm(int a)
d004c9e2aa40 ARM: optimised integer clip functions
mru
parents: 980
diff changeset
63 {
d004c9e2aa40 ARM: optimised integer clip functions
mru
parents: 980
diff changeset
64 unsigned x;
d004c9e2aa40 ARM: optimised integer clip functions
mru
parents: 980
diff changeset
65 __asm__ volatile ("usat %0, #16, %1" : "=r"(x) : "r"(a));
d004c9e2aa40 ARM: optimised integer clip functions
mru
parents: 980
diff changeset
66 return x;
d004c9e2aa40 ARM: optimised integer clip functions
mru
parents: 980
diff changeset
67 }
d004c9e2aa40 ARM: optimised integer clip functions
mru
parents: 980
diff changeset
68
d004c9e2aa40 ARM: optimised integer clip functions
mru
parents: 980
diff changeset
69 #define av_clip_int16 av_clip_int16_arm
d004c9e2aa40 ARM: optimised integer clip functions
mru
parents: 980
diff changeset
70 static inline av_const int16_t av_clip_int16_arm(int a)
d004c9e2aa40 ARM: optimised integer clip functions
mru
parents: 980
diff changeset
71 {
d004c9e2aa40 ARM: optimised integer clip functions
mru
parents: 980
diff changeset
72 int x;
d004c9e2aa40 ARM: optimised integer clip functions
mru
parents: 980
diff changeset
73 __asm__ volatile ("ssat %0, #16, %1" : "=r"(x) : "r"(a));
d004c9e2aa40 ARM: optimised integer clip functions
mru
parents: 980
diff changeset
74 return x;
d004c9e2aa40 ARM: optimised integer clip functions
mru
parents: 980
diff changeset
75 }
d004c9e2aa40 ARM: optimised integer clip functions
mru
parents: 980
diff changeset
76
980
f08c66310125 ARM: intmath.h cosmetics
mru
parents: 873
diff changeset
77 #else /* HAVE_ARMV6 */
f08c66310125 ARM: intmath.h cosmetics
mru
parents: 873
diff changeset
78
f08c66310125 ARM: intmath.h cosmetics
mru
parents: 873
diff changeset
79 #define FASTDIV FASTDIV
816
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
80 static inline av_const int FASTDIV(int a, int b)
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
81 {
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
82 int r, t;
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
83 __asm__ volatile("umull %1, %0, %2, %3"
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
84 : "=&r"(r), "=&r"(t) : "r"(a), "r"(ff_inverse[b]));
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
85 return r;
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
86 }
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
87
980
f08c66310125 ARM: intmath.h cosmetics
mru
parents: 873
diff changeset
88 #endif /* HAVE_ARMV6 */
816
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
89
981
d004c9e2aa40 ARM: optimised integer clip functions
mru
parents: 980
diff changeset
90 #define av_clipl_int32 av_clipl_int32_arm
d004c9e2aa40 ARM: optimised integer clip functions
mru
parents: 980
diff changeset
91 static inline av_const int32_t av_clipl_int32_arm(int64_t a)
d004c9e2aa40 ARM: optimised integer clip functions
mru
parents: 980
diff changeset
92 {
d004c9e2aa40 ARM: optimised integer clip functions
mru
parents: 980
diff changeset
93 int x, y;
d004c9e2aa40 ARM: optimised integer clip functions
mru
parents: 980
diff changeset
94 __asm__ volatile ("adds %1, %R2, %Q2, lsr #31 \n\t"
d004c9e2aa40 ARM: optimised integer clip functions
mru
parents: 980
diff changeset
95 "mvnne %1, #1<<31 \n\t"
d004c9e2aa40 ARM: optimised integer clip functions
mru
parents: 980
diff changeset
96 "eorne %0, %1, %R2, asr #31 \n\t"
d004c9e2aa40 ARM: optimised integer clip functions
mru
parents: 980
diff changeset
97 : "=r"(x), "=&r"(y) : "r"(a));
d004c9e2aa40 ARM: optimised integer clip functions
mru
parents: 980
diff changeset
98 return x;
d004c9e2aa40 ARM: optimised integer clip functions
mru
parents: 980
diff changeset
99 }
d004c9e2aa40 ARM: optimised integer clip functions
mru
parents: 980
diff changeset
100
816
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
101 #endif /* HAVE_INLINE_ASM */
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
102
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
103 #endif /* AVUTIL_ARM_INTMATH_H */