Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mpc-hc/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Almer <jamrial@gmail.com>2015-03-19 04:43:33 +0300
committerJames Almer <jamrial@gmail.com>2015-03-20 21:47:43 +0300
commit60b9373dbd52bba91d2286d5f8a1366090a9df08 (patch)
treecf66d9f3900a6f19b92b93dbac9716c442f31d13 /libavutil
parentd13e521cc861e791545dd6022fbf93f821e33618 (diff)
libavutil: add bmi2 optimized av_mod_uintp2
Reviewed-by: Michael Niedermayer <michaelni@gmx.at> Signed-off-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavutil')
-rw-r--r--libavutil/x86/intmath.h24
1 files changed, 22 insertions, 2 deletions
diff --git a/libavutil/x86/intmath.h b/libavutil/x86/intmath.h
index 7aa6bc42fb..c42fa8352b 100644
--- a/libavutil/x86/intmath.h
+++ b/libavutil/x86/intmath.h
@@ -24,15 +24,35 @@
#include <stdint.h>
#include "config.h"
+#if defined(__GNUC__)
+
/* Our generic version of av_popcount is faster than GCC's built-in on
* CPUs that don't support the popcnt instruction.
*/
-#if defined(__GNUC__) && defined(__POPCNT__)
+#if defined(__POPCNT__)
#define av_popcount __builtin_popcount
#if ARCH_X86_64
#define av_popcount64 __builtin_popcountll
#endif
-#endif /* defined(__GNUC__) && defined(__POPCNT__) */
+#endif /* __POPCNT__ */
+
+#if defined(__BMI2__)
+
+#define av_mod_uintp2 av_mod_uintp2_bmi2
+static av_always_inline av_const unsigned av_mod_uintp2_bmi2(unsigned a, unsigned p)
+{
+ if (av_builtin_constant_p(p))
+ return a & ((1 << p) - 1);
+ else {
+ unsigned x;
+ __asm__ ("bzhi %2, %1, %0 \n\t" : "=r"(x) : "rm"(a), "r"(p));
+ return x;
+ }
+}
+
+#endif /* __BMI2__ */
+
+#endif /* __GNUC__ */
#endif /* AVUTIL_X86_INTMATH_H */