00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef AVCODEC_ARM_MATHOPS_H
00023 #define AVCODEC_ARM_MATHOPS_H
00024
00025 #include <stdint.h>
00026 #include "config.h"
00027 #include "libavutil/common.h"
00028
00029 #if HAVE_INLINE_ASM
00030
00031 #if HAVE_ARMV6_INLINE
00032 #define MULH MULH
00033 static inline av_const int MULH(int a, int b)
00034 {
00035 int r;
00036 __asm__ ("smmul %0, %1, %2" : "=r"(r) : "r"(a), "r"(b));
00037 return r;
00038 }
00039
00040 #define FASTDIV FASTDIV
00041 static av_always_inline av_const int FASTDIV(int a, int b)
00042 {
00043 int r;
00044 __asm__ ("cmp %2, #2 \n\t"
00045 "ldr %0, [%3, %2, lsl #2] \n\t"
00046 "ite le \n\t"
00047 "lsrle %0, %1, #1 \n\t"
00048 "smmulgt %0, %0, %1 \n\t"
00049 : "=&r"(r) : "r"(a), "r"(b), "r"(ff_inverse) : "cc");
00050 return r;
00051 }
00052
00053 #else
00054
00055 #define FASTDIV FASTDIV
00056 static av_always_inline av_const int FASTDIV(int a, int b)
00057 {
00058 int r, t;
00059 __asm__ ("umull %1, %0, %2, %3"
00060 : "=&r"(r), "=&r"(t) : "r"(a), "r"(ff_inverse[b]));
00061 return r;
00062 }
00063 #endif
00064
00065 #define MLS64(d, a, b) MAC64(d, -(a), b)
00066
00067 #if HAVE_ARMV5TE_INLINE
00068
00069
00070 # define MAC16(rt, ra, rb) \
00071 __asm__ ("smlabb %0, %1, %2, %0" : "+r"(rt) : "r"(ra), "r"(rb));
00072
00073
00074 # define MUL16 MUL16
00075 static inline av_const int MUL16(int ra, int rb)
00076 {
00077 int rt;
00078 __asm__ ("smulbb %0, %1, %2" : "=r"(rt) : "r"(ra), "r"(rb));
00079 return rt;
00080 }
00081
00082 #endif
00083
00084 #define mid_pred mid_pred
00085 static inline av_const int mid_pred(int a, int b, int c)
00086 {
00087 int m;
00088 __asm__ (
00089 "mov %0, %2 \n\t"
00090 "cmp %1, %2 \n\t"
00091 "itt gt \n\t"
00092 "movgt %0, %1 \n\t"
00093 "movgt %1, %2 \n\t"
00094 "cmp %1, %3 \n\t"
00095 "it le \n\t"
00096 "movle %1, %3 \n\t"
00097 "cmp %0, %1 \n\t"
00098 "it gt \n\t"
00099 "movgt %0, %1 \n\t"
00100 : "=&r"(m), "+r"(a)
00101 : "r"(b), "r"(c)
00102 : "cc");
00103 return m;
00104 }
00105
00106 #endif
00107
00108 #endif