Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(145)

Side by Side Diff: webrtc/video/send_statistics_proxy.cc

Issue 1870043002: Add histogram stats for average QP per frame for VP9 (for sent video streams): (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: rebase Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2013 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 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 RTC_LOGGED_HISTOGRAMS_COUNTS_100000( 187 RTC_LOGGED_HISTOGRAMS_COUNTS_100000(
188 kIndex, uma_prefix_ + "SendSideDelayInMs", delay_ms); 188 kIndex, uma_prefix_ + "SendSideDelayInMs", delay_ms);
189 189
190 int max_delay_ms = max_delay_counter_.Avg(kMinRequiredSamples); 190 int max_delay_ms = max_delay_counter_.Avg(kMinRequiredSamples);
191 if (max_delay_ms != -1) { 191 if (max_delay_ms != -1) {
192 RTC_LOGGED_HISTOGRAMS_COUNTS_100000( 192 RTC_LOGGED_HISTOGRAMS_COUNTS_100000(
193 kIndex, uma_prefix_ + "SendSideDelayMaxInMs", max_delay_ms); 193 kIndex, uma_prefix_ + "SendSideDelayMaxInMs", max_delay_ms);
194 } 194 }
195 195
196 for (const auto& it : qp_counters_) { 196 for (const auto& it : qp_counters_) {
197 int qp = it.second.vp8.Avg(kMinRequiredSamples); 197 int qp_vp8 = it.second.vp8.Avg(kMinRequiredSamples);
198 if (qp != -1) { 198 if (qp_vp8 != -1) {
199 int spatial_idx = it.first; 199 int spatial_idx = it.first;
200 if (spatial_idx == -1) { 200 if (spatial_idx == -1) {
201 RTC_LOGGED_HISTOGRAMS_COUNTS_200(kIndex, uma_prefix_ + "Encoded.Qp.Vp8", 201 RTC_LOGGED_HISTOGRAMS_COUNTS_200(kIndex, uma_prefix_ + "Encoded.Qp.Vp8",
202 qp); 202 qp_vp8);
203 } else if (spatial_idx == 0) { 203 } else if (spatial_idx == 0) {
204 RTC_LOGGED_HISTOGRAMS_COUNTS_200(kIndex, 204 RTC_LOGGED_HISTOGRAMS_COUNTS_200(
205 uma_prefix_ + "Encoded.Qp.Vp8.S0", qp); 205 kIndex, uma_prefix_ + "Encoded.Qp.Vp8.S0", qp_vp8);
206 } else if (spatial_idx == 1) { 206 } else if (spatial_idx == 1) {
207 RTC_LOGGED_HISTOGRAMS_COUNTS_200(kIndex, 207 RTC_LOGGED_HISTOGRAMS_COUNTS_200(
208 uma_prefix_ + "Encoded.Qp.Vp8.S1", qp); 208 kIndex, uma_prefix_ + "Encoded.Qp.Vp8.S1", qp_vp8);
209 } else if (spatial_idx == 2) { 209 } else if (spatial_idx == 2) {
210 RTC_LOGGED_HISTOGRAMS_COUNTS_200(kIndex, 210 RTC_LOGGED_HISTOGRAMS_COUNTS_200(
211 uma_prefix_ + "Encoded.Qp.Vp8.S2", qp); 211 kIndex, uma_prefix_ + "Encoded.Qp.Vp8.S2", qp_vp8);
212 } else { 212 } else {
213 LOG(LS_WARNING) << "QP stats not recorded for VP8 spatial idx " 213 LOG(LS_WARNING) << "QP stats not recorded for VP8 spatial idx "
214 << spatial_idx; 214 << spatial_idx;
215 } 215 }
216 } 216 }
217 int qp_vp9 = it.second.vp9.Avg(kMinRequiredSamples);
218 if (qp_vp9 != -1) {
219 int spatial_idx = it.first;
220 if (spatial_idx == -1) {
221 RTC_LOGGED_HISTOGRAMS_COUNTS_500(kIndex, uma_prefix_ + "Encoded.Qp.Vp9",
222 qp_vp9);
223 } else if (spatial_idx == 0) {
224 RTC_LOGGED_HISTOGRAMS_COUNTS_500(
225 kIndex, uma_prefix_ + "Encoded.Qp.Vp9.S0", qp_vp9);
226 } else if (spatial_idx == 1) {
227 RTC_LOGGED_HISTOGRAMS_COUNTS_500(
228 kIndex, uma_prefix_ + "Encoded.Qp.Vp9.S1", qp_vp9);
229 } else if (spatial_idx == 2) {
230 RTC_LOGGED_HISTOGRAMS_COUNTS_500(
231 kIndex, uma_prefix_ + "Encoded.Qp.Vp9.S2", qp_vp9);
232 } else {
233 LOG(LS_WARNING) << "QP stats not recorded for VP9 spatial layer "
234 << spatial_idx;
235 }
236 }
217 } 237 }
218 238
219 if (first_rtcp_stats_time_ms_ != -1) { 239 if (first_rtcp_stats_time_ms_ != -1) {
220 int64_t elapsed_sec = 240 int64_t elapsed_sec =
221 (clock_->TimeInMilliseconds() - first_rtcp_stats_time_ms_) / 1000; 241 (clock_->TimeInMilliseconds() - first_rtcp_stats_time_ms_) / 1000;
222 if (elapsed_sec >= metrics::kMinRunTimeInSeconds) { 242 if (elapsed_sec >= metrics::kMinRunTimeInSeconds) {
223 int fraction_lost = report_block_stats_.FractionLostInPercent(); 243 int fraction_lost = report_block_stats_.FractionLostInPercent();
224 if (fraction_lost != -1) { 244 if (fraction_lost != -1) {
225 RTC_LOGGED_HISTOGRAMS_PERCENTAGE( 245 RTC_LOGGED_HISTOGRAMS_PERCENTAGE(
226 kIndex, uma_prefix_ + "SentPacketsLostInPercent", fraction_lost); 246 kIndex, uma_prefix_ + "SentPacketsLostInPercent", fraction_lost);
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 } 462 }
443 if (encoded_image.adapt_reason_.bw_resolutions_disabled != -1) { 463 if (encoded_image.adapt_reason_.bw_resolutions_disabled != -1) {
444 bool bw_limited = encoded_image.adapt_reason_.bw_resolutions_disabled > 0; 464 bool bw_limited = encoded_image.adapt_reason_.bw_resolutions_disabled > 0;
445 uma_container_->bw_limited_frame_counter_.Add(bw_limited); 465 uma_container_->bw_limited_frame_counter_.Add(bw_limited);
446 if (bw_limited) { 466 if (bw_limited) {
447 uma_container_->bw_resolutions_disabled_counter_.Add( 467 uma_container_->bw_resolutions_disabled_counter_.Add(
448 encoded_image.adapt_reason_.bw_resolutions_disabled); 468 encoded_image.adapt_reason_.bw_resolutions_disabled);
449 } 469 }
450 } 470 }
451 471
452 if (encoded_image.qp_ != -1 && rtp_video_header && 472 if (encoded_image.qp_ != -1 && rtp_video_header) {
453 rtp_video_header->codec == kRtpVideoVp8) { 473 if (rtp_video_header->codec == kRtpVideoVp8) {
454 int spatial_idx = 474 int spatial_idx = (config_.rtp.ssrcs.size() == 1)
455 (config_.rtp.ssrcs.size() == 1) ? -1 : static_cast<int>(simulcast_idx); 475 ? -1
456 uma_container_->qp_counters_[spatial_idx].vp8.Add(encoded_image.qp_); 476 : static_cast<int>(simulcast_idx);
477 uma_container_->qp_counters_[spatial_idx].vp8.Add(encoded_image.qp_);
478 } else if (rtp_video_header->codec == kRtpVideoVp9) {
479 int spatial_idx =
480 (rtp_video_header->codecHeader.VP9.num_spatial_layers == 1)
481 ? -1
482 : rtp_video_header->codecHeader.VP9.spatial_idx;
483 uma_container_->qp_counters_[spatial_idx].vp9.Add(encoded_image.qp_);
484 }
457 } 485 }
458 486
459 // TODO(asapersson): This is incorrect if simulcast layers are encoded on 487 // TODO(asapersson): This is incorrect if simulcast layers are encoded on
460 // different threads and there is no guarantee that one frame of all layers 488 // different threads and there is no guarantee that one frame of all layers
461 // are encoded before the next start. 489 // are encoded before the next start.
462 if (last_sent_frame_timestamp_ > 0 && 490 if (last_sent_frame_timestamp_ > 0 &&
463 encoded_image._timeStamp != last_sent_frame_timestamp_) { 491 encoded_image._timeStamp != last_sent_frame_timestamp_) {
464 uma_container_->sent_frame_rate_tracker_.AddSamples(1); 492 uma_container_->sent_frame_rate_tracker_.AddSamples(1);
465 uma_container_->sent_width_counter_.Add( 493 uma_container_->sent_width_counter_.Add(
466 uma_container_->max_sent_width_per_timestamp_); 494 uma_container_->max_sent_width_per_timestamp_);
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 return Fraction(min_required_samples, 1000.0f); 615 return Fraction(min_required_samples, 1000.0f);
588 } 616 }
589 617
590 int SendStatisticsProxy::BoolSampleCounter::Fraction( 618 int SendStatisticsProxy::BoolSampleCounter::Fraction(
591 int min_required_samples, float multiplier) const { 619 int min_required_samples, float multiplier) const {
592 if (num_samples < min_required_samples || num_samples == 0) 620 if (num_samples < min_required_samples || num_samples == 0)
593 return -1; 621 return -1;
594 return static_cast<int>((sum * multiplier / num_samples) + 0.5f); 622 return static_cast<int>((sum * multiplier / num_samples) + 0.5f);
595 } 623 }
596 } // namespace webrtc 624 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698