| Index: content/common/gpu/media/vaapi_wrapper.cc
|
| diff --git a/content/common/gpu/media/vaapi_wrapper.cc b/content/common/gpu/media/vaapi_wrapper.cc
|
| index 63450b4a58001dba70505640f3b9197e7f75c896..34a92116314087f9ccb659c93c6e153e5b35c7f7 100644
|
| --- a/content/common/gpu/media/vaapi_wrapper.cc
|
| +++ b/content/common/gpu/media/vaapi_wrapper.cc
|
| @@ -164,12 +164,34 @@ VaapiWrapper::~VaapiWrapper() {
|
|
|
| scoped_ptr<VaapiWrapper> VaapiWrapper::Create(
|
| CodecMode mode,
|
| + VAProfile va_profile,
|
| + const base::Closure& report_error_to_uma_cb) {
|
| + scoped_ptr<VaapiWrapper> vaapi_wrapper(new VaapiWrapper());
|
| +
|
| + if (!vaapi_wrapper->VaInitialize(report_error_to_uma_cb))
|
| + return nullptr;
|
| + if (!vaapi_wrapper->Initialize(mode, va_profile, report_error_to_uma_cb))
|
| + return nullptr;
|
| +
|
| + return vaapi_wrapper.Pass();
|
| +}
|
| +
|
| +scoped_ptr<VaapiWrapper> VaapiWrapper::CreateForVideoCodec(
|
| + CodecMode mode,
|
| media::VideoCodecProfile profile,
|
| const base::Closure& report_error_to_uma_cb) {
|
| scoped_ptr<VaapiWrapper> vaapi_wrapper(new VaapiWrapper());
|
|
|
| - if (!vaapi_wrapper->Initialize(mode, profile, report_error_to_uma_cb))
|
| - vaapi_wrapper.reset();
|
| + if (!vaapi_wrapper->VaInitialize(report_error_to_uma_cb))
|
| + return nullptr;
|
| +
|
| + std::vector<VAProfile> supported_va_profiles;
|
| + if (!vaapi_wrapper->GetSupportedVaProfiles(&supported_va_profiles))
|
| + return nullptr;
|
| +
|
| + VAProfile va_profile = ProfileToVAProfile(profile, supported_va_profiles);
|
| + if (!vaapi_wrapper->Initialize(mode, va_profile, report_error_to_uma_cb))
|
| + return nullptr;
|
|
|
| return vaapi_wrapper.Pass();
|
| }
|
| @@ -339,14 +361,8 @@ bool VaapiWrapper::AreAttribsSupported(
|
| }
|
|
|
| bool VaapiWrapper::Initialize(CodecMode mode,
|
| - media::VideoCodecProfile profile,
|
| + VAProfile va_profile,
|
| const base::Closure& report_error_to_uma_cb) {
|
| - if (!VaInitialize(report_error_to_uma_cb))
|
| - return false;
|
| - std::vector<VAProfile> supported_va_profiles;
|
| - if (!GetSupportedVaProfiles(&supported_va_profiles))
|
| - return false;
|
| - VAProfile va_profile = ProfileToVAProfile(profile, supported_va_profiles);
|
| if (va_profile == VAProfileNone) {
|
| DVLOG(1) << "Unsupported profile";
|
| return false;
|
| @@ -665,9 +681,9 @@ bool VaapiWrapper::PutSurfaceIntoPixmap(VASurfaceID va_surface_id,
|
| }
|
| #endif // USE_X11
|
|
|
| -bool VaapiWrapper::GetVaImageForTesting(VASurfaceID va_surface_id,
|
| - VAImage* image,
|
| - void** mem) {
|
| +bool VaapiWrapper::GetDerivedVaImageForTesting(VASurfaceID va_surface_id,
|
| + VAImage* image,
|
| + void** mem) {
|
| base::AutoLock auto_lock(va_lock_);
|
|
|
| VAStatus va_res = vaSyncSurface(va_display_, va_surface_id);
|
| @@ -691,7 +707,39 @@ bool VaapiWrapper::GetVaImageForTesting(VASurfaceID va_surface_id,
|
| return false;
|
| }
|
|
|
| -void VaapiWrapper::ReturnVaImageForTesting(VAImage* image) {
|
| +bool VaapiWrapper::GetVaImage(VASurfaceID va_surface_id,
|
| + VAImageFormat* format,
|
| + const gfx::Size& size,
|
| + VAImage* image,
|
| + void** mem) {
|
| + base::AutoLock auto_lock(va_lock_);
|
| +
|
| + VAStatus va_res = vaSyncSurface(va_display_, va_surface_id);
|
| + VA_SUCCESS_OR_RETURN(va_res, "Failed syncing surface", false);
|
| +
|
| + va_res =
|
| + vaCreateImage(va_display_, format, size.width(), size.height(), image);
|
| + VA_SUCCESS_OR_RETURN(va_res, "vaCreateImage failed", false);
|
| +
|
| + va_res = vaGetImage(va_display_, va_surface_id, 0, 0, size.width(),
|
| + size.height(), image->image_id);
|
| + VA_LOG_ON_ERROR(va_res, "vaGetImage failed");
|
| +
|
| + if (va_res == VA_STATUS_SUCCESS) {
|
| + // Map the VAImage into memory
|
| + va_res = vaMapBuffer(va_display_, image->buf, mem);
|
| + VA_LOG_ON_ERROR(va_res, "vaMapBuffer failed");
|
| + }
|
| +
|
| + if (va_res != VA_STATUS_SUCCESS) {
|
| + va_res = vaDestroyImage(va_display_, image->image_id);
|
| + VA_LOG_ON_ERROR(va_res, "vaDestroyImage failed");
|
| + }
|
| +
|
| + return va_res == VA_STATUS_SUCCESS;
|
| +}
|
| +
|
| +void VaapiWrapper::ReturnVaImage(VAImage* image) {
|
| base::AutoLock auto_lock(va_lock_);
|
|
|
| VAStatus va_res = vaUnmapBuffer(va_display_, image->buf);
|
|
|