diff options
author | dalecurtis <dalecurtis@chromium.org> | 2016-03-18 21:54:11 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-03-19 05:03:16 +0000 |
commit | 4708098a8d03f9d0e7b5e6931f9c52c092e78fa9 (patch) | |
tree | 1460370fb7cedee1f5cff474dd9d03a8e1cb6ac4 | |
parent | aa65f0b204028f560fb98c3c7ab2f2eeca3aaca2 (diff) | |
download | chromium_src-4708098a8d03f9d0e7b5e6931f9c52c092e78fa9.zip chromium_src-4708098a8d03f9d0e7b5e6931f9c52c092e78fa9.tar.gz chromium_src-4708098a8d03f9d0e7b5e6931f9c52c092e78fa9.tar.bz2 |
Expose encrypted_only attribute on VDA supported profiles.
This allows us to reduce video playback startup for software codecs
from ~50-300ms (N5..Android One) to ~microseconds.
BUG=596236
CQ_INCLUDE_TRYBOTS=tryserver.chromium.win:win_optional_gpu_tests_rel;tryserver.chromium.mac:mac_optional_gpu_tests_rel
Review URL: https://codereview.chromium.org/1820553002
Cr-Commit-Position: refs/heads/master@{#382185}
-rw-r--r-- | content/common/gpu/gpu_param_traits_macros.h | 1 | ||||
-rw-r--r-- | content/common/gpu/media/android_video_decode_accelerator.cc | 27 | ||||
-rw-r--r-- | content/common/gpu/media/gpu_video_accelerator_util.cc | 2 | ||||
-rw-r--r-- | gpu/config/gpu_info.cc | 1 | ||||
-rw-r--r-- | gpu/config/gpu_info.h | 1 | ||||
-rw-r--r-- | media/filters/gpu_video_decoder.cc | 16 | ||||
-rw-r--r-- | media/filters/gpu_video_decoder.h | 5 | ||||
-rw-r--r-- | media/video/video_decode_accelerator.cc | 2 | ||||
-rw-r--r-- | media/video/video_decode_accelerator.h | 1 |
9 files changed, 39 insertions, 17 deletions
diff --git a/content/common/gpu/gpu_param_traits_macros.h b/content/common/gpu/gpu_param_traits_macros.h index f62399a..4932e7d 100644 --- a/content/common/gpu/gpu_param_traits_macros.h +++ b/content/common/gpu/gpu_param_traits_macros.h @@ -24,6 +24,7 @@ IPC_STRUCT_TRAITS_BEGIN(gpu::VideoDecodeAcceleratorSupportedProfile) IPC_STRUCT_TRAITS_MEMBER(profile) IPC_STRUCT_TRAITS_MEMBER(max_resolution) IPC_STRUCT_TRAITS_MEMBER(min_resolution) + IPC_STRUCT_TRAITS_MEMBER(encrypted_only) IPC_STRUCT_TRAITS_END() IPC_STRUCT_TRAITS_BEGIN(gpu::VideoDecodeAcceleratorCapabilities) diff --git a/content/common/gpu/media/android_video_decode_accelerator.cc b/content/common/gpu/media/android_video_decode_accelerator.cc index 9eccdc6..5e719f9 100644 --- a/content/common/gpu/media/android_video_decode_accelerator.cc +++ b/content/common/gpu/media/android_video_decode_accelerator.cc @@ -317,15 +317,10 @@ bool AndroidVideoDecodeAccelerator::Initialize(const Config& config, // Only use MediaCodec for VP8/9 if it's likely backed by hardware // or if the stream is encrypted. - if ((codec_ == media::kCodecVP8 || codec_ == media::kCodecVP9) && - !is_encrypted_) { - if (media::VideoCodecBridge::IsKnownUnaccelerated( - codec_, media::MEDIA_CODEC_DECODER)) { - DVLOG(1) << "Initialization failed: " - << (codec_ == media::kCodecVP8 ? "vp8" : "vp9") - << " is not hardware accelerated"; - return false; - } + if (codec_ == media::kCodecVP8 || codec_ == media::kCodecVP9) { + DCHECK(is_encrypted_ || + !media::VideoCodecBridge::IsKnownUnaccelerated( + codec_, media::MEDIA_CODEC_DECODER)); } if (!make_context_current_.Run()) { @@ -1175,6 +1170,13 @@ AndroidVideoDecodeAccelerator::GetCapabilities() { profile.profile = media::VP8PROFILE_ANY; profile.min_resolution.SetSize(0, 0); profile.max_resolution.SetSize(1920, 1088); + // If we know MediaCodec will just create a software codec, prefer our + // internal software decoder instead. It's more up to date and secured + // within the renderer sandbox. However if the content is encrypted, we + // must use MediaCodec anyways since MediaDrm offers no way to decrypt + // the buffers and let us use our internal software decoders. + profile.encrypted_only = media::VideoCodecBridge::IsKnownUnaccelerated( + media::kCodecVP8, media::MEDIA_CODEC_DECODER); profiles.push_back(profile); } @@ -1182,6 +1184,13 @@ AndroidVideoDecodeAccelerator::GetCapabilities() { profile.profile = media::VP9PROFILE_ANY; profile.min_resolution.SetSize(0, 0); profile.max_resolution.SetSize(1920, 1088); + // If we know MediaCodec will just create a software codec, prefer our + // internal software decoder instead. It's more up to date and secured + // within the renderer sandbox. However if the content is encrypted, we + // must use MediaCodec anyways since MediaDrm offers no way to decrypt + // the buffers and let us use our internal software decoders. + profile.encrypted_only = media::VideoCodecBridge::IsKnownUnaccelerated( + media::kCodecVP9, media::MEDIA_CODEC_DECODER); profiles.push_back(profile); } diff --git a/content/common/gpu/media/gpu_video_accelerator_util.cc b/content/common/gpu/media/gpu_video_accelerator_util.cc index 7692fdd..635e331 100644 --- a/content/common/gpu/media/gpu_video_accelerator_util.cc +++ b/content/common/gpu/media/gpu_video_accelerator_util.cc @@ -52,6 +52,7 @@ GpuVideoAcceleratorUtil::ConvertGpuToMediaDecodeProfiles(const static_cast<media::VideoCodecProfile>(gpu_profile.profile); profile.max_resolution = gpu_profile.max_resolution; profile.min_resolution = gpu_profile.min_resolution; + profile.encrypted_only = gpu_profile.encrypted_only; profiles.push_back(profile); } return profiles; @@ -79,6 +80,7 @@ GpuVideoAcceleratorUtil::ConvertMediaToGpuDecodeProfiles(const static_cast<gpu::VideoCodecProfile>(media_profile.profile); profile.max_resolution = media_profile.max_resolution; profile.min_resolution = media_profile.min_resolution; + profile.encrypted_only = media_profile.encrypted_only; profiles.push_back(profile); } return profiles; diff --git a/gpu/config/gpu_info.cc b/gpu/config/gpu_info.cc index 4b442f3..58a871f 100644 --- a/gpu/config/gpu_info.cc +++ b/gpu/config/gpu_info.cc @@ -28,6 +28,7 @@ void EnumerateVideoDecodeAcceleratorSupportedProfile( enumerator->AddInt("maxResolutionHeight", profile.max_resolution.height()); enumerator->AddInt("minResolutionWidth", profile.min_resolution.width()); enumerator->AddInt("minResolutionHeight", profile.min_resolution.height()); + enumerator->AddBool("encrypted_only", profile.encrypted_only); enumerator->EndVideoDecodeAcceleratorSupportedProfile(); } diff --git a/gpu/config/gpu_info.h b/gpu/config/gpu_info.h index 568bd46..6e9817a 100644 --- a/gpu/config/gpu_info.h +++ b/gpu/config/gpu_info.h @@ -60,6 +60,7 @@ struct GPU_EXPORT VideoDecodeAcceleratorSupportedProfile { VideoCodecProfile profile; gfx::Size max_resolution; gfx::Size min_resolution; + bool encrypted_only; }; using VideoDecodeAcceleratorSupportedProfiles = diff --git a/media/filters/gpu_video_decoder.cc b/media/filters/gpu_video_decoder.cc index 0109dc7..6100bdc 100644 --- a/media/filters/gpu_video_decoder.cc +++ b/media/filters/gpu_video_decoder.cc @@ -168,10 +168,12 @@ void GpuVideoDecoder::Initialize(const VideoDecoderConfig& config, VideoDecodeAccelerator::Capabilities capabilities = factories_->GetVideoDecodeAcceleratorCapabilities(); - if (!IsProfileSupported(capabilities, config.profile(), - config.coded_size())) { - DVLOG(1) << "Profile " << config.profile() << " or coded size " - << config.coded_size().ToString() << " not supported."; + if (!IsProfileSupported(capabilities, config.profile(), config.coded_size(), + config.is_encrypted())) { + DVLOG(1) << "Unsupported profile " << config.profile() + << ", unsupported coded size " << config.coded_size().ToString() + << ", or accelerator should only be used for encrypted content. " + << " is_encrypted: " << (config.is_encrypted() ? "yes." : "no."); bound_init_cb.Run(false); return; } @@ -708,10 +710,14 @@ void GpuVideoDecoder::NotifyError(media::VideoDecodeAccelerator::Error error) { bool GpuVideoDecoder::IsProfileSupported( const VideoDecodeAccelerator::Capabilities& capabilities, VideoCodecProfile profile, - const gfx::Size& coded_size) { + const gfx::Size& coded_size, + bool is_encrypted) { DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent(); for (const auto& supported_profile : capabilities.supported_profiles) { if (profile == supported_profile.profile) { + if (supported_profile.encrypted_only && !is_encrypted) + continue; + return IsCodedSizeSupported(coded_size, supported_profile.min_resolution, supported_profile.max_resolution); diff --git a/media/filters/gpu_video_decoder.h b/media/filters/gpu_video_decoder.h index c615684..3e6c0ca 100644 --- a/media/filters/gpu_video_decoder.h +++ b/media/filters/gpu_video_decoder.h @@ -142,11 +142,12 @@ class MEDIA_EXPORT GpuVideoDecoder void DestroyPictureBuffers(PictureBufferMap* buffers); // Returns true if the video decoder with |capabilities| can support - // |profile| and |coded_size|. + // |profile|, |coded_size|, and |is_encrypted|. bool IsProfileSupported( const VideoDecodeAccelerator::Capabilities& capabilities, VideoCodecProfile profile, - const gfx::Size& coded_size); + const gfx::Size& coded_size, + bool is_encrypted); // Assert the contract that this class is operated on the right thread. void DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent() const; diff --git a/media/video/video_decode_accelerator.cc b/media/video/video_decode_accelerator.cc index 4275d5f..f99787a 100644 --- a/media/video/video_decode_accelerator.cc +++ b/media/video/video_decode_accelerator.cc @@ -45,7 +45,7 @@ GLenum VideoDecodeAccelerator::GetSurfaceInternalFormat() const { } VideoDecodeAccelerator::SupportedProfile::SupportedProfile() - : profile(media::VIDEO_CODEC_PROFILE_UNKNOWN) {} + : profile(media::VIDEO_CODEC_PROFILE_UNKNOWN), encrypted_only(false) {} VideoDecodeAccelerator::SupportedProfile::~SupportedProfile() {} diff --git a/media/video/video_decode_accelerator.h b/media/video/video_decode_accelerator.h index c0f6b1e..ad73432 100644 --- a/media/video/video_decode_accelerator.h +++ b/media/video/video_decode_accelerator.h @@ -33,6 +33,7 @@ class MEDIA_EXPORT VideoDecodeAccelerator { VideoCodecProfile profile; gfx::Size max_resolution; gfx::Size min_resolution; + bool encrypted_only; }; using SupportedProfiles = std::vector<SupportedProfile>; |