From 827cab3fc2f43153e840078003ad1eb01ab6f61c Mon Sep 17 00:00:00 2001 From: asapersson Date: Wed, 2 Nov 2016 09:08:47 -0700 Subject: [PATCH] Add qp counter for H264 in SendStatisticsProxy. BUG=webrtc:6578 Review-Url: https://codereview.webrtc.org/2437323002 Cr-Commit-Position: refs/heads/master@{#14895} --- webrtc/video/send_statistics_proxy.cc | 10 ++++++++++ webrtc/video/send_statistics_proxy.h | 5 +++-- webrtc/video/send_statistics_proxy_unittest.cc | 14 ++++++++++++++ 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/webrtc/video/send_statistics_proxy.cc b/webrtc/video/send_statistics_proxy.cc index 2da71eb6ec..a996976e5d 100644 --- a/webrtc/video/send_statistics_proxy.cc +++ b/webrtc/video/send_statistics_proxy.cc @@ -250,6 +250,13 @@ void SendStatisticsProxy::UmaSamplesContainer::UpdateHistograms( << spatial_idx; } } + int qp_h264 = it.second.h264.Avg(kMinRequiredMetricsSamples); + if (qp_h264 != -1) { + int spatial_idx = it.first; + RTC_DCHECK_EQ(-1, spatial_idx); + RTC_HISTOGRAMS_COUNTS_100(kIndex, uma_prefix_ + "Encoded.Qp.H264", + qp_h264); + } } if (first_rtcp_stats_time_ms_ != -1) { @@ -520,6 +527,9 @@ void SendStatisticsProxy::OnSendEncodedImage( ? -1 : codec_info->codecSpecific.VP9.spatial_idx; uma_container_->qp_counters_[spatial_idx].vp9.Add(encoded_image.qp_); + } else if (codec_info->codecType == kVideoCodecH264) { + int spatial_idx = -1; + uma_container_->qp_counters_[spatial_idx].h264.Add(encoded_image.qp_); } } } diff --git a/webrtc/video/send_statistics_proxy.h b/webrtc/video/send_statistics_proxy.h index 89c40659b5..ec2fe4c50e 100644 --- a/webrtc/video/send_statistics_proxy.h +++ b/webrtc/video/send_statistics_proxy.h @@ -138,8 +138,9 @@ class SendStatisticsProxy : public CpuOveruseMetricsObserver, int64_t bitrate_update_ms; }; struct QpCounters { - SampleCounter vp8; // QP range: 0-127 - SampleCounter vp9; // QP range: 0-255 + SampleCounter vp8; // QP range: 0-127 + SampleCounter vp9; // QP range: 0-255 + SampleCounter h264; // QP range: 0-51 }; void PurgeOldStats() EXCLUSIVE_LOCKS_REQUIRED(crit_); VideoSendStream::StreamStats* GetStatsEntry(uint32_t ssrc) diff --git a/webrtc/video/send_statistics_proxy_unittest.cc b/webrtc/video/send_statistics_proxy_unittest.cc index fcab7d1de0..a467f6c5d1 100644 --- a/webrtc/video/send_statistics_proxy_unittest.cc +++ b/webrtc/video/send_statistics_proxy_unittest.cc @@ -467,6 +467,20 @@ TEST_F(SendStatisticsProxyTest, VerifyQpHistogramStats_Vp9OneSpatialLayer) { EXPECT_EQ(1, metrics::NumEvents("WebRTC.Video.Encoded.Qp.Vp9", kQpIdx0)); } +TEST_F(SendStatisticsProxyTest, VerifyQpHistogramStats_H264) { + EncodedImage encoded_image; + CodecSpecificInfo codec_info; + codec_info.codecType = kVideoCodecH264; + + for (int i = 0; i < SendStatisticsProxy::kMinRequiredMetricsSamples; ++i) { + encoded_image.qp_ = kQpIdx0; + statistics_proxy_->OnSendEncodedImage(encoded_image, &codec_info); + } + statistics_proxy_.reset(); + EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.Encoded.Qp.H264")); + EXPECT_EQ(1, metrics::NumEvents("WebRTC.Video.Encoded.Qp.H264", kQpIdx0)); +} + TEST_F(SendStatisticsProxyTest, BandwidthLimitedHistogramsNotUpdatedWhenDisabled) { EncodedImage encoded_image;