summaryrefslogtreecommitdiffstats
path: root/voip/jni
diff options
context:
space:
mode:
authorChia-chi Yeh <chiachi@android.com>2010-11-30 16:23:17 -0800
committerAndroid Git Automerger <android-git-automerger@android.com>2010-11-30 16:23:17 -0800
commit342a9be0096752aa0ae80120a64751a7d0b9e7a2 (patch)
tree465a8a636ff9ab30b0df768f22891bceffb20e21 /voip/jni
parenta5e22df10a791a9bdffec1be8413cc67cd40f86a (diff)
parente843dfa8dcd0a7bfa956b75424bb5db834975a64 (diff)
downloadframeworks_base-342a9be0096752aa0ae80120a64751a7d0b9e7a2.zip
frameworks_base-342a9be0096752aa0ae80120a64751a7d0b9e7a2.tar.gz
frameworks_base-342a9be0096752aa0ae80120a64751a7d0b9e7a2.tar.bz2
am e843dfa8: am bd399b0b: Merge "RTP: Pause echo suppressor when far-end volume is low." into gingerbread
* commit 'e843dfa8dcd0a7bfa956b75424bb5db834975a64': RTP: Pause echo suppressor when far-end volume is low.
Diffstat (limited to 'voip/jni')
-rw-r--r--voip/jni/rtp/EchoSuppressor.cpp21
1 files changed, 13 insertions, 8 deletions
diff --git a/voip/jni/rtp/EchoSuppressor.cpp b/voip/jni/rtp/EchoSuppressor.cpp
index 4cff588..6127d3c 100644
--- a/voip/jni/rtp/EchoSuppressor.cpp
+++ b/voip/jni/rtp/EchoSuppressor.cpp
@@ -161,22 +161,27 @@ void EchoSuppressor::run(int16_t *playbacked, int16_t *recorded)
}
// Compute correlations.
- float corr2 = 0.0f;
int latency = 0;
+ float corr2 = 0.0f;
+ float varX = 0.0f;
float varY = mY2Sum - mWeight * mYSum * mYSum;
for (int i = mTailLength - 1; i >= 0; --i) {
- float varX = mX2Sums[i] - mWeight * mXSums[i] * mXSums[i];
float cov = mXYSums[i] - mWeight * mXSums[i] * mYSum;
- float c2 = cov * cov / (varX * varY + 1);
- if (c2 > corr2) {
- corr2 = c2;
- latency = i;
+ if (cov > 0.0f) {
+ float varXi = mX2Sums[i] - mWeight * mXSums[i] * mXSums[i];
+ float corr2i = cov * cov / (varXi * varY + 1);
+ if (corr2i > corr2) {
+ varX = varXi;
+ corr2 = corr2i;
+ latency = i;
+ }
}
}
- //LOGI("correlation^2 = %.10f, latency = %d", corr2, latency * mScale);
+ //LOGI("corr^2 %.5f, var %8.0f %8.0f, latency %d", corr2, varX, varY,
+ // latency * mScale);
// Do echo suppression.
- if (corr2 > 0.1f) {
+ if (corr2 > 0.1f && varX > 10000.0f) {
int factor = (corr2 > 1.0f) ? 0 : (1.0f - sqrtf(corr2)) * 4096;
for (int i = 0; i < mSampleCount; ++i) {
recorded[i] = recorded[i] * factor >> 16;