00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef AVCODEC_MATHOPS_H
00023 #define AVCODEC_MATHOPS_H
00024
00025 #include "libavutil/common.h"
00026
00027 #if ARCH_ARM
00028 # include "arm/mathops.h"
00029 #elif ARCH_AVR32
00030 # include "avr32/mathops.h"
00031 #elif ARCH_BFIN
00032 # include "bfin/mathops.h"
00033 #elif ARCH_MIPS
00034 # include "mips/mathops.h"
00035 #elif ARCH_PPC
00036 # include "ppc/mathops.h"
00037 #elif ARCH_X86
00038 # include "x86/mathops.h"
00039 #endif
00040
00041
00042
00043 #ifndef MULL
00044 # define MULL(a,b,s) (((int64_t)(a) * (int64_t)(b)) >> (s))
00045 #endif
00046
00047 #ifndef MULH
00048
00049
00050
00051 static av_always_inline int MULH(int a, int b){
00052 return ((int64_t)(a) * (int64_t)(b))>>32;
00053 }
00054 #endif
00055
00056 #ifndef UMULH
00057 static av_always_inline unsigned UMULH(unsigned a, unsigned b){
00058 return ((uint64_t)(a) * (uint64_t)(b))>>32;
00059 }
00060 #endif
00061
00062 #ifndef MUL64
00063 # define MUL64(a,b) ((int64_t)(a) * (int64_t)(b))
00064 #endif
00065
00066 #ifndef MAC64
00067 # define MAC64(d, a, b) ((d) += MUL64(a, b))
00068 #endif
00069
00070 #ifndef MLS64
00071 # define MLS64(d, a, b) ((d) -= MUL64(a, b))
00072 #endif
00073
00074
00075 #ifndef MAC16
00076 # define MAC16(rt, ra, rb) rt += (ra) * (rb)
00077 #endif
00078
00079
00080 #ifndef MUL16
00081 # define MUL16(ra, rb) ((ra) * (rb))
00082 #endif
00083
00084 #ifndef MLS16
00085 # define MLS16(rt, ra, rb) ((rt) -= (ra) * (rb))
00086 #endif
00087
00088
00089 #ifndef mid_pred
00090 #define mid_pred mid_pred
00091 static inline av_const int mid_pred(int a, int b, int c)
00092 {
00093 #if 0
00094 int t= (a-b)&((a-b)>>31);
00095 a-=t;
00096 b+=t;
00097 b-= (b-c)&((b-c)>>31);
00098 b+= (a-b)&((a-b)>>31);
00099
00100 return b;
00101 #else
00102 if(a>b){
00103 if(c>b){
00104 if(c>a) b=a;
00105 else b=c;
00106 }
00107 }else{
00108 if(b>c){
00109 if(c>a) b=c;
00110 else b=a;
00111 }
00112 }
00113 return b;
00114 #endif
00115 }
00116 #endif
00117
00118 #ifndef sign_extend
00119 static inline av_const int sign_extend(int val, unsigned bits)
00120 {
00121 return (val << (INT_BIT - bits)) >> (INT_BIT - bits);
00122 }
00123 #endif
00124
00125 #ifndef zero_extend
00126 static inline av_const unsigned zero_extend(unsigned val, unsigned bits)
00127 {
00128 return (val << (INT_BIT - bits)) >> (INT_BIT - bits);
00129 }
00130 #endif
00131
00132 #ifndef COPY3_IF_LT
00133 #define COPY3_IF_LT(x, y, a, b, c, d)\
00134 if ((y) < (x)) {\
00135 (x) = (y);\
00136 (a) = (b);\
00137 (c) = (d);\
00138 }
00139 #endif
00140
00141 #ifndef NEG_SSR32
00142 # define NEG_SSR32(a,s) ((( int32_t)(a))>>(32-(s)))
00143 #endif
00144
00145 #ifndef NEG_USR32
00146 # define NEG_USR32(a,s) (((uint32_t)(a))>>(32-(s)))
00147 #endif
00148
00149 #endif
00150