00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef AVUTIL_ARM_INTMATH_H
00022 #define AVUTIL_ARM_INTMATH_H
00023
00024 #include <stdint.h>
00025
00026 #include "config.h"
00027 #include "libavutil/attributes.h"
00028
00029 #if HAVE_INLINE_ASM
00030
00031 #if HAVE_ARMV6
00032
00033 #define FASTDIV FASTDIV
00034 static av_always_inline av_const int FASTDIV(int a, int b)
00035 {
00036 int r;
00037 __asm__ ("cmp %2, #2 \n\t"
00038 "ldr %0, [%3, %2, lsl #2] \n\t"
00039 "ite le \n\t"
00040 "lsrle %0, %1, #1 \n\t"
00041 "smmulgt %0, %0, %1 \n\t"
00042 : "=&r"(r) : "r"(a), "r"(b), "r"(ff_inverse) : "cc");
00043 return r;
00044 }
00045
00046 #define av_clip_uint8 av_clip_uint8_arm
00047 static av_always_inline av_const uint8_t av_clip_uint8_arm(int a)
00048 {
00049 unsigned x;
00050 __asm__ ("usat %0, #8, %1" : "=r"(x) : "r"(a));
00051 return x;
00052 }
00053
00054 #define av_clip_int8 av_clip_int8_arm
00055 static av_always_inline av_const uint8_t av_clip_int8_arm(int a)
00056 {
00057 unsigned x;
00058 __asm__ ("ssat %0, #8, %1" : "=r"(x) : "r"(a));
00059 return x;
00060 }
00061
00062 #define av_clip_uint16 av_clip_uint16_arm
00063 static av_always_inline av_const uint16_t av_clip_uint16_arm(int a)
00064 {
00065 unsigned x;
00066 __asm__ ("usat %0, #16, %1" : "=r"(x) : "r"(a));
00067 return x;
00068 }
00069
00070 #define av_clip_int16 av_clip_int16_arm
00071 static av_always_inline av_const int16_t av_clip_int16_arm(int a)
00072 {
00073 int x;
00074 __asm__ ("ssat %0, #16, %1" : "=r"(x) : "r"(a));
00075 return x;
00076 }
00077
00078 #define av_clip_uintp2 av_clip_uintp2_arm
00079 static av_always_inline av_const unsigned av_clip_uintp2_arm(int a, int p)
00080 {
00081 unsigned x;
00082 __asm__ ("usat %0, %2, %1" : "=r"(x) : "r"(a), "i"(p));
00083 return x;
00084 }
00085
00086
00087 #else
00088
00089 #define FASTDIV FASTDIV
00090 static av_always_inline av_const int FASTDIV(int a, int b)
00091 {
00092 int r, t;
00093 __asm__ ("umull %1, %0, %2, %3"
00094 : "=&r"(r), "=&r"(t) : "r"(a), "r"(ff_inverse[b]));
00095 return r;
00096 }
00097
00098 #endif
00099
00100 #define av_clipl_int32 av_clipl_int32_arm
00101 static av_always_inline av_const int32_t av_clipl_int32_arm(int64_t a)
00102 {
00103 int x, y;
00104 __asm__ ("adds %1, %R2, %Q2, lsr #31 \n\t"
00105 "itet ne \n\t"
00106 "mvnne %1, #1<<31 \n\t"
00107 "moveq %0, %Q2 \n\t"
00108 "eorne %0, %1, %R2, asr #31 \n\t"
00109 : "=r"(x), "=&r"(y) : "r"(a):"cc");
00110 return x;
00111 }
00112
00113 #endif
00114
00115 #endif