Commit f52c1adb authored by Oscar Johansson's avatar Oscar Johansson Committed by Commit Bot

Resolve jumbo conflict in video decoders (media/filters)

When building using jumbo, files gets merged. Files and
variables with the same name may merge into the same
namespace or scope and conflict. This happens in the files:
media/filters/aom_video_decoder.cc
media/filters/ffmpeg_video_decoder.cc
media/filters/vpx_video_decoder.cc

This commit solves the issue by renaming the function
GetThreadCount to something more file specific. It also
moves some constants to that function.

Bug: 867350
Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel;luci.chromium.try:linux_optional_gpu_tests_rel;luci.chromium.try:mac_optional_gpu_tests_rel;luci.chromium.try:win_optional_gpu_tests_rel
Change-Id: Id57aa6cc6ac10acd0073eee032d0d04592ba87e4
Reviewed-on: https://chromium-review.googlesource.com/1151311
Commit-Queue: Chrome Cunningham (In Paris) <chcunningham@chromium.org>
Reviewed-by: default avatarChrome Cunningham (In Paris) <chcunningham@chromium.org>
Cr-Commit-Position: refs/heads/master@{#578593}
parent 750549e1
......@@ -27,7 +27,7 @@ extern "C" {
namespace media {
// Returns the number of threads.
static int GetThreadCount(const VideoDecoderConfig& config) {
static int GetAomVideoDecoderThreadCount(const VideoDecoderConfig& config) {
// Always try to use at least two threads for video decoding. There is little
// reason not to since current day CPUs tend to be multi-core and we measured
// performance benefits on older machines such as P4s with hyperthreading.
......@@ -187,7 +187,7 @@ void AomVideoDecoder::Initialize(
aom_codec_dec_cfg_t aom_config = {0};
aom_config.w = config.coded_size().width();
aom_config.h = config.coded_size().height();
aom_config.threads = GetThreadCount(config);
aom_config.threads = GetAomVideoDecoderThreadCount(config);
// TODO(dalecurtis): Refactor the MemoryPool and OffloadTaskRunner out of
// VpxVideoDecoder so that they can be used here for zero copy decoding off
......
......@@ -31,21 +31,22 @@
namespace media {
// Always use 2 or more threads for video decoding. Most machines today will
// have 2-8 execution contexts. Using more cores generally doesn't seem to
// increase power usage and allows us to decode video faster.
//
// Handling decoding on separate threads also frees up the pipeline thread to
// continue processing. Although it'd be nice to have the option of a single
// decoding thread, FFmpeg treats having one thread the same as having zero
// threads (i.e., decoding will execute on the calling thread). Yet another
// reason for having two threads :)
static const int kDecodeThreads = 2;
static const int kMaxDecodeThreads = 16;
// Returns the number of threads given the FFmpeg CodecID. Also inspects the
// command line for a valid --video-threads flag.
static int GetThreadCount(const VideoDecoderConfig& config) {
static int GetFFmpegVideoDecoderThreadCount(const VideoDecoderConfig& config) {
// Always use 2 or more threads for video decoding. Most machines today will
// have 2-8 execution contexts. Using more cores generally doesn't seem to
// increase power usage and allows us to decode video faster.
//
// Handling decoding on separate threads also frees up the pipeline thread to
// continue processing. Although it'd be nice to have the option of a single
// decoding thread, FFmpeg treats having one thread the same as having zero
// threads (i.e., decoding will execute on the calling thread). Yet another
// reason for having two threads :)
constexpr int kDecodeThreads = 2;
constexpr int kMaxDecodeThreads = 16;
// Refer to http://crbug.com/93932 for tsan suppressions on decoding.
int decode_threads = kDecodeThreads;
......@@ -414,7 +415,7 @@ bool FFmpegVideoDecoder::ConfigureDecoder(const VideoDecoderConfig& config,
codec_context_.reset(avcodec_alloc_context3(NULL));
VideoDecoderConfigToAVCodecContext(config, codec_context_.get());
codec_context_->thread_count = GetThreadCount(config);
codec_context_->thread_count = GetFFmpegVideoDecoderThreadCount(config);
codec_context_->thread_type =
FF_THREAD_SLICE | (low_delay ? 0 : FF_THREAD_FRAME);
codec_context_->opaque = this;
......
......@@ -35,14 +35,14 @@
namespace media {
// Always try to use three threads for video decoding. There is little reason
// not to since current day CPUs tend to be multi-core and we measured
// performance benefits on older machines such as P4s with hyperthreading.
static const int kDecodeThreads = 2;
static const int kMaxDecodeThreads = 32;
// Returns the number of threads.
static int GetThreadCount(const VideoDecoderConfig& config) {
static int GetVpxVideoDecoderThreadCount(const VideoDecoderConfig& config) {
// Always try to use at least two threads for video decoding. There is little
// reason not to since current day CPUs tend to be multi-core and we measured
// performance benefits on older machines such as P4s with hyperthreading.
constexpr int kDecodeThreads = 2;
constexpr int kMaxDecodeThreads = 32;
// Refer to http://crbug.com/93932 for tsan suppressions on decoding.
int decode_threads = kDecodeThreads;
......@@ -80,7 +80,7 @@ static std::unique_ptr<vpx_codec_ctx> InitializeVpxContext(
vpx_codec_dec_cfg_t vpx_config = {0};
vpx_config.w = config.coded_size().width();
vpx_config.h = config.coded_size().height();
vpx_config.threads = GetThreadCount(config);
vpx_config.threads = GetVpxVideoDecoderThreadCount(config);
vpx_codec_err_t status = vpx_codec_dec_init(
context.get(),
......
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