Index: webrtc/modules/audio_processing/intelligibility/intelligibility_utils.cc |
diff --git a/webrtc/modules/audio_processing/intelligibility/intelligibility_utils.cc b/webrtc/modules/audio_processing/intelligibility/intelligibility_utils.cc |
index d67d200689f1613391c18c138b55f504a18ffde4..ccbee85724c1be53b210dd06aa92e50ed305c523 100644 |
--- a/webrtc/modules/audio_processing/intelligibility/intelligibility_utils.cc |
+++ b/webrtc/modules/audio_processing/intelligibility/intelligibility_utils.cc |
@@ -15,6 +15,7 @@ |
#include "webrtc/modules/audio_processing/intelligibility/intelligibility_utils.h" |
#include <math.h> |
+#include <stdlib.h> |
#include <string.h> |
#include <algorithm> |
@@ -31,26 +32,10 @@ float UpdateFactor(float target, float current, float limit) { |
return current + sign * fminf(delta, limit); |
} |
-bool cplxfinite(complex<float> c) { |
- return std::isfinite(c.real()) && std::isfinite(c.imag()); |
-} |
- |
-bool cplxnormal(complex<float> c) { |
- return std::isnormal(c.real()) && std::isnormal(c.imag()); |
-} |
- |
complex<float> zerofudge(complex<float> c) { |
- const static complex<float> fudge[7] = {{0.001f, 0.002f}, |
- {0.008f, 0.001f}, |
- {0.003f, 0.008f}, |
- {0.0006f, 0.0009f}, |
- {0.001f, 0.004f}, |
- {0.003f, 0.004f}, |
- {0.002f, 0.009f}}; |
- static int fudge_index = 0; |
- if (cplxfinite(c) && !cplxnormal(c)) { |
- fudge_index = (fudge_index + 1) % 7; |
- return c + fudge[fudge_index]; |
+ if (c.real() == 0.f || c.imag() == 0.f) { |
+ auto float_rand = []() { return std::rand() * 0.01f / RAND_MAX; }; |
+ return c + std::complex<float>(float_rand(),float_rand()); |
Andrew MacDonald
2015/07/22 23:35:00
This would overwrite a valid component in the case
ekm
2015/07/23 00:06:26
Fixed. Used your suggested template.
|
} |
return c; |
} |
@@ -137,9 +122,6 @@ void VarianceArray::InfiniteStep(const complex<float>* data, bool skip_fudge) { |
.real(); |
variance_[i] = |
conj_sum_[i] / (count_ - 1); // + fudge[fudge_index].real(); |
- if (skip_fudge && false) { |
- // variance_[i] -= fudge[fudge_index].real(); |
- } |
} |
array_mean_ += (variance_[i] - array_mean_) / (i + 1); |
} |
@@ -152,7 +134,7 @@ void VarianceArray::DecayStep(const complex<float>* data, bool /*dummy*/) { |
++count_; |
for (int i = 0; i < freqs_; ++i) { |
complex<float> sample = data[i]; |
- sample = zerofudge(sample); |
+ //sample = zerofudge(sample); |
Andrew MacDonald
2015/07/22 23:35:00
You didn't mean to leave this commented, right? Or
ekm
2015/07/23 00:06:26
Done.
|
if (count_ == 1) { |
running_mean_[i] = sample; |