xref: /aosp_15_r20/external/webrtc/modules/audio_processing/aec3/BUILD.gn (revision d9f758449e529ab9291ac668be2861e7a55c2422)
1# Copyright (c) 2018 The WebRTC project authors. All Rights Reserved.
2#
3# Use of this source code is governed by a BSD-style license
4# that can be found in the LICENSE file in the root of the source
5# tree. An additional intellectual property rights grant can be found
6# in the file PATENTS.  All contributing project authors may
7# be found in the AUTHORS file in the root of the source tree.
8
9import("../../../webrtc.gni")
10
11rtc_library("aec3") {
12  visibility = [ "*" ]
13  configs += [ "..:apm_debug_dump" ]
14  sources = [
15    "adaptive_fir_filter.cc",
16    "adaptive_fir_filter_erl.cc",
17    "aec3_common.cc",
18    "aec3_fft.cc",
19    "aec_state.cc",
20    "aec_state.h",
21    "alignment_mixer.cc",
22    "alignment_mixer.h",
23    "api_call_jitter_metrics.cc",
24    "api_call_jitter_metrics.h",
25    "block.h",
26    "block_buffer.cc",
27    "block_delay_buffer.cc",
28    "block_delay_buffer.h",
29    "block_framer.cc",
30    "block_framer.h",
31    "block_processor.cc",
32    "block_processor.h",
33    "block_processor_metrics.cc",
34    "block_processor_metrics.h",
35    "clockdrift_detector.cc",
36    "clockdrift_detector.h",
37    "coarse_filter_update_gain.cc",
38    "coarse_filter_update_gain.h",
39    "comfort_noise_generator.cc",
40    "comfort_noise_generator.h",
41    "config_selector.cc",
42    "config_selector.h",
43    "decimator.cc",
44    "decimator.h",
45    "delay_estimate.h",
46    "dominant_nearend_detector.cc",
47    "dominant_nearend_detector.h",
48    "downsampled_render_buffer.cc",
49    "downsampled_render_buffer.h",
50    "echo_audibility.cc",
51    "echo_audibility.h",
52    "echo_canceller3.cc",
53    "echo_canceller3.h",
54    "echo_path_delay_estimator.cc",
55    "echo_path_delay_estimator.h",
56    "echo_path_variability.cc",
57    "echo_path_variability.h",
58    "echo_remover.cc",
59    "echo_remover.h",
60    "echo_remover_metrics.cc",
61    "echo_remover_metrics.h",
62    "erl_estimator.cc",
63    "erl_estimator.h",
64    "erle_estimator.cc",
65    "erle_estimator.h",
66    "fft_buffer.cc",
67    "filter_analyzer.cc",
68    "filter_analyzer.h",
69    "frame_blocker.cc",
70    "frame_blocker.h",
71    "fullband_erle_estimator.cc",
72    "fullband_erle_estimator.h",
73    "matched_filter.cc",
74    "matched_filter_lag_aggregator.cc",
75    "matched_filter_lag_aggregator.h",
76    "moving_average.cc",
77    "moving_average.h",
78    "multi_channel_content_detector.cc",
79    "multi_channel_content_detector.h",
80    "nearend_detector.h",
81    "refined_filter_update_gain.cc",
82    "refined_filter_update_gain.h",
83    "render_buffer.cc",
84    "render_delay_buffer.cc",
85    "render_delay_buffer.h",
86    "render_delay_controller.cc",
87    "render_delay_controller.h",
88    "render_delay_controller_metrics.cc",
89    "render_delay_controller_metrics.h",
90    "render_signal_analyzer.cc",
91    "render_signal_analyzer.h",
92    "residual_echo_estimator.cc",
93    "residual_echo_estimator.h",
94    "reverb_decay_estimator.cc",
95    "reverb_decay_estimator.h",
96    "reverb_frequency_response.cc",
97    "reverb_frequency_response.h",
98    "reverb_model.cc",
99    "reverb_model.h",
100    "reverb_model_estimator.cc",
101    "reverb_model_estimator.h",
102    "signal_dependent_erle_estimator.cc",
103    "signal_dependent_erle_estimator.h",
104    "spectrum_buffer.cc",
105    "stationarity_estimator.cc",
106    "stationarity_estimator.h",
107    "subband_erle_estimator.cc",
108    "subband_erle_estimator.h",
109    "subband_nearend_detector.cc",
110    "subband_nearend_detector.h",
111    "subtractor.cc",
112    "subtractor.h",
113    "subtractor_output.cc",
114    "subtractor_output.h",
115    "subtractor_output_analyzer.cc",
116    "subtractor_output_analyzer.h",
117    "suppression_filter.cc",
118    "suppression_filter.h",
119    "suppression_gain.cc",
120    "suppression_gain.h",
121    "transparent_mode.cc",
122    "transparent_mode.h",
123  ]
124
125  defines = []
126  if (rtc_build_with_neon && current_cpu != "arm64") {
127    suppressed_configs += [ "//build/config/compiler:compiler_arm_fpu" ]
128    cflags = [ "-mfpu=neon" ]
129  }
130
131  deps = [
132    ":adaptive_fir_filter",
133    ":adaptive_fir_filter_erl",
134    ":aec3_common",
135    ":aec3_fft",
136    ":fft_data",
137    ":matched_filter",
138    ":render_buffer",
139    ":vector_math",
140    "..:apm_logging",
141    "..:audio_buffer",
142    "..:high_pass_filter",
143    "../../../api:array_view",
144    "../../../api/audio:aec3_config",
145    "../../../api/audio:echo_control",
146    "../../../common_audio:common_audio_c",
147    "../../../rtc_base:checks",
148    "../../../rtc_base:logging",
149    "../../../rtc_base:macromagic",
150    "../../../rtc_base:race_checker",
151    "../../../rtc_base:safe_minmax",
152    "../../../rtc_base:swap_queue",
153    "../../../rtc_base/experiments:field_trial_parser",
154    "../../../rtc_base/system:arch",
155    "../../../system_wrappers",
156    "../../../system_wrappers:field_trial",
157    "../../../system_wrappers:metrics",
158    "../utility:cascaded_biquad_filter",
159  ]
160  absl_deps = [
161    "//third_party/abseil-cpp/absl/strings",
162    "//third_party/abseil-cpp/absl/types:optional",
163  ]
164
165  if (current_cpu == "x86" || current_cpu == "x64") {
166    deps += [ ":aec3_avx2" ]
167  }
168}
169
170rtc_source_set("aec3_common") {
171  sources = [ "aec3_common.h" ]
172}
173
174rtc_source_set("aec3_fft") {
175  sources = [ "aec3_fft.h" ]
176  deps = [
177    ":aec3_common",
178    ":fft_data",
179    "../../../api:array_view",
180    "../../../common_audio/third_party/ooura:fft_size_128",
181    "../../../rtc_base:checks",
182    "../../../rtc_base/system:arch",
183  ]
184}
185
186rtc_source_set("render_buffer") {
187  sources = [
188    "block.h",
189    "block_buffer.h",
190    "fft_buffer.h",
191    "render_buffer.h",
192    "spectrum_buffer.h",
193  ]
194  deps = [
195    ":aec3_common",
196    ":fft_data",
197    "../../../api:array_view",
198    "../../../rtc_base:checks",
199    "../../../rtc_base/system:arch",
200  ]
201}
202
203rtc_source_set("adaptive_fir_filter") {
204  sources = [ "adaptive_fir_filter.h" ]
205  deps = [
206    ":aec3_common",
207    ":aec3_fft",
208    ":fft_data",
209    ":render_buffer",
210    "..:apm_logging",
211    "../../../api:array_view",
212    "../../../rtc_base/system:arch",
213  ]
214  absl_deps = [ "//third_party/abseil-cpp/absl/strings" ]
215}
216
217rtc_source_set("adaptive_fir_filter_erl") {
218  sources = [ "adaptive_fir_filter_erl.h" ]
219  deps = [
220    ":aec3_common",
221    "../../../api:array_view",
222    "../../../rtc_base/system:arch",
223  ]
224}
225
226rtc_source_set("matched_filter") {
227  sources = [ "matched_filter.h" ]
228  deps = [
229    ":aec3_common",
230    "../../../api:array_view",
231    "../../../rtc_base:gtest_prod",
232    "../../../rtc_base/system:arch",
233  ]
234  absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ]
235}
236
237rtc_source_set("vector_math") {
238  sources = [ "vector_math.h" ]
239  deps = [
240    ":aec3_common",
241    "../../../api:array_view",
242    "../../../rtc_base:checks",
243    "../../../rtc_base/system:arch",
244  ]
245}
246
247rtc_source_set("fft_data") {
248  sources = [ "fft_data.h" ]
249  deps = [
250    ":aec3_common",
251    "../../../api:array_view",
252    "../../../rtc_base/system:arch",
253  ]
254}
255
256if (current_cpu == "x86" || current_cpu == "x64") {
257  rtc_library("aec3_avx2") {
258    configs += [ "..:apm_debug_dump" ]
259    sources = [
260      "adaptive_fir_filter_avx2.cc",
261      "adaptive_fir_filter_erl_avx2.cc",
262      "fft_data_avx2.cc",
263      "matched_filter_avx2.cc",
264      "vector_math_avx2.cc",
265    ]
266
267    if (is_win) {
268      cflags = [ "/arch:AVX2" ]
269    } else {
270      cflags = [
271        "-mavx2",
272        "-mfma",
273      ]
274    }
275
276    deps = [
277      ":adaptive_fir_filter",
278      ":adaptive_fir_filter_erl",
279      ":fft_data",
280      ":matched_filter",
281      ":vector_math",
282      "../../../api:array_view",
283      "../../../rtc_base:checks",
284    ]
285  }
286}
287
288if (rtc_include_tests) {
289  rtc_library("aec3_unittests") {
290    testonly = true
291
292    configs += [ "..:apm_debug_dump" ]
293    sources = [
294      "mock/mock_block_processor.cc",
295      "mock/mock_block_processor.h",
296      "mock/mock_echo_remover.cc",
297      "mock/mock_echo_remover.h",
298      "mock/mock_render_delay_buffer.cc",
299      "mock/mock_render_delay_buffer.h",
300      "mock/mock_render_delay_controller.cc",
301      "mock/mock_render_delay_controller.h",
302    ]
303
304    deps = [
305      ":adaptive_fir_filter",
306      ":adaptive_fir_filter_erl",
307      ":aec3",
308      ":aec3_common",
309      ":aec3_fft",
310      ":fft_data",
311      ":matched_filter",
312      ":render_buffer",
313      ":vector_math",
314      "..:apm_logging",
315      "..:audio_buffer",
316      "..:audio_processing",
317      "..:high_pass_filter",
318      "../../../api:array_view",
319      "../../../api/audio:aec3_config",
320      "../../../rtc_base:checks",
321      "../../../rtc_base:macromagic",
322      "../../../rtc_base:random",
323      "../../../rtc_base:safe_minmax",
324      "../../../rtc_base:stringutils",
325      "../../../rtc_base/system:arch",
326      "../../../system_wrappers",
327      "../../../system_wrappers:metrics",
328      "../../../test:field_trial",
329      "../../../test:test_support",
330      "../utility:cascaded_biquad_filter",
331    ]
332    absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ]
333
334    defines = []
335
336    if (rtc_enable_protobuf) {
337      sources += [
338        "adaptive_fir_filter_erl_unittest.cc",
339        "adaptive_fir_filter_unittest.cc",
340        "aec3_fft_unittest.cc",
341        "aec_state_unittest.cc",
342        "alignment_mixer_unittest.cc",
343        "api_call_jitter_metrics_unittest.cc",
344        "block_delay_buffer_unittest.cc",
345        "block_framer_unittest.cc",
346        "block_processor_metrics_unittest.cc",
347        "block_processor_unittest.cc",
348        "clockdrift_detector_unittest.cc",
349        "coarse_filter_update_gain_unittest.cc",
350        "comfort_noise_generator_unittest.cc",
351        "config_selector_unittest.cc",
352        "decimator_unittest.cc",
353        "echo_canceller3_unittest.cc",
354        "echo_path_delay_estimator_unittest.cc",
355        "echo_path_variability_unittest.cc",
356        "echo_remover_metrics_unittest.cc",
357        "echo_remover_unittest.cc",
358        "erl_estimator_unittest.cc",
359        "erle_estimator_unittest.cc",
360        "fft_data_unittest.cc",
361        "filter_analyzer_unittest.cc",
362        "frame_blocker_unittest.cc",
363        "matched_filter_lag_aggregator_unittest.cc",
364        "matched_filter_unittest.cc",
365        "moving_average_unittest.cc",
366        "multi_channel_content_detector_unittest.cc",
367        "refined_filter_update_gain_unittest.cc",
368        "render_buffer_unittest.cc",
369        "render_delay_buffer_unittest.cc",
370        "render_delay_controller_metrics_unittest.cc",
371        "render_delay_controller_unittest.cc",
372        "render_signal_analyzer_unittest.cc",
373        "residual_echo_estimator_unittest.cc",
374        "reverb_model_estimator_unittest.cc",
375        "signal_dependent_erle_estimator_unittest.cc",
376        "subtractor_unittest.cc",
377        "suppression_filter_unittest.cc",
378        "suppression_gain_unittest.cc",
379        "vector_math_unittest.cc",
380      ]
381    }
382
383    if (!build_with_chromium) {
384      deps += [ "..:audio_processing_unittests" ]
385    }
386  }
387}
388