OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
414 EXPECT_EQ(kMinBitrateBps, states.encoder->GetTargetBitrate()); | 414 EXPECT_EQ(kMinBitrateBps, states.encoder->GetTargetBitrate()); |
415 | 415 |
416 // Set a target rate that is greater than |kMaxBitrateBps| when overhead is | 416 // Set a target rate that is greater than |kMaxBitrateBps| when overhead is |
417 // subtracted. The eventual codec rate should be bounded by |kMaxBitrateBps|. | 417 // subtracted. The eventual codec rate should be bounded by |kMaxBitrateBps|. |
418 target_bitrate = | 418 target_bitrate = |
419 kOverheadBytesPerPacket * 8 * packet_rate + kMaxBitrateBps + 1; | 419 kOverheadBytesPerPacket * 8 * packet_rate + kMaxBitrateBps + 1; |
420 states.encoder->OnReceivedTargetAudioBitrate(target_bitrate); | 420 states.encoder->OnReceivedTargetAudioBitrate(target_bitrate); |
421 EXPECT_EQ(kMaxBitrateBps, states.encoder->GetTargetBitrate()); | 421 EXPECT_EQ(kMaxBitrateBps, states.encoder->GetTargetBitrate()); |
422 } | 422 } |
423 | 423 |
| 424 // Verifies that the complexity adaptation in the config works as intended. |
| 425 TEST(AudioEncoderOpusTest, ConfigComplexityAdaptation) { |
| 426 AudioEncoderOpus::Config config; |
| 427 config.low_rate_complexity = 8; |
| 428 config.complexity = 6; |
| 429 |
| 430 // Bitrate within hysteresis window. Expect empty output. |
| 431 config.bitrate_bps = rtc::Optional<int>(12500); |
| 432 EXPECT_EQ(rtc::Optional<int>(), config.GetNewComplexity()); |
| 433 |
| 434 // Bitrate below hysteresis window. Expect higher complexity. |
| 435 config.bitrate_bps = rtc::Optional<int>(10999); |
| 436 EXPECT_EQ(rtc::Optional<int>(8), config.GetNewComplexity()); |
| 437 |
| 438 // Bitrate within hysteresis window. Expect empty output. |
| 439 config.bitrate_bps = rtc::Optional<int>(12500); |
| 440 EXPECT_EQ(rtc::Optional<int>(), config.GetNewComplexity()); |
| 441 |
| 442 // Bitrate above hysteresis window. Expect lower complexity. |
| 443 config.bitrate_bps = rtc::Optional<int>(14001); |
| 444 EXPECT_EQ(rtc::Optional<int>(6), config.GetNewComplexity()); |
| 445 } |
424 } // namespace webrtc | 446 } // namespace webrtc |
OLD | NEW |