Chromium Code Reviews| Index: content/common/gpu/media/android_video_decode_accelerator.cc |
| diff --git a/content/common/gpu/media/android_video_decode_accelerator.cc b/content/common/gpu/media/android_video_decode_accelerator.cc |
| index 06d59863d049cacd6c03b22a0ebbf0e908d9755e..e67ac518e9012977c198bd3af465123c8d6dd533 100644 |
| --- a/content/common/gpu/media/android_video_decode_accelerator.cc |
| +++ b/content/common/gpu/media/android_video_decode_accelerator.cc |
| @@ -12,6 +12,7 @@ |
| #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
| #include "media/base/bitstream_buffer.h" |
| #include "media/base/limits.h" |
| +#include "media/base/video_decoder_config.h" |
| #include "media/video/picture.h" |
| #include "ui/gl/android/scoped_java_surface.h" |
| #include "ui/gl/android/surface_texture.h" |
| @@ -88,18 +89,26 @@ bool AndroidVideoDecodeAccelerator::Initialize(media::VideoCodecProfile profile, |
| DCHECK(thread_checker_.CalledOnValidThread()); |
| client_ = client; |
| + codec_ = VideoCodecProfileToVideoCodec(profile); |
| - if (profile == media::VP8PROFILE_ANY) { |
| - codec_ = media::kCodecVP8; |
| - } else { |
| - // TODO(dwkang): enable H264 once b/8125974 is fixed. |
| + bool profile_supported = codec_ == media::kCodecVP8; |
| +#if defined(ENABLE_MEDIA_PIPELINE_ON_ANDROID) |
| + profile_supported |= |
| + (codec_ == media::kCodecVP9 || codec_ == media::kCodecH264); |
| +#endif |
| + |
| + if (!profile_supported) { |
| LOG(ERROR) << "Unsupported profile: " << profile; |
| return false; |
| } |
| - // Only consider using MediaCodec if it's likely backed by hardware. |
| - if (media::VideoCodecBridge::IsKnownUnaccelerated( |
| + // Only use MediaCodec for VP8/9 if it's likely backed by hardware. |
| + if ((codec_ == media::kCodecVP8 || codec_ == media::kCodecVP9) && |
| + media::VideoCodecBridge::IsKnownUnaccelerated( |
| codec_, media::MEDIA_CODEC_DECODER)) { |
| + DVLOG(1) << "Initialization failed: " |
| + << (codec_ == media::kCodecVP8 ? "vp8" : "vp9") |
| + << " is not hardware accelerated"; |
| return false; |
| } |
| @@ -558,15 +567,37 @@ void AndroidVideoDecodeAccelerator::NotifyError( |
| media::VideoDecodeAccelerator::SupportedProfiles |
| AndroidVideoDecodeAccelerator::GetSupportedProfiles() { |
| SupportedProfiles profiles; |
| - if (media::VideoCodecBridge::IsKnownUnaccelerated( |
| + |
| + if (!media::VideoCodecBridge::IsKnownUnaccelerated( |
| media::kCodecVP8, media::MEDIA_CODEC_DECODER)) { |
| - return profiles; |
| + SupportedProfile profile; |
| + profile.profile = media::VP8PROFILE_ANY; |
| + profile.min_resolution.SetSize(0, 0); |
| + profile.max_resolution.SetSize(1920, 1088); |
| + profiles.push_back(profile); |
| } |
| + |
| +#if defined(ENABLE_MEDIA_PIPELINE_ON_ANDROID) |
| + if (!media::VideoCodecBridge::IsKnownUnaccelerated( |
| + media::kCodecVP9, media::MEDIA_CODEC_DECODER)) { |
| + SupportedProfile profile; |
| + profile.profile = media::VP9PROFILE_ANY; |
| + profile.min_resolution.SetSize(0, 0); |
| + profile.max_resolution.SetSize(1920, 1088); |
| + profiles.push_back(profile); |
| + } |
| + |
| SupportedProfile profile; |
| - profile.profile = media::VP8PROFILE_ANY; |
| - profile.min_resolution.SetSize(16, 16); |
| - profile.max_resolution.SetSize(1920, 1088); |
| + // MediaCodec is only guaranteed to support the baseline profile. |
| + profile.profile = media::H264PROFILE_BASELINE; |
|
DaleCurtis
2015/08/11 19:15:46
As discussed offline we should go ahead and includ
watk
2015/08/11 20:07:47
Done.
|
| + profile.min_resolution.SetSize(0, 0); |
| + // MediaCodec resolution support is likely device dependent, but it's |
| + // expected that consumers won't have software fallback for h264 on Android, |
| + // so it's ok to overpromise and fail to decode later. |
| + profile.max_resolution.SetSize(3840, 2160); |
| profiles.push_back(profile); |
| +#endif |
| + |
| return profiles; |
| } |