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

Side by Side Diff: media/filters/vpx_video_decoder.cc

Issue 55213002: media: Increase max number of decode threads for VP9 decodes at higher resolutions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Copying my notes is hard. I meant >=, I swear... even the notes say >=. Oops. Created 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/filters/vpx_video_decoder.h" 5 #include "media/filters/vpx_video_decoder.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 24 matching lines...) Expand all
35 35
36 namespace media { 36 namespace media {
37 37
38 // Always try to use three threads for video decoding. There is little reason 38 // Always try to use three threads for video decoding. There is little reason
39 // not to since current day CPUs tend to be multi-core and we measured 39 // not to since current day CPUs tend to be multi-core and we measured
40 // performance benefits on older machines such as P4s with hyperthreading. 40 // performance benefits on older machines such as P4s with hyperthreading.
41 static const int kDecodeThreads = 2; 41 static const int kDecodeThreads = 2;
42 static const int kMaxDecodeThreads = 16; 42 static const int kMaxDecodeThreads = 16;
43 43
44 // Returns the number of threads. 44 // Returns the number of threads.
45 static int GetThreadCount() { 45 static int GetThreadCount(const VideoDecoderConfig& config) {
46 // TODO(scherkus): De-duplicate this function and the one used by
47 // FFmpegVideoDecoder.
48
49 // Refer to http://crbug.com/93932 for tsan suppressions on decoding. 46 // Refer to http://crbug.com/93932 for tsan suppressions on decoding.
50 int decode_threads = kDecodeThreads; 47 int decode_threads = kDecodeThreads;
51 48
52 const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); 49 const CommandLine* cmd_line = CommandLine::ForCurrentProcess();
53 std::string threads(cmd_line->GetSwitchValueASCII(switches::kVideoThreads)); 50 std::string threads(cmd_line->GetSwitchValueASCII(switches::kVideoThreads));
54 if (threads.empty() || !base::StringToInt(threads, &decode_threads)) 51 if (threads.empty() || !base::StringToInt(threads, &decode_threads)) {
52 if (config.codec() == kCodecVP9) {
53 // For VP9 decode when using the default thread count, increase the number
54 // of decode threads to equal the maximum number of tiles possible for
55 // higher resolution streams.
56 if (config.coded_size().width() >= 2048)
scherkus (not reviewing) 2013/11/04 20:30:54 I don't know much about tiling, but do we need to
57 decode_threads = 8;
58 else if (config.coded_size().width() >= 1024)
59 decode_threads = 4;
60 }
61
55 return decode_threads; 62 return decode_threads;
63 }
56 64
57 decode_threads = std::max(decode_threads, 0); 65 decode_threads = std::max(decode_threads, 0);
58 decode_threads = std::min(decode_threads, kMaxDecodeThreads); 66 decode_threads = std::min(decode_threads, kMaxDecodeThreads);
59 return decode_threads; 67 return decode_threads;
60 } 68 }
61 69
62 VpxVideoDecoder::VpxVideoDecoder( 70 VpxVideoDecoder::VpxVideoDecoder(
63 const scoped_refptr<base::MessageLoopProxy>& message_loop) 71 const scoped_refptr<base::MessageLoopProxy>& message_loop)
64 : message_loop_(message_loop), 72 : message_loop_(message_loop),
65 weak_factory_(this), 73 weak_factory_(this),
(...skipping 27 matching lines...) Expand all
93 state_ = kNormal; 101 state_ = kNormal;
94 status_cb.Run(PIPELINE_OK); 102 status_cb.Run(PIPELINE_OK);
95 } 103 }
96 104
97 static vpx_codec_ctx* InitializeVpxContext(vpx_codec_ctx* context, 105 static vpx_codec_ctx* InitializeVpxContext(vpx_codec_ctx* context,
98 const VideoDecoderConfig& config) { 106 const VideoDecoderConfig& config) {
99 context = new vpx_codec_ctx(); 107 context = new vpx_codec_ctx();
100 vpx_codec_dec_cfg_t vpx_config = {0}; 108 vpx_codec_dec_cfg_t vpx_config = {0};
101 vpx_config.w = config.coded_size().width(); 109 vpx_config.w = config.coded_size().width();
102 vpx_config.h = config.coded_size().height(); 110 vpx_config.h = config.coded_size().height();
103 vpx_config.threads = GetThreadCount(); 111 vpx_config.threads = GetThreadCount(config);
104 112
105 vpx_codec_err_t status = vpx_codec_dec_init(context, 113 vpx_codec_err_t status = vpx_codec_dec_init(context,
106 config.codec() == kCodecVP9 ? 114 config.codec() == kCodecVP9 ?
107 vpx_codec_vp9_dx() : 115 vpx_codec_vp9_dx() :
108 vpx_codec_vp8_dx(), 116 vpx_codec_vp8_dx(),
109 &vpx_config, 117 &vpx_config,
110 0); 118 0);
111 if (status != VPX_CODEC_OK) { 119 if (status != VPX_CODEC_OK) {
112 LOG(ERROR) << "vpx_codec_dec_init failed, status=" << status; 120 LOG(ERROR) << "vpx_codec_dec_init failed, status=" << status;
113 delete context; 121 delete context;
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 vpx_image->stride[VPX_PLANE_Y], vpx_image->d_h, video_frame->get()); 370 vpx_image->stride[VPX_PLANE_Y], vpx_image->d_h, video_frame->get());
363 return; 371 return;
364 } 372 }
365 CopyAPlane(vpx_image_alpha->planes[VPX_PLANE_Y], 373 CopyAPlane(vpx_image_alpha->planes[VPX_PLANE_Y],
366 vpx_image->stride[VPX_PLANE_Y], 374 vpx_image->stride[VPX_PLANE_Y],
367 vpx_image->d_h, 375 vpx_image->d_h,
368 video_frame->get()); 376 video_frame->get());
369 } 377 }
370 378
371 } // namespace media 379 } // namespace media
OLDNEW
« 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