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

Side by Side Diff: webrtc/modules/audio_processing/beamformer/nonlinear_beamformer.cc

Issue 1534193008: Misc. small cleanups (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Unnecessary parens Created 4 years, 11 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) 2014 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2014 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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 const complex<float>* in_elements = in.elements()[0]; 156 const complex<float>* in_elements = in.elements()[0];
157 complex<float>* const* out_elements = out->elements(); 157 complex<float>* const* out_elements = out->elements();
158 for (int i = 0; i < out->num_rows(); ++i) { 158 for (int i = 0; i < out->num_rows(); ++i) {
159 for (int j = 0; j < out->num_columns(); ++j) { 159 for (int j = 0; j < out->num_columns(); ++j) {
160 out_elements[i][j] = in_elements[i] * conj(in_elements[j]); 160 out_elements[i][j] = in_elements[i] * conj(in_elements[j]);
161 } 161 }
162 } 162 }
163 } 163 }
164 164
165 std::vector<Point> GetCenteredArray(std::vector<Point> array_geometry) { 165 std::vector<Point> GetCenteredArray(std::vector<Point> array_geometry) {
166 for (int dim = 0; dim < 3; ++dim) { 166 for (size_t dim = 0; dim < 3; ++dim) {
167 float center = 0.f; 167 float center = 0.f;
168 for (size_t i = 0; i < array_geometry.size(); ++i) { 168 for (size_t i = 0; i < array_geometry.size(); ++i) {
169 center += array_geometry[i].c[dim]; 169 center += array_geometry[i].c[dim];
170 } 170 }
171 center /= array_geometry.size(); 171 center /= array_geometry.size();
172 for (size_t i = 0; i < array_geometry.size(); ++i) { 172 for (size_t i = 0; i < array_geometry.size(); ++i) {
173 array_geometry[i].c[dim] -= center; 173 array_geometry[i].c[dim] -= center;
174 } 174 }
175 } 175 }
176 return array_geometry; 176 return array_geometry;
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 RTC_DCHECK_EQ(input.num_frames_per_band(), chunk_length_); 372 RTC_DCHECK_EQ(input.num_frames_per_band(), chunk_length_);
373 373
374 float old_high_pass_mask = high_pass_postfilter_mask_; 374 float old_high_pass_mask = high_pass_postfilter_mask_;
375 lapped_transform_->ProcessChunk(input.channels(0), output->channels(0)); 375 lapped_transform_->ProcessChunk(input.channels(0), output->channels(0));
376 // Ramp up/down for smoothing. 1 mask per 10ms results in audible 376 // Ramp up/down for smoothing. 1 mask per 10ms results in audible
377 // discontinuities. 377 // discontinuities.
378 const float ramp_increment = 378 const float ramp_increment =
379 (high_pass_postfilter_mask_ - old_high_pass_mask) / 379 (high_pass_postfilter_mask_ - old_high_pass_mask) /
380 input.num_frames_per_band(); 380 input.num_frames_per_band();
381 // Apply the smoothed high-pass mask to the first channel of each band. 381 // Apply the smoothed high-pass mask to the first channel of each band.
382 // This can be done because the effct of the linear beamformer is negligible 382 // This can be done because the effect of the linear beamformer is negligible
383 // compared to the post-filter. 383 // compared to the post-filter.
384 for (size_t i = 1; i < input.num_bands(); ++i) { 384 for (size_t i = 1; i < input.num_bands(); ++i) {
385 float smoothed_mask = old_high_pass_mask; 385 float smoothed_mask = old_high_pass_mask;
386 for (size_t j = 0; j < input.num_frames_per_band(); ++j) { 386 for (size_t j = 0; j < input.num_frames_per_band(); ++j) {
387 smoothed_mask += ramp_increment; 387 smoothed_mask += ramp_increment;
388 output->channels(i)[0][j] = input.channels(i)[0][j] * smoothed_mask; 388 output->channels(i)[0][j] = input.channels(i)[0][j] * smoothed_mask;
389 } 389 }
390 } 390 }
391 } 391 }
392 392
(...skipping 12 matching lines...) Expand all
405 // you are out of the beam. 405 // you are out of the beam.
406 return fabs(spherical_point.azimuth() - target_angle_radians_) < 406 return fabs(spherical_point.azimuth() - target_angle_radians_) <
407 kHalfBeamWidthRadians; 407 kHalfBeamWidthRadians;
408 } 408 }
409 409
410 void NonlinearBeamformer::ProcessAudioBlock(const complex_f* const* input, 410 void NonlinearBeamformer::ProcessAudioBlock(const complex_f* const* input,
411 int num_input_channels, 411 int num_input_channels,
412 size_t num_freq_bins, 412 size_t num_freq_bins,
413 int num_output_channels, 413 int num_output_channels,
414 complex_f* const* output) { 414 complex_f* const* output) {
415 RTC_CHECK_EQ(num_freq_bins, kNumFreqBins); 415 RTC_CHECK_EQ(kNumFreqBins, num_freq_bins);
416 RTC_CHECK_EQ(num_input_channels, num_input_channels_); 416 RTC_CHECK_EQ(num_input_channels_, num_input_channels);
417 RTC_CHECK_EQ(num_output_channels, 1); 417 RTC_CHECK_EQ(1, num_output_channels);
418 418
419 // Calculating the post-filter masks. Note that we need two for each 419 // Calculating the post-filter masks. Note that we need two for each
420 // frequency bin to account for the positive and negative interferer 420 // frequency bin to account for the positive and negative interferer
421 // angle. 421 // angle.
422 for (size_t i = low_mean_start_bin_; i <= high_mean_end_bin_; ++i) { 422 for (size_t i = low_mean_start_bin_; i <= high_mean_end_bin_; ++i) {
423 eig_m_.CopyFromColumn(input, i, num_input_channels_); 423 eig_m_.CopyFromColumn(input, i, num_input_channels_);
424 float eig_m_norm_factor = std::sqrt(SumSquares(eig_m_)); 424 float eig_m_norm_factor = std::sqrt(SumSquares(eig_m_));
425 if (eig_m_norm_factor != 0.f) { 425 if (eig_m_norm_factor != 0.f) {
426 eig_m_.Scale(1.f / eig_m_norm_factor); 426 eig_m_.Scale(1.f / eig_m_norm_factor);
427 } 427 }
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 new_mask_ + high_mean_end_bin_ + 1); 561 new_mask_ + high_mean_end_bin_ + 1);
562 if (new_mask_[quantile] > kMaskTargetThreshold) { 562 if (new_mask_[quantile] > kMaskTargetThreshold) {
563 is_target_present_ = true; 563 is_target_present_ = true;
564 interference_blocks_count_ = 0; 564 interference_blocks_count_ = 0;
565 } else { 565 } else {
566 is_target_present_ = interference_blocks_count_++ < hold_target_blocks_; 566 is_target_present_ = interference_blocks_count_++ < hold_target_blocks_;
567 } 567 }
568 } 568 }
569 569
570 } // namespace webrtc 570 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/audio_processing/audio_processing_impl_locking_unittest.cc ('k') | webrtc/modules/audio_processing/common.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698