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..78364a8ea901d5611d5088b5c2bbf55ecd0cfb56 100644 |
| --- a/media/filters/ffmpeg_video_decoder.cc |
| +++ b/media/filters/ffmpeg_video_decoder.cc |
| @@ -50,21 +50,38 @@ 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. |
| + // Only add more threads for those codecs that we know will benefit. |
| + switch (config.codec()) { |
| + case kUnknownVideoCodec: |
| + case kCodecVC1: |
| + case kCodecTheora: |
| + // No extra threads for these codecs. |
| + break; |
| + |
| + case kCodecH264: |
| + case kCodecMPEG2: |
| + case kCodecMPEG4: |
| + case kCodecVP8: |
| + case kCodecVP9: |
| + case kCodecHEVC: |
|
DaleCurtis
2016/10/31 22:07:57
Unknown, VC1, MPEG2, and HEVC should all be NOTREA
hubbe
2016/10/31 22:18:38
Done.
|
| + // 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); |