[Adaptation] Don't allow frame dropping to re-enable when scaling is off

There was a small miss in https://webrtc-review.googlesource.com/c/src/+/181369
which allowed frame dropping to re-enable, and there was no test to catch this.
This case has been fixed along with a test to ensure this isn't missed in the future.

Bug: webrtc:11843
Change-Id: I201aa451d4751586c780a07dc72a7401aed78088
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/181661
Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
Commit-Queue: Evan Shrubsole <eshr@google.com>
Cr-Commit-Position: refs/heads/master@{#31936}
This commit is contained in:
Evan Shrubsole
2020-08-14 15:58:33 +02:00
committed by Commit Bot
parent 360450f4ad
commit e3da1d33a1
2 changed files with 44 additions and 0 deletions

View File

@ -86,6 +86,7 @@ class VideoStreamEncoderResourceManager::InitialFrameDropper {
void SetTargetBitrate(DataRate target_bitrate, int64_t now_ms) {
if (set_start_bitrate_ > DataRate::Zero() && !has_seen_first_bwe_drop_ &&
quality_scaler_resource_->is_started() &&
quality_scaler_settings_.InitialBitrateIntervalMs() &&
quality_scaler_settings_.InitialBitrateFactor()) {
int64_t diff_ms = now_ms - set_start_bitrate_time_ms_;

View File

@ -4144,6 +4144,49 @@ TEST_F(VideoStreamEncoderTest, InitialFrameDropActivatesWhenBweDrops) {
video_stream_encoder_->Stop();
}
TEST_F(VideoStreamEncoderTest,
InitialFrameDropNotReactivatedWhenBweDropsWhenScalingDisabled) {
webrtc::test::ScopedFieldTrials field_trials(
"WebRTC-Video-QualityScalerSettings/"
"initial_bitrate_interval_ms:1000,initial_bitrate_factor:0.2/");
fake_encoder_.SetQualityScaling(false);
ConfigureEncoder(video_encoder_config_.Copy());
const int kNotTooLowBitrateForFrameSizeBps = kTargetBitrateBps * 0.2;
const int kTooLowBitrateForFrameSizeBps = kTargetBitrateBps * 0.19;
const int kWidth = 640;
const int kHeight = 360;
video_stream_encoder_->OnBitrateUpdatedAndWaitForManagedResources(
DataRate::BitsPerSec(kTargetBitrateBps),
DataRate::BitsPerSec(kTargetBitrateBps),
DataRate::BitsPerSec(kTargetBitrateBps), 0, 0, 0);
video_source_.IncomingCapturedFrame(CreateFrame(1, kWidth, kHeight));
// Frame should not be dropped.
WaitForEncodedFrame(1);
video_stream_encoder_->OnBitrateUpdatedAndWaitForManagedResources(
DataRate::BitsPerSec(kNotTooLowBitrateForFrameSizeBps),
DataRate::BitsPerSec(kNotTooLowBitrateForFrameSizeBps),
DataRate::BitsPerSec(kNotTooLowBitrateForFrameSizeBps), 0, 0, 0);
video_source_.IncomingCapturedFrame(CreateFrame(2, kWidth, kHeight));
// Frame should not be dropped.
WaitForEncodedFrame(2);
video_stream_encoder_->OnBitrateUpdatedAndWaitForManagedResources(
DataRate::BitsPerSec(kTooLowBitrateForFrameSizeBps),
DataRate::BitsPerSec(kTooLowBitrateForFrameSizeBps),
DataRate::BitsPerSec(kTooLowBitrateForFrameSizeBps), 0, 0, 0);
video_source_.IncomingCapturedFrame(CreateFrame(3, kWidth, kHeight));
// Not dropped since quality scaling is disabled.
WaitForEncodedFrame(3);
// Expect the sink_wants to specify a scaled frame.
video_stream_encoder_->WaitUntilAdaptationTaskQueueIsIdle();
EXPECT_THAT(video_source_.sink_wants(), ResolutionMax());
video_stream_encoder_->Stop();
}
TEST_F(VideoStreamEncoderTest, RampsUpInQualityWhenBwIsHigh) {
webrtc::test::ScopedFieldTrials field_trials(
"WebRTC-Video-QualityRampupSettings/min_pixels:1,min_duration_ms:2000/");