From 2cc8baa14433871f0c47d3a772d6ea0c3975172d Mon Sep 17 00:00:00 2001 From: Alex Glaznev Date: Tue, 14 Jun 2016 14:28:29 -0700 Subject: [PATCH] Adjust the amount of VP8 encoder threads for Android builds. Current number of threads selection code does not work well for Android builds - middle and low end devices are having hard time encoding VGA and QVGA with just one thread. Increase the amount of vp8 encoder threads for 180p and above resolution. Also limit maximum number of thread to 3, since for 8 core devices most of time 4 cores are idle when thermal throttling kicks in. BUG=b/27946721 R=marpan@webrtc.org Review URL: https://codereview.webrtc.org/2058753003 . Cr-Commit-Position: refs/heads/master@{#13142} --- .../modules/video_coding/codecs/vp8/vp8_impl.cc | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/webrtc/modules/video_coding/codecs/vp8/vp8_impl.cc b/webrtc/modules/video_coding/codecs/vp8/vp8_impl.cc index ee30cfa983..9834ddcc7b 100644 --- a/webrtc/modules/video_coding/codecs/vp8/vp8_impl.cc +++ b/webrtc/modules/video_coding/codecs/vp8/vp8_impl.cc @@ -633,6 +633,20 @@ int VP8EncoderImpl::SetCpuSpeed(int width, int height) { } int VP8EncoderImpl::NumberOfThreads(int width, int height, int cpus) { +#if defined(ANDROID) + if (width * height >= 320 * 180) { + if (cpus >= 4) { + // 3 threads for CPUs with 4 and more cores since most of times only 4 + // cores will be active. + return 3; + } else if (cpus == 3 || cpus == 2) { + return 2; + } else { + return 1; + } + } + return 1; +#else if (width * height >= 1920 * 1080 && cpus > 8) { return 8; // 8 threads for 1080p on high perf machines. } else if (width * height > 1280 * 960 && cpus >= 6) { @@ -645,6 +659,7 @@ int VP8EncoderImpl::NumberOfThreads(int width, int height, int cpus) { // 1 thread for VGA or less. return 1; } +#endif } int VP8EncoderImpl::InitAndSetControlSettings() {