| Index: third_party/libwebp/dsp/cpu.c
|
| diff --git a/third_party/libwebp/dsp/cpu.c b/third_party/libwebp/dsp/cpu.c
|
| index ef04a75a08f8999c58c35193f2148369809fb98b..8844cb406415fb3d0d994e5918e140410f3f06a9 100644
|
| --- a/third_party/libwebp/dsp/cpu.c
|
| +++ b/third_party/libwebp/dsp/cpu.c
|
| @@ -13,7 +13,7 @@
|
|
|
| #include "./dsp.h"
|
|
|
| -#if defined(__ANDROID__)
|
| +#if defined(WEBP_ANDROID_NEON)
|
| #include <cpu-features.h>
|
| #endif
|
|
|
| @@ -31,6 +31,18 @@ static WEBP_INLINE void GetCPUInfo(int cpu_info[4], int info_type) {
|
| : "=a"(cpu_info[0]), "=D"(cpu_info[1]), "=c"(cpu_info[2]), "=d"(cpu_info[3])
|
| : "a"(info_type), "c"(0));
|
| }
|
| +#elif defined(__x86_64__) && \
|
| + (defined(__code_model_medium__) || defined(__code_model_large__)) && \
|
| + defined(__PIC__)
|
| +static WEBP_INLINE void GetCPUInfo(int cpu_info[4], int info_type) {
|
| + __asm__ volatile (
|
| + "xchg{q}\t{%%rbx}, %q1\n"
|
| + "cpuid\n"
|
| + "xchg{q}\t{%%rbx}, %q1\n"
|
| + : "=a"(cpu_info[0]), "=&r"(cpu_info[1]), "=c"(cpu_info[2]),
|
| + "=d"(cpu_info[3])
|
| + : "a"(info_type), "c"(0));
|
| +}
|
| #elif defined(__i386__) || defined(__x86_64__)
|
| static WEBP_INLINE void GetCPUInfo(int cpu_info[4], int info_type) {
|
| __asm__ volatile (
|
| @@ -79,7 +91,16 @@ static WEBP_INLINE uint64_t xgetbv(void) {
|
|
|
| #if defined(__i386__) || defined(__x86_64__) || defined(WEBP_MSC_SSE2)
|
| static int x86CPUInfo(CPUFeature feature) {
|
| + int max_cpuid_value;
|
| int cpu_info[4];
|
| +
|
| + // get the highest feature value cpuid supports
|
| + GetCPUInfo(cpu_info, 0);
|
| + max_cpuid_value = cpu_info[0];
|
| + if (max_cpuid_value < 1) {
|
| + return 0;
|
| + }
|
| +
|
| GetCPUInfo(cpu_info, 1);
|
| if (feature == kSSE2) {
|
| return 0 != (cpu_info[3] & 0x04000000);
|
| @@ -87,6 +108,9 @@ static int x86CPUInfo(CPUFeature feature) {
|
| if (feature == kSSE3) {
|
| return 0 != (cpu_info[2] & 0x00000001);
|
| }
|
| + if (feature == kSSE4_1) {
|
| + return 0 != (cpu_info[2] & 0x00080000);
|
| + }
|
| if (feature == kAVX) {
|
| // bits 27 (OSXSAVE) & 28 (256-bit AVX)
|
| if ((cpu_info[2] & 0x18000000) == 0x18000000) {
|
| @@ -95,7 +119,7 @@ static int x86CPUInfo(CPUFeature feature) {
|
| }
|
| }
|
| if (feature == kAVX2) {
|
| - if (x86CPUInfo(kAVX)) {
|
| + if (x86CPUInfo(kAVX) && max_cpuid_value >= 7) {
|
| GetCPUInfo(cpu_info, 7);
|
| return ((cpu_info[1] & 0x00000020) == 0x00000020);
|
| }
|
| @@ -122,10 +146,14 @@ static int armCPUInfo(CPUFeature feature) {
|
| return 1;
|
| }
|
| VP8CPUInfo VP8GetCPUInfo = armCPUInfo;
|
| -#elif defined(WEBP_USE_MIPS32)
|
| +#elif defined(WEBP_USE_MIPS32) || defined(WEBP_USE_MIPS_DSP_R2)
|
| static int mipsCPUInfo(CPUFeature feature) {
|
| - (void)feature;
|
| - return 1;
|
| + if ((feature == kMIPS32) || (feature == kMIPSdspR2)) {
|
| + return 1;
|
| + } else {
|
| + return 0;
|
| + }
|
| +
|
| }
|
| VP8CPUInfo VP8GetCPUInfo = mipsCPUInfo;
|
| #else
|
|
|