From 8c1dd8d32f72893efc644c5f08f7001fccda9415 Mon Sep 17 00:00:00 2001 From: "henrik.lundin" Date: Mon, 19 Dec 2016 06:18:35 -0800 Subject: [PATCH] Re-enable Opus complexity tests on Android This effectively reverts commit c3e1cabc696240e4b5a128653264785292878205 (https://codereview.webrtc.org/2589703002/). The reason the test was failing before was missing resource dependencies in the GN file. This is now fixed. Furthermore, the test did not trigger the complexity adaptation that it was supposed to test, since the hysteresis window of the bitrate was not taken into account. This is also fixed. Finally, a percent label was added to a printout, to match the same printout in the other test. BUG=webrtc:6708 Review-Url: https://codereview.webrtc.org/2580383002 Cr-Commit-Position: refs/heads/master@{#15679} --- webrtc/BUILD.gn | 1 + .../codecs/opus/opus_complexity_unittest.cc | 32 +++++++++---------- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/webrtc/BUILD.gn b/webrtc/BUILD.gn index 064b1b440b..da67c093ec 100644 --- a/webrtc/BUILD.gn +++ b/webrtc/BUILD.gn @@ -591,6 +591,7 @@ if (rtc_include_tests) { webrtc_perf_tests_resources = [ "//resources/audio_coding/speech_mono_16kHz.pcm", + "//resources/audio_coding/speech_mono_32_48kHz.pcm", "//resources/audio_coding/testfile32kHz.pcm", "//resources/ConferenceMotion_1280_720_50.yuv", "//resources/difficult_photo_1850_1110.yuv", diff --git a/webrtc/modules/audio_coding/codecs/opus/opus_complexity_unittest.cc b/webrtc/modules/audio_coding/codecs/opus/opus_complexity_unittest.cc index 5339cffdfc..f242aa48c7 100644 --- a/webrtc/modules/audio_coding/codecs/opus/opus_complexity_unittest.cc +++ b/webrtc/modules/audio_coding/codecs/opus/opus_complexity_unittest.cc @@ -49,16 +49,8 @@ int64_t RunComplexityTest(const AudioEncoderOpus::Config& config) { } } // namespace -#if defined(WEBRTC_ANDROID) -#define MAYBE_AudioEncoderOpusComplexityAdaptationTest \ - DISABLED_AudioEncoderOpusComplexityAdaptationTest -#else -#define MAYBE_AudioEncoderOpusComplexityAdaptationTest \ - AudioEncoderOpusComplexityAdaptationTest -#endif - // This test encodes an audio file using Opus twice with different bitrates -// (12.5 kbps and 15.5 kbps). The runtime for each is measured, and the ratio +// (~11 kbps and 15.5 kbps). The runtime for each is measured, and the ratio // between the two is calculated and tracked. This test explicitly sets the // low_rate_complexity to 9. When running on desktop platforms, this is the same // as the regular complexity, and the expectation is that the resulting ratio @@ -67,34 +59,40 @@ int64_t RunComplexityTest(const AudioEncoderOpus::Config& config) { // mobiles, the regular complexity is 5, and we expect the resulting ratio to // be higher, since we have explicitly asked for a higher complexity setting at // the lower rate. -TEST(MAYBE_AudioEncoderOpusComplexityAdaptationTest, AdaptationOn) { +TEST(AudioEncoderOpusComplexityAdaptationTest, AdaptationOn) { // Create config. AudioEncoderOpus::Config config; - config.bitrate_bps = rtc::Optional(12500); + // The limit -- including the hysteresis window -- at which the complexity + // shuold be increased. + config.bitrate_bps = rtc::Optional(11000 - 1); config.low_rate_complexity = 9; - int64_t runtime_12500bps = RunComplexityTest(config); + int64_t runtime_10999bps = RunComplexityTest(config); config.bitrate_bps = rtc::Optional(15500); int64_t runtime_15500bps = RunComplexityTest(config); test::PrintResult("opus_encoding_complexity_ratio", "", "adaptation_on", - 100.0 * runtime_12500bps / runtime_15500bps, "percent", + 100.0 * runtime_10999bps / runtime_15500bps, "percent", true); } // This test is identical to the one above, but without the complexity // adaptation enabled (neither on desktop, nor on mobile). The expectation is // that the resulting ratio is less than 100% at all times. -TEST(MAYBE_AudioEncoderOpusComplexityAdaptationTest, AdaptationOff) { +TEST(AudioEncoderOpusComplexityAdaptationTest, AdaptationOff) { // Create config. AudioEncoderOpus::Config config; - config.bitrate_bps = rtc::Optional(12500); - int64_t runtime_12500bps = RunComplexityTest(config); + // The limit -- including the hysteresis window -- at which the complexity + // shuold be increased (but not in this test since complexity adaptation is + // disabled). + config.bitrate_bps = rtc::Optional(11000 - 1); + int64_t runtime_10999bps = RunComplexityTest(config); config.bitrate_bps = rtc::Optional(15500); int64_t runtime_15500bps = RunComplexityTest(config); test::PrintResult("opus_encoding_complexity_ratio", "", "adaptation_off", - 100.0 * runtime_12500bps / runtime_15500bps, "", true); + 100.0 * runtime_10999bps / runtime_15500bps, "percent", + true); } } // namespace webrtc