From 1bcfce5ff2cda67aeaf796cbb4779afaace2847e Mon Sep 17 00:00:00 2001 From: peah Date: Fri, 26 Aug 2016 07:16:04 -0700 Subject: [PATCH] Deactivated the intelligibility enhancement functionality by default NOTRY=true BUG= Review-Url: https://codereview.webrtc.org/2272423003 Cr-Commit-Position: refs/heads/master@{#13937} --- webrtc/build/common.gypi | 3 ++ webrtc/build/webrtc.gni | 3 ++ webrtc/media/BUILD.gn | 6 +++ webrtc/media/engine/webrtcvoiceengine.cc | 13 +++++ webrtc/media/media.gyp | 5 ++ webrtc/modules/BUILD.gn | 12 ++++- webrtc/modules/audio_processing/BUILD.gn | 50 +++++++++++-------- .../audio_processing/audio_processing.gypi | 15 ++++-- .../audio_processing/audio_processing_impl.cc | 26 ++++++++++ .../audio_processing_tests.gypi | 35 +++++++------ webrtc/modules/modules.gyp | 11 +++- 11 files changed, 137 insertions(+), 42 deletions(-) diff --git a/webrtc/build/common.gypi b/webrtc/build/common.gypi index 414fd02e6f..c4a548f9ff 100644 --- a/webrtc/build/common.gypi +++ b/webrtc/build/common.gypi @@ -118,6 +118,9 @@ # Enables the use of protocol buffers for debug recordings. 'enable_protobuf%': 1, + # Disable the code for the intelligibility enhancer by default. + 'enable_intelligibility_enhancer%': 0, + # Disable these to not build components which can be externally provided. 'build_expat%': 1, 'build_json%': 1, diff --git a/webrtc/build/webrtc.gni b/webrtc/build/webrtc.gni index b345d735f1..a6282b84fe 100644 --- a/webrtc/build/webrtc.gni +++ b/webrtc/build/webrtc.gni @@ -36,6 +36,9 @@ declare_args() { # Enables the use of protocol buffers for debug recordings. rtc_enable_protobuf = true + # Disable the code for the intelligibility enhancer by default. + rtc_enable_intelligibility_enhancer = false + # Disable these to not build components which can be externally provided. rtc_build_expat = true rtc_build_json = true diff --git a/webrtc/media/BUILD.gn b/webrtc/media/BUILD.gn index e2d9217ba8..5f9a0af422 100644 --- a/webrtc/media/BUILD.gn +++ b/webrtc/media/BUILD.gn @@ -141,6 +141,12 @@ source_set("rtc_media") { ] } + if (rtc_enable_intelligibility_enhancer) { + defines += [ "WEBRTC_INTELLIGIBILITY_ENHANCER=1" ] + } else { + defines += [ "WEBRTC_INTELLIGIBILITY_ENHANCER=0" ] + } + include_dirs = [] if (rtc_build_libyuv) { deps += [ "$rtc_libyuv_dir" ] diff --git a/webrtc/media/engine/webrtcvoiceengine.cc b/webrtc/media/engine/webrtcvoiceengine.cc index a61b8c4284..d0ca9aea61 100644 --- a/webrtc/media/engine/webrtcvoiceengine.cc +++ b/webrtc/media/engine/webrtcvoiceengine.cc @@ -64,6 +64,14 @@ const int kDefaultAudioDeviceId = 0; constexpr int kNackRtpHistoryMs = 5000; +// Check to verify that the define for the intelligibility enhancer is properly +// set. +#if !defined(WEBRTC_INTELLIGIBILITY_ENHANCER) || \ + (WEBRTC_INTELLIGIBILITY_ENHANCER != 0 && \ + WEBRTC_INTELLIGIBILITY_ENHANCER != 1) +#error "Set WEBRTC_INTELLIGIBILITY_ENHANCER to either 0 or 1" +#endif + // Codec parameters for Opus. // draft-spittka-payload-rtp-opus-03 @@ -649,6 +657,11 @@ bool WebRtcVoiceEngine::ApplyOptions(const AudioOptions& options_in) { } #endif +#if (WEBRTC_INTELLIGIBILITY_ENHANCER == 0) + // Hardcode the intelligibility enhancer to be off. + options.intelligibility_enhancer = rtc::Optional(false); +#endif + webrtc::VoEAudioProcessing* voep = voe_wrapper_->processing(); if (options.echo_cancellation) { diff --git a/webrtc/media/media.gyp b/webrtc/media/media.gyp index f3f110267c..ecd0a769c5 100644 --- a/webrtc/media/media.gyp +++ b/webrtc/media/media.gyp @@ -125,6 +125,11 @@ '<(DEPTH)/third_party/usrsctp/usrsctp.gyp:usrsctplib', ], }], + ['enable_intelligibility_enhancer==1', { + 'defines': ['WEBRTC_INTELLIGIBILITY_ENHANCER=1',], + }, { + 'defines': ['WEBRTC_INTELLIGIBILITY_ENHANCER=0',], + }], ['build_with_chromium==1', { 'dependencies': [ '<(webrtc_root)/modules/modules.gyp:video_capture', diff --git a/webrtc/modules/BUILD.gn b/webrtc/modules/BUILD.gn index c04f00c49b..873c978680 100644 --- a/webrtc/modules/BUILD.gn +++ b/webrtc/modules/BUILD.gn @@ -199,8 +199,6 @@ if (rtc_include_tests) { "audio_processing/beamformer/mock_nonlinear_beamformer.h", "audio_processing/beamformer/nonlinear_beamformer_unittest.cc", "audio_processing/echo_cancellation_impl_unittest.cc", - "audio_processing/intelligibility/intelligibility_enhancer_unittest.cc", - "audio_processing/intelligibility/intelligibility_utils_unittest.cc", "audio_processing/splitting_filter_unittest.cc", "audio_processing/transient/dyadic_decimator_unittest.cc", "audio_processing/transient/file_utils.cc", @@ -348,6 +346,16 @@ if (rtc_include_tests) { "video_processing/test/video_processing_unittest.h", ] + if (rtc_enable_intelligibility_enhancer) { + defines += [ "WEBRTC_INTELLIGIBILITY_ENHANCER=1" ] + sources += [ + "audio_processing/intelligibility/intelligibility_enhancer_unittest.cc", + "audio_processing/intelligibility/intelligibility_utils_unittest.cc", + ] + } else { + defines += [ "WEBRTC_INTELLIGIBILITY_ENHANCER=0" ] + } + if (rtc_libvpx_build_vp9) { sources += [ "video_coding/codecs/vp9/vp9_screenshare_layers_unittest.cc" ] diff --git a/webrtc/modules/audio_processing/BUILD.gn b/webrtc/modules/audio_processing/BUILD.gn index 21c89d3ad7..97705c69c5 100644 --- a/webrtc/modules/audio_processing/BUILD.gn +++ b/webrtc/modules/audio_processing/BUILD.gn @@ -74,10 +74,6 @@ source_set("audio_processing") { "high_pass_filter_impl.cc", "high_pass_filter_impl.h", "include/audio_processing.h", - "intelligibility/intelligibility_enhancer.cc", - "intelligibility/intelligibility_enhancer.h", - "intelligibility/intelligibility_utils.cc", - "intelligibility/intelligibility_utils.h", "level_controller/biquad_filter.cc", "level_controller/biquad_filter.h", "level_controller/down_sampler.cc", @@ -182,6 +178,18 @@ source_set("audio_processing") { 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" ] sources += [ @@ -481,22 +489,24 @@ if (rtc_include_tests) { } } - 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 (is_clang) { - # Suppress warnings from the Chromium Clang plugins (bugs.webrtc.org/163). - configs -= [ "//build/config/clang:find_bad_constructs" ] + if (rtc_enable_intelligibility_enhancer) { + 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 (is_clang) { + # Suppress warnings from the Chromium Clang plugins (bugs.webrtc.org/163). + configs -= [ "//build/config/clang:find_bad_constructs" ] + } } } diff --git a/webrtc/modules/audio_processing/audio_processing.gypi b/webrtc/modules/audio_processing/audio_processing.gypi index 3cfc727020..14e1b66862 100644 --- a/webrtc/modules/audio_processing/audio_processing.gypi +++ b/webrtc/modules/audio_processing/audio_processing.gypi @@ -85,10 +85,6 @@ 'high_pass_filter_impl.cc', 'high_pass_filter_impl.h', 'include/audio_processing.h', - 'intelligibility/intelligibility_enhancer.cc', - 'intelligibility/intelligibility_enhancer.h', - 'intelligibility/intelligibility_utils.cc', - 'intelligibility/intelligibility_utils.h', 'level_controller/biquad_filter.cc', 'level_controller/biquad_filter.h', 'level_controller/down_sampler.cc', @@ -184,6 +180,17 @@ 'dependencies': ['audioproc_debug_proto'], 'defines': ['WEBRTC_AUDIOPROC_DEBUG_DUMP'], }], + ['enable_intelligibility_enhancer==1', { + 'defines': ['WEBRTC_INTELLIGIBILITY_ENHANCER=1',], + 'sources': [ + 'intelligibility/intelligibility_enhancer.cc', + 'intelligibility/intelligibility_enhancer.h', + 'intelligibility/intelligibility_utils.cc', + 'intelligibility/intelligibility_utils.h', + ], + }, { + 'defines': ['WEBRTC_INTELLIGIBILITY_ENHANCER=0',], + }], ['prefer_fixed_point==1', { 'defines': ['WEBRTC_NS_FIXED'], 'sources': [ diff --git a/webrtc/modules/audio_processing/audio_processing_impl.cc b/webrtc/modules/audio_processing/audio_processing_impl.cc index 3b3a9518b1..011325f8ca 100644 --- a/webrtc/modules/audio_processing/audio_processing_impl.cc +++ b/webrtc/modules/audio_processing/audio_processing_impl.cc @@ -30,7 +30,9 @@ #include "webrtc/modules/audio_processing/gain_control_for_experimental_agc.h" #include "webrtc/modules/audio_processing/gain_control_impl.h" #include "webrtc/modules/audio_processing/high_pass_filter_impl.h" +#if WEBRTC_INTELLIGIBILITY_ENHANCER #include "webrtc/modules/audio_processing/intelligibility/intelligibility_enhancer.h" +#endif #include "webrtc/modules/audio_processing/level_controller/level_controller.h" #include "webrtc/modules/audio_processing/level_estimator_impl.h" #include "webrtc/modules/audio_processing/noise_suppression_impl.h" @@ -50,6 +52,14 @@ #endif #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP +// Check to verify that the define for the intelligibility enhancer is properly +// set. +#if !defined(WEBRTC_INTELLIGIBILITY_ENHANCER) || \ + (WEBRTC_INTELLIGIBILITY_ENHANCER != 0 && \ + WEBRTC_INTELLIGIBILITY_ENHANCER != 1) +#error "Set WEBRTC_INTELLIGIBILITY_ENHANCER to either 0 or 1" +#endif + #define RETURN_ON_ERR(expr) \ do { \ int err = (expr); \ @@ -124,7 +134,9 @@ struct AudioProcessingImpl::ApmPublicSubmodules { // Accessed internally from both render and capture. std::unique_ptr transient_suppressor; +#if WEBRTC_INTELLIGIBILITY_ENHANCER std::unique_ptr intelligibility_enhancer; +#endif }; struct AudioProcessingImpl::ApmPrivateSubmodules { @@ -321,7 +333,9 @@ int AudioProcessingImpl::InitializeLocked() { InitializeExperimentalAgc(); InitializeTransient(); InitializeBeamformer(); +#if WEBRTC_INTELLIGIBILITY_ENHANCER InitializeIntelligibility(); +#endif InitializeHighPassFilter(); InitializeNoiseSuppression(); InitializeLevelEstimator(); @@ -423,12 +437,14 @@ void AudioProcessingImpl::SetExtraOptions(const Config& config) { InitializeLevelController(); } +#if WEBRTC_INTELLIGIBILITY_ENHANCER if(capture_nonlocked_.intelligibility_enabled != config.Get().enabled) { capture_nonlocked_.intelligibility_enabled = config.Get().enabled; InitializeIntelligibility(); } +#endif #ifdef WEBRTC_ANDROID_PLATFORM_BUILD if (capture_nonlocked_.beamformer_enabled != @@ -725,6 +741,7 @@ int AudioProcessingImpl::ProcessStreamLocked() { ca->CopyLowPassToReference(); } public_submodules_->noise_suppression->ProcessCaptureAudio(ca); +#if WEBRTC_INTELLIGIBILITY_ENHANCER if (capture_nonlocked_.intelligibility_enabled) { RTC_DCHECK(public_submodules_->noise_suppression->is_enabled()); int gain_db = public_submodules_->gain_control->is_enabled() ? @@ -737,6 +754,7 @@ int AudioProcessingImpl::ProcessStreamLocked() { public_submodules_->intelligibility_enhancer->SetCaptureNoiseEstimate( public_submodules_->noise_suppression->NoiseEstimate(), gain); } +#endif // Ensure that the stream delay was set before the call to the // AECM ProcessCaptureAudio function. @@ -936,11 +954,13 @@ int AudioProcessingImpl::ProcessReverseStreamLocked() { ra->SplitIntoFrequencyBands(); } +#if WEBRTC_INTELLIGIBILITY_ENHANCER if (capture_nonlocked_.intelligibility_enabled) { public_submodules_->intelligibility_enhancer->ProcessRenderAudio( ra->split_channels_f(kBand0To8kHz), capture_nonlocked_.split_rate, ra->num_channels()); } +#endif RETURN_ON_ERR(public_submodules_->echo_cancellation->ProcessRenderAudio(ra)); RETURN_ON_ERR( @@ -1172,7 +1192,11 @@ bool AudioProcessingImpl::fwd_analysis_needed() const { } bool AudioProcessingImpl::is_rev_processed() const { +#if WEBRTC_INTELLIGIBILITY_ENHANCER return capture_nonlocked_.intelligibility_enabled; +#else + return false; +#endif } bool AudioProcessingImpl::rev_synthesis_needed() const { @@ -1237,12 +1261,14 @@ void AudioProcessingImpl::InitializeBeamformer() { } void AudioProcessingImpl::InitializeIntelligibility() { +#if WEBRTC_INTELLIGIBILITY_ENHANCER if (capture_nonlocked_.intelligibility_enabled) { public_submodules_->intelligibility_enhancer.reset( new IntelligibilityEnhancer(capture_nonlocked_.split_rate, render_.render_audio->num_channels(), NoiseSuppressionImpl::num_noise_bins())); } +#endif } void AudioProcessingImpl::InitializeHighPassFilter() { diff --git a/webrtc/modules/audio_processing/audio_processing_tests.gypi b/webrtc/modules/audio_processing/audio_processing_tests.gypi index 87598edeef..d68fed3ff1 100644 --- a/webrtc/modules/audio_processing/audio_processing_tests.gypi +++ b/webrtc/modules/audio_processing/audio_processing_tests.gypi @@ -61,22 +61,29 @@ 'beamformer/nonlinear_beamformer_test.cc', ], }, # nonlinear_beamformer_test - { - 'target_name': 'intelligibility_proc', - 'type': 'executable', - 'dependencies': [ - 'audioproc_test_utils', - '<(DEPTH)/third_party/gflags/gflags.gyp:gflags', - '<(DEPTH)/testing/gtest.gyp:gtest', - '<(webrtc_root)/modules/modules.gyp:audio_processing', - '<(webrtc_root)/test/test.gyp:test_support', - ], - 'sources': [ - 'intelligibility/test/intelligibility_proc.cc', - ], - }, # intelligibility_proc ], 'conditions': [ + ['enable_intelligibility_enhancer==1', { + 'defines': ['WEBRTC_INTELLIGIBILITY_ENHANCER=1',], + 'targets': [ + { + 'target_name': 'intelligibility_proc', + 'type': 'executable', + 'dependencies': [ + 'audioproc_test_utils', + '<(DEPTH)/third_party/gflags/gflags.gyp:gflags', + '<(DEPTH)/testing/gtest.gyp:gtest', + '<(webrtc_root)/modules/modules.gyp:audio_processing', + '<(webrtc_root)/test/test.gyp:test_support', + ], + 'sources': [ + 'intelligibility/test/intelligibility_proc.cc', + ], + }, + ], + }, { + 'defines': ['WEBRTC_INTELLIGIBILITY_ENHANCER=0',], + }], ['enable_protobuf==1', { 'targets': [ { diff --git a/webrtc/modules/modules.gyp b/webrtc/modules/modules.gyp index 582b750e43..16fb8188c2 100644 --- a/webrtc/modules/modules.gyp +++ b/webrtc/modules/modules.gyp @@ -249,8 +249,6 @@ 'audio_processing/beamformer/mock_nonlinear_beamformer.h', 'audio_processing/beamformer/nonlinear_beamformer_unittest.cc', 'audio_processing/echo_cancellation_impl_unittest.cc', - 'audio_processing/intelligibility/intelligibility_enhancer_unittest.cc', - 'audio_processing/intelligibility/intelligibility_utils_unittest.cc', 'audio_processing/splitting_filter_unittest.cc', 'audio_processing/transient/dyadic_decimator_unittest.cc', 'audio_processing/transient/file_utils.cc', @@ -398,6 +396,15 @@ 'video_processing/test/video_processing_unittest.h', ], 'conditions': [ + ['enable_intelligibility_enhancer==1', { + 'defines': ['WEBRTC_INTELLIGIBILITY_ENHANCER=1',], + 'sources': [ + 'audio_processing/intelligibility/intelligibility_enhancer_unittest.cc', + 'audio_processing/intelligibility/intelligibility_utils_unittest.cc', + ], + }, { + 'defines': ['WEBRTC_INTELLIGIBILITY_ENHANCER=0',], + }], ['libvpx_build_vp9==1', { 'sources': [ 'video_coding/codecs/vp9/vp9_screenshare_layers_unittest.cc',