From f394f65b7195a5f9f71c9f0dec3bb68300590b5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20M=C3=B6ller?= Date: Tue, 24 Apr 2018 09:13:08 +0200 Subject: [PATCH] Make VideoStreamEncoder::ReconfigureEncoder always call ConfigureQualityScaler. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In addition restore call to ConfigureQualityScaler in SetSource, which is needed if degradation preferences change mid-stream. Fixes a regressions from https://webrtc-review.googlesource.com/70740, The encoder's GetScalingSettings may depend on arguments to InitEncode, so configuring the quality scaler only at encoder creation time isn't enough. Bug: webrtc:8830 Change-Id: I48f66cde219c56272f44441fdb26ec64c6002068 Reviewed-on: https://webrtc-review.googlesource.com/72000 Reviewed-by: Åsa Persson Commit-Queue: Niels Moller Cr-Commit-Position: refs/heads/master@{#22993} --- video/video_stream_encoder.cc | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/video/video_stream_encoder.cc b/video/video_stream_encoder.cc index 9b5dc1600f..02f16a9258 100644 --- a/video/video_stream_encoder.cc +++ b/video/video_stream_encoder.cc @@ -418,8 +418,8 @@ void VideoStreamEncoder::SetSource( bool allow_scaling = IsResolutionScalingEnabled(degradation_preference_); initial_rampup_ = allow_scaling ? 0 : kMaxInitialFramedrop; - stats_proxy_->SetAdaptationStats(GetActiveCounts(kCpu), - GetActiveCounts(kQuality)); + if (encoder_) + ConfigureQualityScaler(); if (!IsFramerateScalingEnabled(degradation_preference) && max_framerate_ != -1) { @@ -542,8 +542,6 @@ void VideoStreamEncoder::ReconfigureEncoder() { // or just discard incoming frames? RTC_CHECK(encoder_); - ConfigureQualityScaler(); - const webrtc::VideoEncoderFactory::CodecInfo info = settings_.encoder_factory->QueryVideoEncoder( encoder_config_.video_format); @@ -592,6 +590,8 @@ void VideoStreamEncoder::ReconfigureEncoder() { int target_framerate = std::min( max_framerate_, source_proxy_->GetActiveSinkWants().max_framerate_fps); overuse_detector_->OnTargetFramerateUpdated(target_framerate); + + ConfigureQualityScaler(); } void VideoStreamEncoder::ConfigureQualityScaler() { @@ -616,8 +616,6 @@ void VideoStreamEncoder::ConfigureQualityScaler() { initial_rampup_ = kMaxInitialFramedrop; } - // TODO(nisse): Is this still the right place to do this? This is - // now called when the encoder is created. stats_proxy_->SetAdaptationStats(GetActiveCounts(kCpu), GetActiveCounts(kQuality)); }