| 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 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 456 std::move(streams), encoder_config_.min_transmit_bitrate_bps); | 456 std::move(streams), encoder_config_.min_transmit_bitrate_bps); |
| 457 | 457 |
| 458 ConfigureQualityScaler(); | 458 ConfigureQualityScaler(); |
| 459 } | 459 } |
| 460 | 460 |
| 461 void ViEEncoder::ConfigureQualityScaler() { | 461 void ViEEncoder::ConfigureQualityScaler() { |
| 462 RTC_DCHECK_RUN_ON(&encoder_queue_); | 462 RTC_DCHECK_RUN_ON(&encoder_queue_); |
| 463 const auto scaling_settings = settings_.encoder->GetScalingSettings(); | 463 const auto scaling_settings = settings_.encoder->GetScalingSettings(); |
| 464 const bool degradation_preference_allows_scaling = | 464 const bool degradation_preference_allows_scaling = |
| 465 degradation_preference_ != DegradationPreference::kMaintainResolution; | 465 degradation_preference_ != DegradationPreference::kMaintainResolution; |
| 466 if (degradation_preference_allows_scaling && scaling_settings.enabled) { | 466 |
| 467 stats_proxy_->SetResolutionRestrictionStats( |
| 468 degradation_preference_allows_scaling, scale_counter_[kCpu] > 0, |
| 469 scale_counter_[kQuality]); |
| 470 |
| 471 if (degradation_preference_allows_scaling && |
| 472 scaling_settings.enabled) { |
| 473 // Abort if quality scaler has already been configured. |
| 474 if (quality_scaler_.get() != nullptr) |
| 475 return; |
| 467 // Drop frames and scale down until desired quality is achieved. | 476 // Drop frames and scale down until desired quality is achieved. |
| 468 if (scaling_settings.thresholds) { | 477 if (scaling_settings.thresholds) { |
| 469 quality_scaler_.reset( | 478 quality_scaler_.reset( |
| 470 new QualityScaler(this, *(scaling_settings.thresholds))); | 479 new QualityScaler(this, *(scaling_settings.thresholds))); |
| 471 } else { | 480 } else { |
| 472 quality_scaler_.reset(new QualityScaler(this, codec_type_)); | 481 quality_scaler_.reset(new QualityScaler(this, codec_type_)); |
| 473 } | 482 } |
| 474 } else { | 483 } else { |
| 475 quality_scaler_.reset(nullptr); | 484 quality_scaler_.reset(nullptr); |
| 476 initial_rampup_ = kMaxInitialFramedrop; | 485 initial_rampup_ = kMaxInitialFramedrop; |
| 477 } | 486 } |
| 478 stats_proxy_->SetResolutionRestrictionStats( | |
| 479 degradation_preference_allows_scaling, scale_counter_[kCpu] > 0, | |
| 480 scale_counter_[kQuality]); | |
| 481 } | 487 } |
| 482 | 488 |
| 483 void ViEEncoder::OnFrame(const VideoFrame& video_frame) { | 489 void ViEEncoder::OnFrame(const VideoFrame& video_frame) { |
| 484 RTC_DCHECK_RUNS_SERIALIZED(&incoming_frame_race_checker_); | 490 RTC_DCHECK_RUNS_SERIALIZED(&incoming_frame_race_checker_); |
| 485 VideoFrame incoming_frame = video_frame; | 491 VideoFrame incoming_frame = video_frame; |
| 486 | 492 |
| 487 // Local time in webrtc time base. | 493 // Local time in webrtc time base. |
| 488 int64_t current_time_us = clock_->TimeInMicroseconds(); | 494 int64_t current_time_us = clock_->TimeInMicroseconds(); |
| 489 int64_t current_time_ms = current_time_us / rtc::kNumMicrosecsPerMillisec; | 495 int64_t current_time_ms = current_time_us / rtc::kNumMicrosecsPerMillisec; |
| 490 // TODO(nisse): This always overrides the incoming timestamp. Don't | 496 // TODO(nisse): This always overrides the incoming timestamp. Don't |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 809 --scale_counter_[reason]; | 815 --scale_counter_[reason]; |
| 810 source_proxy_->RequestHigherResolutionThan(current_pixel_count); | 816 source_proxy_->RequestHigherResolutionThan(current_pixel_count); |
| 811 LOG(LS_INFO) << "Scaling up resolution."; | 817 LOG(LS_INFO) << "Scaling up resolution."; |
| 812 for (size_t i = 0; i < kScaleReasonSize; ++i) { | 818 for (size_t i = 0; i < kScaleReasonSize; ++i) { |
| 813 LOG(LS_INFO) << "Scaled " << scale_counter_[i] | 819 LOG(LS_INFO) << "Scaled " << scale_counter_[i] |
| 814 << " times for reason: " << (i ? "cpu" : "quality"); | 820 << " times for reason: " << (i ? "cpu" : "quality"); |
| 815 } | 821 } |
| 816 } | 822 } |
| 817 | 823 |
| 818 } // namespace webrtc | 824 } // namespace webrtc |
| OLD | NEW |