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 HAVE_INLINE_ASM
00029
00030 #if ARCH_X86_32
00031
00032 #define MULL MULL
00033 static av_always_inline av_const int MULL(int a, int b, unsigned shift)
00034 {
00035 int rt, dummy;
00036 __asm__ (
00037 "imull %3 \n\t"
00038 "shrdl %4, %%edx, %%eax \n\t"
00039 :"=a"(rt), "=d"(dummy)
00040 :"a"(a), "rm"(b), "ci"((uint8_t)shift)
00041 );
00042 return rt;
00043 }
00044
00045 #define MULH MULH
00046 static av_always_inline av_const int MULH(int a, int b)
00047 {
00048 int rt, dummy;
00049 __asm__ (
00050 "imull %3"
00051 :"=d"(rt), "=a"(dummy)
00052 :"a"(a), "rm"(b)
00053 );
00054 return rt;
00055 }
00056
00057 #define MUL64 MUL64
00058 static av_always_inline av_const int64_t MUL64(int a, int b)
00059 {
00060 int64_t rt;
00061 __asm__ (
00062 "imull %2"
00063 :"=A"(rt)
00064 :"a"(a), "rm"(b)
00065 );
00066 return rt;
00067 }
00068
00069 #endif
00070
00071 #if HAVE_CMOV
00072
00073 #define mid_pred mid_pred
00074 static inline av_const int mid_pred(int a, int b, int c)
00075 {
00076 int i=b;
00077 __asm__ volatile(
00078 "cmp %2, %1 \n\t"
00079 "cmovg %1, %0 \n\t"
00080 "cmovg %2, %1 \n\t"
00081 "cmp %3, %1 \n\t"
00082 "cmovl %3, %1 \n\t"
00083 "cmp %1, %0 \n\t"
00084 "cmovg %1, %0 \n\t"
00085 :"+&r"(i), "+&r"(a)
00086 :"r"(b), "r"(c)
00087 );
00088 return i;
00089 }
00090 #endif
00091
00092 #if HAVE_CMOV
00093 #define COPY3_IF_LT(x, y, a, b, c, d)\
00094 __asm__ volatile(\
00095 "cmpl %0, %3 \n\t"\
00096 "cmovl %3, %0 \n\t"\
00097 "cmovl %4, %1 \n\t"\
00098 "cmovl %5, %2 \n\t"\
00099 : "+&r" (x), "+&r" (a), "+r" (c)\
00100 : "r" (y), "r" (b), "r" (d)\
00101 );
00102 #endif
00103
00104 #define MASK_ABS(mask, level) \
00105 __asm__ ("cltd \n\t" \
00106 "xorl %1, %0 \n\t" \
00107 "subl %1, %0 \n\t" \
00108 : "+a"(level), "=&d"(mask))
00109
00110
00111 #define NEG_SSR32 NEG_SSR32
00112 static inline int32_t NEG_SSR32( int32_t a, int8_t s){
00113 __asm__ ("sarl %1, %0\n\t"
00114 : "+r" (a)
00115 : "ic" ((uint8_t)(-s))
00116 );
00117 return a;
00118 }
00119
00120 #define NEG_USR32 NEG_USR32
00121 static inline uint32_t NEG_USR32(uint32_t a, int8_t s){
00122 __asm__ ("shrl %1, %0\n\t"
00123 : "+r" (a)
00124 : "ic" ((uint8_t)(-s))
00125 );
00126 return a;
00127 }
00128
00129 #endif
00130 #endif