aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/common.h
diff options
context:
space:
mode:
authorBERO <bero@geocities.co.jp>2003-05-14 15:12:13 +0000
committerMichael Niedermayer <michaelni@gmx.at>2003-05-14 15:12:13 +0000
commitd4961b35236beb67785410473442f5923ac8a488 (patch)
tree7b8474ce797d6e8b33ef0b3e6c19ff5b532ea375 /libavcodec/common.h
parentb82cdc727855fc11f0110c46c39eadd00009ebc0 (diff)
downloadffmpeg-d4961b35236beb67785410473442f5923ac8a488.tar.gz
fastdiv patch by (BERO <bero at geocities dot co dot jp>) with fixes & cleanup by me
Originally committed as revision 1879 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/common.h')
-rw-r--r--libavcodec/common.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/libavcodec/common.h b/libavcodec/common.h
index 1a8202d709..092026d78e 100644
--- a/libavcodec/common.h
+++ b/libavcodec/common.h
@@ -197,6 +197,25 @@ inline void dprintf(const char* fmt,...) {}
#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){