Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(565)

Unified Diff: media/filters/ffmpeg_video_decoder.cc

Issue 2467623002: media: Only add more threads for codecs that benefit from it (Closed)
Patch Set: NOTREACHED -> comment Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..04e3630e866d9c3048246826b72a685b711c39ff 100644
--- a/media/filters/ffmpeg_video_decoder.cc
+++ b/media/filters/ffmpeg_video_decoder.cc
@@ -50,21 +50,41 @@ 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 kCodecMPEG2:
+ case kCodecHEVC:
+ case kCodecVP9:
+ // We do not compile ffmpeg with support for any of these codecs.
+ break;
+
+ case kCodecTheora:
+ // No extra threads for these codecs.
+ break;
+
+ case kCodecH264:
+ case kCodecMPEG4:
+ case kCodecVP8:
+ // 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);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698