mirror of
https://github.com/outbackdingo/UltraGrid.git
synced 2026-03-21 11:40:22 +00:00
lavc video: prefer libaom-av1 for ARM macs
While on x86_64 is libsvtav1 still slightly ahead, on the M1 mac, the AOM AV1 performs significantly better (2x faster). The above holds for native builds, it actually looks like the x86_64 build running SVT AV1 on M1 mac doesn't run correctly at all - it produces just blank picture (green as is zeroed YCbCr buffer).
This commit is contained in:
@@ -45,6 +45,7 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#include <cassert>
|
||||
#include <cerrno>
|
||||
#include <climits>
|
||||
#include <cmath>
|
||||
#include <cstring>
|
||||
@@ -57,6 +58,11 @@
|
||||
#include "utils/misc.h"
|
||||
#include "utils/color_out.h"
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include <sys/types.h>
|
||||
#include <sys/sysctl.h>
|
||||
#endif
|
||||
|
||||
#define STRERROR_BUF_LEN 1024
|
||||
|
||||
using std::invalid_argument;
|
||||
@@ -305,3 +311,24 @@ uint32_t parse_uint32(const char *value_str) noexcept(false)
|
||||
return val;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether host machine is an ARM Mac (native or running x86_64 code with Rosetta2)
|
||||
*/
|
||||
bool is_arm_mac() {
|
||||
#ifdef __APPLE__
|
||||
char machine[256];
|
||||
size_t len = sizeof machine;
|
||||
if (sysctlbyname("hw.machine", &machine, &len, NULL, 0) != 0) {
|
||||
perror("sysctlbyname hw.machine");
|
||||
return false;
|
||||
}
|
||||
int proc_translated = -1; // Rosetta2 - 0 off, 1 on; sysctl ENOENT - x86_64 mac
|
||||
len = sizeof proc_translated;
|
||||
if (int ret = sysctlbyname("sysctl.proc_translated", &proc_translated, &len, NULL, 0); ret != 0 && errno != ENOENT) {
|
||||
perror("sysctlbyname sysctl.proc_translated");
|
||||
}
|
||||
return strstr(machine, "arm") != NULL || proc_translated == 1;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user