Mercurial > libavcodec.hg
diff common.h @ 1261:362947395f5c libavcodec
fastdiv patch by (BERO <bero at geocities dot co dot jp>) with fixes & cleanup by me
author | michaelni |
---|---|
date | Wed, 14 May 2003 15:12:13 +0000 |
parents | 6defe392d5d2 |
children | 9fce515e9894 |
line wrap: on
line diff
--- a/common.h Wed May 14 12:32:17 2003 +0000 +++ b/common.h Wed May 14 15:12:13 2003 +0000 @@ -197,6 +197,25 @@ #define FFMAX(a,b) ((a) > (b) ? (a) : (b)) #define FFMIN(a,b) ((a) > (b) ? (b) : (a)) +extern const uint32_t inverse[256]; + +#ifdef ARCH_X86 +# define FASTDIV(a,b) \ + ({\ + int ret,dmy;\ + asm volatile(\ + "mull %3"\ + :"=d"(ret),"=a"(dmy)\ + :"1"(a),"g"(inverse[b])\ + );\ + ret;\ + }) +#elif defined(CONFIG_FASTDIV) +# define FASTDIV(a,b) ((uint32_t)((((uint64_t)a)*inverse[b])>>32)) +#else +# define FASTDIV(a,b) ((a)/(b)) +#endif + #ifdef ARCH_X86 // avoid +32 for shift optimization (gcc should do that ...) static inline int32_t NEG_SSR32( int32_t a, int8_t s){