yading@11
|
1 /*
|
yading@11
|
2 * Copyright (c) 2010 Mans Rullgard <mans@mansr.com>
|
yading@11
|
3 *
|
yading@11
|
4 * This file is part of FFmpeg.
|
yading@11
|
5 *
|
yading@11
|
6 * FFmpeg is free software; you can redistribute it and/or
|
yading@11
|
7 * modify it under the terms of the GNU Lesser General Public
|
yading@11
|
8 * License as published by the Free Software Foundation; either
|
yading@11
|
9 * version 2.1 of the License, or (at your option) any later version.
|
yading@11
|
10 *
|
yading@11
|
11 * FFmpeg is distributed in the hope that it will be useful,
|
yading@11
|
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
yading@11
|
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
yading@11
|
14 * Lesser General Public License for more details.
|
yading@11
|
15 *
|
yading@11
|
16 * You should have received a copy of the GNU Lesser General Public
|
yading@11
|
17 * License along with FFmpeg; if not, write to the Free Software
|
yading@11
|
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
yading@11
|
19 */
|
yading@11
|
20
|
yading@11
|
21 #ifndef AVUTIL_ARM_INTMATH_H
|
yading@11
|
22 #define AVUTIL_ARM_INTMATH_H
|
yading@11
|
23
|
yading@11
|
24 #include <stdint.h>
|
yading@11
|
25
|
yading@11
|
26 #include "config.h"
|
yading@11
|
27 #include "libavutil/attributes.h"
|
yading@11
|
28
|
yading@11
|
29 #if HAVE_INLINE_ASM
|
yading@11
|
30
|
yading@11
|
31 #if HAVE_ARMV6_INLINE
|
yading@11
|
32
|
yading@11
|
33 #define av_clip_uint8 av_clip_uint8_arm
|
yading@11
|
34 static av_always_inline av_const unsigned av_clip_uint8_arm(int a)
|
yading@11
|
35 {
|
yading@11
|
36 unsigned x;
|
yading@11
|
37 __asm__ ("usat %0, #8, %1" : "=r"(x) : "r"(a));
|
yading@11
|
38 return x;
|
yading@11
|
39 }
|
yading@11
|
40
|
yading@11
|
41 #define av_clip_int8 av_clip_int8_arm
|
yading@11
|
42 static av_always_inline av_const int av_clip_int8_arm(int a)
|
yading@11
|
43 {
|
yading@11
|
44 int x;
|
yading@11
|
45 __asm__ ("ssat %0, #8, %1" : "=r"(x) : "r"(a));
|
yading@11
|
46 return x;
|
yading@11
|
47 }
|
yading@11
|
48
|
yading@11
|
49 #define av_clip_uint16 av_clip_uint16_arm
|
yading@11
|
50 static av_always_inline av_const unsigned av_clip_uint16_arm(int a)
|
yading@11
|
51 {
|
yading@11
|
52 unsigned x;
|
yading@11
|
53 __asm__ ("usat %0, #16, %1" : "=r"(x) : "r"(a));
|
yading@11
|
54 return x;
|
yading@11
|
55 }
|
yading@11
|
56
|
yading@11
|
57 #define av_clip_int16 av_clip_int16_arm
|
yading@11
|
58 static av_always_inline av_const int av_clip_int16_arm(int a)
|
yading@11
|
59 {
|
yading@11
|
60 int x;
|
yading@11
|
61 __asm__ ("ssat %0, #16, %1" : "=r"(x) : "r"(a));
|
yading@11
|
62 return x;
|
yading@11
|
63 }
|
yading@11
|
64
|
yading@11
|
65 #define av_clip_uintp2 av_clip_uintp2_arm
|
yading@11
|
66 static av_always_inline av_const unsigned av_clip_uintp2_arm(int a, int p)
|
yading@11
|
67 {
|
yading@11
|
68 unsigned x;
|
yading@11
|
69 __asm__ ("usat %0, %2, %1" : "=r"(x) : "r"(a), "i"(p));
|
yading@11
|
70 return x;
|
yading@11
|
71 }
|
yading@11
|
72
|
yading@11
|
73 #define av_sat_add32 av_sat_add32_arm
|
yading@11
|
74 static av_always_inline int av_sat_add32_arm(int a, int b)
|
yading@11
|
75 {
|
yading@11
|
76 int r;
|
yading@11
|
77 __asm__ ("qadd %0, %1, %2" : "=r"(r) : "r"(a), "r"(b));
|
yading@11
|
78 return r;
|
yading@11
|
79 }
|
yading@11
|
80
|
yading@11
|
81 #define av_sat_dadd32 av_sat_dadd32_arm
|
yading@11
|
82 static av_always_inline int av_sat_dadd32_arm(int a, int b)
|
yading@11
|
83 {
|
yading@11
|
84 int r;
|
yading@11
|
85 __asm__ ("qdadd %0, %1, %2" : "=r"(r) : "r"(a), "r"(b));
|
yading@11
|
86 return r;
|
yading@11
|
87 }
|
yading@11
|
88
|
yading@11
|
89 #endif /* HAVE_ARMV6_INLINE */
|
yading@11
|
90
|
yading@11
|
91 #if HAVE_ASM_MOD_Q
|
yading@11
|
92
|
yading@11
|
93 #define av_clipl_int32 av_clipl_int32_arm
|
yading@11
|
94 static av_always_inline av_const int32_t av_clipl_int32_arm(int64_t a)
|
yading@11
|
95 {
|
yading@11
|
96 int x, y;
|
yading@11
|
97 __asm__ ("adds %1, %R2, %Q2, lsr #31 \n\t"
|
yading@11
|
98 "itet ne \n\t"
|
yading@11
|
99 "mvnne %1, #1<<31 \n\t"
|
yading@11
|
100 "moveq %0, %Q2 \n\t"
|
yading@11
|
101 "eorne %0, %1, %R2, asr #31 \n\t"
|
yading@11
|
102 : "=r"(x), "=&r"(y) : "r"(a) : "cc");
|
yading@11
|
103 return x;
|
yading@11
|
104 }
|
yading@11
|
105
|
yading@11
|
106 #endif /* HAVE_ASM_MOD_Q */
|
yading@11
|
107
|
yading@11
|
108 #endif /* HAVE_INLINE_ASM */
|
yading@11
|
109
|
yading@11
|
110 #endif /* AVUTIL_ARM_INTMATH_H */
|