From a85995ac66d0451abcf7dc9a2abefb57742bb5a2 Mon Sep 17 00:00:00 2001 From: Sergey Silkin Date: Tue, 2 Oct 2018 10:28:10 +0200 Subject: [PATCH] Set frame duration per spatial layer. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This allows VP9 encoder correctly calculate target frame budgets when encoding multiple spatial layers with different frame rate. Bug: webrtc:9768 Change-Id: I21d76cc1670024710371464898d8b3f8572229b1 Reviewed-on: https://webrtc-review.googlesource.com/c/98865 Commit-Queue: Sergey Silkin Reviewed-by: Erik Språng Cr-Commit-Position: refs/heads/master@{#25164} --- modules/video_coding/codecs/vp9/vp9_impl.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/modules/video_coding/codecs/vp9/vp9_impl.cc b/modules/video_coding/codecs/vp9/vp9_impl.cc index d8f5877e24..3e58e44072 100644 --- a/modules/video_coding/codecs/vp9/vp9_impl.cc +++ b/modules/video_coding/codecs/vp9/vp9_impl.cc @@ -788,6 +788,14 @@ int VP9EncoderImpl::Encode(const VideoFrame& input_image, if (external_ref_control_) { vpx_svc_ref_frame_config_t ref_config = SetReferences(force_key_frame_); + + if (VideoCodecMode::kScreensharing == codec_.mode) { + for (uint8_t sl_idx = 0; sl_idx < num_active_spatial_layers_; ++sl_idx) { + ref_config.duration[sl_idx] = static_cast( + 90000 / framerate_controller_[sl_idx].GetTargetRate()); + } + } + vpx_codec_control(encoder_, VP9E_SET_SVC_REF_FRAME_CONFIG, &ref_config); }