Chromium Code Reviews| Index: media/filters/ffmpeg_video_decoder.cc |
| diff --git a/media/filters/ffmpeg_video_decoder.cc b/media/filters/ffmpeg_video_decoder.cc |
| index 1384987f90fc0018950fab5909b0a041c43bf7a4..3854eb4df8bd0bf57a6b2d6a6084fc48d9895245 100644 |
| --- a/media/filters/ffmpeg_video_decoder.cc |
| +++ b/media/filters/ffmpeg_video_decoder.cc |
| @@ -50,21 +50,26 @@ static int GetThreadCount(const VideoDecoderConfig& config) { |
| const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); |
| std::string threads(cmd_line->GetSwitchValueASCII(switches::kVideoThreads)); |
| if (threads.empty() || !base::StringToInt(threads, &decode_threads)) { |
| - // Normalize to three threads for 1080p content, then scale linearly |
| - // with number of pixels. |
| - // Examples: |
| - // 4k: 12 threads |
| - // 1440p: 5 threads |
| - // 1080p: 3 threads |
| - // anything lower than 1080p: 2 threads |
| - decode_threads = config.coded_size().width() * |
| - config.coded_size().height() * 3 / 1920 / 1080; |
| - |
| - int cores = base::SysInfo::NumberOfProcessors(); |
| - // Leave two execution contexts for other things to run. |
| - decode_threads = std::min(decode_threads, cores - 2); |
| - // Use at least two threads, or ffmpeg will decode on the calling thread. |
| - decode_threads = std::max(decode_threads, kDecodeThreads); |
| + // Some ffmpeg codecs don't actually benefit from using more threads. |
|
DaleCurtis
2016/10/31 21:26:33
vp8 should benefit? I'd just exclude THEORA?
hubbe
2016/10/31 22:01:49
Replaced the if statement with a switch to remind
|
| + // Only add more threads for those codecs that we know will benefit. |
| + if (config.codec() == kCodecH264 || config.codec() == kCodecMPEG4 || |
| + config.codec() == kCodecHEVC || config.codec() == kCodecMPEG2) { |
| + // Normalize to three threads for 1080p content, then scale linearly |
| + // with number of pixels. |
| + // Examples: |
| + // 4k: 12 threads |
| + // 1440p: 5 threads |
| + // 1080p: 3 threads |
| + // anything lower than 1080p: 2 threads |
| + decode_threads = config.coded_size().width() * |
| + config.coded_size().height() * 3 / 1920 / 1080; |
| + |
| + int cores = base::SysInfo::NumberOfProcessors(); |
| + // Leave two execution contexts for other things to run. |
| + decode_threads = std::min(decode_threads, cores - 2); |
| + // Use at least two threads, or ffmpeg will decode on the calling thread. |
| + decode_threads = std::max(decode_threads, kDecodeThreads); |
| + } |
| } |
| decode_threads = std::max(decode_threads, 0); |