Skip to content

Commit

Permalink
Add runtime NEON detection for AArch32
Browse files Browse the repository at this point in the history
- Add NEON detection w/o libavutil
- Remove libavutil dependency with ARM
  • Loading branch information
dofuuz committed Aug 15, 2024
1 parent 0a28e99 commit edbdb40
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ if (WITH_AVFFT)
endif ()
endif ()

if (WITH_AVFFT OR (CMAKE_SYSTEM_PROCESSOR MATCHES "^arm" AND SIMD32_FOUND AND WITH_CR32))
if (WITH_AVFFT AND (CMAKE_SYSTEM_PROCESSOR MATCHES "^arm" AND SIMD32_FOUND AND WITH_CR32))
find_package (LibAVUtil)
if (AVUTIL_FOUND)
include_directories (${AVUTIL_INCLUDE_DIRS})
Expand All @@ -146,6 +146,7 @@ check_function_exists (lrint HAVE_LRINT)
check_include_files (fenv.h HAVE_FENV_H)
check_include_files (stdbool.h HAVE_STDBOOL_H)
check_include_files (stdint.h HAVE_STDINT_H)
check_include_files (sys/auxv.h HAVE_GETAUXVAL)
test_big_endian (HAVE_BIGENDIAN)


Expand Down
1 change: 1 addition & 0 deletions msvc/soxr-config.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#define HAVE_FENV_H 1
#define HAVE_STDBOOL_H 1
#define HAVE_STDINT_H 1
#define HAVE_GETAUXVAL 0
#define HAVE_LRINT 1
#define HAVE_BIGENDIAN 0

Expand Down
1 change: 1 addition & 0 deletions soxr-config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#cmakedefine01 HAVE_FENV_H
#cmakedefine01 HAVE_STDBOOL_H
#cmakedefine01 HAVE_STDINT_H
#cmakedefine01 HAVE_GETAUXVAL
#cmakedefine01 HAVE_LRINT
#cmakedefine01 HAVE_BIGENDIAN

Expand Down
5 changes: 5 additions & 0 deletions src/soxr.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@

#if AVUTIL_FOUND
#include <libavutil/cpu.h>
#elif HAVE_GETAUXVAL && defined(__arm__)
#include <sys/auxv.h>
#include <asm/hwcap.h>
#endif


Expand Down Expand Up @@ -256,6 +259,8 @@ soxr_io_spec_t soxr_io_spec(
return true;
#elif defined AV_CPU_FLAG_NEON
return !!(av_get_cpu_flags() & AV_CPU_FLAG_NEON);
#elif defined HWCAP_NEON
return !!(getauxval(AT_HWCAP) & HWCAP_NEON);
#else
return false;
#endif
Expand Down

0 comments on commit edbdb40

Please sign in to comment.