Bug 1296152: [ffmpeg] Don't use all CPUs available when decoding. r?mattwoodrow draft
authorJean-Yves Avenard <jyavenard@mozilla.com>
Thu, 18 Aug 2016 15:34:19 +1000
changeset 402417 d927a793b7ec4ac43cb2a709666247ffb6fa892f
parent 402416 655772261c80b3483c3177318044b4c8395df2dc
child 528653 3f80a93ee8214d15ed5d7d9c4361f192cb6690d8
push id26639
push userbmo:jyavenard@mozilla.com
push dateThu, 18 Aug 2016 05:35:10 +0000
reviewersmattwoodrow
bugs1296152
milestone51.0a1
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;