Fix incorrect FPS measure when frame dropper kicks in

Bug: webrtc:10302
Change-Id: I4f8df7d41d8750e0810c2300fcd90b3eff7fb56d
Reviewed-on: https://webrtc-review.googlesource.com/c/121954
Commit-Queue: Erik Språng <sprang@webrtc.org>
Reviewed-by: Stefan Holmer <stefan@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#26610}
This commit is contained in:
Erik Språng 2019-02-08 14:17:40 +01:00 committed by Commit Bot
parent bdfadd666e
commit a8d48ab87b
2 changed files with 16 additions and 6 deletions

View File

@ -884,6 +884,9 @@ void VideoStreamEncoder::MaybeEncodeVideoFrame(const VideoFrame& video_frame,
// InitialFrameDropOffWhenEncoderDisabledScaling, the return value
// from GetScalingSettings should enable or disable the frame drop.
// Update input frame rate before we start using it. If we update it after
// any potential frame drop we are going to artifically increase frame sizes.
input_framerate_.Update(1u, clock_->TimeInMilliseconds());
uint32_t framerate_fps = GetInputFramerateFps();
int64_t now_ms = clock_->TimeInMilliseconds();
@ -1016,8 +1019,6 @@ void VideoStreamEncoder::EncodeVideoFrame(const VideoFrame& video_frame,
}
encoder_info_ = info;
input_framerate_.Update(1u, clock_->TimeInMilliseconds());
video_sender_.AddVideoFrame(out_frame, nullptr, encoder_info_);
}

View File

@ -3295,8 +3295,11 @@ TEST_F(VideoStreamEncoderTest, DropsFramesWhenEncoderOvershoots) {
timestamp_ms += 1000 / kFps;
}
// Frame drops should be less than 5%
EXPECT_LT(num_dropped, 5 * kNumFramesInRun / 100);
// Framerate should be measured to be near the expected target rate.
EXPECT_NEAR(fake_encoder_.GetLastFramerate(), kFps, 1);
// Frame drops should be within 5% of expected 0%.
EXPECT_NEAR(num_dropped, 0, 5 * kNumFramesInRun / 100);
// Make encoder produce frames at double the expected bitrate during 3 seconds
// of video, verify number of drops. Rate needs to be slightly changed in
@ -3320,8 +3323,14 @@ TEST_F(VideoStreamEncoderTest, DropsFramesWhenEncoderOvershoots) {
timestamp_ms += 1000 / kFps;
}
// Frame drops should be more than 40%.
EXPECT_GT(num_dropped, 40 * kNumFramesInRun / 100);
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
// Target framerate should be still be near the expected target, despite
// the frame drops.
EXPECT_NEAR(fake_encoder_.GetLastFramerate(), kFps, 1);
// Frame drops should be within 5% of expected 50%.
EXPECT_NEAR(num_dropped, kNumFramesInRun / 2, 5 * kNumFramesInRun / 100);
video_stream_encoder_->Stop();
}