diff options
author | Måns Rullgård <mans@mansr.com> | 2010-07-07 17:27:51 +0000 |
---|---|---|
committer | Måns Rullgård <mans@mansr.com> | 2010-07-07 17:27:51 +0000 |
commit | 9077e29eccd39fca766aa5b2df843dbb171ec837 (patch) | |
tree | ca1647cf4eb59a178d46a902953f12a5a58159d1 /libavutil/arm | |
parent | edd7fa82d7db69ae79b4c8994dcbdd0d4e26d907 (diff) | |
download | ffmpeg-9077e29eccd39fca766aa5b2df843dbb171ec837.tar.gz |
ARM: optimised integer clip functions
Originally committed as revision 24089 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavutil/arm')
-rw-r--r-- | libavutil/arm/intmath.h | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/libavutil/arm/intmath.h b/libavutil/arm/intmath.h index 5514020339..2c0aa3b11c 100644 --- a/libavutil/arm/intmath.h +++ b/libavutil/arm/intmath.h @@ -21,6 +21,8 @@ #ifndef AVUTIL_ARM_INTMATH_H #define AVUTIL_ARM_INTMATH_H +#include <stdint.h> + #include "config.h" #include "libavutil/attributes.h" @@ -40,6 +42,38 @@ static inline av_const int FASTDIV(int a, int b) return r; } +#define av_clip_uint8 av_clip_uint8_arm +static inline av_const uint8_t av_clip_uint8_arm(int a) +{ + unsigned x; + __asm__ volatile ("usat %0, #8, %1" : "=r"(x) : "r"(a)); + return x; +} + +#define av_clip_int8 av_clip_int8_arm +static inline av_const uint8_t av_clip_int8_arm(int a) +{ + unsigned x; + __asm__ volatile ("ssat %0, #8, %1" : "=r"(x) : "r"(a)); + return x; +} + +#define av_clip_uint16 av_clip_uint16_arm +static inline av_const uint16_t av_clip_uint16_arm(int a) +{ + unsigned x; + __asm__ volatile ("usat %0, #16, %1" : "=r"(x) : "r"(a)); + return x; +} + +#define av_clip_int16 av_clip_int16_arm +static inline av_const int16_t av_clip_int16_arm(int a) +{ + int x; + __asm__ volatile ("ssat %0, #16, %1" : "=r"(x) : "r"(a)); + return x; +} + #else /* HAVE_ARMV6 */ #define FASTDIV FASTDIV @@ -53,6 +87,17 @@ static inline av_const int FASTDIV(int a, int b) #endif /* HAVE_ARMV6 */ +#define av_clipl_int32 av_clipl_int32_arm +static inline av_const int32_t av_clipl_int32_arm(int64_t a) +{ + int x, y; + __asm__ volatile ("adds %1, %R2, %Q2, lsr #31 \n\t" + "mvnne %1, #1<<31 \n\t" + "eorne %0, %1, %R2, asr #31 \n\t" + : "=r"(x), "=&r"(y) : "r"(a)); + return x; +} + #endif /* HAVE_INLINE_ASM */ #endif /* AVUTIL_ARM_INTMATH_H */ |