From e3a9212bfc4ee1f541f0df4b8d4f4da4d7095bd1 Mon Sep 17 00:00:00 2001 From: Martijn van Beurden Date: Mon, 2 May 2022 21:59:40 +0200 Subject: [PATCH] [CMake] Fix ARM64 intrinsics activation In 95e2c52 the autotools build worked fine, but CMake missed a few defines. Activition of the lpc_compute_residual_from_qlp_coefficients depended on encoder->private_->cpuinfo.use_asm for no reason, so this dependency is removed --- config.cmake.h.in | 6 ++++++ src/libFLAC/lpc_intrin_neon.c | 2 +- src/libFLAC/stream_encoder.c | 19 +++++++++---------- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/config.cmake.h.in b/config.cmake.h.in index e6460837..04f8d6cb 100644 --- a/config.cmake.h.in +++ b/config.cmake.h.in @@ -9,6 +9,9 @@ /* Target processor is little endian. */ #cmakedefine01 CPU_IS_LITTLE_ENDIAN +/* Target processor ARM64 */ +#cmakedefine FLAC__CPU_ARM64 + /* Target processor PPC */ #cmakedefine FLAC__CPU_PPC @@ -43,6 +46,9 @@ /* Set to 1 if is available. */ #cmakedefine01 FLAC__HAS_NEONINTRIN +/* Set to 1 if contains A64 intrinsics */ +#cmakedefine01 FLAC__HAS_A64NEONINTRIN + /* define if building for Darwin / MacOS X */ #cmakedefine FLAC__SYS_DARWIN diff --git a/src/libFLAC/lpc_intrin_neon.c b/src/libFLAC/lpc_intrin_neon.c index eedc2f69..ffab5d38 100644 --- a/src/libFLAC/lpc_intrin_neon.c +++ b/src/libFLAC/lpc_intrin_neon.c @@ -41,7 +41,7 @@ #include "private/macros.h" #include -#ifdef FLAC__HAS_A64NEONINTRIN +#if FLAC__HAS_A64NEONINTRIN void FLAC__lpc_compute_autocorrelation_intrin_neon_lag_14(const FLAC__real data[], uint32_t data_len, uint32_t lag, double autoc[]) { #undef MAX_LAG diff --git a/src/libFLAC/stream_encoder.c b/src/libFLAC/stream_encoder.c index be3b4506..9d0188d7 100644 --- a/src/libFLAC/stream_encoder.c +++ b/src/libFLAC/stream_encoder.c @@ -906,8 +906,10 @@ static FLAC__StreamEncoderInitStatus init_stream_internal_( encoder->private_->local_lpc_compute_autocorrelation = FLAC__lpc_compute_autocorrelation; } #endif -#endif -#if defined FLAC__CPU_ARM64 && FLAC__HAS_NEONINTRIN && FLAC__HAS_A64NEONINTRIN +#endif /* defined(FLAC__CPU_PPC64) && defined(FLAC__USE_VSX) */ + +#if defined FLAC__CPU_ARM64 && FLAC__HAS_NEONINTRIN +#if FLAC__HAS_A64NEONINTRIN if(encoder->protected_->max_lpc_order < 8) encoder->private_->local_lpc_compute_autocorrelation = FLAC__lpc_compute_autocorrelation_intrin_neon_lag_8; else if(encoder->protected_->max_lpc_order < 10) @@ -917,6 +919,11 @@ static FLAC__StreamEncoderInitStatus init_stream_internal_( else encoder->private_->local_lpc_compute_autocorrelation = FLAC__lpc_compute_autocorrelation; #endif + encoder->private_->local_lpc_compute_residual_from_qlp_coefficients_16bit = FLAC__lpc_compute_residual_from_qlp_coefficients_intrin_neon; + encoder->private_->local_lpc_compute_residual_from_qlp_coefficients = FLAC__lpc_compute_residual_from_qlp_coefficients_intrin_neon; + encoder->private_->local_lpc_compute_residual_from_qlp_coefficients_64bit = FLAC__lpc_compute_residual_from_qlp_coefficients_wide_intrin_neon; +#endif /* defined FLAC__CPU_ARM64 && FLAC__HAS_NEONINTRIN */ + if(encoder->private_->cpuinfo.use_asm) { # ifdef FLAC__CPU_IA32 FLAC__ASSERT(encoder->private_->cpuinfo.type == FLAC__CPUINFO_TYPE_IA32); @@ -1013,14 +1020,6 @@ static FLAC__StreamEncoderInitStatus init_stream_internal_( # endif # endif /* FLAC__HAS_X86INTRIN */ # endif /* FLAC__CPU_... */ - - #if defined FLAC__CPU_ARM64 && FLAC__HAS_NEONINTRIN - - encoder->private_->local_lpc_compute_residual_from_qlp_coefficients_16bit = FLAC__lpc_compute_residual_from_qlp_coefficients_intrin_neon; - encoder->private_->local_lpc_compute_residual_from_qlp_coefficients = FLAC__lpc_compute_residual_from_qlp_coefficients_intrin_neon; - encoder->private_->local_lpc_compute_residual_from_qlp_coefficients_64bit = FLAC__lpc_compute_residual_from_qlp_coefficients_wide_intrin_neon; - # endif - } # endif /* !FLAC__NO_ASM */