From c66a00dd0b9c70cef3eff1e85d941ef9608d93b9 Mon Sep 17 00:00:00 2001 From: Sandro Mani Date: Wed, 4 Oct 2023 21:29:06 -0500 Subject: [PATCH 7/7] Don't use SSE2 if it is not available --- aconfigure.ac | 22 +++++++++++++++++-- third_party/build/os-auto.mak.in | 3 +-- .../modules/audio_processing/aec/aec_core.c | 2 +- .../modules/audio_processing/aec/aec_rdft.c | 2 +- 4 files changed, 23 insertions(+), 6 deletions(-) diff --git a/aconfigure.ac b/aconfigure.ac index 986a58a56..8c928d25e 100644 --- a/aconfigure.ac +++ b/aconfigure.ac @@ -2322,6 +2322,24 @@ AC_SUBST(ac_no_webrtc) AC_SUBST(ac_webrtc_instset) AC_SUBST(ac_webrtc_cflags) AC_SUBST(ac_webrtc_ldflags) + +AC_MSG_CHECKING(for available instruction set) +AC_LINK_IFELSE([ + AC_LANG_PROGRAM([[ + #include + __m128 testfunc(float *a, float *b) { + return _mm_add_ps(_mm_loadu_ps(a), _mm_loadu_ps(b)); + } + ]])], + [ + instrset=sse2 + ], + [ + instrset=generic + ] +) +AC_MSG_RESULT($instrset) + AC_ARG_ENABLE(libwebrtc, AS_HELP_STRING([--disable-libwebrtc], [Exclude libwebrtc in the build]), @@ -2343,7 +2361,7 @@ AC_ARG_ENABLE(libwebrtc, ac_webrtc_instset=neon ;; *) - ac_webrtc_instset=sse2 + ac_webrtc_instset=$instrset ;; esac ;; @@ -2390,7 +2408,7 @@ AC_ARG_ENABLE(libwebrtc, ac_webrtc_cflags="-DWEBRTC_ARCH_ARM64" ;; *) - ac_webrtc_instset=sse2 + ac_webrtc_instset=$instrset ;; esac ;; diff --git a/third_party/build/os-auto.mak.in b/third_party/build/os-auto.mak.in index 7a1db7fb3..aa0bb668f 100644 --- a/third_party/build/os-auto.mak.in +++ b/third_party/build/os-auto.mak.in @@ -118,8 +118,7 @@ else ifneq ($(findstring mips,@ac_webrtc_instset@),) else # Generic fixed point WEBRTC_SRC = \ modules/audio_processing/aecm/aecm_core_c.o \ - modules/audio_processing/ns/nsx_core_c.o \ - common_audio/signal_processing/complex_fft.o + modules/audio_processing/ns/nsx_core_c.o endif endif endif diff --git a/third_party/webrtc/src/webrtc/modules/audio_processing/aec/aec_core.c b/third_party/webrtc/src/webrtc/modules/audio_processing/aec/aec_core.c index 9d54b62fc..71536f638 100644 --- a/third_party/webrtc/src/webrtc/modules/audio_processing/aec/aec_core.c +++ b/third_party/webrtc/src/webrtc/modules/audio_processing/aec/aec_core.c @@ -1478,7 +1478,7 @@ AecCore* WebRtcAec_CreateAec() { WebRtcAec_ComfortNoise = ComfortNoise; WebRtcAec_SubbandCoherence = SubbandCoherence; -#if defined(WEBRTC_ARCH_X86_FAMILY) +#if defined(WEBRTC_ARCH_X86_FAMILY) && defined(__SSE2__) if (WebRtc_GetCPUInfo(kSSE2)) { WebRtcAec_InitAec_SSE2(); } diff --git a/third_party/webrtc/src/webrtc/modules/audio_processing/aec/aec_rdft.c b/third_party/webrtc/src/webrtc/modules/audio_processing/aec/aec_rdft.c index 2c3cff2df..f02d99098 100644 --- a/third_party/webrtc/src/webrtc/modules/audio_processing/aec/aec_rdft.c +++ b/third_party/webrtc/src/webrtc/modules/audio_processing/aec/aec_rdft.c @@ -571,7 +571,7 @@ void aec_rdft_init(void) { cftfsub_128 = cftfsub_128_C; cftbsub_128 = cftbsub_128_C; bitrv2_128 = bitrv2_128_C; -#if defined(WEBRTC_ARCH_X86_FAMILY) +#if defined(WEBRTC_ARCH_X86_FAMILY) && defined(__SSE2__) if (WebRtc_GetCPUInfo(kSSE2)) { aec_rdft_init_sse2(); } -- 2.41.0