1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-29 23:33:05 +04:00

android: make optional "cpufeatures", build fixes for NDK r15

This commit is contained in:
Alexander Alekhin
2017-06-12 16:10:13 +00:00
committed by Alexander Alekhin
parent cf86f88c71
commit 3e3e2dd512
24 changed files with 240 additions and 155 deletions
+17 -1
View File
@@ -73,7 +73,7 @@ Mutex* __initialization_mutex_initializer = &getInitializationMutex();
#endif
#endif
#if defined ANDROID
#if defined ANDROID && defined HAVE_CPUFEATURES
# include <cpu-features.h>
#endif
@@ -450,11 +450,27 @@ struct HWFeatures
have[CV_CPU_NEON] = true;
have[CV_CPU_FP16] = true;
#elif defined __arm__ && defined __ANDROID__
#if defined HAVE_CPUFEATURES
__android_log_print(ANDROID_LOG_INFO, "OpenCV", "calling android_getCpuFeatures() ...");
uint64_t features = android_getCpuFeatures();
__android_log_print(ANDROID_LOG_INFO, "OpenCV", "calling android_getCpuFeatures() ... Done (%llx)", features);
have[CV_CPU_NEON] = (features & ANDROID_CPU_ARM_FEATURE_NEON) != 0;
have[CV_CPU_FP16] = (features & ANDROID_CPU_ARM_FEATURE_VFP_FP16) != 0;
#else
__android_log_print(ANDROID_LOG_INFO, "OpenCV", "cpufeatures library is not avaialble for CPU detection");
#if CV_NEON
__android_log_print(ANDROID_LOG_INFO, "OpenCV", "- NEON instructions is enabled via build flags");
have[CV_CPU_NEON] = true;
#else
__android_log_print(ANDROID_LOG_INFO, "OpenCV", "- NEON instructions is NOT enabled via build flags");
#endif
#if CV_FP16
__android_log_print(ANDROID_LOG_INFO, "OpenCV", "- FP16 instructions is enabled via build flags");
have[CV_CPU_FP16] = true;
#else
__android_log_print(ANDROID_LOG_INFO, "OpenCV", "- FP16 instructions is NOT enabled via build flags");
#endif
#endif
#elif defined __arm__
int cpufile = open("/proc/self/auxv", O_RDONLY);