media: Increase max number of decode threads for VP9 decodes at higher resolutions.

This improves decode performance of VP9 input encoded with tiling enabled.  Each 
tile must be at least 256 pixels wide. The number of tile columns are log2. So encoded
files can have 1, 2, 4, 8, 16 tile columns. E.g. 1920x1080 files can have up to 4
encoded tile columns. Tile rows do not matter for decode performance.

Specifically, any system with multiple cores and/or hyper threading will
benefit from this change.

On desktop 1080p decode speed is roughly 1.5-2x with this change. For example, 
on the low end of the results from the test set used to produce these numbers 
an average increase is from 82 frames/second to 163 frames/second.

This holds on Android devices as well, with the same clip on a Nexus 7 going
from 14 frames/second to 25. Chrome OS shows similar gains. This puts some 1080p 
in the playable range and gives 720p more clearance.

Review URL: https://codereview.chromium.org/55213002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@232932 0039d316-1c4b-4281-b951-d872f2087c98
parent 9bec0881
...@@ -42,17 +42,25 @@ static const int kDecodeThreads = 2; ...@@ -42,17 +42,25 @@ static const int kDecodeThreads = 2;
static const int kMaxDecodeThreads = 16; static const int kMaxDecodeThreads = 16;
// Returns the number of threads. // Returns the number of threads.
static int GetThreadCount() { static int GetThreadCount(const VideoDecoderConfig& config) {
// TODO(scherkus): De-duplicate this function and the one used by
// FFmpegVideoDecoder.
// Refer to http://crbug.com/93932 for tsan suppressions on decoding. // Refer to http://crbug.com/93932 for tsan suppressions on decoding.
int decode_threads = kDecodeThreads; int decode_threads = kDecodeThreads;
const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); const CommandLine* cmd_line = CommandLine::ForCurrentProcess();
std::string threads(cmd_line->GetSwitchValueASCII(switches::kVideoThreads)); std::string threads(cmd_line->GetSwitchValueASCII(switches::kVideoThreads));
if (threads.empty() || !base::StringToInt(threads, &decode_threads)) if (threads.empty() || !base::StringToInt(threads, &decode_threads)) {
if (config.codec() == kCodecVP9) {
// For VP9 decode when using the default thread count, increase the number
// of decode threads to equal the maximum number of tiles possible for
// higher resolution streams.
if (config.coded_size().width() >= 2048)
decode_threads = 8;
else if (config.coded_size().width() >= 1024)
decode_threads = 4;
}
return decode_threads; return decode_threads;
}
decode_threads = std::max(decode_threads, 0); decode_threads = std::max(decode_threads, 0);
decode_threads = std::min(decode_threads, kMaxDecodeThreads); decode_threads = std::min(decode_threads, kMaxDecodeThreads);
...@@ -100,7 +108,7 @@ static vpx_codec_ctx* InitializeVpxContext(vpx_codec_ctx* context, ...@@ -100,7 +108,7 @@ static vpx_codec_ctx* InitializeVpxContext(vpx_codec_ctx* context,
vpx_codec_dec_cfg_t vpx_config = {0}; vpx_codec_dec_cfg_t vpx_config = {0};
vpx_config.w = config.coded_size().width(); vpx_config.w = config.coded_size().width();
vpx_config.h = config.coded_size().height(); vpx_config.h = config.coded_size().height();
vpx_config.threads = GetThreadCount(); vpx_config.threads = GetThreadCount(config);
vpx_codec_err_t status = vpx_codec_dec_init(context, vpx_codec_err_t status = vpx_codec_dec_init(context,
config.codec() == kCodecVP9 ? config.codec() == kCodecVP9 ?
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment