Index: webrtc/video/vie_encoder.cc |
diff --git a/webrtc/video/vie_encoder.cc b/webrtc/video/vie_encoder.cc |
index a9e7e097c1d9d97cc87a8938bf918cbf4595aa6c..b5ff9a6f58cbc4634bb46c09e62ca4b7cb627f57 100644 |
--- a/webrtc/video/vie_encoder.cc |
+++ b/webrtc/video/vie_encoder.cc |
@@ -237,6 +237,7 @@ class ViEEncoder::EncodeTask : public rtc::QueuedTask { |
LOG(LS_VERBOSE) |
<< "Incoming frame dropped due to that the encoder is blocked."; |
++vie_encoder_->dropped_frame_count_; |
+ vie_encoder_->quality_scaler_.ReportDroppedFrame(); |
} |
if (log_stats_) { |
LOG(LS_INFO) << "Number of frames: captured " |
@@ -414,6 +415,7 @@ void ViEEncoder::Stop() { |
video_sender_.RegisterExternalEncoder(nullptr, settings_.payload_type, |
false); |
overuse_detector_.StopCheckForOveruse(); |
+ quality_scaler_.Stop(); |
shutdown_event_.Set(); |
}); |
@@ -508,6 +510,13 @@ void ViEEncoder::ReconfigureEncoder() { |
codec.startBitrate = std::min(codec.startBitrate, codec.maxBitrate); |
codec.expect_encode_from_texture = last_frame_info_->is_texture; |
+ const auto thresholds = settings_.encoder->GetQPThresholds(); |
+ if (thresholds) |
+ quality_scaler_.Init(this, thresholds->first, thresholds->second, |
+ streams[0].max_framerate); |
+ else |
+ quality_scaler_.Init(this, codec_type_, streams[0].max_framerate); |
+ |
bool success = video_sender_.RegisterSendCodec( |
&codec, number_of_cores_, |
static_cast<uint32_t>(max_data_payload_length_)) == VCM_OK; |
@@ -688,9 +697,10 @@ 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); |
+ quality_scaler_.ReportQP(encoded_image.qp_); |
}); |
return result; |
} |
@@ -767,7 +777,7 @@ void ViEEncoder::OnBitrateUpdated(uint32_t bitrate_bps, |
} |
} |
-void ViEEncoder::OveruseDetected() { |
+void ViEEncoder::ScaleDown() { |
RTC_DCHECK_RUN_ON(&encoder_queue_); |
if (disable_resolution_scaling_) |
@@ -776,6 +786,7 @@ void ViEEncoder::OveruseDetected() { |
if (cpu_restricted_counter_ >= kMaxCpuDowngrades) { |
return; |
} |
+ LOG(LS_ERROR) << "Actually doing it tho!" << '\n'; |
// Request lower resolution if the current resolution is lower than last time |
// we asked for the resolution to be lowered. |
// Update stats accordingly. |
@@ -790,7 +801,7 @@ void ViEEncoder::OveruseDetected() { |
} |
} |
-void ViEEncoder::NormalUsage() { |
+void ViEEncoder::ScaleUp() { |
RTC_DCHECK_RUN_ON(&encoder_queue_); |
if (disable_resolution_scaling_) |
return; |