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 "libavutil/common.h"
00027
00028 # define MULL MULL
00029 static inline av_const int MULL(int a, int b, unsigned shift)
00030 {
00031 int lo, hi;
00032 __asm__("smull %0, %1, %2, %3 \n\t"
00033 "mov %0, %0, lsr %4 \n\t"
00034 "add %1, %0, %1, lsl %5 \n\t"
00035 : "=&r"(lo), "=&r"(hi)
00036 : "r"(b), "r"(a), "ir"(shift), "ir"(32-shift));
00037 return hi;
00038 }
00039
00040 #define MULH MULH
00041 #if HAVE_ARMV6
00042 static inline av_const int MULH(int a, int b)
00043 {
00044 int r;
00045 __asm__ ("smmul %0, %1, %2" : "=r"(r) : "r"(a), "r"(b));
00046 return r;
00047 }
00048 #else
00049 static inline av_const int MULH(int a, int b)
00050 {
00051 int lo, hi;
00052 __asm__ ("smull %0, %1, %2, %3" : "=&r"(lo), "=&r"(hi) : "r"(b), "r"(a));
00053 return hi;
00054 }
00055 #endif
00056
00057 static inline av_const int64_t MUL64(int a, int b)
00058 {
00059 union { uint64_t x; unsigned hl[2]; } x;
00060 __asm__ ("smull %0, %1, %2, %3"
00061 : "=r"(x.hl[0]), "=r"(x.hl[1]) : "r"(a), "r"(b));
00062 return x.x;
00063 }
00064 #define MUL64 MUL64
00065
00066 static inline av_const int64_t MAC64(int64_t d, int a, int b)
00067 {
00068 union { uint64_t x; unsigned hl[2]; } x = { d };
00069 __asm__ ("smlal %0, %1, %2, %3"
00070 : "+r"(x.hl[0]), "+r"(x.hl[1]) : "r"(a), "r"(b));
00071 return x.x;
00072 }
00073 #define MAC64(d, a, b) ((d) = MAC64(d, a, b))
00074 #define MLS64(d, a, b) MAC64(d, -(a), b)
00075
00076 #if HAVE_ARMV5TE
00077
00078
00079 # define MAC16(rt, ra, rb) \
00080 __asm__ ("smlabb %0, %1, %2, %0" : "+r"(rt) : "r"(ra), "r"(rb));
00081
00082
00083 # define MUL16 MUL16
00084 static inline av_const int MUL16(int ra, int rb)
00085 {
00086 int rt;
00087 __asm__ ("smulbb %0, %1, %2" : "=r"(rt) : "r"(ra), "r"(rb));
00088 return rt;
00089 }
00090
00091 #endif
00092
00093 #define mid_pred mid_pred
00094 static inline av_const int mid_pred(int a, int b, int c)
00095 {
00096 int m;
00097 __asm__ volatile (
00098 "mov %0, %2 \n\t"
00099 "cmp %1, %2 \n\t"
00100 "movgt %0, %1 \n\t"
00101 "movgt %1, %2 \n\t"
00102 "cmp %1, %3 \n\t"
00103 "movle %1, %3 \n\t"
00104 "cmp %0, %1 \n\t"
00105 "movgt %0, %1 \n\t"
00106 : "=&r"(m), "+r"(a)
00107 : "r"(b), "r"(c));
00108 return m;
00109 }
00110
00111 #endif