Index: webrtc/modules/audio_processing/intelligibility/intelligibility_enhancer_unittest.cc |
diff --git a/webrtc/modules/audio_processing/intelligibility/intelligibility_enhancer_unittest.cc b/webrtc/modules/audio_processing/intelligibility/intelligibility_enhancer_unittest.cc |
index 436d174775922c95a059b9dc13b7fe9ae6d8a01b..ab071258ad2658fe34e9d267c77e3c921bb5b3b3 100644 |
--- a/webrtc/modules/audio_processing/intelligibility/intelligibility_enhancer_unittest.cc |
+++ b/webrtc/modules/audio_processing/intelligibility/intelligibility_enhancer_unittest.cc |
@@ -8,10 +8,6 @@ |
* be found in the AUTHORS file in the root of the source tree. |
*/ |
-// |
-// Unit tests for intelligibility enhancer. |
-// |
- |
#include <math.h> |
#include <stdlib.h> |
#include <algorithm> |
@@ -63,14 +59,14 @@ const float kTestZeroVar[] = {1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, |
1.f, 1.f, 1.f, 0.f, 0.f, 0.f, 0.f, 0.f, |
0.f, 0.f, 0.f, 0.f, 0.f, 0.f}; |
static_assert(arraysize(kTestCenterFreqs) == arraysize(kTestZeroVar), |
- "Variance test data badly initialized."); |
+ "Power test data badly initialized."); |
const float kTestNonZeroVarLambdaTop[] = { |
1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, |
1.f, 1.f, 1.f, 0.f, 0.f, 0.0351f, 0.0636f, 0.0863f, |
0.1037f, 0.1162f, 0.1236f, 0.1251f, 0.1189f, 0.0993f}; |
static_assert(arraysize(kTestCenterFreqs) == |
arraysize(kTestNonZeroVarLambdaTop), |
- "Variance test data badly initialized."); |
+ "Power test data badly initialized."); |
const float kMaxTestError = 0.005f; |
// Enhancer initialization parameters. |
@@ -81,9 +77,6 @@ const int kFragmentSize = kSampleRate / 100; |
} // namespace |
-using std::vector; |
-using intelligibility::VarianceArray; |
- |
class IntelligibilityEnhancerTest : public ::testing::Test { |
protected: |
IntelligibilityEnhancerTest() |
@@ -92,9 +85,8 @@ class IntelligibilityEnhancerTest : public ::testing::Test { |
enh_.reset(new IntelligibilityEnhancer(config_)); |
} |
- bool CheckUpdate(VarianceArray::StepType step_type) { |
+ bool CheckUpdate() { |
config_.sample_rate_hz = kSampleRate; |
- config_.var_type = step_type; |
enh_.reset(new IntelligibilityEnhancer(config_)); |
float* clear_cursor = &clear_data_[0]; |
float* noise_cursor = &noise_data_[0]; |
@@ -113,37 +105,25 @@ class IntelligibilityEnhancerTest : public ::testing::Test { |
IntelligibilityEnhancer::Config config_; |
rtc::scoped_ptr<IntelligibilityEnhancer> enh_; |
- vector<float> clear_data_; |
- vector<float> noise_data_; |
- vector<float> orig_data_; |
+ std::vector<float> clear_data_; |
+ std::vector<float> noise_data_; |
+ std::vector<float> orig_data_; |
}; |
-// For each class of generated data, tests that render stream is |
-// updated when it should be for each variance update method. |
+// For each class of generated data, tests that render stream is updated when |
+// it should be. |
TEST_F(IntelligibilityEnhancerTest, TestRenderUpdate) { |
- vector<VarianceArray::StepType> step_types; |
- step_types.push_back(VarianceArray::kStepInfinite); |
- step_types.push_back(VarianceArray::kStepDecaying); |
- step_types.push_back(VarianceArray::kStepWindowed); |
- step_types.push_back(VarianceArray::kStepBlocked); |
- step_types.push_back(VarianceArray::kStepBlockBasedMovingAverage); |
std::fill(noise_data_.begin(), noise_data_.end(), 0.0f); |
std::fill(orig_data_.begin(), orig_data_.end(), 0.0f); |
- for (auto step_type : step_types) { |
- std::fill(clear_data_.begin(), clear_data_.end(), 0.0f); |
- EXPECT_FALSE(CheckUpdate(step_type)); |
- } |
+ std::fill(clear_data_.begin(), clear_data_.end(), 0.0f); |
+ EXPECT_FALSE(CheckUpdate()); |
std::srand(1); |
auto float_rand = []() { return std::rand() * 2.f / RAND_MAX - 1; }; |
std::generate(noise_data_.begin(), noise_data_.end(), float_rand); |
- for (auto step_type : step_types) { |
- EXPECT_FALSE(CheckUpdate(step_type)); |
- } |
- for (auto step_type : step_types) { |
- std::generate(clear_data_.begin(), clear_data_.end(), float_rand); |
- orig_data_ = clear_data_; |
- EXPECT_TRUE(CheckUpdate(step_type)); |
- } |
+ EXPECT_FALSE(CheckUpdate()); |
+ std::generate(clear_data_.begin(), clear_data_.end(), float_rand); |
+ orig_data_ = clear_data_; |
+ EXPECT_TRUE(CheckUpdate()); |
} |
// Tests ERB bank creation, comparing against matlab output. |
@@ -163,11 +143,11 @@ TEST_F(IntelligibilityEnhancerTest, TestErbCreation) { |
// against matlab output. |
TEST_F(IntelligibilityEnhancerTest, TestSolveForGains) { |
ASSERT_EQ(kTestStartFreq, enh_->start_freq_); |
- vector<float> sols(enh_->bank_size_); |
+ std::vector<float> sols(enh_->bank_size_); |
float lambda = -0.001f; |
for (size_t i = 0; i < enh_->bank_size_; i++) { |
- enh_->filtered_clear_var_[i] = 0.0f; |
- enh_->filtered_noise_var_[i] = 0.0f; |
+ enh_->filtered_clear_pow_[i] = 0.0f; |
+ enh_->filtered_noise_pow_[i] = 0.0f; |
enh_->rho_[i] = 0.02f; |
} |
enh_->SolveForGainsGivenLambda(lambda, enh_->start_freq_, &sols[0]); |
@@ -175,8 +155,8 @@ TEST_F(IntelligibilityEnhancerTest, TestSolveForGains) { |
EXPECT_NEAR(kTestZeroVar[i], sols[i], kMaxTestError); |
} |
for (size_t i = 0; i < enh_->bank_size_; i++) { |
- enh_->filtered_clear_var_[i] = static_cast<float>(i + 1); |
- enh_->filtered_noise_var_[i] = static_cast<float>(enh_->bank_size_ - i); |
+ enh_->filtered_clear_pow_[i] = static_cast<float>(i + 1); |
+ enh_->filtered_noise_pow_[i] = static_cast<float>(enh_->bank_size_ - i); |
} |
enh_->SolveForGainsGivenLambda(lambda, enh_->start_freq_, &sols[0]); |
for (size_t i = 0; i < enh_->bank_size_; i++) { |