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

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

Issue 2398963003: Move usage of QualityScaler to ViEEncoder. (Closed)
Patch Set: rebase Created 4 years 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
« no previous file with comments | « webrtc/video/overuse_frame_detector.h ('k') | webrtc/video/overuse_frame_detector_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 // Expontential back-off factor, to prevent annoying up-down behaviour. 42 // Expontential back-off factor, to prevent annoying up-down behaviour.
43 const double kRampUpBackoffFactor = 2.0; 43 const double kRampUpBackoffFactor = 2.0;
44 44
45 // Max number of overuses detected before always applying the rampup delay. 45 // Max number of overuses detected before always applying the rampup delay.
46 const int kMaxOverusesBeforeApplyRampupDelay = 4; 46 const int kMaxOverusesBeforeApplyRampupDelay = 4;
47 47
48 // The maximum exponent to use in VCMExpFilter. 48 // The maximum exponent to use in VCMExpFilter.
49 const float kSampleDiffMs = 33.0f; 49 const float kSampleDiffMs = 33.0f;
50 const float kMaxExp = 7.0f; 50 const float kMaxExp = 7.0f;
51 51
52 const auto kScaleReasonCpu = ScalingObserverInterface::ScaleReason::kCpu;
52 } // namespace 53 } // namespace
53 54
54 CpuOveruseOptions::CpuOveruseOptions() 55 CpuOveruseOptions::CpuOveruseOptions()
55 : high_encode_usage_threshold_percent(85), 56 : high_encode_usage_threshold_percent(85),
56 frame_timeout_interval_ms(1500), 57 frame_timeout_interval_ms(1500),
57 min_frame_samples(120), 58 min_frame_samples(120),
58 min_process_count(3), 59 min_process_count(3),
59 high_threshold_consecutive_count(2) { 60 high_threshold_consecutive_count(2) {
60 #if defined(WEBRTC_MAC) && !defined(WEBRTC_IOS) 61 #if defined(WEBRTC_MAC) && !defined(WEBRTC_IOS)
61 // This is proof-of-concept code for letting the physical core count affect 62 // This is proof-of-concept code for letting the physical core count affect
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 // transferred to the task queue when PostDelayedTask was called. 198 // transferred to the task queue when PostDelayedTask was called.
198 return false; 199 return false;
199 } 200 }
200 rtc::SequencedTaskChecker task_checker_; 201 rtc::SequencedTaskChecker task_checker_;
201 OveruseFrameDetector* overuse_detector_; 202 OveruseFrameDetector* overuse_detector_;
202 }; 203 };
203 204
204 OveruseFrameDetector::OveruseFrameDetector( 205 OveruseFrameDetector::OveruseFrameDetector(
205 Clock* clock, 206 Clock* clock,
206 const CpuOveruseOptions& options, 207 const CpuOveruseOptions& options,
207 CpuOveruseObserver* observer, 208 ScalingObserverInterface* observer,
208 EncodedFrameObserver* encoder_timing, 209 EncodedFrameObserver* encoder_timing,
209 CpuOveruseMetricsObserver* metrics_observer) 210 CpuOveruseMetricsObserver* metrics_observer)
210 : check_overuse_task_(nullptr), 211 : check_overuse_task_(nullptr),
211 options_(options), 212 options_(options),
212 observer_(observer), 213 observer_(observer),
213 encoder_timing_(encoder_timing), 214 encoder_timing_(encoder_timing),
214 metrics_observer_(metrics_observer), 215 metrics_observer_(metrics_observer),
215 clock_(clock), 216 clock_(clock),
216 num_process_times_(0), 217 num_process_times_(0),
217 last_capture_time_ms_(-1), 218 last_capture_time_ms_(-1),
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 current_rampup_delay_ms_ = kStandardRampUpDelayMs; 364 current_rampup_delay_ms_ = kStandardRampUpDelayMs;
364 } 365 }
365 } 366 }
366 367
367 last_overuse_time_ms_ = now; 368 last_overuse_time_ms_ = now;
368 in_quick_rampup_ = false; 369 in_quick_rampup_ = false;
369 checks_above_threshold_ = 0; 370 checks_above_threshold_ = 0;
370 ++num_overuse_detections_; 371 ++num_overuse_detections_;
371 372
372 if (observer_) 373 if (observer_)
373 observer_->OveruseDetected(); 374 observer_->ScaleDown(kScaleReasonCpu);
374 } else if (IsUnderusing(*metrics_, now)) { 375 } else if (IsUnderusing(*metrics_, now)) {
375 last_rampup_time_ms_ = now; 376 last_rampup_time_ms_ = now;
376 in_quick_rampup_ = true; 377 in_quick_rampup_ = true;
377 378
378 if (observer_) 379 if (observer_)
379 observer_->NormalUsage(); 380 observer_->ScaleUp(kScaleReasonCpu);
380 } 381 }
381 382
382 int rampup_delay = 383 int rampup_delay =
383 in_quick_rampup_ ? kQuickRampUpDelayMs : current_rampup_delay_ms_; 384 in_quick_rampup_ ? kQuickRampUpDelayMs : current_rampup_delay_ms_;
384 385
385 LOG(LS_VERBOSE) << " Frame stats: " 386 LOG(LS_VERBOSE) << " Frame stats: "
386 << " encode usage " << metrics_->encode_usage_percent 387 << " encode usage " << metrics_->encode_usage_percent
387 << " overuse detections " << num_overuse_detections_ 388 << " overuse detections " << num_overuse_detections_
388 << " rampup delay " << rampup_delay; 389 << " rampup delay " << rampup_delay;
389 } 390 }
(...skipping 13 matching lines...) Expand all
403 int64_t time_now) { 404 int64_t time_now) {
404 RTC_DCHECK_CALLED_SEQUENTIALLY(&task_checker_); 405 RTC_DCHECK_CALLED_SEQUENTIALLY(&task_checker_);
405 int delay = in_quick_rampup_ ? kQuickRampUpDelayMs : current_rampup_delay_ms_; 406 int delay = in_quick_rampup_ ? kQuickRampUpDelayMs : current_rampup_delay_ms_;
406 if (time_now < last_rampup_time_ms_ + delay) 407 if (time_now < last_rampup_time_ms_ + delay)
407 return false; 408 return false;
408 409
409 return metrics.encode_usage_percent < 410 return metrics.encode_usage_percent <
410 options_.low_encode_usage_threshold_percent; 411 options_.low_encode_usage_threshold_percent;
411 } 412 }
412 } // namespace webrtc 413 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/video/overuse_frame_detector.h ('k') | webrtc/video/overuse_frame_detector_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698