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
This commit is contained in:
aluebs@webrtc.org 2015-02-11 00:48:10 +00:00
parent bc35703694
commit 5d608955cf
2 changed files with 5 additions and 15 deletions

View File

@ -295,17 +295,12 @@ void Beamformer::ProcessChunk(const float* const* input,
CHECK_EQ(num_input_channels, num_input_channels_); CHECK_EQ(num_input_channels, num_input_channels_);
CHECK_EQ(num_frames_per_band, chunk_length_); CHECK_EQ(num_frames_per_band, chunk_length_);
num_blocks_in_this_chunk_ = 0;
float old_high_pass_mask = high_pass_postfilter_mask_; 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); lapped_transform_->ProcessChunk(input, output);
// Apply delay and sum and post-filter in the time domain. WARNING: only works // Apply delay and sum and post-filter in the time domain. WARNING: only works
// because delay-and-sum is not frequency dependent. // because delay-and-sum is not frequency dependent.
if (high_pass_exists_) { if (high_pass_split_input != NULL) {
high_pass_postfilter_mask_ /= num_blocks_in_this_chunk_;
if (previous_block_ix_ == -1) { if (previous_block_ix_ == -1) {
old_high_pass_mask = high_pass_postfilter_mask_; 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_; previous_block_ix_ = current_block_ix_;
current_block_ix_ = (current_block_ix_ + 1) % kNumberSavedPostfilterMasks; current_block_ix_ = (current_block_ix_ + 1) % kNumberSavedPostfilterMasks;
num_blocks_in_this_chunk_++;
} }
float Beamformer::CalculatePostfilterMask(const ComplexMatrixF& interf_cov_mat, float Beamformer::CalculatePostfilterMask(const ComplexMatrixF& interf_cov_mat,
@ -457,19 +451,17 @@ void Beamformer::ApplyLowFrequencyCorrection() {
} }
void Beamformer::ApplyHighFrequencyCorrection() { 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]; float* mask_els = postfilter_masks_[current_block_ix_].elements()[0];
for (int i = high_average_start_bin_; i < high_average_end_bin_; ++i) { 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) { 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. // This method CHECKs for a uniform linear array.

View File

@ -160,8 +160,6 @@ class Beamformer : public LappedTransform::Callback {
ComplexMatrixF eig_m_; ComplexMatrixF eig_m_;
// For processing the high-frequency input signal. // For processing the high-frequency input signal.
bool high_pass_exists_;
int num_blocks_in_this_chunk_;
float high_pass_postfilter_mask_; float high_pass_postfilter_mask_;
// True when the target signal is present. // True when the target signal is present.