peah 219208991b Adding full initial version of delay estimation functionality in echo
canceller 3

This CL adds code to the all the delay estimation functionality that is
available for the first version of echo canceller 3. The code completes
the class EchoPathDelayEstimator.

Note that this code does not yet include any handling of clock-drift so
there will be upcoming versions of this code.

Also note that the CL includes some minor changes in other files for
echo canceller 3.

BUG=webrtc:6018

Review-Url: https://codereview.webrtc.org/2644123002
Cr-Commit-Position: refs/heads/master@{#16489}
2017-02-08 13:08:56 +00:00

763 lines
22 KiB
Plaintext

# 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("//third_party/protobuf/proto_library.gni")
import("../../webrtc.gni")
declare_args() {
# Disables the usual mode where we trust the reported system delay
# values the AEC receives. The corresponding define is set appropriately
# in the code, but it can be force-enabled here for testing.
aec_untrusted_delay_for_testing = false
}
rtc_static_library("audio_processing") {
sources = [
"aec/aec_core.cc",
"aec/aec_core.h",
"aec/aec_core_optimized_methods.h",
"aec/aec_resampler.cc",
"aec/aec_resampler.h",
"aec/echo_cancellation.cc",
"aec/echo_cancellation.h",
"aec3/aec3_constants.h",
"aec3/block_framer.cc",
"aec3/block_framer.h",
"aec3/block_processor.cc",
"aec3/block_processor.h",
"aec3/cascaded_biquad_filter.cc",
"aec3/cascaded_biquad_filter.h",
"aec3/decimator_by_4.cc",
"aec3/decimator_by_4.h",
"aec3/echo_canceller3.cc",
"aec3/echo_canceller3.h",
"aec3/echo_path_delay_estimator.cc",
"aec3/echo_path_delay_estimator.h",
"aec3/echo_path_variability.h",
"aec3/echo_remover.cc",
"aec3/echo_remover.h",
"aec3/frame_blocker.cc",
"aec3/frame_blocker.h",
"aec3/matched_filter.cc",
"aec3/matched_filter.h",
"aec3/matched_filter_lag_aggregator.cc",
"aec3/matched_filter_lag_aggregator.h",
"aec3/render_delay_buffer.cc",
"aec3/render_delay_buffer.h",
"aec3/render_delay_controller.cc",
"aec3/render_delay_controller.h",
"aecm/aecm_core.cc",
"aecm/aecm_core.h",
"aecm/echo_control_mobile.cc",
"aecm/echo_control_mobile.h",
"agc/agc.cc",
"agc/agc.h",
"agc/agc_manager_direct.cc",
"agc/agc_manager_direct.h",
"agc/gain_map_internal.h",
"agc/loudness_histogram.cc",
"agc/loudness_histogram.h",
"agc/utility.cc",
"agc/utility.h",
"audio_buffer.cc",
"audio_buffer.h",
"audio_processing_impl.cc",
"audio_processing_impl.h",
"beamformer/array_util.cc",
"beamformer/array_util.h",
"beamformer/complex_matrix.h",
"beamformer/covariance_matrix_generator.cc",
"beamformer/covariance_matrix_generator.h",
"beamformer/matrix.h",
"beamformer/nonlinear_beamformer.cc",
"beamformer/nonlinear_beamformer.h",
"common.h",
"echo_cancellation_impl.cc",
"echo_cancellation_impl.h",
"echo_control_mobile_impl.cc",
"echo_control_mobile_impl.h",
"echo_detector/circular_buffer.cc",
"echo_detector/circular_buffer.h",
"echo_detector/mean_variance_estimator.cc",
"echo_detector/mean_variance_estimator.h",
"echo_detector/moving_max.cc",
"echo_detector/moving_max.h",
"echo_detector/normalized_covariance_estimator.cc",
"echo_detector/normalized_covariance_estimator.h",
"gain_control_for_experimental_agc.cc",
"gain_control_for_experimental_agc.h",
"gain_control_impl.cc",
"gain_control_impl.h",
"include/audio_processing.cc",
"include/audio_processing.h",
"include/config.cc",
"include/config.h",
"level_controller/biquad_filter.cc",
"level_controller/biquad_filter.h",
"level_controller/down_sampler.cc",
"level_controller/down_sampler.h",
"level_controller/gain_applier.cc",
"level_controller/gain_applier.h",
"level_controller/gain_selector.cc",
"level_controller/gain_selector.h",
"level_controller/level_controller.cc",
"level_controller/level_controller.h",
"level_controller/level_controller_constants.h",
"level_controller/noise_level_estimator.cc",
"level_controller/noise_level_estimator.h",
"level_controller/noise_spectrum_estimator.cc",
"level_controller/noise_spectrum_estimator.h",
"level_controller/peak_level_estimator.cc",
"level_controller/peak_level_estimator.h",
"level_controller/saturating_gain_estimator.cc",
"level_controller/saturating_gain_estimator.h",
"level_controller/signal_classifier.cc",
"level_controller/signal_classifier.h",
"level_estimator_impl.cc",
"level_estimator_impl.h",
"logging/apm_data_dumper.cc",
"logging/apm_data_dumper.h",
"low_cut_filter.cc",
"low_cut_filter.h",
"noise_suppression_impl.cc",
"noise_suppression_impl.h",
"render_queue_item_verifier.h",
"residual_echo_detector.cc",
"residual_echo_detector.h",
"rms_level.cc",
"rms_level.h",
"splitting_filter.cc",
"splitting_filter.h",
"three_band_filter_bank.cc",
"three_band_filter_bank.h",
"transient/common.h",
"transient/daubechies_8_wavelet_coeffs.h",
"transient/dyadic_decimator.h",
"transient/moving_moments.cc",
"transient/moving_moments.h",
"transient/transient_detector.cc",
"transient/transient_detector.h",
"transient/transient_suppressor.cc",
"transient/transient_suppressor.h",
"transient/wpd_node.cc",
"transient/wpd_node.h",
"transient/wpd_tree.cc",
"transient/wpd_tree.h",
"typing_detection.cc",
"typing_detection.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",
"vad/common.h",
"vad/gmm.cc",
"vad/gmm.h",
"vad/noise_gmm_tables.h",
"vad/pitch_based_vad.cc",
"vad/pitch_based_vad.h",
"vad/pitch_internal.cc",
"vad/pitch_internal.h",
"vad/pole_zero_filter.cc",
"vad/pole_zero_filter.h",
"vad/standalone_vad.cc",
"vad/standalone_vad.h",
"vad/vad_audio_proc.cc",
"vad/vad_audio_proc.h",
"vad/vad_audio_proc_internal.h",
"vad/vad_circular_buffer.cc",
"vad/vad_circular_buffer.h",
"vad/voice_activity_detector.cc",
"vad/voice_activity_detector.h",
"vad/voice_gmm_tables.h",
"voice_detection_impl.cc",
"voice_detection_impl.h",
]
defines = []
deps = [
"../..:webrtc_common",
"../../audio/utility:audio_frame_operations",
"../../base:gtest_prod",
"../audio_coding:isac",
]
public_deps = [
":audio_processing_c",
]
if (apm_debug_dump) {
defines += [ "WEBRTC_APM_DEBUG_DUMP=1" ]
} else {
defines += [ "WEBRTC_APM_DEBUG_DUMP=0" ]
}
if (aec_untrusted_delay_for_testing) {
defines += [ "WEBRTC_UNTRUSTED_DELAY" ]
}
if (rtc_enable_protobuf) {
defines += [ "WEBRTC_AUDIOPROC_DEBUG_DUMP" ]
deps += [ ":audioproc_debug_proto" ]
}
if (rtc_enable_intelligibility_enhancer) {
defines += [ "WEBRTC_INTELLIGIBILITY_ENHANCER=1" ]
sources += [
"intelligibility/intelligibility_enhancer.cc",
"intelligibility/intelligibility_enhancer.h",
"intelligibility/intelligibility_utils.cc",
"intelligibility/intelligibility_utils.h",
]
} else {
defines += [ "WEBRTC_INTELLIGIBILITY_ENHANCER=0" ]
}
if (rtc_prefer_fixed_point) {
defines += [ "WEBRTC_NS_FIXED" ]
} else {
defines += [ "WEBRTC_NS_FLOAT" ]
}
if (current_cpu == "x86" || current_cpu == "x64") {
deps += [ ":audio_processing_sse2" ]
}
if (rtc_build_with_neon) {
deps += [ ":audio_processing_neon" ]
}
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",
]
}
} else {
sources += [ "aecm/aecm_core_c.cc" ]
}
# TODO(jschuh): Bug 1348: fix this warning.
configs += [ "//build/config/compiler:no_size_t_to_int_warning" ]
deps += [
"../../base:rtc_base_approved",
"../../common_audio",
"../../system_wrappers",
]
}
rtc_source_set("audio_processing_c") {
visibility = [ ":*" ] # Only targets in this file can depend on this.
sources = [
"agc/legacy/analog_agc.c",
"agc/legacy/analog_agc.h",
"agc/legacy/digital_agc.c",
"agc/legacy/digital_agc.h",
"agc/legacy/gain_control.h",
]
if (rtc_prefer_fixed_point) {
sources += [
"ns/noise_suppression_x.c",
"ns/noise_suppression_x.h",
"ns/nsx_core.c",
"ns/nsx_core.h",
"ns/nsx_defines.h",
]
if (current_cpu == "mipsel") {
sources += [ "ns/nsx_core_mips.c" ]
} else {
sources += [ "ns/nsx_core_c.c" ]
}
} else {
sources += [
"ns/defines.h",
"ns/noise_suppression.c",
"ns/noise_suppression.h",
"ns/ns_core.c",
"ns/ns_core.h",
"ns/windows_private.h",
]
}
deps = [
"../..:webrtc_common",
"../../base:rtc_base_approved",
"../../common_audio",
"../../system_wrappers",
]
if (rtc_build_with_neon) {
deps += [ ":audio_processing_neon_c" ]
}
}
if (rtc_enable_protobuf) {
proto_library("audioproc_debug_proto") {
sources = [
"debug.proto",
]
proto_out_dir = "webrtc/modules/audio_processing"
}
}
if (current_cpu == "x86" || current_cpu == "x64") {
rtc_static_library("audio_processing_sse2") {
# TODO(ehmaldonado): Remove (bugs.webrtc.org/6828)
# Errors on cyclic dependency with :audio_processing if enabled.
check_includes = false
sources = [
"aec/aec_core_sse2.cc",
"utility/ooura_fft_sse2.cc",
"utility/ooura_fft_tables_neon_sse2.h",
]
if (is_posix) {
cflags = [ "-msse2" ]
}
if (apm_debug_dump) {
defines = [ "WEBRTC_APM_DEBUG_DUMP=1" ]
} else {
defines = [ "WEBRTC_APM_DEBUG_DUMP=0" ]
}
}
}
if (rtc_build_with_neon) {
rtc_static_library("audio_processing_neon") {
# TODO(ehmaldonado): Remove (bugs.webrtc.org/6828)
# Errors on cyclic dependency with :audio_processing if enabled.
check_includes = false
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") {
# 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",
]
}
deps = [
"../../common_audio",
]
public_deps = [
":audio_processing_neon_c",
]
if (apm_debug_dump) {
defines = [ "WEBRTC_APM_DEBUG_DUMP=1" ]
} else {
defines = [ "WEBRTC_APM_DEBUG_DUMP=0" ]
}
}
rtc_static_library("audio_processing_neon_c") {
# TODO(mbonadei): Remove (bugs.webrtc.org/6828)
# Errors on cyclic dependency with :audio_processing_c if enabled.
check_includes = false
sources = [
"ns/nsx_core_neon.c",
]
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",
]
}
deps = [
"../../base:rtc_base_approved",
]
}
}
if (rtc_include_tests) {
group("audio_processing_tests") {
testonly = true
public_deps = [
":audioproc_test_utils",
":click_annotate",
":nonlinear_beamformer_test",
":transient_suppression_test",
]
if (rtc_enable_intelligibility_enhancer) {
public_deps += [ ":intelligibility_proc" ]
}
if (rtc_enable_protobuf) {
public_deps += [
":audioproc_f",
":audioproc_unittest_proto",
":unpack_aecdump",
]
}
}
rtc_source_set("audio_processing_unittests") {
testonly = true
sources = [
"aec/echo_cancellation_unittest.cc",
"aec/system_delay_unittest.cc",
"agc/agc_manager_direct_unittest.cc",
"agc/loudness_histogram_unittest.cc",
"agc/mock_agc.h",
"audio_buffer_unittest.cc",
"beamformer/array_util_unittest.cc",
"beamformer/complex_matrix_unittest.cc",
"beamformer/covariance_matrix_generator_unittest.cc",
"beamformer/matrix_unittest.cc",
"beamformer/mock_nonlinear_beamformer.h",
"config_unittest.cc",
"echo_cancellation_impl_unittest.cc",
"splitting_filter_unittest.cc",
"transient/dyadic_decimator_unittest.cc",
"transient/file_utils.cc",
"transient/file_utils.h",
"transient/file_utils_unittest.cc",
"transient/moving_moments_unittest.cc",
"transient/transient_detector_unittest.cc",
"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",
"vad/gmm_unittest.cc",
"vad/pitch_based_vad_unittest.cc",
"vad/pitch_internal_unittest.cc",
"vad/pole_zero_filter_unittest.cc",
"vad/standalone_vad_unittest.cc",
"vad/vad_audio_proc_unittest.cc",
"vad/vad_circular_buffer_unittest.cc",
"vad/voice_activity_detector_unittest.cc",
]
deps = [
":audio_processing",
":audioproc_test_utils",
"../..:webrtc_common",
"../../base:gtest_prod",
"../../base:rtc_base",
"../../base:rtc_base_approved",
"../../common_audio:common_audio",
"../../system_wrappers:system_wrappers",
"../../test:test_support",
"../audio_coding:neteq_unittest_tools",
"//testing/gmock",
"//testing/gtest",
]
defines = []
if (apm_debug_dump) {
defines += [ "WEBRTC_APM_DEBUG_DUMP=1" ]
} else {
defines += [ "WEBRTC_APM_DEBUG_DUMP=0" ]
}
if (rtc_enable_intelligibility_enhancer) {
defines += [ "WEBRTC_INTELLIGIBILITY_ENHANCER=1" ]
sources += [
"intelligibility/intelligibility_enhancer_unittest.cc",
"intelligibility/intelligibility_utils_unittest.cc",
]
} else {
defines += [ "WEBRTC_INTELLIGIBILITY_ENHANCER=0" ]
}
if (rtc_prefer_fixed_point) {
defines += [ "WEBRTC_AUDIOPROC_FIXED_PROFILE" ]
} else {
defines += [ "WEBRTC_AUDIOPROC_FLOAT_PROFILE" ]
}
if (rtc_enable_protobuf) {
defines += [ "WEBRTC_AUDIOPROC_DEBUG_DUMP" ]
deps += [
":audioproc_debug_proto",
":audioproc_protobuf_utils",
":audioproc_unittest_proto",
]
sources += [
"aec3/block_framer_unittest.cc",
"aec3/block_processor_unittest.cc",
"aec3/cascaded_biquad_filter_unittest.cc",
"aec3/decimator_by_4_unittest.cc",
"aec3/echo_canceller3_unittest.cc",
"aec3/echo_path_delay_estimator_unittest.cc",
"aec3/echo_remover_unittest.cc",
"aec3/frame_blocker_unittest.cc",
"aec3/matched_filter_lag_aggregator_unittest.cc",
"aec3/matched_filter_unittest.cc",
"aec3/mock/mock_block_processor.h",
"aec3/mock/mock_echo_remover.h",
"aec3/mock/mock_render_delay_buffer.h",
"aec3/mock/mock_render_delay_controller.h",
"aec3/render_delay_buffer_unittest.cc",
"aec3/render_delay_controller_unittest.cc",
"audio_processing_impl_locking_unittest.cc",
"audio_processing_impl_unittest.cc",
"audio_processing_unittest.cc",
"beamformer/nonlinear_beamformer_unittest.cc",
"echo_cancellation_bit_exact_unittest.cc",
"echo_control_mobile_unittest.cc",
"echo_detector/circular_buffer_unittest.cc",
"echo_detector/mean_variance_estimator_unittest.cc",
"echo_detector/moving_max_unittest.cc",
"echo_detector/normalized_covariance_estimator_unittest.cc",
"gain_control_unittest.cc",
"level_controller/level_controller_unittest.cc",
"level_estimator_unittest.cc",
"low_cut_filter_unittest.cc",
"noise_suppression_unittest.cc",
"residual_echo_detector_unittest.cc",
"rms_level_unittest.cc",
"test/bitexactness_tools.cc",
"test/bitexactness_tools.h",
"test/debug_dump_replayer.cc",
"test/debug_dump_replayer.h",
"test/debug_dump_test.cc",
"test/echo_canceller_test_tools.cc",
"test/echo_canceller_test_tools.h",
"test/echo_canceller_test_tools_unittest.cc",
"test/test_utils.h",
"voice_detection_unittest.cc",
]
}
if ((!build_with_chromium || is_win) && is_clang) {
# Suppress warnings from the Chromium Clang plugin (bugs.webrtc.org/163).
suppressed_configs += [ "//build/config/clang:find_bad_constructs" ]
}
}
rtc_source_set("audio_processing_perf_tests") {
# Has problems with autogenerated targets on Android and iOS
# Dependency chain (there may also be others):
# //webrtc/modules/audio_processing:audio_processing_perf_tests -->
# //webrtc/modules:modules_unittests --[private]-->
# //webrtc/modules:modules_unittests_apk -->
# //webrtc/modules:modules_unittests_apk__create -->
# //webrtc/modules:modules_unittests_apk__create__finalize -->
# //webrtc/modules:modules_unittests_apk__create__package --[private]-->
# //webrtc/modules:_modules_unittests__library
check_includes = false
testonly = true
sources = [
"audio_processing_performance_unittest.cc",
"level_controller/level_controller_complexity_unittest.cc",
"residual_echo_detector_complexity_unittest.cc",
]
deps = [
":audio_processing",
":audioproc_test_utils",
"//testing/gtest",
]
if (rtc_enable_intelligibility_enhancer) {
defines = [ "WEBRTC_INTELLIGIBILITY_ENHANCER=1" ]
} else {
defines = [ "WEBRTC_INTELLIGIBILITY_ENHANCER=0" ]
}
}
if (rtc_enable_protobuf) {
rtc_executable("unpack_aecdump") {
testonly = true
sources = [
"test/unpack.cc",
]
deps = [
":audio_processing",
":audioproc_debug_proto",
":audioproc_protobuf_utils",
":audioproc_test_utils",
"../..:webrtc_common",
"../../base:rtc_base_approved",
"../../common_audio",
"../../system_wrappers:system_wrappers_default",
"//third_party/gflags:gflags",
]
} # unpack_aecdump
rtc_executable("audioproc_f") {
testonly = true
sources = [
"test/aec_dump_based_simulator.cc",
"test/aec_dump_based_simulator.h",
"test/audio_processing_simulator.cc",
"test/audio_processing_simulator.h",
"test/audioproc_float.cc",
"test/wav_based_simulator.cc",
"test/wav_based_simulator.h",
]
deps = [
":audio_processing",
":audioproc_debug_proto",
":audioproc_protobuf_utils",
":audioproc_test_utils",
"../../base:rtc_base_approved",
"../../common_audio:common_audio",
"../../system_wrappers",
"../../system_wrappers:system_wrappers_default",
"../../test:test_support",
"//testing/gtest",
"//third_party/gflags:gflags",
]
} # audioproc_f
}
rtc_source_set("audioproc_test_utils") {
testonly = true
sources = [
"test/audio_buffer_tools.cc",
"test/audio_buffer_tools.h",
"test/performance_timer.cc",
"test/performance_timer.h",
"test/simulator_buffers.cc",
"test/simulator_buffers.h",
"test/test_utils.cc",
"test/test_utils.h",
]
deps = [
":audio_processing",
"../../base:rtc_base_approved",
"../../common_audio",
"../../system_wrappers:system_wrappers",
]
}
rtc_executable("transient_suppression_test") {
testonly = true
sources = [
"transient/file_utils.cc",
"transient/file_utils.h",
"transient/transient_suppression_test.cc",
]
deps = [
":audio_processing",
"../..:webrtc_common",
"../../common_audio:common_audio",
"../../system_wrappers:metrics_default",
"../../system_wrappers:system_wrappers",
"../../test:test_support",
"//testing/gtest",
"//third_party/gflags",
]
}
rtc_executable("click_annotate") {
testonly = true
sources = [
"transient/click_annotate.cc",
"transient/file_utils.cc",
"transient/file_utils.h",
]
deps = [
":audio_processing",
"../..:webrtc_common",
"../../system_wrappers:metrics_default",
"../../system_wrappers:system_wrappers",
]
}
rtc_executable("nonlinear_beamformer_test") {
testonly = true
sources = [
"beamformer/nonlinear_beamformer_test.cc",
]
deps = [
":audio_processing",
":audioproc_test_utils",
"../../base:rtc_base_approved",
"../../common_audio:common_audio",
"../../system_wrappers:metrics_default",
"//third_party/gflags",
]
}
if (rtc_enable_intelligibility_enhancer) {
rtc_executable("intelligibility_proc") {
testonly = true
sources = [
"intelligibility/test/intelligibility_proc.cc",
]
deps = [
":audio_processing",
":audioproc_test_utils",
"../../system_wrappers:metrics_default",
"../../test:test_support",
"//testing/gtest",
"//third_party/gflags",
]
}
}
if (rtc_enable_protobuf) {
proto_library("audioproc_unittest_proto") {
sources = [
"test/unittest.proto",
]
proto_out_dir = "webrtc/modules/audio_processing"
}
rtc_static_library("audioproc_protobuf_utils") {
sources = [
"test/protobuf_utils.cc",
"test/protobuf_utils.h",
]
deps = [
":audioproc_debug_proto",
"../..:webrtc_common",
"../../base:rtc_base_approved",
]
}
}
}