diff options
author | Kieran Kunhya <kierank@ob-encoder.com> | 2013-10-25 07:53:56 -0500 |
---|---|---|
committer | Derek Buitenhuis <derek.buitenhuis@gmail.com> | 2013-10-25 19:36:55 +0100 |
commit | 4d6ee0725553a43ba88d6f8327ebcf8f1c5ae8d4 (patch) | |
tree | d816bbf9d9dee4bc7e5c8f8b5074b0136d4e5c17 /libavutil/x86 | |
parent | 7177df90a043bd59e172843fc7cb9e767080ea12 (diff) | |
download | ffmpeg-4d6ee0725553a43ba88d6f8327ebcf8f1c5ae8d4.tar.gz |
libavutil: x86: Add AVX2 capable CPU detection.
Patch based on x264's AVX2 detection
Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
Diffstat (limited to 'libavutil/x86')
-rw-r--r-- | libavutil/x86/cpu.c | 8 | ||||
-rw-r--r-- | libavutil/x86/cpu.h | 3 |
2 files changed, 11 insertions, 0 deletions
diff --git a/libavutil/x86/cpu.c b/libavutil/x86/cpu.c index 3e946b8dc2..0e06d5deb2 100644 --- a/libavutil/x86/cpu.c +++ b/libavutil/x86/cpu.c @@ -134,6 +134,14 @@ int ff_get_cpu_flags_x86(void) if ((eax & 0x6) == 0x6) rval |= AV_CPU_FLAG_AVX; } +#if HAVE_AVX2 + if (max_std_level >= 7) { + cpuid(7, eax, ebx, ecx, edx); + if (ebx&0x00000020) + rval |= AV_CPU_FLAG_AVX2; + /* TODO: BMI1/2 */ + } +#endif /* HAVE_AVX2 */ #endif /* HAVE_AVX */ #endif /* HAVE_SSE */ } diff --git a/libavutil/x86/cpu.h b/libavutil/x86/cpu.h index e5153bb8b1..5303c5ae02 100644 --- a/libavutil/x86/cpu.h +++ b/libavutil/x86/cpu.h @@ -38,6 +38,7 @@ #define X86_SSE42(flags) CPUEXT(flags, SSE42) #define X86_AVX(flags) CPUEXT(flags, AVX) #define X86_FMA4(flags) CPUEXT(flags, FMA4) +#define X86_AVX2(flags) CPUEXT(flags, AVX2) #define EXTERNAL_AMD3DNOW(flags) CPUEXT_SUFFIX(flags, _EXTERNAL, AMD3DNOW) #define EXTERNAL_AMD3DNOWEXT(flags) CPUEXT_SUFFIX(flags, _EXTERNAL, AMD3DNOWEXT) @@ -51,6 +52,7 @@ #define EXTERNAL_SSE42(flags) CPUEXT_SUFFIX(flags, _EXTERNAL, SSE42) #define EXTERNAL_AVX(flags) CPUEXT_SUFFIX(flags, _EXTERNAL, AVX) #define EXTERNAL_FMA4(flags) CPUEXT_SUFFIX(flags, _EXTERNAL, FMA4) +#define EXTERNAL_AVX2(flags) CPUEXT_SUFFIX(flags, _EXTERNAL, AVX2) #define INLINE_AMD3DNOW(flags) CPUEXT_SUFFIX(flags, _INLINE, AMD3DNOW) #define INLINE_AMD3DNOWEXT(flags) CPUEXT_SUFFIX(flags, _INLINE, AMD3DNOWEXT) @@ -64,6 +66,7 @@ #define INLINE_SSE42(flags) CPUEXT_SUFFIX(flags, _INLINE, SSE42) #define INLINE_AVX(flags) CPUEXT_SUFFIX(flags, _INLINE, AVX) #define INLINE_FMA4(flags) CPUEXT_SUFFIX(flags, _INLINE, FMA4) +#define INLINE_AVX2(flags) CPUEXT_SUFFIX(flags, _INLINE, AVX2) void ff_cpu_cpuid(int index, int *eax, int *ebx, int *ecx, int *edx); void ff_cpu_xgetbv(int op, int *eax, int *edx); |