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..fa207301bec4e8328b9cbd2e3d56dbad72529c00 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) { |
wuchengli
2015/01/30 06:38:59
Not used. Remove.
kcwu
2015/01/30 06:52:34
Done.
|
- 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::GetDerivedVaImage(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,40 @@ 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 false; |
+ } |
+ |
+ return true; |
+} |
+ |
+void VaapiWrapper::ReturnVaImage(VAImage* image) { |
base::AutoLock auto_lock(va_lock_); |
VAStatus va_res = vaUnmapBuffer(va_display_, image->buf); |