Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(591)

Unified Diff: content/common/gpu/media/vaapi_wrapper.cc

Issue 825843002: Add JPEG decoder for VAAPI JPEG decode acceleration (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mjpeg-vaapi-jpeg-parser
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/common/gpu/media/vaapi_wrapper.h ('k') | content/content_common.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..588fee3981e59072c6118996099258acaa51e82b 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))
+ 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))
+ return nullptr;
return vaapi_wrapper.Pass();
}
@@ -338,15 +360,7 @@ bool VaapiWrapper::AreAttribsSupported(
return true;
}
-bool VaapiWrapper::Initialize(CodecMode mode,
- media::VideoCodecProfile 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);
+bool VaapiWrapper::Initialize(CodecMode mode, VAProfile va_profile) {
if (va_profile == VAProfileNone) {
DVLOG(1) << "Unsupported profile";
return false;
@@ -665,9 +679,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 +705,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);
« no previous file with comments | « content/common/gpu/media/vaapi_wrapper.h ('k') | content/content_common.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698