From f4e44af724b28eaef7d6806617e5d55b9bb135ed Mon Sep 17 00:00:00 2001 From: asapersson Date: Wed, 19 Apr 2017 02:01:06 -0700 Subject: [PATCH] Do not report cpu limited resolution stats when degradation preference is disabled and no scaling is done. When degradation preference is kDegradationDisabled, do not update WebRTC.Video.CpuLimitedResolutionInPercent. BUG=webrtc:6634 Review-Url: https://codereview.webrtc.org/2807133002 Cr-Commit-Position: refs/heads/master@{#17757} --- webrtc/video/send_statistics_proxy.cc | 5 +++- .../video/send_statistics_proxy_unittest.cc | 17 ++++++++++++- webrtc/video/vie_encoder_unittest.cc | 25 +++++++++++++++++-- 3 files changed, 43 insertions(+), 4 deletions(-) diff --git a/webrtc/video/send_statistics_proxy.cc b/webrtc/video/send_statistics_proxy.cc index 822ed97695..4fcf84261d 100644 --- a/webrtc/video/send_statistics_proxy.cc +++ b/webrtc/video/send_statistics_proxy.cc @@ -709,7 +709,10 @@ void SendStatisticsProxy::OnIncomingFrame(int width, int height) { uma_container_->input_fps_counter_.Add(1); uma_container_->input_width_counter_.Add(width); uma_container_->input_height_counter_.Add(height); - uma_container_->cpu_limited_frame_counter_.Add(stats_.cpu_limited_resolution); + if (cpu_downscales_ >= 0) { + uma_container_->cpu_limited_frame_counter_.Add( + stats_.cpu_limited_resolution); + } TRACE_EVENT_INSTANT2("webrtc_stats", "WebRTC.Video.InputFrameRate", "frame_rate", round( uma_container_->input_frame_rate_tracker_.ComputeRate()), diff --git a/webrtc/video/send_statistics_proxy_unittest.cc b/webrtc/video/send_statistics_proxy_unittest.cc index e2cb2fdbb2..edb756433b 100644 --- a/webrtc/video/send_statistics_proxy_unittest.cc +++ b/webrtc/video/send_statistics_proxy_unittest.cc @@ -841,7 +841,22 @@ TEST_F(SendStatisticsProxyTest, SentFpsHistogramExcludesSuspendedTime) { EXPECT_EQ(1, metrics::NumEvents("WebRTC.Video.SentFramesPerSecond", kFps)); } -TEST_F(SendStatisticsProxyTest, CpuLimitedResolutionUpdated) { +TEST_F(SendStatisticsProxyTest, CpuLimitedHistogramNotUpdatedWhenDisabled) { + const int kNumDownscales = -1; + statistics_proxy_->SetQualityScalingStats(kNumDownscales); + + for (int i = 0; i < SendStatisticsProxy::kMinRequiredMetricsSamples; ++i) + statistics_proxy_->OnIncomingFrame(kWidth, kHeight); + + statistics_proxy_.reset(); + EXPECT_EQ(0, + metrics::NumSamples("WebRTC.Video.CpuLimitedResolutionInPercent")); +} + +TEST_F(SendStatisticsProxyTest, CpuLimitedHistogramUpdated) { + const int kNumDownscales = 0; + statistics_proxy_->SetCpuScalingStats(kNumDownscales); + for (int i = 0; i < SendStatisticsProxy::kMinRequiredMetricsSamples; ++i) statistics_proxy_->OnIncomingFrame(kWidth, kHeight); diff --git a/webrtc/video/vie_encoder_unittest.cc b/webrtc/video/vie_encoder_unittest.cc index 79a08b354a..765efbc99e 100644 --- a/webrtc/video/vie_encoder_unittest.cc +++ b/webrtc/video/vie_encoder_unittest.cc @@ -1425,9 +1425,8 @@ TEST_F(ViEEncoderTest, DoesNotScaleBelowSetLimit) { vie_encoder_->Stop(); } -TEST_F(ViEEncoderTest, UMACpuLimitedResolutionInPercent) { +TEST_F(ViEEncoderTest, CpuLimitedHistogramIsReported) { vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0); - const int kWidth = 640; const int kHeight = 360; @@ -1454,6 +1453,28 @@ TEST_F(ViEEncoderTest, UMACpuLimitedResolutionInPercent) { 1, metrics::NumEvents("WebRTC.Video.CpuLimitedResolutionInPercent", 50)); } +TEST_F(ViEEncoderTest, CpuLimitedHistogramIsNotReportedForDisabledDegradation) { + vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0); + const int kWidth = 640; + const int kHeight = 360; + + vie_encoder_->SetSource( + &video_source_, + VideoSendStream::DegradationPreference::kDegradationDisabled); + + for (int i = 1; i <= SendStatisticsProxy::kMinRequiredMetricsSamples; ++i) { + video_source_.IncomingCapturedFrame(CreateFrame(i, kWidth, kHeight)); + sink_.WaitForEncodedFrame(i); + } + + vie_encoder_->Stop(); + vie_encoder_.reset(); + stats_proxy_.reset(); + + EXPECT_EQ(0, + metrics::NumSamples("WebRTC.Video.CpuLimitedResolutionInPercent")); +} + TEST_F(ViEEncoderTest, CallsBitrateObserver) { class MockBitrateObserver : public VideoBitrateAllocationObserver { public: