mirror of https://git.videolan.org/git/ffmpeg.git
aarch64: Factorize code for CPU feature detection on Apple platforms
Signed-off-by: Martin Storsjö <martin@martin.st>
This commit is contained in:
parent
41b73ae883
commit
8339a45400
|
@ -45,22 +45,23 @@ static int detect_flags(void)
|
||||||
#elif defined(__APPLE__) && HAVE_SYSCTLBYNAME
|
#elif defined(__APPLE__) && HAVE_SYSCTLBYNAME
|
||||||
#include <sys/sysctl.h>
|
#include <sys/sysctl.h>
|
||||||
|
|
||||||
|
static int have_feature(const char *feature) {
|
||||||
|
uint32_t value = 0;
|
||||||
|
size_t size = sizeof(value);
|
||||||
|
if (!sysctlbyname(feature, &value, &size, NULL, 0))
|
||||||
|
return value;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int detect_flags(void)
|
static int detect_flags(void)
|
||||||
{
|
{
|
||||||
uint32_t value = 0;
|
|
||||||
size_t size;
|
|
||||||
int flags = 0;
|
int flags = 0;
|
||||||
|
|
||||||
size = sizeof(value);
|
if (have_feature("hw.optional.arm.FEAT_DotProd"))
|
||||||
if (!sysctlbyname("hw.optional.arm.FEAT_DotProd", &value, &size, NULL, 0)) {
|
flags |= AV_CPU_FLAG_DOTPROD;
|
||||||
if (value)
|
if (have_feature("hw.optional.arm.FEAT_I8MM"))
|
||||||
flags |= AV_CPU_FLAG_DOTPROD;
|
flags |= AV_CPU_FLAG_I8MM;
|
||||||
}
|
|
||||||
size = sizeof(value);
|
|
||||||
if (!sysctlbyname("hw.optional.arm.FEAT_I8MM", &value, &size, NULL, 0)) {
|
|
||||||
if (value)
|
|
||||||
flags |= AV_CPU_FLAG_I8MM;
|
|
||||||
}
|
|
||||||
return flags;
|
return flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue