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

Unified Diff: webrtc/modules/audio_processing/beamformer/covariance_matrix_generator.cc

Issue 1378973003: Implement new version of the NonlinearBeamformer (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/audio_processing/beamformer/covariance_matrix_generator.cc
diff --git a/webrtc/modules/audio_processing/beamformer/covariance_matrix_generator.cc b/webrtc/modules/audio_processing/beamformer/covariance_matrix_generator.cc
index efc5b0f71afd5b04782bd238e26bc78784d38da0..34a08650e1ead1aa20147c9fc17c6f2a80fe14c1 100644
--- a/webrtc/modules/audio_processing/beamformer/covariance_matrix_generator.cc
+++ b/webrtc/modules/audio_processing/beamformer/covariance_matrix_generator.cc
@@ -14,6 +14,7 @@
#include <cmath>
+namespace webrtc {
namespace {
float BesselJ0(float x) {
@@ -24,9 +25,18 @@ float BesselJ0(float x) {
#endif
}
-} // namespace
+float norm(const ComplexMatrix<float>& x) {
Andrew MacDonald 2015/10/06 23:54:31 Norm Add a comment clarifying what it computes.
aluebs-webrtc 2015/10/07 22:08:05 Changed naming and added documentation. Yes, it on
+ RTC_CHECK_EQ(1, x.num_rows());
+ size_t length = x.num_columns();
Andrew MacDonald 2015/10/06 23:54:31 const
aluebs-webrtc 2015/10/07 22:08:05 Done.
+ const complex<float>* elems = x.elements()[0];
+ float result = 0.f;
+ for (size_t i = 0u; i < length; ++i) {
+ result += std::abs(elems[i]) * std::abs(elems[i]);
Andrew MacDonald 2015/10/06 23:54:31 Don't compute std::abs twice. Looks like what you
aluebs-webrtc 2015/10/07 22:08:05 Good point. Done.
+ }
+ return std::sqrt(result);
+}
-namespace webrtc {
+} // namespace
void CovarianceMatrixGenerator::UniformCovarianceMatrix(
float wave_number,
@@ -69,6 +79,8 @@ void CovarianceMatrixGenerator::AngledCovarianceMatrix(
geometry,
angle,
&interf_cov_vector);
+ complex<float> norm_factor = norm(interf_cov_vector);
+ interf_cov_vector.Scale(1.f / norm_factor);
interf_cov_vector_transposed.Transpose(interf_cov_vector);
interf_cov_vector.PointwiseConjugate();
mat->Multiply(interf_cov_vector_transposed, interf_cov_vector);

Powered by Google App Engine
This is Rietveld 408576698