From 5d608955cfc05b9bd177d04bbe0e1df0ab34354a Mon Sep 17 00:00:00 2001 From: "aluebs@webrtc.org" Date: Wed, 11 Feb 2015 00:48:10 +0000 Subject: [PATCH] Fix bug when there are no blocks in a chunk in Beamformer R=andrew@webrtc.org Review URL: https://webrtc-codereview.appspot.com/37119004 Cr-Commit-Position: refs/heads/master@{#8321} git-svn-id: http://webrtc.googlecode.com/svn/trunk@8321 4adac7df-926f-26a2-2b94-8c16560cd09d --- .../audio_processing/beamformer/beamformer.cc | 18 +++++------------- .../audio_processing/beamformer/beamformer.h | 2 -- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/webrtc/modules/audio_processing/beamformer/beamformer.cc b/webrtc/modules/audio_processing/beamformer/beamformer.cc index a52accb89..ca18cb479 100644 --- a/webrtc/modules/audio_processing/beamformer/beamformer.cc +++ b/webrtc/modules/audio_processing/beamformer/beamformer.cc @@ -295,17 +295,12 @@ void Beamformer::ProcessChunk(const float* const* input, CHECK_EQ(num_input_channels, num_input_channels_); CHECK_EQ(num_frames_per_band, chunk_length_); - num_blocks_in_this_chunk_ = 0; float old_high_pass_mask = high_pass_postfilter_mask_; - high_pass_postfilter_mask_ = 0.f; - high_pass_exists_ = high_pass_split_input != NULL; lapped_transform_->ProcessChunk(input, output); // Apply delay and sum and post-filter in the time domain. WARNING: only works // because delay-and-sum is not frequency dependent. - if (high_pass_exists_) { - high_pass_postfilter_mask_ /= num_blocks_in_this_chunk_; - + if (high_pass_split_input != NULL) { if (previous_block_ix_ == -1) { old_high_pass_mask = high_pass_postfilter_mask_; } @@ -388,7 +383,6 @@ void Beamformer::ProcessAudioBlock(const complex_f* const* input, previous_block_ix_ = current_block_ix_; current_block_ix_ = (current_block_ix_ + 1) % kNumberSavedPostfilterMasks; - num_blocks_in_this_chunk_++; } float Beamformer::CalculatePostfilterMask(const ComplexMatrixF& interf_cov_mat, @@ -457,19 +451,17 @@ void Beamformer::ApplyLowFrequencyCorrection() { } void Beamformer::ApplyHighFrequencyCorrection() { - float high_pass_mask = 0.f; + high_pass_postfilter_mask_ = 0.f; float* mask_els = postfilter_masks_[current_block_ix_].elements()[0]; for (int i = high_average_start_bin_; i < high_average_end_bin_; ++i) { - high_pass_mask += mask_els[i]; + high_pass_postfilter_mask_ += mask_els[i]; } - high_pass_mask /= high_average_end_bin_ - high_average_start_bin_; + high_pass_postfilter_mask_ /= high_average_end_bin_ - high_average_start_bin_; for (int i = high_average_end_bin_; i < kNumFreqBins; ++i) { - mask_els[i] = high_pass_mask; + mask_els[i] = high_pass_postfilter_mask_; } - - high_pass_postfilter_mask_ += high_pass_mask; } // This method CHECKs for a uniform linear array. diff --git a/webrtc/modules/audio_processing/beamformer/beamformer.h b/webrtc/modules/audio_processing/beamformer/beamformer.h index 574e121cb..37c26a892 100644 --- a/webrtc/modules/audio_processing/beamformer/beamformer.h +++ b/webrtc/modules/audio_processing/beamformer/beamformer.h @@ -160,8 +160,6 @@ class Beamformer : public LappedTransform::Callback { ComplexMatrixF eig_m_; // For processing the high-frequency input signal. - bool high_pass_exists_; - int num_blocks_in_this_chunk_; float high_pass_postfilter_mask_; // True when the target signal is present.