Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(157)

Unified Diff: webrtc/modules/audio_processing/intelligibility/intelligibility_enhancer_unittest.cc

Issue 2320833002: Compensate for the IntelligibilityEnhancer processing delay in high bands (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 45f338c642540acaabf8fb96652b55c28f51cce0..cc9aa128b28f1a17f9d39ee4d7465b289c251aad 100644
--- a/webrtc/modules/audio_processing/intelligibility/intelligibility_enhancer_unittest.cc
+++ b/webrtc/modules/audio_processing/intelligibility/intelligibility_enhancer_unittest.cc
@@ -202,7 +202,7 @@ static_assert(arraysize(kTestCenterFreqs) ==
const float kMaxTestError = 0.005f;
// Enhancer initialization parameters.
-const int kSamples = 1000;
+const int kSamples = 10000;
const int kSampleRate = 4000;
const int kNumChannels = 1;
const int kFragmentSize = kSampleRate / 100;
@@ -229,9 +229,7 @@ void ProcessOneFrame(int sample_rate_hz,
}
intelligibility_enhancer->ProcessRenderAudio(
- render_audio_buffer->split_channels_f(kBand0To8kHz),
- IntelligibilityEnhancerSampleRate(sample_rate_hz),
- render_audio_buffer->num_channels());
+ render_audio_buffer, IntelligibilityEnhancerSampleRate(sample_rate_hz));
noise_suppressor->AnalyzeCaptureAudio(capture_audio_buffer);
noise_suppressor->ProcessCaptureAudio(capture_audio_buffer);
@@ -320,7 +318,15 @@ float float_rand() {
class IntelligibilityEnhancerTest : public ::testing::Test {
protected:
IntelligibilityEnhancerTest()
- : clear_data_(kSamples), noise_data_(kSamples), orig_data_(kSamples) {
+ : clear_buffer_(kFragmentSize,
+ kNumChannels,
+ kFragmentSize,
+ kNumChannels,
+ kFragmentSize),
+ stream_config_(kSampleRate, kNumChannels),
+ clear_data_(kSamples),
+ noise_data_(kNumNoiseBins),
+ orig_data_(kSamples) {
std::srand(1);
enh_.reset(
new IntelligibilityEnhancer(kSampleRate, kNumChannels, kNumNoiseBins));
@@ -330,11 +336,12 @@ class IntelligibilityEnhancerTest : public ::testing::Test {
enh_.reset(
new IntelligibilityEnhancer(kSampleRate, kNumChannels, kNumNoiseBins));
float* clear_cursor = clear_data_.data();
- float* noise_cursor = noise_data_.data();
for (int i = 0; i < kSamples; i += kFragmentSize) {
- enh_->ProcessRenderAudio(&clear_cursor, kSampleRate, kNumChannels);
+ enh_->SetCaptureNoiseEstimate(noise_data_, 1);
+ clear_buffer_.CopyFrom(&clear_cursor, stream_config_);
+ enh_->ProcessRenderAudio(&clear_buffer_, kSampleRate);
+ clear_buffer_.CopyTo(stream_config_, &clear_cursor);
clear_cursor += kFragmentSize;
- noise_cursor += kFragmentSize;
}
for (int i = 0; i < kSamples; i++) {
if (std::fabs(clear_data_[i] - orig_data_[i]) > kMaxTestError) {
@@ -345,6 +352,8 @@ class IntelligibilityEnhancerTest : public ::testing::Test {
}
std::unique_ptr<IntelligibilityEnhancer> enh_;
+ AudioBuffer clear_buffer_;
+ StreamConfig stream_config_;
std::vector<float> clear_data_;
std::vector<float> noise_data_;
std::vector<float> orig_data_;
@@ -357,10 +366,11 @@ TEST_F(IntelligibilityEnhancerTest, TestRenderUpdate) {
std::fill(orig_data_.begin(), orig_data_.end(), 0.f);
std::fill(clear_data_.begin(), clear_data_.end(), 0.f);
EXPECT_FALSE(CheckUpdate());
- std::generate(noise_data_.begin(), noise_data_.end(), float_rand);
- EXPECT_FALSE(CheckUpdate());
std::generate(clear_data_.begin(), clear_data_.end(), float_rand);
orig_data_ = clear_data_;
+ EXPECT_FALSE(CheckUpdate());
+ std::generate(noise_data_.begin(), noise_data_.end(), float_rand);
+ FloatToFloatS16(noise_data_.data(), noise_data_.size(), noise_data_.data());
EXPECT_TRUE(CheckUpdate());
}
@@ -418,7 +428,8 @@ TEST_F(IntelligibilityEnhancerTest, TestNoiseGainHasExpectedResult) {
float* clear_cursor = clear_data_.data();
for (size_t i = 0; i < kNumFramesToProcess; ++i) {
enh_->SetCaptureNoiseEstimate(noise, kGain);
- enh_->ProcessRenderAudio(&clear_cursor, kSampleRate, kNumChannels);
+ clear_buffer_.CopyFrom(&clear_cursor, stream_config_);
+ enh_->ProcessRenderAudio(&clear_buffer_, kSampleRate);
}
const std::vector<float>& estimated_psd =
enh_->noise_power_estimator_.power();

Powered by Google App Engine
This is Rietveld 408576698