OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
529 | 529 |
530 ConfigureQualityScaler(); | 530 ConfigureQualityScaler(); |
531 } | 531 } |
532 | 532 |
533 void ViEEncoder::ConfigureQualityScaler() { | 533 void ViEEncoder::ConfigureQualityScaler() { |
534 RTC_DCHECK_RUN_ON(&encoder_queue_); | 534 RTC_DCHECK_RUN_ON(&encoder_queue_); |
535 const auto scaling_settings = settings_.encoder->GetScalingSettings(); | 535 const auto scaling_settings = settings_.encoder->GetScalingSettings(); |
536 const bool degradation_preference_allows_scaling = | 536 const bool degradation_preference_allows_scaling = |
537 degradation_preference_ == DegradationPreference::kMaintainFramerate || | 537 degradation_preference_ == DegradationPreference::kMaintainFramerate || |
538 degradation_preference_ == DegradationPreference::kBalanced; | 538 degradation_preference_ == DegradationPreference::kBalanced; |
| 539 const bool quality_scaling_allowed = |
| 540 degradation_preference_allows_scaling && scaling_settings.enabled; |
539 | 541 |
540 const std::vector<int>& scale_counters = GetScaleCounters(); | 542 const std::vector<int>& scale_counters = GetScaleCounters(); |
541 stats_proxy_->SetResolutionRestrictionStats( | 543 stats_proxy_->SetResolutionRestrictionStats( |
542 degradation_preference_allows_scaling, scale_counters[kCpu] > 0, | 544 degradation_preference_allows_scaling, quality_scaling_allowed, |
543 scale_counters[kQuality]); | 545 scale_counters[kCpu] > 0, scale_counters[kQuality]); |
544 | 546 |
545 if (degradation_preference_allows_scaling && | 547 if (quality_scaling_allowed) { |
546 scaling_settings.enabled) { | |
547 // Abort if quality scaler has already been configured. | 548 // Abort if quality scaler has already been configured. |
548 if (quality_scaler_.get() != nullptr) | 549 if (quality_scaler_.get() != nullptr) |
549 return; | 550 return; |
550 // Drop frames and scale down until desired quality is achieved. | 551 // Drop frames and scale down until desired quality is achieved. |
551 if (scaling_settings.thresholds) { | 552 if (scaling_settings.thresholds) { |
552 quality_scaler_.reset( | 553 quality_scaler_.reset( |
553 new QualityScaler(this, *(scaling_settings.thresholds))); | 554 new QualityScaler(this, *(scaling_settings.thresholds))); |
554 } else { | 555 } else { |
555 quality_scaler_.reset(new QualityScaler(this, codec_type_)); | 556 quality_scaler_.reset(new QualityScaler(this, codec_type_)); |
556 } | 557 } |
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
969 void ViEEncoder::IncrementScaleCounter(int reason, int delta) { | 970 void ViEEncoder::IncrementScaleCounter(int reason, int delta) { |
970 // Get the counters and validate. This may also lazily initialize the state. | 971 // Get the counters and validate. This may also lazily initialize the state. |
971 const std::vector<int>& counter = GetScaleCounters(); | 972 const std::vector<int>& counter = GetScaleCounters(); |
972 if (delta < 0) { | 973 if (delta < 0) { |
973 RTC_DCHECK_GE(counter[reason], delta); | 974 RTC_DCHECK_GE(counter[reason], delta); |
974 } | 975 } |
975 scale_counters_[degradation_preference_][reason] += delta; | 976 scale_counters_[degradation_preference_][reason] += delta; |
976 } | 977 } |
977 | 978 |
978 } // namespace webrtc | 979 } // namespace webrtc |
OLD | NEW |