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

Unified Diff: webrtc/modules/audio_processing/level_controller/level_controller_unittest.cc

Issue 2337083002: Reland of added functionality for specifying the initial signal level to use for the gain estimation (Closed)
Patch Set: Changed parameter name from initial_level to the more correct initial_peak_level 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/level_controller/level_controller_unittest.cc
diff --git a/webrtc/modules/audio_processing/level_controller/level_controller_unittest.cc b/webrtc/modules/audio_processing/level_controller/level_controller_unittest.cc
index f5cea0dbccd9357717d634c9d4e1862b742ffc4d..37d6932887f2cad3b50f4eb03a099a058295b9ad 100644
--- a/webrtc/modules/audio_processing/level_controller/level_controller_unittest.cc
+++ b/webrtc/modules/audio_processing/level_controller/level_controller_unittest.cc
@@ -10,13 +10,18 @@
#include <vector>
-#include "testing/gtest/include/gtest/gtest.h"
#include "webrtc/base/array_view.h"
+#include "webrtc/base/optional.h"
#include "webrtc/modules/audio_processing/audio_buffer.h"
#include "webrtc/modules/audio_processing/include/audio_processing.h"
#include "webrtc/modules/audio_processing/level_controller/level_controller.h"
#include "webrtc/modules/audio_processing/test/audio_buffer_tools.h"
#include "webrtc/modules/audio_processing/test/bitexactness_tools.h"
+#ifdef WEBRTC_ANDROID_PLATFORM_BUILD
+#include "gtest/gtest.h"
hlundin-webrtc 2016/09/19 12:03:03 Why this special case for Android?
peah-webrtc 2016/09/19 16:37:10 I have no idea. Sorry, but I got that from audio_p
+#else
+#include "testing/gtest/include/gtest/gtest.h"
+#endif
namespace webrtc {
namespace {
@@ -27,9 +32,15 @@ const int kNumFramesToProcess = 1000;
// any errors.
void RunBitexactnessTest(int sample_rate_hz,
size_t num_channels,
+ rtc::Optional<float> initial_peak_level,
rtc::ArrayView<const float> output_reference) {
LevelController level_controller;
level_controller.Initialize(sample_rate_hz);
+ if (initial_peak_level) {
+ AudioProcessing::Config::LevelController config;
+ config.initial_peak_level = *initial_peak_level;
+ level_controller.ApplyConfig(config);
+ }
int samples_per_channel = rtc::CheckedDivExact(sample_rate_hz, 100);
const StreamConfig capture_config(sample_rate_hz, num_channels, false);
@@ -68,41 +79,56 @@ void RunBitexactnessTest(int sample_rate_hz,
} // namespace
-TEST(LevelControlConfigTest, ToStringEnabled) {
+TEST(LevelControllerConfig, ToString) {
the sun 2016/09/16 12:40:25 Thank you, for not using fixtures!
peah-webrtc 2016/09/19 16:37:10 My sincere pleasure :-)
AudioProcessing::Config config;
config.level_controller.enabled = true;
- EXPECT_EQ("{enabled: true}",
+ config.level_controller.initial_peak_level = -6.0206;
+ EXPECT_EQ("{enabled: true,initial_peak_level: -6.0206}",
LevelController::ToString(config.level_controller));
-}
-TEST(LevelControlConfigTest, ToStringNotEnabled) {
- AudioProcessing::Config config;
config.level_controller.enabled = false;
- EXPECT_EQ("{enabled: false}",
+ config.level_controller.initial_peak_level = -50;
+ EXPECT_EQ("{enabled: false,initial_peak_level: -50}",
LevelController::ToString(config.level_controller));
}
-TEST(LevelControlConfigTest, DefaultValue) {
+TEST(LevelControllerConfig, DefaultValue) {
+ const float kTolerance = 0.0001f;
AudioProcessing::Config config;
EXPECT_FALSE(config.level_controller.enabled);
+ EXPECT_NEAR(-6.0206f, config.level_controller.initial_peak_level, kTolerance);
+}
+
+TEST(LevelControllerConfig, InitialLevel) {
+ const float kTolerance = 0.0001f;
+ LevelController lc;
+ AudioProcessing::Config::LevelController config;
+ config.initial_peak_level = -6.0206;
+ lc.ApplyConfig(config);
+ EXPECT_EQ(kTargetLcPeakLevel, lc.peak_level_estimator_.initial_peak_level_);
+
+ config.initial_peak_level = -50.f;
+ lc.ApplyConfig(config);
+ EXPECT_NEAR(103.62151336f, lc.peak_level_estimator_.initial_peak_level_,
+ kTolerance);
}
TEST(LevelControlBitExactnessTest, DISABLED_Mono8kHz) {
const float kOutputReference[] = {-0.013939f, -0.012154f, -0.009054f};
RunBitexactnessTest(AudioProcessing::kSampleRate8kHz, 1,
- kOutputReference);
+ rtc::Optional<float>(), kOutputReference);
}
TEST(LevelControlBitExactnessTest, DISABLED_Mono16kHz) {
const float kOutputReference[] = {-0.013706f, -0.013215f, -0.013018f};
RunBitexactnessTest(AudioProcessing::kSampleRate16kHz, 1,
- kOutputReference);
+ rtc::Optional<float>(), kOutputReference);
}
TEST(LevelControlBitExactnessTest, DISABLED_Mono32kHz) {
const float kOutputReference[] = {-0.014495f, -0.016425f, -0.016085f};
RunBitexactnessTest(AudioProcessing::kSampleRate32kHz, 1,
- kOutputReference);
+ rtc::Optional<float>(), kOutputReference);
}
// TODO(peah): Investigate why this particular testcase differ between Android
@@ -115,37 +141,41 @@ TEST(LevelControlBitExactnessTest, DISABLED_Mono48kHz) {
const float kOutputReference[] = {-0.015949f, -0.016957f, -0.019478f};
#endif
RunBitexactnessTest(AudioProcessing::kSampleRate48kHz, 1,
- kOutputReference);
+ rtc::Optional<float>(), kOutputReference);
}
TEST(LevelControlBitExactnessTest, DISABLED_Stereo8kHz) {
const float kOutputReference[] = {-0.014063f, -0.008450f, -0.012159f,
-0.051967f, -0.023202f, -0.047858f};
RunBitexactnessTest(AudioProcessing::kSampleRate8kHz, 2,
- kOutputReference);
+ rtc::Optional<float>(), kOutputReference);
}
TEST(LevelControlBitExactnessTest, DISABLED_Stereo16kHz) {
const float kOutputReference[] = {-0.012714f, -0.005896f, -0.012220f,
-0.053306f, -0.024549f, -0.051527f};
RunBitexactnessTest(AudioProcessing::kSampleRate16kHz, 2,
- kOutputReference);
+ rtc::Optional<float>(), kOutputReference);
}
TEST(LevelControlBitExactnessTest, DISABLED_Stereo32kHz) {
const float kOutputReference[] = {-0.011737f, -0.007018f, -0.013446f,
-0.053505f, -0.026292f, -0.056221f};
RunBitexactnessTest(AudioProcessing::kSampleRate32kHz, 2,
- kOutputReference);
+ rtc::Optional<float>(), kOutputReference);
}
TEST(LevelControlBitExactnessTest, DISABLED_Stereo48kHz) {
const float kOutputReference[] = {-0.010643f, -0.006334f, -0.011377f,
-0.049088f, -0.023600f, -0.050465f};
RunBitexactnessTest(AudioProcessing::kSampleRate48kHz, 2,
- kOutputReference);
+ rtc::Optional<float>(), kOutputReference);
}
-
+TEST(LevelControlBitExactnessTest, DISABLED_MonoInitial48kHz) {
+ const float kOutputReference[] = {-0.013753f, -0.014623f, -0.016797f};
+ RunBitexactnessTest(AudioProcessing::kSampleRate48kHz, 1,
+ rtc::Optional<float>(-50), kOutputReference);
+}
} // namespace webrtc

Powered by Google App Engine
This is Rietveld 408576698