forked from cropsly/ffmpeg-android-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharmArch.c
More file actions
29 lines (25 loc) · 851 Bytes
/
armArch.c
File metadata and controls
29 lines (25 loc) · 851 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <jni.h>
#include <stdio.h>
#include <stdlib.h>
#include <cpu-features.h>
jstring
Java_com_github_hiteshsondhi88_libffmpeg_ArmArchHelper_cpuArchFromJNI(JNIEnv* env, jobject obj)
{
// Maximum we need to store here is ARM v7-neon
// Which is 11 char long, so initializing a character array of length 11
char arch_info[11] = "";
// checking if CPU is of ARM family or not
if (android_getCpuFamily() == ANDROID_CPU_FAMILY_ARM) {
strcpy(arch_info, "ARM");
// checking if CPU is ARM v7 or not
uint64_t cpuFeatures = android_getCpuFeatures();
if ((cpuFeatures & ANDROID_CPU_ARM_FEATURE_ARMv7) != 0) {
strcat(arch_info, " v7");
// checking if CPU is ARM v7 Neon
if((cpuFeatures & ANDROID_CPU_ARM_FEATURE_NEON) != 0) {
strcat(arch_info, "-neon");
}
}
}
return (*env)->NewStringUTF(env, arch_info);
}