Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(284)

Side by Side Diff: webrtc/modules/audio_processing/audio_processing_impl.cc

Issue 1982183002: Pull out the PostFilter to its own NonlinearBeamformer API (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Remove ChannelBuffer fix Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 std::unique_ptr<VoiceDetectionImpl> voice_detection; 120 std::unique_ptr<VoiceDetectionImpl> voice_detection;
121 std::unique_ptr<GainControlForExperimentalAgc> 121 std::unique_ptr<GainControlForExperimentalAgc>
122 gain_control_for_experimental_agc; 122 gain_control_for_experimental_agc;
123 123
124 // Accessed internally from both render and capture. 124 // Accessed internally from both render and capture.
125 std::unique_ptr<TransientSuppressor> transient_suppressor; 125 std::unique_ptr<TransientSuppressor> transient_suppressor;
126 std::unique_ptr<IntelligibilityEnhancer> intelligibility_enhancer; 126 std::unique_ptr<IntelligibilityEnhancer> intelligibility_enhancer;
127 }; 127 };
128 128
129 struct AudioProcessingImpl::ApmPrivateSubmodules { 129 struct AudioProcessingImpl::ApmPrivateSubmodules {
130 explicit ApmPrivateSubmodules(Beamformer<float>* beamformer) 130 explicit ApmPrivateSubmodules(NonlinearBeamformer* beamformer)
131 : beamformer(beamformer) {} 131 : beamformer(beamformer) {}
132 // Accessed internally from capture or during initialization 132 // Accessed internally from capture or during initialization
133 std::unique_ptr<Beamformer<float>> beamformer; 133 std::unique_ptr<NonlinearBeamformer> beamformer;
134 std::unique_ptr<AgcManagerDirect> agc_manager; 134 std::unique_ptr<AgcManagerDirect> agc_manager;
135 }; 135 };
136 136
137 AudioProcessing* AudioProcessing::Create() { 137 AudioProcessing* AudioProcessing::Create() {
138 Config config; 138 Config config;
139 return Create(config, nullptr); 139 return Create(config, nullptr);
140 } 140 }
141 141
142 AudioProcessing* AudioProcessing::Create(const Config& config) { 142 AudioProcessing* AudioProcessing::Create(const Config& config) {
143 return Create(config, nullptr); 143 return Create(config, nullptr);
144 } 144 }
145 145
146 AudioProcessing* AudioProcessing::Create(const Config& config, 146 AudioProcessing* AudioProcessing::Create(const Config& config,
147 Beamformer<float>* beamformer) { 147 NonlinearBeamformer* beamformer) {
148 AudioProcessingImpl* apm = new AudioProcessingImpl(config, beamformer); 148 AudioProcessingImpl* apm = new AudioProcessingImpl(config, beamformer);
149 if (apm->Initialize() != kNoError) { 149 if (apm->Initialize() != kNoError) {
150 delete apm; 150 delete apm;
151 apm = nullptr; 151 apm = nullptr;
152 } 152 }
153 153
154 return apm; 154 return apm;
155 } 155 }
156 156
157 AudioProcessingImpl::AudioProcessingImpl(const Config& config) 157 AudioProcessingImpl::AudioProcessingImpl(const Config& config)
158 : AudioProcessingImpl(config, nullptr) {} 158 : AudioProcessingImpl(config, nullptr) {}
159 159
160 AudioProcessingImpl::AudioProcessingImpl(const Config& config, 160 AudioProcessingImpl::AudioProcessingImpl(const Config& config,
161 Beamformer<float>* beamformer) 161 NonlinearBeamformer* beamformer)
162 : public_submodules_(new ApmPublicSubmodules()), 162 : public_submodules_(new ApmPublicSubmodules()),
163 private_submodules_(new ApmPrivateSubmodules(beamformer)), 163 private_submodules_(new ApmPrivateSubmodules(beamformer)),
164 constants_(config.Get<ExperimentalAgc>().startup_min_volume, 164 constants_(config.Get<ExperimentalAgc>().startup_min_volume,
165 #if defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS) 165 #if defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS)
166 false), 166 false),
167 #else 167 #else
168 config.Get<ExperimentalAgc>().enabled), 168 config.Get<ExperimentalAgc>().enabled),
169 #endif 169 #endif
170 #if defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS) 170 #if defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS)
171 capture_(false, 171 capture_(false,
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after
679 private_submodules_->agc_manager->AnalyzePreProcess( 679 private_submodules_->agc_manager->AnalyzePreProcess(
680 ca->channels()[0], ca->num_channels(), 680 ca->channels()[0], ca->num_channels(),
681 capture_nonlocked_.fwd_proc_format.num_frames()); 681 capture_nonlocked_.fwd_proc_format.num_frames());
682 } 682 }
683 683
684 if (fwd_analysis_needed()) { 684 if (fwd_analysis_needed()) {
685 ca->SplitIntoFrequencyBands(); 685 ca->SplitIntoFrequencyBands();
686 } 686 }
687 687
688 if (capture_nonlocked_.beamformer_enabled) { 688 if (capture_nonlocked_.beamformer_enabled) {
689 private_submodules_->beamformer->ProcessChunk(*ca->split_data_f(), 689 private_submodules_->beamformer->AnalyzeChunk(*ca->split_data_f());
690 ca->split_data_f()); 690 // Discards all channels by the leftmost one.
691 ca->set_num_channels(1); 691 ca->set_num_channels(1);
peah-webrtc 2016/06/23 22:02:40 The handling of the number of channels is a bit me
aluebs-webrtc 2016/06/24 03:00:54 That makes sense, but it should be a different CL.
692 } 692 }
693 693
694 public_submodules_->high_pass_filter->ProcessCaptureAudio(ca); 694 public_submodules_->high_pass_filter->ProcessCaptureAudio(ca);
695 RETURN_ON_ERR(public_submodules_->gain_control->AnalyzeCaptureAudio(ca)); 695 RETURN_ON_ERR(public_submodules_->gain_control->AnalyzeCaptureAudio(ca));
696 public_submodules_->noise_suppression->AnalyzeCaptureAudio(ca); 696 public_submodules_->noise_suppression->AnalyzeCaptureAudio(ca);
697 697
698 // Ensure that the stream delay was set before the call to the 698 // Ensure that the stream delay was set before the call to the
699 // AEC ProcessCaptureAudio function. 699 // AEC ProcessCaptureAudio function.
700 if (public_submodules_->echo_cancellation->is_enabled() && 700 if (public_submodules_->echo_cancellation->is_enabled() &&
701 !was_stream_delay_set()) { 701 !was_stream_delay_set()) {
(...skipping 20 matching lines...) Expand all
722 // Ensure that the stream delay was set before the call to the 722 // Ensure that the stream delay was set before the call to the
723 // AECM ProcessCaptureAudio function. 723 // AECM ProcessCaptureAudio function.
724 if (public_submodules_->echo_control_mobile->is_enabled() && 724 if (public_submodules_->echo_control_mobile->is_enabled() &&
725 !was_stream_delay_set()) { 725 !was_stream_delay_set()) {
726 return AudioProcessing::kStreamParameterNotSetError; 726 return AudioProcessing::kStreamParameterNotSetError;
727 } 727 }
728 728
729 RETURN_ON_ERR(public_submodules_->echo_control_mobile->ProcessCaptureAudio( 729 RETURN_ON_ERR(public_submodules_->echo_control_mobile->ProcessCaptureAudio(
730 ca, stream_delay_ms())); 730 ca, stream_delay_ms()));
731 731
732 if (capture_nonlocked_.beamformer_enabled) {
733 private_submodules_->beamformer->PostFilter(ca->split_data_f());
734 }
735
732 public_submodules_->voice_detection->ProcessCaptureAudio(ca); 736 public_submodules_->voice_detection->ProcessCaptureAudio(ca);
733 737
734 if (constants_.use_experimental_agc && 738 if (constants_.use_experimental_agc &&
735 public_submodules_->gain_control->is_enabled() && 739 public_submodules_->gain_control->is_enabled() &&
736 (!capture_nonlocked_.beamformer_enabled || 740 (!capture_nonlocked_.beamformer_enabled ||
737 private_submodules_->beamformer->is_target_present())) { 741 private_submodules_->beamformer->is_target_present())) {
738 private_submodules_->agc_manager->Process( 742 private_submodules_->agc_manager->Process(
739 ca->split_bands_const(0)[kBand0To8kHz], ca->num_frames_per_band(), 743 ca->split_bands_const(0)[kBand0To8kHz], ca->num_frames_per_band(),
740 capture_nonlocked_.split_rate); 744 capture_nonlocked_.split_rate);
741 } 745 }
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after
1207 capture_nonlocked_.fwd_proc_format.sample_rate_hz(), 1211 capture_nonlocked_.fwd_proc_format.sample_rate_hz(),
1208 capture_nonlocked_.split_rate, 1212 capture_nonlocked_.split_rate,
1209 num_proc_channels()); 1213 num_proc_channels());
1210 } 1214 }
1211 } 1215 }
1212 1216
1213 void AudioProcessingImpl::InitializeBeamformer() { 1217 void AudioProcessingImpl::InitializeBeamformer() {
1214 if (capture_nonlocked_.beamformer_enabled) { 1218 if (capture_nonlocked_.beamformer_enabled) {
1215 if (!private_submodules_->beamformer) { 1219 if (!private_submodules_->beamformer) {
1216 private_submodules_->beamformer.reset(new NonlinearBeamformer( 1220 private_submodules_->beamformer.reset(new NonlinearBeamformer(
1217 capture_.array_geometry, capture_.target_direction)); 1221 capture_.array_geometry, 1u, capture_.target_direction));
1218 } 1222 }
1219 private_submodules_->beamformer->Initialize(kChunkSizeMs, 1223 private_submodules_->beamformer->Initialize(kChunkSizeMs,
1220 capture_nonlocked_.split_rate); 1224 capture_nonlocked_.split_rate);
1221 } 1225 }
1222 } 1226 }
1223 1227
1224 void AudioProcessingImpl::InitializeIntelligibility() { 1228 void AudioProcessingImpl::InitializeIntelligibility() {
1225 if (capture_nonlocked_.intelligibility_enabled) { 1229 if (capture_nonlocked_.intelligibility_enabled) {
1226 public_submodules_->intelligibility_enhancer.reset( 1230 public_submodules_->intelligibility_enhancer.reset(
1227 new IntelligibilityEnhancer(capture_nonlocked_.split_rate, 1231 new IntelligibilityEnhancer(capture_nonlocked_.split_rate,
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
1470 debug_dump_.capture.event_msg->mutable_config()->CopyFrom(config); 1474 debug_dump_.capture.event_msg->mutable_config()->CopyFrom(config);
1471 1475
1472 RETURN_ON_ERR(WriteMessageToDebugFile(debug_dump_.debug_file.get(), 1476 RETURN_ON_ERR(WriteMessageToDebugFile(debug_dump_.debug_file.get(),
1473 &debug_dump_.num_bytes_left_for_log_, 1477 &debug_dump_.num_bytes_left_for_log_,
1474 &crit_debug_, &debug_dump_.capture)); 1478 &crit_debug_, &debug_dump_.capture));
1475 return kNoError; 1479 return kNoError;
1476 } 1480 }
1477 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP 1481 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP
1478 1482
1479 } // namespace webrtc 1483 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698