Make sure that the norms are positive in Beamformer

This has a bit exact output, but is just to be sure that there are no nummerical errors when the covariance matrices are nearly singular.

R=andrew@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/39019004

Cr-Commit-Position: refs/heads/master@{#8316}
git-svn-id: http://webrtc.googlecode.com/svn/trunk@8316 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
aluebs@webrtc.org 2015-02-10 22:38:05 +00:00
parent b6856d2823
commit 91ba79ae3f

View File

@ -76,6 +76,7 @@ const float kHoldTargetSeconds = 0.25f;
// Does conjugate(|norm_mat|) * |mat| * transpose(|norm_mat|). No extra space is
// used; to accomplish this, we compute both multiplications in the same loop.
// The returned norm is clamped to be non-negative.
float Norm(const ComplexMatrix<float>& mat,
const ComplexMatrix<float>& norm_mat) {
CHECK_EQ(norm_mat.num_rows(), 1);
@ -97,7 +98,7 @@ float Norm(const ComplexMatrix<float>& mat,
second_product += first_product * norm_mat_els[0][i];
first_product = 0.f;
}
return second_product.real();
return std::max(second_product.real(), 0.f);
}
// Does conjugate(|lhs|) * |rhs| for row vectors |lhs| and |rhs|.
@ -352,7 +353,7 @@ void Beamformer::ProcessAudioBlock(const complex_f* const* input,
float rxim = Norm(target_cov_mats_[i], eig_m_);
float ratio_rxiw_rxim = 0.f;
if (rxim != 0.f) {
if (rxim > 0.f) {
ratio_rxiw_rxim = rxiws_[i] / rxim;
}
@ -398,7 +399,10 @@ float Beamformer::CalculatePostfilterMask(const ComplexMatrixF& interf_cov_mat,
float rpsim = Norm(interf_cov_mat, eig_m_);
// Find lambda.
float ratio = rpsiw / rpsim;
float ratio = 0.f;
if (rpsim > 0.f) {
ratio = rpsiw / rpsim;
}
float numerator = rmw_r - ratio;
float denominator = ratio_rxiw_rxim - ratio;