mirror of
https://github.com/webmproject/libwebp.git
synced 2024-12-26 05:38:22 +01:00
dsp/cpu.c: Android: fix crash on non-neon arm builds
add proper cpu-detection for Android targets Fixes issue #118 (and is a better solution for #117). based on patch by pepijn vaneeckhoudt Change-Id: I6b00ea6d51ca658ccf6a3d55b87b99c01c6805be
This commit is contained in:
parent
9a214fa112
commit
834f937f3c
@ -60,7 +60,10 @@ LOCAL_C_INCLUDES += $(LOCAL_PATH)/src
|
||||
ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
|
||||
LOCAL_ARM_NEON := true
|
||||
endif
|
||||
LOCAL_STATIC_LIBRARIES := cpufeatures
|
||||
|
||||
LOCAL_MODULE:= webp
|
||||
|
||||
include $(BUILD_STATIC_LIBRARY)
|
||||
|
||||
$(call import-module,android/cpufeatures)
|
||||
|
@ -11,6 +11,10 @@
|
||||
|
||||
#include "./dsp.h"
|
||||
|
||||
#if defined(__ANDROID__)
|
||||
#include <cpu-features.h>
|
||||
#endif
|
||||
|
||||
#if defined(__cplusplus) || defined(c_plusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
@ -53,6 +57,17 @@ static int x86CPUInfo(CPUFeature feature) {
|
||||
return 0;
|
||||
}
|
||||
VP8CPUInfo VP8GetCPUInfo = x86CPUInfo;
|
||||
#elif defined(__ANDROID__)
|
||||
static int AndroidCPUInfo(CPUFeature feature) {
|
||||
const AndroidCpuFamily cpu_family = android_getCpuFamily();
|
||||
const uint64_t cpu_features = android_getCpuFeatures();
|
||||
if (feature == kNEON) {
|
||||
return (cpu_family == ANDROID_CPU_FAMILY_ARM &&
|
||||
0 != (cpu_features & ANDROID_CPU_ARM_FEATURE_NEON));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
VP8CPUInfo VP8GetCPUInfo = AndroidCPUInfo;
|
||||
#elif defined(__ARM_NEON__)
|
||||
// define a dummy function to enable turning off NEON at runtime by setting
|
||||
// VP8DecGetCPUInfo = NULL
|
||||
|
Loading…
Reference in New Issue
Block a user