Index: media/filters/gpu_video_decoder.cc |
diff --git a/media/filters/gpu_video_decoder.cc b/media/filters/gpu_video_decoder.cc |
index 150dd05a26dccfa2801728f786369cf8a73baaeb..f3705ca6dd3f7134c1b41da2a90bfb61b27a1752 100644 |
--- a/media/filters/gpu_video_decoder.cc |
+++ b/media/filters/gpu_video_decoder.cc |
@@ -9,7 +9,6 @@ |
#include "base/bind.h" |
#include "base/callback_helpers.h" |
#include "base/command_line.h" |
-#include "base/cpu.h" |
#include "base/message_loop/message_loop.h" |
#include "base/metrics/histogram.h" |
#include "base/stl_util.h" |
@@ -18,7 +17,6 @@ |
#include "gpu/command_buffer/common/mailbox_holder.h" |
#include "media/base/bind_to_current_loop.h" |
#include "media/base/decoder_buffer.h" |
-#include "media/base/media_switches.h" |
#include "media/base/pipeline.h" |
#include "media/base/pipeline_status.h" |
#include "media/base/video_decoder_config.h" |
@@ -98,35 +96,6 @@ void GpuVideoDecoder::Reset(const base::Closure& closure) { |
vda_->Reset(); |
} |
-static bool IsCodedSizeSupported(const gfx::Size& coded_size) { |
-#if defined(OS_WIN) |
- // Windows Media Foundation H.264 decoding does not support decoding videos |
- // with any dimension smaller than 48 pixels: |
- // http://msdn.microsoft.com/en-us/library/windows/desktop/dd797815 |
- if (coded_size.width() < 48 || coded_size.height() < 48) |
- return false; |
-#endif |
- |
- // Only non-Windows, Ivy Bridge+ platforms can support more than 1920x1080. |
- // We test against 1088 to account for 16x16 macroblocks. |
- if (coded_size.width() <= 1920 && coded_size.height() <= 1088) |
- return true; |
- |
- // NOTE: additional autodetection logic may require updating input buffer size |
- // selection in platform-specific implementations, such as |
- // V4L2VideoDecodeAccelerator. |
- base::CPU cpu; |
- bool hw_large_video_support = |
- CommandLine::ForCurrentProcess()->HasSwitch( |
- switches::kIgnoreResolutionLimitsForAcceleratedVideoDecode) || |
- ((cpu.vendor_name() == "GenuineIntel") && cpu.model() >= 55); |
- bool os_large_video_support = true; |
-#if defined(OS_WIN) |
- os_large_video_support = false; |
-#endif |
- return os_large_video_support && hw_large_video_support; |
-} |
- |
// Report |status| to UMA and run |cb| with it. This is super-specific to the |
// UMA stat reported because the UMA_HISTOGRAM_ENUMERATION API requires a |
// callsite to always be called with the same stat name (can't parameterize it). |
@@ -184,6 +153,11 @@ void GpuVideoDecoder::Initialize(const VideoDecoderConfig& config, |
return; |
} |
+ if (!IsProfileSupported(config.profile())) { |
+ status_cb.Run(DECODER_ERROR_NOT_SUPPORTED); |
+ return; |
+ } |
+ |
vda_ = factories_->CreateVideoDecodeAccelerator().Pass(); |
if (!vda_ || !vda_->Initialize(config.profile(), this)) { |
status_cb.Run(DECODER_ERROR_NOT_SUPPORTED); |
wuchengli
2014/12/19 03:35:18
PIPELINE_ERROR_INITIALIZATION_FAILED? Please find
|
@@ -623,6 +597,32 @@ void GpuVideoDecoder::NotifyError(media::VideoDecodeAccelerator::Error error) { |
DestroyVDA(); |
} |
+bool GpuVideoDecoder::IsCodedSizeSupported(const gfx::Size& coded_size) { |
+ DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent(); |
+ std::vector<VideoDecodeAccelerator::SupportedProfile> supported_profiles = |
+ factories_->GetVideoDecodeAcceleratorSupportedProfiles(); |
+ for (size_t i = 0; i < supported_profiles.size(); i++) { |
wuchengli
2014/12/19 03:35:18
You have to check the corresponding profile. You c
|
+ if (coded_size.width() <= supported_profiles[i].max_resolution.width() && |
+ coded_size.height() <= supported_profiles[i].max_resolution.height() && |
+ coded_size.width() >= supported_profiles[i].min_resolution.width() && |
+ coded_size.height() >= supported_profiles[i].min_resolution.height()) { |
+ return true; |
+ } |
+ } |
+ return false; |
+} |
+ |
+bool GpuVideoDecoder::IsProfileSupported(const VideoCodecProfile& profile) { |
+ DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent(); |
+ std::vector<VideoDecodeAccelerator::SupportedProfile> supported_profiles = |
+ factories_->GetVideoDecodeAcceleratorSupportedProfiles(); |
+ for (size_t i = 0; i < supported_profiles.size(); i++) { |
+ if (profile == supported_profiles[i].profile) |
+ return true; |
+ } |
+ return false; |
+} |
+ |
void GpuVideoDecoder::DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent() |
const { |
DCHECK(factories_->GetTaskRunner()->BelongsToCurrentThread()); |