Index: webrtc/video/vie_encoder.cc |
diff --git a/webrtc/video/vie_encoder.cc b/webrtc/video/vie_encoder.cc |
index a9e7e097c1d9d97cc87a8938bf918cbf4595aa6c..3e77a61ab5f59dbea646cfdf28ce21fc3e390436 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); |
+ } else { |
+ quality_scaler_.Init(this, codec_type_); |
magjed_webrtc
2016/10/07 12:02:54
No thresholds should mean no quality scaling, not
|
+ } |
+ |
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_) |
@@ -790,7 +800,7 @@ void ViEEncoder::OveruseDetected() { |
} |
} |
-void ViEEncoder::NormalUsage() { |
+void ViEEncoder::ScaleUp() { |
RTC_DCHECK_RUN_ON(&encoder_queue_); |
if (disable_resolution_scaling_) |
return; |