Bug 1296152: [ffmpeg] Don't use all CPUs available when decoding. r=mattwoodrow
authorJean-Yves Avenard <jyavenard@mozilla.com>
Thu, 18 Aug 2016 15:34:19 +1000
changeset 309911 f8f422cda9d58189d100489111128f450c0bf581
parent 309910 f5ed7f38160ed375a0ea04eb2ac847983b1da2f1
child 309912 751ab2b45ddce43b1ba342cc17e00c08ebeb1732
child 309986 cf06fbc831754e54c6abb71d3136597488a530e0
push id31475
push userjyavenard@mozilla.com
push dateThu, 18 Aug 2016 07:09:08 +0000
treeherderautoland@f8f422cda9d5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow
bugs1296152
milestone51.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1296152: [ffmpeg] Don't use all CPUs available when decoding. r=mattwoodrow MozReview-Commit-ID: C4CTiC9H79A
dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp
--- a/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp
+++ b/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp
@@ -140,17 +140,18 @@ FFmpegVideoDecoder<LIBAV_VER>::InitCodec
   if (mInfo.mDisplay.width >= 2048) {
     decode_threads = 8;
   } else if (mInfo.mDisplay.width >= 1024) {
     decode_threads = 4;
   } else if (mInfo.mDisplay.width >= 320) {
     decode_threads = 2;
   }
 
-  decode_threads = std::min(decode_threads, PR_GetNumberOfProcessors());
+  decode_threads = std::min(decode_threads, PR_GetNumberOfProcessors() - 1);
+  decode_threads = std::max(decode_threads, 1);
   mCodecContext->thread_count = decode_threads;
   if (decode_threads > 1) {
     mCodecContext->thread_type = FF_THREAD_SLICE | FF_THREAD_FRAME;
   }
 
   // FFmpeg will call back to this to negotiate a video pixel format.
   mCodecContext->get_format = ChoosePixelFormat;