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

Unified Diff: webrtc/video/vie_encoder.cc

Issue 2398963003: Move usage of QualityScaler to ViEEncoder. (Closed)
Patch Set: implement getQPThresholds for various wrappers Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: webrtc/video/vie_encoder.cc
diff --git a/webrtc/video/vie_encoder.cc b/webrtc/video/vie_encoder.cc
index a9e7e097c1d9d97cc87a8938bf918cbf4595aa6c..a1b1164157b532dd546cf6773bd06b95b7df830a 100644
--- a/webrtc/video/vie_encoder.cc
+++ b/webrtc/video/vie_encoder.cc
@@ -363,7 +363,8 @@ ViEEncoder::ViEEncoder(uint32_t number_of_cores,
settings_(settings),
codec_type_(PayloadNameToCodecType(settings.payload_name)),
video_sender_(Clock::GetRealTimeClock(), this, this),
- disable_resolution_scaling_(false),
+ disable_cpu_adaptation_(false),
+ disable_quality_scaling_(true),
overuse_detector_(Clock::GetRealTimeClock(),
GetCpuOveruseOptions(settings.full_overuse_time),
this,
@@ -414,6 +415,8 @@ void ViEEncoder::Stop() {
video_sender_.RegisterExternalEncoder(nullptr, settings_.payload_type,
false);
overuse_detector_.StopCheckForOveruse();
+ if (!disable_quality_scaling_)
+ quality_scaler_.Stop();
shutdown_event_.Set();
});
@@ -439,11 +442,11 @@ void ViEEncoder::SetSource(rtc::VideoSourceInterface<VideoFrame>* source,
source_proxy_->SetSource(source, disable_resolution_scaling);
encoder_queue_.PostTask([this, disable_resolution_scaling] {
RTC_DCHECK_RUN_ON(&encoder_queue_);
- if (disable_resolution_scaling_ != disable_resolution_scaling) {
+ if (disable_cpu_adaptation_ != disable_resolution_scaling) {
stats_proxy_->SetCpuRestrictedResolution(!disable_resolution_scaling &&
cpu_restricted_counter_ != 0);
}
- disable_resolution_scaling_ = disable_resolution_scaling;
+ disable_cpu_adaptation_ = disable_resolution_scaling;
});
}
@@ -529,6 +532,19 @@ void ViEEncoder::ReconfigureEncoder() {
}
sink_->OnEncoderConfigurationChanged(
std::move(streams), encoder_config_.min_transmit_bitrate_bps);
+
+ const auto scaling_settings = settings_.encoder->GetQPThresholds();
+ LOG(LS_INFO) << settings_.encoder->ImplementationName();
+ disable_quality_scaling_ = !scaling_settings.enabled;
+ if (!disable_quality_scaling_) {
+ LOG(LS_INFO) << "Initializing quality scaler.";
+ if (scaling_settings.thresholds) {
+ const auto thresholds = *scaling_settings.thresholds;
+ quality_scaler_.Init(this, thresholds.first, thresholds.second);
+ } else {
+ quality_scaler_.Init(this, codec_type_);
+ }
+ }
}
void ViEEncoder::OnFrame(const VideoFrame& video_frame) {
@@ -688,9 +704,11 @@ EncodedImageCallback::Result ViEEncoder::OnEncodedImage(
int64_t time_sent = clock_->TimeInMilliseconds();
uint32_t timestamp = encoded_image._timeStamp;
- encoder_queue_.PostTask([this, timestamp, time_sent] {
+ encoder_queue_.PostTask([this, timestamp, time_sent, encoded_image] {
RTC_DCHECK_RUN_ON(&encoder_queue_);
overuse_detector_.FrameSent(timestamp, time_sent);
+ if (!disable_quality_scaling_)
+ quality_scaler_.ReportQP(encoded_image.qp_);
});
return result;
}
@@ -767,10 +785,10 @@ void ViEEncoder::OnBitrateUpdated(uint32_t bitrate_bps,
}
}
-void ViEEncoder::OveruseDetected() {
+void ViEEncoder::ScaleDown() {
RTC_DCHECK_RUN_ON(&encoder_queue_);
- if (disable_resolution_scaling_)
+ if (disable_cpu_adaptation_)
return;
if (cpu_restricted_counter_ >= kMaxCpuDowngrades) {
@@ -790,9 +808,9 @@ void ViEEncoder::OveruseDetected() {
}
}
-void ViEEncoder::NormalUsage() {
+void ViEEncoder::ScaleUp() {
RTC_DCHECK_RUN_ON(&encoder_queue_);
- if (disable_resolution_scaling_)
+ if (disable_cpu_adaptation_)
return;
int current_pixel_count = last_frame_height_ * last_frame_width_;

Powered by Google App Engine
This is Rietveld 408576698