Chromium Code Reviews| Index: content/common/gpu/media/vaapi_wrapper.h |
| diff --git a/content/common/gpu/media/vaapi_wrapper.h b/content/common/gpu/media/vaapi_wrapper.h |
| index d21f3f1ee5ec52ece294ce53594c01e4f7252846..e93326318b43e1a985e15ff45589b9164a7fd042 100644 |
| --- a/content/common/gpu/media/vaapi_wrapper.h |
| +++ b/content/common/gpu/media/vaapi_wrapper.h |
| @@ -13,12 +13,14 @@ |
| #include <set> |
| #include <vector> |
| +#include "base/lazy_instance.h" |
| #include "base/memory/ref_counted.h" |
| #include "base/synchronization/lock.h" |
| #include "content/common/content_export.h" |
| #include "content/common/gpu/media/va_surface.h" |
| #include "media/base/video_decoder_config.h" |
| #include "media/base/video_frame.h" |
| +#include "media/video/video_encode_accelerator.h" |
| #include "third_party/libva/va/va.h" |
| #include "third_party/libva/va/va_vpp.h" |
| #include "ui/gfx/geometry/size.h" |
| @@ -43,14 +45,15 @@ class CONTENT_EXPORT VaapiWrapper { |
| enum CodecMode { |
| kDecode, |
| kEncode, |
| + kCodecModeMax, |
| }; |
| - // Create VaapiWrapper for VAProfile. |
| - // |report_error_to_uma_cb| will be called independently from reporting |
| - // errors to clients via method return values. |
| + // Return an instance of VaapiWrapper initialized for |va_profile| and |
| + // |mode|. |report_error_to_uma_cb| will be called independently from |
| + // reporting errors to clients via method return values. |
| static scoped_ptr<VaapiWrapper> Create( |
| CodecMode mode, |
| - VAProfile profile, |
| + VAProfile va_profile, |
| const base::Closure& report_error_to_uma_cb); |
| // Create VaapiWrapper for VideoCodecProfile. It maps VideoCodecProfile |
| @@ -63,8 +66,14 @@ class CONTENT_EXPORT VaapiWrapper { |
| const base::Closure& report_error_to_uma_cb); |
| // Return the supported encode profiles. |
| - static std::vector<media::VideoCodecProfile> GetSupportedEncodeProfiles( |
| - const base::Closure& report_error_to_uma_cb); |
| + static std::vector<media::VideoEncodeAccelerator::SupportedProfile> |
| + GetSupportedEncodeProfiles(); |
| + |
| + // This workaround is for crbug.com/345569. If va_profile is h264 baseline |
| + // and it is not supported. We try constrained baseline. |
|
wuchengli
2015/03/04 04:03:18
s/supported. We/supported, we/
henryhsu
2015/03/04 06:30:18
Done.
|
| + static VAProfile CheckConstrainedBaselineWorkaround( |
|
wuchengli
2015/03/04 04:03:18
This should be moved to private.
henryhsu
2015/03/04 06:30:17
Done.
|
| + CodecMode mode, |
| + VAProfile va_profile); |
| ~VaapiWrapper(); |
| @@ -183,6 +192,22 @@ class CONTENT_EXPORT VaapiWrapper { |
| const gfx::Size& dest_size); |
| private: |
| + struct ProfileInfo { |
| + VAProfile va_profile; |
| + gfx::Size max_resolution; |
| + }; |
| + |
| + class LazyProfileInfos { |
| + public: |
| + LazyProfileInfos(); |
| + ~LazyProfileInfos(); |
| + std::vector<ProfileInfo> GetSupportedProfileInfosForCodecMode( |
| + CodecMode mode); |
| + bool IsProfileSupported(CodecMode mode, VAProfile va_profile); |
| + private: |
| + std::vector<ProfileInfo> supported_profiles_[kCodecModeMax]; |
| + }; |
| + |
| VaapiWrapper(); |
| bool Initialize(CodecMode mode, VAProfile va_profile); |
| @@ -194,6 +219,11 @@ class CONTENT_EXPORT VaapiWrapper { |
| VAEntrypoint entrypoint, |
| const std::vector<VAConfigAttrib>& required_attribs); |
| + // Get maximum resolution of a profile by |config|. If return value is true, |
| + // |resolution| is the maximum resolution. |
| + bool GetMaxResolutionForVAConfigID( |
| + VAConfigID va_config_id, gfx::Size* resolution); |
| + |
| // Destroys a |va_surface| created using CreateUnownedSurface. |
| void DestroyUnownedSurface(VASurfaceID va_surface_id); |
| @@ -212,10 +242,19 @@ class CONTENT_EXPORT VaapiWrapper { |
| // Attempt to set render mode to "render to texture.". Failure is non-fatal. |
| void TryToSetVADisplayAttributeToLocalGPU(); |
| + // Get all supported profile infos. |
| + std::vector<ProfileInfo> GetSupportedProfileInfosForCodecModeInternal( |
| + CodecMode mode); |
| + |
| // Lazily initialize static data after sandbox is enabled. Return false on |
| // init failure. |
| static bool PostSandboxInitialization(); |
| + // Get all supported profile infos. This is a wrapper of |
| + // GetSupportedProfileInfosForCodecModeInternal for static usage. |
| + static std::vector<ProfileInfo> GetSupportedProfileInfosForCodecMode( |
| + CodecMode mode); |
| + |
| // Libva is not thread safe, so we have to do locking for it ourselves. |
| // This lock is to be taken for the duration of all VA-API calls and for |
| // the entire job submission sequence in ExecuteAndDestroyPendingBuffers(). |
| @@ -255,6 +294,10 @@ class CONTENT_EXPORT VaapiWrapper { |
| VAContextID va_vpp_context_id_; |
| VABufferID va_vpp_buffer_id_; |
| + // Singleton variable to store supported profile information for encode and |
| + // decode. |
| + static base::LazyInstance<LazyProfileInfos> profile_infos_; |
| + |
| DISALLOW_COPY_AND_ASSIGN(VaapiWrapper); |
| }; |