00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef AVCODEC_X86_MATHOPS_H
00023 #define AVCODEC_X86_MATHOPS_H
00024
00025 #include "config.h"
00026 #include "libavutil/common.h"
00027
00028 #if ARCH_X86_32
00029 #define MULL(ra, rb, shift) \
00030 ({ int rt, dummy; __asm__ (\
00031 "imull %3 \n\t"\
00032 "shrdl %4, %%edx, %%eax \n\t"\
00033 : "=a"(rt), "=d"(dummy)\
00034 : "a" ((int)(ra)), "rm" ((int)(rb)), "i"(shift));\
00035 rt; })
00036
00037 #define MULH(ra, rb) \
00038 ({ int rt, dummy;\
00039 __asm__ ("imull %3\n\t" : "=d"(rt), "=a"(dummy): "a" ((int)(ra)), "rm" ((int)(rb)));\
00040 rt; })
00041
00042 #define MUL64(ra, rb) \
00043 ({ int64_t rt;\
00044 __asm__ ("imull %2\n\t" : "=A"(rt) : "a" ((int)(ra)), "g" ((int)(rb)));\
00045 rt; })
00046 #endif
00047
00048 #if HAVE_CMOV
00049
00050 #define mid_pred mid_pred
00051 static inline av_const int mid_pred(int a, int b, int c)
00052 {
00053 int i=b;
00054 __asm__ volatile(
00055 "cmp %2, %1 \n\t"
00056 "cmovg %1, %0 \n\t"
00057 "cmovg %2, %1 \n\t"
00058 "cmp %3, %1 \n\t"
00059 "cmovl %3, %1 \n\t"
00060 "cmp %1, %0 \n\t"
00061 "cmovg %1, %0 \n\t"
00062 :"+&r"(i), "+&r"(a)
00063 :"r"(b), "r"(c)
00064 );
00065 return i;
00066 }
00067 #endif
00068
00069 #if HAVE_CMOV
00070 #define COPY3_IF_LT(x, y, a, b, c, d)\
00071 __asm__ volatile(\
00072 "cmpl %0, %3 \n\t"\
00073 "cmovl %3, %0 \n\t"\
00074 "cmovl %4, %1 \n\t"\
00075 "cmovl %5, %2 \n\t"\
00076 : "+&r" (x), "+&r" (a), "+r" (c)\
00077 : "r" (y), "r" (b), "r" (d)\
00078 );
00079 #endif
00080
00081
00082 #define NEG_SSR32 NEG_SSR32
00083 static inline int32_t NEG_SSR32( int32_t a, int8_t s){
00084 __asm__ ("sarl %1, %0\n\t"
00085 : "+r" (a)
00086 : "ic" ((uint8_t)(-s))
00087 );
00088 return a;
00089 }
00090
00091 #define NEG_USR32 NEG_USR32
00092 static inline uint32_t NEG_USR32(uint32_t a, int8_t s){
00093 __asm__ ("shrl %1, %0\n\t"
00094 : "+r" (a)
00095 : "ic" ((uint8_t)(-s))
00096 );
00097 return a;
00098 }
00099
00100 #endif