From b2e176522e920458f85c769ca42a8cce4a31ddac Mon Sep 17 00:00:00 2001 From: Sam Zackrisson Date: Thu, 5 Jul 2018 16:41:55 +0200 Subject: [PATCH] Create separate build targets for utility/ in APM This clarifies the dependencies of utility/ a lot (spoiler: there are very few) and makes it easier to separate the build targets for aecm and aec2. Bug: webrtc:9488 Change-Id: If916f86e80c19d1b650d0908fbe8343ea7c47bd7 Reviewed-on: https://webrtc-review.googlesource.com/87141 Reviewed-by: Alex Loiko Commit-Queue: Sam Zackrisson Cr-Commit-Position: refs/heads/master@{#23860} --- modules/audio_processing/BUILD.gn | 30 ++--- modules/audio_processing/aec3/BUILD.gn | 2 +- modules/audio_processing/agc2/BUILD.gn | 3 +- modules/audio_processing/utility/BUILD.gn | 119 ++++++++++++++++++ .../utility/delay_estimator_unittest.cc | 4 +- 5 files changed, 130 insertions(+), 28 deletions(-) create mode 100644 modules/audio_processing/utility/BUILD.gn diff --git a/modules/audio_processing/BUILD.gn b/modules/audio_processing/BUILD.gn index 5c90a0cfe0..f717411ee8 100644 --- a/modules/audio_processing/BUILD.gn +++ b/modules/audio_processing/BUILD.gn @@ -335,16 +335,6 @@ rtc_source_set("aec_core") { "aecm/aecm_defines.h", "aecm/echo_control_mobile.cc", "aecm/echo_control_mobile.h", - "utility/block_mean_calculator.cc", - "utility/block_mean_calculator.h", - "utility/delay_estimator.cc", - "utility/delay_estimator.h", - "utility/delay_estimator_internal.h", - "utility/delay_estimator_wrapper.cc", - "utility/delay_estimator_wrapper.h", - "utility/ooura_fft.cc", - "utility/ooura_fft.h", - "utility/ooura_fft_tables_common.h", ] deps = [ ":apm_logging", @@ -358,16 +348,15 @@ rtc_source_set("aec_core") { "../../rtc_base:sanitizer", "../../system_wrappers:cpu_features_api", "../../system_wrappers:metrics_api", + "utility:block_mean_calculator", + "utility:legacy_delay_estimator", + "utility:ooura_fft", ] cflags = [] defines = [] if (current_cpu == "x86" || current_cpu == "x64") { - sources += [ - "aec/aec_core_sse2.cc", - "utility/ooura_fft_sse2.cc", - "utility/ooura_fft_tables_neon_sse2.h", - ] + sources += [ "aec/aec_core_sse2.cc" ] if (is_posix || is_fuchsia) { cflags += [ "-msse2" ] } @@ -377,8 +366,6 @@ rtc_source_set("aec_core") { sources += [ "aec/aec_core_neon.cc", "aecm/aecm_core_neon.cc", - "utility/ooura_fft_neon.cc", - "utility/ooura_fft_tables_neon_sse2.h", ] if (current_cpu != "arm64") { @@ -404,10 +391,7 @@ rtc_source_set("aec_core") { if (current_cpu == "mipsel") { sources += [ "aecm/aecm_core_mips.cc" ] if (mips_float_abi == "hard") { - sources += [ - "aec/aec_core_mips.cc", - "utility/ooura_fft_mips.cc", - ] + sources += [ "aec/aec_core_mips.cc" ] } } else { sources += [ "aecm/aecm_core_c.cc" ] @@ -482,8 +466,6 @@ if (rtc_include_tests) { "transient/transient_suppressor_unittest.cc", "transient/wpd_node_unittest.cc", "transient/wpd_tree_unittest.cc", - "utility/block_mean_calculator_unittest.cc", - "utility/delay_estimator_unittest.cc", ] deps = [ @@ -521,6 +503,8 @@ if (rtc_include_tests) { "agc2:noise_estimator_unittests", "agc2/rnn_vad:unittests", "test/conversational_speech:unittest", + "utility:block_mean_calculator_unittest", + "utility:legacy_delay_estimator_unittest", "vad:vad_unittests", "//testing/gtest", "//third_party/abseil-cpp/absl/memory", diff --git a/modules/audio_processing/aec3/BUILD.gn b/modules/audio_processing/aec3/BUILD.gn index 292242f868..75d890d4f1 100644 --- a/modules/audio_processing/aec3/BUILD.gn +++ b/modules/audio_processing/aec3/BUILD.gn @@ -111,7 +111,6 @@ rtc_static_library("aec3") { defines = [] deps = [ - "..:aec_core", "..:apm_logging", "..:audio_processing", "../../..:typedefs", @@ -125,6 +124,7 @@ rtc_static_library("aec3") { "../../../system_wrappers:cpu_features_api", "../../../system_wrappers:field_trial_api", "../../../system_wrappers:metrics_api", + "../utility:ooura_fft", "//third_party/abseil-cpp/absl/types:optional", ] } diff --git a/modules/audio_processing/agc2/BUILD.gn b/modules/audio_processing/agc2/BUILD.gn index 1eb8e6150f..bc8a1df649 100644 --- a/modules/audio_processing/agc2/BUILD.gn +++ b/modules/audio_processing/agc2/BUILD.gn @@ -34,7 +34,6 @@ rtc_source_set("adaptive_digital") { ":gain_applier", ":noise_level_estimator", ":rnn_vad_with_level", - "..:aec_core", "..:apm_logging", "..:audio_frame_view", "../../../api:array_view", @@ -119,13 +118,13 @@ rtc_source_set("noise_level_estimator") { ] deps = [ ":biquad_filter", - "..:aec_core", "..:apm_logging", "..:audio_frame_view", "../../../api:array_view", "../../../common_audio", "../../../rtc_base:checks", "../../../rtc_base:macromagic", + "../utility:ooura_fft", ] configs += [ "..:apm_debug_dump" ] diff --git a/modules/audio_processing/utility/BUILD.gn b/modules/audio_processing/utility/BUILD.gn new file mode 100644 index 0000000000..309527d530 --- /dev/null +++ b/modules/audio_processing/utility/BUILD.gn @@ -0,0 +1,119 @@ +# Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. +# +# Use of this source code is governed by a BSD-style license +# that can be found in the LICENSE file in the root of the source +# tree. An additional intellectual property rights grant can be found +# in the file PATENTS. All contributing project authors may +# be found in the AUTHORS file in the root of the source tree. + +import("//build/config/arm.gni") +import("../../../webrtc.gni") + +rtc_source_set("block_mean_calculator") { + sources = [ + "block_mean_calculator.cc", + "block_mean_calculator.h", + ] + deps = [ + "../../../rtc_base:checks", + "../../../rtc_base:rtc_base_approved", + ] +} + +rtc_source_set("legacy_delay_estimator") { + sources = [ + "delay_estimator.cc", + "delay_estimator.h", + "delay_estimator_internal.h", + "delay_estimator_wrapper.cc", + "delay_estimator_wrapper.h", + ] + deps = [ + "../../..:typedefs", + "../../../rtc_base:checks", + ] +} + +rtc_source_set("ooura_fft") { + sources = [ + "ooura_fft.cc", + "ooura_fft.h", + "ooura_fft_tables_common.h", + ] + deps = [ + "../../..:typedefs", + "../../../system_wrappers:cpu_features_api", + ] + cflags = [] + + if (current_cpu == "x86" || current_cpu == "x64") { + sources += [ + "ooura_fft_sse2.cc", + "ooura_fft_tables_neon_sse2.h", + ] + if (is_posix || is_fuchsia) { + cflags += [ "-msse2" ] + } + } + + if (rtc_build_with_neon) { + sources += [ + "ooura_fft_neon.cc", + "ooura_fft_tables_neon_sse2.h", + ] + + deps += [ "../../../common_audio" ] + + if (current_cpu != "arm64") { + # Enable compilation for the NEON instruction set. This is needed + # since //build/config/arm.gni only enables NEON for iOS, not Android. + # This provides the same functionality as webrtc/build/arm_neon.gypi. + suppressed_configs += [ "//build/config/compiler:compiler_arm_fpu" ] + cflags += [ "-mfpu=neon" ] + } + + # Disable LTO on NEON targets due to compiler bug. + # TODO(fdegans): Enable this. See crbug.com/408997. + if (rtc_use_lto) { + cflags -= [ + "-flto", + "-ffat-lto-objects", + ] + } + } + + if (current_cpu == "mipsel" && mips_float_abi == "hard") { + sources += [ "ooura_fft_mips.cc" ] + } +} + +if (rtc_include_tests) { + rtc_source_set("block_mean_calculator_unittest") { + testonly = true + + sources = [ + "block_mean_calculator_unittest.cc", + ] + deps = [ + ":block_mean_calculator", + "../../../rtc_base:rtc_base_approved", + "../../../test:test_support", + "//testing/gtest", + ] + } + + rtc_source_set("legacy_delay_estimator_unittest") { + testonly = true + + sources = [ + "delay_estimator_unittest.cc", + ] + deps = [ + ":legacy_delay_estimator", + "../../..:typedefs", + "../../../rtc_base:rtc_base_approved", + "../../../test:test_support", + "//testing/gtest", + ] + } +} diff --git a/modules/audio_processing/utility/delay_estimator_unittest.cc b/modules/audio_processing/utility/delay_estimator_unittest.cc index 3e4e050504..8d65cb98bf 100644 --- a/modules/audio_processing/utility/delay_estimator_unittest.cc +++ b/modules/audio_processing/utility/delay_estimator_unittest.cc @@ -33,8 +33,8 @@ const size_t kSizeEnable = sizeof(kEnable) / sizeof(*kEnable); class DelayEstimatorTest : public ::testing::Test { protected: DelayEstimatorTest(); - virtual void SetUp(); - virtual void TearDown(); + void SetUp() override; + void TearDown() override; void Init(); void InitBinary();