diff options
author | Mans Rullgard <mans@mansr.com> | 2011-02-16 05:39:42 +0300 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2011-02-20 21:05:47 +0300 |
commit | cdeba2de821df504ca799c103e48f3e9a92241f9 (patch) | |
tree | cb2afb48e3787dfb5302a290b40ce8f84f77e86b /libavutil/x86/cpu.c | |
parent | 91861ce25c7f19c38afdb0f115bf90118fc19428 (diff) |
x86: check for AVX support
This adds configure and runtime checks for AVX support on x86 CPUs.
Signed-off-by: Mans Rullgard <mans@mansr.com>
(cherry picked from commit 87f1355f9b4fc11414d0e6a91404203c2745f89f)
Diffstat (limited to 'libavutil/x86/cpu.c')
-rw-r--r-- | libavutil/x86/cpu.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/libavutil/x86/cpu.c b/libavutil/x86/cpu.c index 6fa4a46567..2caac2fb23 100644 --- a/libavutil/x86/cpu.c +++ b/libavutil/x86/cpu.c @@ -35,6 +35,9 @@ "=c" (ecx), "=d" (edx)\ : "0" (index)); +#define xgetbv(index,eax,edx) \ + __asm__ ("xgetbv" : "=a"(eax), "=d"(edx) : "c" (index)) + /* Function to test if multimedia instructions are supported... */ int ff_get_cpu_flags_x86(void) { @@ -93,6 +96,15 @@ int ff_get_cpu_flags_x86(void) rval |= AV_CPU_FLAG_SSE4; if (ecx & 0x00100000 ) rval |= AV_CPU_FLAG_SSE42; +#if HAVE_AVX + /* Check OXSAVE and AVX bits */ + if ((ecx & 0x18000000) == 0x18000000) { + /* Check for OS support */ + xgetbv(0, eax, edx); + if ((eax & 0x6) == 0x6) + rval |= AV_CPU_FLAG_AVX; + } +#endif #endif ; } |