From 26e50469513a3df2abb88c9ae2a5af70de0b029c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20Spr=C3=A5ng?= Date: Fri, 12 Jun 2020 12:20:42 +0200 Subject: [PATCH] Adjusts allowable thread count for vp9 decoders. Set 2 thread as target for 1280x720 pixel count, and then scale up linearly from there - but cap at physical core count. For common resolutions this results in: 1 for 360p 2 for 720p 4 for 1080p 8 for 1440p 18 for 4K Bug: webrtc:11551 Change-Id: I666bd971eccddee096749f20d3b08eb40fe868ad Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/177012 Reviewed-by: Johannes Kron Cr-Commit-Position: refs/heads/master@{#31513} --- modules/video_coding/codecs/vp9/vp9_impl.cc | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/modules/video_coding/codecs/vp9/vp9_impl.cc b/modules/video_coding/codecs/vp9/vp9_impl.cc index 3ac46f627e..318b704ae0 100644 --- a/modules/video_coding/codecs/vp9/vp9_impl.cc +++ b/modules/video_coding/codecs/vp9/vp9_impl.cc @@ -1671,10 +1671,16 @@ int VP9DecoderImpl::InitDecode(const VideoCodec* inst, int number_of_cores) { // We want to use multithreading when decoding high resolution videos. But not // too many in order to avoid overhead when many stream are decoded // concurrently. - // Set 1280x720 pixel count as target for one core, and then scale up linearly + // Set 2 thread as target for 1280x720 pixel count, and then scale up linearly // from there - but cap at physical core count. - // This results in 2 for 1080p, 4 for 1440p and 8 for 4K. - int num_threads = std::max(1, (inst->width * inst->height) / (1280 * 720)); + // For common resolutions this results in: + // 1 for 360p + // 2 for 720p + // 4 for 1080p + // 8 for 1440p + // 18 for 4K + int num_threads = + std::max(1, 2 * (inst->width * inst->height) / (1280 * 720)); cfg.threads = std::min(number_of_cores, num_threads); #endif current_codec_ = *inst;