Rename Beamformer to NonlinearBeamformer.
R=aluebs@webrtc.org
Review URL: https://webrtc-codereview.appspot.com/42359004
Cr-Commit-Position: refs/heads/master@{#8710}
git-svn-id: http://webrtc.googlecode.com/svn/trunk@8710 4adac7df-926f-26a2-2b94-8c16560cd09d
diff --git a/webrtc/modules/audio_processing/BUILD.gn b/webrtc/modules/audio_processing/BUILD.gn
index 16bcf94..b34c41c 100644
--- a/webrtc/modules/audio_processing/BUILD.gn
+++ b/webrtc/modules/audio_processing/BUILD.gn
@@ -170,8 +170,8 @@
if (rtc_use_openmax_dl) {
defines += [ "WEBRTC_BEAMFORMER" ]
sources += [
- "beamformer/beamformer.cc",
- "beamformer/beamformer.h",
+ "beamformer/nonlinear_beamformer.cc",
+ "beamformer/nonlinear_beamformer.h",
]
}
diff --git a/webrtc/modules/audio_processing/audio_processing.gypi b/webrtc/modules/audio_processing/audio_processing.gypi
index f14892a..3175cc6 100644
--- a/webrtc/modules/audio_processing/audio_processing.gypi
+++ b/webrtc/modules/audio_processing/audio_processing.gypi
@@ -179,8 +179,8 @@
['rtc_use_openmax_dl==1', {
'defines': ['WEBRTC_BEAMFORMER'],
'sources': [
- 'beamformer/beamformer.cc',
- 'beamformer/beamformer.h',
+ 'beamformer/nonlinear_beamformer.cc',
+ 'beamformer/nonlinear_beamformer.h',
],
}],
['target_arch=="ia32" or target_arch=="x64"', {
diff --git a/webrtc/modules/audio_processing/audio_processing_impl.cc b/webrtc/modules/audio_processing/audio_processing_impl.cc
index 9692c8c..d1421f3 100644
--- a/webrtc/modules/audio_processing/audio_processing_impl.cc
+++ b/webrtc/modules/audio_processing/audio_processing_impl.cc
@@ -17,7 +17,7 @@
#include "webrtc/common_audio/signal_processing/include/signal_processing_library.h"
#include "webrtc/modules/audio_processing/agc/agc_manager_direct.h"
#include "webrtc/modules/audio_processing/audio_buffer.h"
-#include "webrtc/modules/audio_processing/beamformer/beamformer.h"
+#include "webrtc/modules/audio_processing/beamformer/nonlinear_beamformer.h"
#include "webrtc/common_audio/channel_buffer.h"
#include "webrtc/modules/audio_processing/common.h"
#include "webrtc/modules/audio_processing/echo_cancellation_impl.h"
@@ -45,7 +45,7 @@
#define RETURN_ON_ERR(expr) \
do { \
- int err = expr; \
+ int err = (expr); \
if (err != kNoError) { \
return err; \
} \
@@ -134,7 +134,7 @@
}
AudioProcessing* AudioProcessing::Create(const Config& config,
- Beamformer* beamformer) {
+ NonlinearBeamformer* beamformer) {
AudioProcessingImpl* apm = new AudioProcessingImpl(config, beamformer);
if (apm->Initialize() != kNoError) {
delete apm;
@@ -148,7 +148,7 @@
: AudioProcessingImpl(config, nullptr) {}
AudioProcessingImpl::AudioProcessingImpl(const Config& config,
- Beamformer* beamformer)
+ NonlinearBeamformer* beamformer)
: echo_cancellation_(NULL),
echo_control_mobile_(NULL),
gain_control_(NULL),
@@ -988,7 +988,7 @@
if (beamformer_enabled_) {
#ifdef WEBRTC_BEAMFORMER
if (!beamformer_) {
- beamformer_.reset(new Beamformer(array_geometry_));
+ beamformer_.reset(new NonlinearBeamformer(array_geometry_));
}
beamformer_->Initialize(kChunkSizeMs, split_rate_);
#else
diff --git a/webrtc/modules/audio_processing/audio_processing_impl.h b/webrtc/modules/audio_processing/audio_processing_impl.h
index 68abdf6..b5114cf 100644
--- a/webrtc/modules/audio_processing/audio_processing_impl.h
+++ b/webrtc/modules/audio_processing/audio_processing_impl.h
@@ -23,7 +23,7 @@
class AgcManagerDirect;
class AudioBuffer;
-class Beamformer;
+class NonlinearBeamformer;
class CriticalSectionWrapper;
class EchoCancellationImpl;
class EchoControlMobileImpl;
@@ -87,7 +87,7 @@
public:
explicit AudioProcessingImpl(const Config& config);
// Only for testing.
- AudioProcessingImpl(const Config& config, Beamformer* beamformer);
+ AudioProcessingImpl(const Config& config, NonlinearBeamformer* beamformer);
virtual ~AudioProcessingImpl();
// AudioProcessing methods.
@@ -218,7 +218,7 @@
bool transient_suppressor_enabled_;
rtc::scoped_ptr<TransientSuppressor> transient_suppressor_;
const bool beamformer_enabled_;
- rtc::scoped_ptr<Beamformer> beamformer_;
+ rtc::scoped_ptr<NonlinearBeamformer> beamformer_;
const std::vector<Point> array_geometry_;
const bool supports_48kHz_;
diff --git a/webrtc/modules/audio_processing/audio_processing_tests.gypi b/webrtc/modules/audio_processing/audio_processing_tests.gypi
index 73aed58..861f9cd 100644
--- a/webrtc/modules/audio_processing/audio_processing_tests.gypi
+++ b/webrtc/modules/audio_processing/audio_processing_tests.gypi
@@ -88,18 +88,18 @@
['rtc_use_openmax_dl==1', {
'targets': [
{
- 'target_name': 'beamformer_test',
+ 'target_name': 'nonlinear_beamformer_test',
'type': 'executable',
'dependencies': [
'<(DEPTH)/third_party/gflags/gflags.gyp:gflags',
'<(webrtc_root)/modules/modules.gyp:audio_processing',
],
'sources': [
- 'beamformer/beamformer_test.cc',
+ 'beamformer/nonlinear_beamformer_test.cc',
'beamformer/pcm_utils.cc',
'beamformer/pcm_utils.h',
],
- }, # beamformer_test
+ }, # nonlinear_beamformer_test
],
}],
],
diff --git a/webrtc/modules/audio_processing/beamformer/mock_beamformer.cc b/webrtc/modules/audio_processing/beamformer/mock_nonlinear_beamformer.cc
similarity index 63%
rename from webrtc/modules/audio_processing/beamformer/mock_beamformer.cc
rename to webrtc/modules/audio_processing/beamformer/mock_nonlinear_beamformer.cc
index 2319c32..4a1936e 100644
--- a/webrtc/modules/audio_processing/beamformer/mock_beamformer.cc
+++ b/webrtc/modules/audio_processing/beamformer/mock_nonlinear_beamformer.cc
@@ -8,15 +8,17 @@
* be found in the AUTHORS file in the root of the source tree.
*/
-#include "webrtc/modules/audio_processing/beamformer/mock_beamformer.h"
+#include "webrtc/modules/audio_processing/beamformer/mock_nonlinear_beamformer.h"
#include <vector>
namespace webrtc {
-MockBeamformer::MockBeamformer(const std::vector<Point>& array_geometry)
- : Beamformer(array_geometry) {}
+MockNonlinearBeamformer::MockNonlinearBeamformer(
+ const std::vector<Point>& array_geometry)
+ : NonlinearBeamformer(array_geometry) {
+}
-MockBeamformer::~MockBeamformer() {}
+MockNonlinearBeamformer::~MockNonlinearBeamformer() {}
} // namespace webrtc
diff --git a/webrtc/modules/audio_processing/beamformer/mock_beamformer.h b/webrtc/modules/audio_processing/beamformer/mock_nonlinear_beamformer.h
similarity index 79%
rename from webrtc/modules/audio_processing/beamformer/mock_beamformer.h
rename to webrtc/modules/audio_processing/beamformer/mock_nonlinear_beamformer.h
index 58995de..56e647b 100644
--- a/webrtc/modules/audio_processing/beamformer/mock_beamformer.h
+++ b/webrtc/modules/audio_processing/beamformer/mock_nonlinear_beamformer.h
@@ -14,14 +14,14 @@
#include <vector>
#include "testing/gmock/include/gmock/gmock.h"
-#include "webrtc/modules/audio_processing/beamformer/beamformer.h"
+#include "webrtc/modules/audio_processing/beamformer/nonlinear_beamformer.h"
namespace webrtc {
-class MockBeamformer : public Beamformer {
+class MockNonlinearBeamformer : public NonlinearBeamformer {
public:
- explicit MockBeamformer(const std::vector<Point>& array_geometry);
- ~MockBeamformer() override;
+ explicit MockNonlinearBeamformer(const std::vector<Point>& array_geometry);
+ ~MockNonlinearBeamformer() override;
MOCK_METHOD2(Initialize, void(int chunk_size_ms, int sample_rate_hz));
MOCK_METHOD2(ProcessChunk, void(const ChannelBuffer<float>* input,
diff --git a/webrtc/modules/audio_processing/beamformer/beamformer.cc b/webrtc/modules/audio_processing/beamformer/nonlinear_beamformer.cc
similarity index 93%
rename from webrtc/modules/audio_processing/beamformer/beamformer.cc
rename to webrtc/modules/audio_processing/beamformer/nonlinear_beamformer.cc
index 6d78de9..9630b7d 100644
--- a/webrtc/modules/audio_processing/beamformer/beamformer.cc
+++ b/webrtc/modules/audio_processing/beamformer/nonlinear_beamformer.cc
@@ -10,10 +10,11 @@
#define _USE_MATH_DEFINES
-#include "webrtc/modules/audio_processing/beamformer/beamformer.h"
+#include "webrtc/modules/audio_processing/beamformer/nonlinear_beamformer.h"
#include <algorithm>
#include <cmath>
+#include <vector>
#include "webrtc/base/arraysize.h"
#include "webrtc/common_audio/window_generator.h"
@@ -174,13 +175,14 @@
} // namespace
-Beamformer::Beamformer(const std::vector<Point>& array_geometry)
- : num_input_channels_(array_geometry.size()),
+NonlinearBeamformer::NonlinearBeamformer(
+ const std::vector<Point>& array_geometry)
+ : num_input_channels_(array_geometry.size()),
array_geometry_(GetCenteredArray(array_geometry)) {
WindowGenerator::KaiserBesselDerived(kAlpha, kFftSize, window_);
}
-void Beamformer::Initialize(int chunk_size_ms, int sample_rate_hz) {
+void NonlinearBeamformer::Initialize(int chunk_size_ms, int sample_rate_hz) {
chunk_length_ = sample_rate_hz / (1000.f / chunk_size_ms);
sample_rate_hz_ = sample_rate_hz;
low_average_start_bin_ =
@@ -230,7 +232,7 @@
}
}
-void Beamformer::InitDelaySumMasks() {
+void NonlinearBeamformer::InitDelaySumMasks() {
for (int f_ix = 0; f_ix < kNumFreqBins; ++f_ix) {
delay_sum_masks_[f_ix].Resize(1, num_input_channels_);
CovarianceMatrixGenerator::PhaseAlignmentMasks(f_ix,
@@ -250,7 +252,7 @@
}
}
-void Beamformer::InitTargetCovMats() {
+void NonlinearBeamformer::InitTargetCovMats() {
for (int i = 0; i < kNumFreqBins; ++i) {
target_cov_mats_[i].Resize(num_input_channels_, num_input_channels_);
TransposedConjugatedProduct(delay_sum_masks_[i], &target_cov_mats_[i]);
@@ -259,7 +261,7 @@
}
}
-void Beamformer::InitInterfCovMats() {
+void NonlinearBeamformer::InitInterfCovMats() {
for (int i = 0; i < kNumFreqBins; ++i) {
interf_cov_mats_[i].Resize(num_input_channels_, num_input_channels_);
ComplexMatrixF uniform_cov_mat(num_input_channels_, num_input_channels_);
@@ -291,7 +293,7 @@
}
}
-void Beamformer::ProcessChunk(const ChannelBuffer<float>* input,
+void NonlinearBeamformer::ProcessChunk(const ChannelBuffer<float>* input,
ChannelBuffer<float>* output) {
DCHECK_EQ(input->num_channels(), num_input_channels_);
DCHECK_EQ(input->num_frames_per_band(), chunk_length_);
@@ -321,7 +323,7 @@
}
}
-void Beamformer::ProcessAudioBlock(const complex_f* const* input,
+void NonlinearBeamformer::ProcessAudioBlock(const complex_f* const* input,
int num_input_channels,
int num_freq_bins,
int num_output_channels,
@@ -371,11 +373,12 @@
EstimateTargetPresence();
}
-float Beamformer::CalculatePostfilterMask(const ComplexMatrixF& interf_cov_mat,
- float rpsiw,
- float ratio_rxiw_rxim,
- float rmw_r,
- float mask_threshold) {
+float NonlinearBeamformer::CalculatePostfilterMask(
+ const ComplexMatrixF& interf_cov_mat,
+ float rpsiw,
+ float ratio_rxiw_rxim,
+ float rmw_r,
+ float mask_threshold) {
float rpsim = Norm(interf_cov_mat, eig_m_);
// Find lambda.
@@ -394,7 +397,7 @@
return mask;
}
-void Beamformer::ApplyMasks(const complex_f* const* input,
+void NonlinearBeamformer::ApplyMasks(const complex_f* const* input,
complex_f* const* output) {
complex_f* output_channel = output[0];
for (int f_ix = 0; f_ix < kNumFreqBins; ++f_ix) {
@@ -410,14 +413,14 @@
}
}
-void Beamformer::ApplyMaskSmoothing() {
+void NonlinearBeamformer::ApplyMaskSmoothing() {
for (int i = 0; i < kNumFreqBins; ++i) {
postfilter_mask_[i] = kMaskSmoothAlpha * new_mask_[i] +
(1.f - kMaskSmoothAlpha) * postfilter_mask_[i];
}
}
-void Beamformer::ApplyLowFrequencyCorrection() {
+void NonlinearBeamformer::ApplyLowFrequencyCorrection() {
float low_frequency_mask = 0.f;
for (int i = low_average_start_bin_; i < low_average_end_bin_; ++i) {
low_frequency_mask += postfilter_mask_[i];
@@ -430,7 +433,7 @@
}
}
-void Beamformer::ApplyHighFrequencyCorrection() {
+void NonlinearBeamformer::ApplyHighFrequencyCorrection() {
high_pass_postfilter_mask_ = 0.f;
for (int i = high_average_start_bin_; i < high_average_end_bin_; ++i) {
high_pass_postfilter_mask_ += postfilter_mask_[i];
@@ -443,7 +446,7 @@
}
}
-void Beamformer::EstimateTargetPresence() {
+void NonlinearBeamformer::EstimateTargetPresence() {
const int quantile = (1.f - kMaskQuantile) * high_average_end_bin_ +
kMaskQuantile * low_average_start_bin_;
std::nth_element(new_mask_ + low_average_start_bin_,
diff --git a/webrtc/modules/audio_processing/beamformer/beamformer.h b/webrtc/modules/audio_processing/beamformer/nonlinear_beamformer.h
similarity index 93%
rename from webrtc/modules/audio_processing/beamformer/beamformer.h
rename to webrtc/modules/audio_processing/beamformer/nonlinear_beamformer.h
index 3407bd3..91e47cd75 100644
--- a/webrtc/modules/audio_processing/beamformer/beamformer.h
+++ b/webrtc/modules/audio_processing/beamformer/nonlinear_beamformer.h
@@ -8,8 +8,10 @@
* be found in the AUTHORS file in the root of the source tree.
*/
-#ifndef WEBRTC_MODULES_AUDIO_PROCESSING_BEAMFORMER_BEAMFORMER_H_
-#define WEBRTC_MODULES_AUDIO_PROCESSING_BEAMFORMER_BEAMFORMER_H_
+#ifndef WEBRTC_MODULES_AUDIO_PROCESSING_BEAMFORMER_NONLINEAR_BEAMFORMER_H_
+#define WEBRTC_MODULES_AUDIO_PROCESSING_BEAMFORMER_NONLINEAR_BEAMFORMER_H_
+
+#include <vector>
#include "webrtc/common_audio/lapped_transform.h"
#include "webrtc/modules/audio_processing/beamformer/complex_matrix.h"
@@ -25,15 +27,14 @@
// Beamforming Postprocessor" by Bastiaan Kleijn.
//
// TODO: Target angle assumed to be 0. Parameterize target angle.
-class Beamformer : public LappedTransform::Callback {
+class NonlinearBeamformer : public LappedTransform::Callback {
public:
// At the moment it only accepts uniform linear microphone arrays. Using the
// first microphone as a reference position [0, 0, 0] is a natural choice.
- explicit Beamformer(const std::vector<Point>& array_geometry);
- virtual ~Beamformer() {};
+ explicit NonlinearBeamformer(const std::vector<Point>& array_geometry);
// Sample rate corresponds to the lower band.
- // Needs to be called before the Beamformer can be used.
+ // Needs to be called before the NonlinearBeamformer can be used.
virtual void Initialize(int chunk_size_ms, int sample_rate_hz);
// Process one time-domain chunk of audio. The audio is expected to be split
@@ -160,4 +161,4 @@
} // namespace webrtc
-#endif // WEBRTC_MODULES_AUDIO_PROCESSING_BEAMFORMER_BEAMFORMER_H_
+#endif // WEBRTC_MODULES_AUDIO_PROCESSING_BEAMFORMER_NONLINEAR_BEAMFORMER_H_
diff --git a/webrtc/modules/audio_processing/beamformer/beamformer_test.cc b/webrtc/modules/audio_processing/beamformer/nonlinear_beamformer_test.cc
similarity index 94%
rename from webrtc/modules/audio_processing/beamformer/beamformer_test.cc
rename to webrtc/modules/audio_processing/beamformer/nonlinear_beamformer_test.cc
index 0048769..9d85ec5 100644
--- a/webrtc/modules/audio_processing/beamformer/beamformer_test.cc
+++ b/webrtc/modules/audio_processing/beamformer/nonlinear_beamformer_test.cc
@@ -9,9 +9,10 @@
*/
#include <iostream>
+#include <vector>
#include "gflags/gflags.h"
-#include "webrtc/modules/audio_processing/beamformer/beamformer.h"
+#include "webrtc/modules/audio_processing/beamformer/nonlinear_beamformer.h"
#include "webrtc/modules/audio_processing/beamformer/pcm_utils.h"
DEFINE_int32(sample_rate,
@@ -59,7 +60,7 @@
for (int i = 0; i < FLAGS_num_input_channels; ++i) {
array_geometry.push_back(webrtc::Point(i * FLAGS_mic_spacing, 0.f, 0.f));
}
- webrtc::Beamformer bf(array_geometry);
+ webrtc::NonlinearBeamformer bf(array_geometry);
bf.Initialize(kChunkTimeMilliseconds, FLAGS_sample_rate);
while (true) {
size_t samples_read = webrtc::PcmReadToFloat(read_file,
diff --git a/webrtc/modules/audio_processing/include/audio_processing.h b/webrtc/modules/audio_processing/include/audio_processing.h
index 049cfbb..7c230d3 100644
--- a/webrtc/modules/audio_processing/include/audio_processing.h
+++ b/webrtc/modules/audio_processing/include/audio_processing.h
@@ -25,7 +25,7 @@
namespace webrtc {
class AudioFrame;
-class Beamformer;
+class NonlinearBeamformer;
class EchoCancellation;
class EchoControlMobile;
class GainControl;
@@ -201,7 +201,8 @@
// Allows passing in an optional configuration at create-time.
static AudioProcessing* Create(const Config& config);
// Only for testing.
- static AudioProcessing* Create(const Config& config, Beamformer* beamformer);
+ static AudioProcessing* Create(const Config& config,
+ NonlinearBeamformer* beamformer);
virtual ~AudioProcessing() {}
// Initializes internal states, while retaining all user settings. This
diff --git a/webrtc/modules/audio_processing/test/audio_processing_unittest.cc b/webrtc/modules/audio_processing/test/audio_processing_unittest.cc
index b034f5f..6546cfa 100644
--- a/webrtc/modules/audio_processing/test/audio_processing_unittest.cc
+++ b/webrtc/modules/audio_processing/test/audio_processing_unittest.cc
@@ -19,7 +19,7 @@
#include "webrtc/common_audio/resampler/include/push_resampler.h"
#include "webrtc/common_audio/resampler/push_sinc_resampler.h"
#include "webrtc/common_audio/signal_processing/include/signal_processing_library.h"
-#include "webrtc/modules/audio_processing/beamformer/mock_beamformer.h"
+#include "webrtc/modules/audio_processing/beamformer/mock_nonlinear_beamformer.h"
#include "webrtc/modules/audio_processing/common.h"
#include "webrtc/modules/audio_processing/include/audio_processing.h"
#include "webrtc/modules/audio_processing/test/test_utils.h"
@@ -1228,8 +1228,8 @@
geometry.push_back(webrtc::Point(0.f, 0.f, 0.f));
geometry.push_back(webrtc::Point(0.05f, 0.f, 0.f));
config.Set<Beamforming>(new Beamforming(true, geometry));
- testing::NiceMock<MockBeamformer>* beamformer =
- new testing::NiceMock<MockBeamformer>(geometry);
+ testing::NiceMock<MockNonlinearBeamformer>* beamformer =
+ new testing::NiceMock<MockNonlinearBeamformer>(geometry);
rtc::scoped_ptr<AudioProcessing> apm(
AudioProcessing::Create(config, beamformer));
EXPECT_EQ(kNoErr, apm->gain_control()->Enable(true));
diff --git a/webrtc/modules/modules.gyp b/webrtc/modules/modules.gyp
index 40b06af..7cf263c 100644
--- a/webrtc/modules/modules.gyp
+++ b/webrtc/modules/modules.gyp
@@ -170,8 +170,8 @@
'audio_processing/beamformer/complex_matrix_unittest.cc',
'audio_processing/beamformer/covariance_matrix_generator_unittest.cc',
'audio_processing/beamformer/matrix_unittest.cc',
- 'audio_processing/beamformer/mock_beamformer.cc',
- 'audio_processing/beamformer/mock_beamformer.h',
+ 'audio_processing/beamformer/mock_nonlinear_beamformer.cc',
+ 'audio_processing/beamformer/mock_nonlinear_beamformer.h',
'audio_processing/beamformer/pcm_utils.cc',
'audio_processing/beamformer/pcm_utils.h',
'audio_processing/echo_cancellation_impl_unittest.cc',