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

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

Issue 490233002: VaapiVideoAccelerator: make Vaapi accelerator work with ozone (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Don't limit h264_bitstream_buffer_unittest to x11 Created 6 years, 3 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
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 5e93b994db02dcf52301327e0c285b82a148e001..abbe74b7509b4397a68aaaf39b46d4e0f30e113f 100644
--- a/content/common/gpu/media/vaapi_wrapper.cc
+++ b/content/common/gpu/media/vaapi_wrapper.cc
@@ -13,15 +13,26 @@
// Auto-generated for dlopen libva libraries
#include "content/common/gpu/media/va_stubs.h"
#include "third_party/libyuv/include/libyuv.h"
+#if defined(USE_X11)
+#include "third_party/libva/va/va_x11.h"
+#include "ui/gfx/x/x11_types.h"
+#else
+#include "third_party/libva/va/drm/va_drm.h"
+#include "third_party/libva/va/va_drmcommon.h"
+#include "ui/ozone/public/ozone_platform.h"
+#include "ui/ozone/public/surface_factory_ozone.h"
+#endif // USE_X11
+#include "ui/gl/gl_bindings.h"
using content_common_gpu_media::kModuleVa;
+#if defined(USE_X11)
+using content_common_gpu_media::kModuleVa_x11;
+#else
+using content_common_gpu_media::kModuleVa_drm;
+#endif // USE_X11
using content_common_gpu_media::InitializeStubs;
using content_common_gpu_media::StubPathMap;
-// libva-x11 depends on libva, so dlopen libva-x11 is enough
-static const base::FilePath::CharType kVaLib[] =
- FILE_PATH_LITERAL("libva-x11.so.1");
-
#define LOG_VA_ERROR_AND_REPORT(va_error, err_msg) \
do { \
DVLOG(1) << err_msg \
@@ -128,12 +139,29 @@ VaapiWrapper::~VaapiWrapper() {
scoped_ptr<VaapiWrapper> VaapiWrapper::Create(
CodecMode mode,
media::VideoCodecProfile profile,
- Display* x_display,
const base::Closure& report_error_to_uma_cb) {
+ static bool vaapi_functions_initialized = PostSandboxInitialization();
scoped_ptr<VaapiWrapper> vaapi_wrapper(new VaapiWrapper());
- if (!vaapi_wrapper->Initialize(
- mode, profile, x_display, report_error_to_uma_cb))
+ if (!vaapi_functions_initialized) {
+ DVLOG(1) << "Failed to initialize VAAPI libs";
+ return vaapi_wrapper.Pass();
+ }
+
+ VADisplay va_display = NULL;
+#if defined(USE_X11)
+ va_display = vaGetDisplay(gfx::GetXDisplay());
+#else
+ ui::OzonePlatform* platform = ui::OzonePlatform::GetInstance();
+ ui::SurfaceFactoryOzone* factory = platform->GetSurfaceFactoryOzone();
+
+ va_display = vaGetDisplayDRM(factory->GetDrmFd());
jiajia.qin 2014/09/16 11:09:55 Hi, llandwerlin. Does it work for other external d
llandwerlin-old 2014/09/16 12:28:58 What do you mean by external display? Are you usin
spang 2014/09/16 16:31:28 No, it doesn't work with wayland. I'm hoping we ca
+#endif // USE_X11
+
+ if (!va_display || !vaapi_wrapper->Initialize(va_display,
+ mode,
+ profile,
+ report_error_to_uma_cb))
vaapi_wrapper.reset();
return vaapi_wrapper.Pass();
@@ -151,21 +179,15 @@ void VaapiWrapper::TryToSetVADisplayAttributeToLocalGPU() {
DVLOG(2) << "vaSetDisplayAttributes unsupported, ignoring by default.";
}
-bool VaapiWrapper::Initialize(CodecMode mode,
+bool VaapiWrapper::Initialize(VADisplay va_display,
+ CodecMode mode,
media::VideoCodecProfile profile,
- Display* x_display,
const base::Closure& report_error_to_uma_cb) {
- static bool vaapi_functions_initialized = PostSandboxInitialization();
- if (!vaapi_functions_initialized) {
- DVLOG(1) << "Failed to initialize VAAPI libs";
- return false;
- }
-
report_error_to_uma_cb_ = report_error_to_uma_cb;
base::AutoLock auto_lock(va_lock_);
- va_display_ = vaGetDisplay(x_display);
+ va_display_ = va_display;
if (!vaDisplayIsValid(va_display_)) {
DVLOG(1) << "Could not get a valid VA display";
return false;
@@ -198,7 +220,7 @@ bool VaapiWrapper::Initialize(CodecMode mode,
VAProfile va_profile = ProfileToVAProfile(profile, supported_profiles);
if (va_profile == VAProfileNone) {
- DVLOG(1) << "Unsupported profile";
+ DVLOG(1) << "Unsupported profile : " << profile;
return false;
}
@@ -296,7 +318,7 @@ bool VaapiWrapper::VAAPIVersionLessThan(int major, int minor) {
(major_version_ == major && minor_version_ < minor);
}
-bool VaapiWrapper::CreateSurfaces(gfx::Size size,
+bool VaapiWrapper::CreateSurfaces(const gfx::Size& size,
size_t num_surfaces,
std::vector<VASurfaceID>* va_surfaces) {
base::AutoLock auto_lock(va_lock_);
@@ -506,25 +528,6 @@ bool VaapiWrapper::ExecuteAndDestroyPendingBuffers(VASurfaceID va_surface_id) {
return result;
}
-bool VaapiWrapper::PutSurfaceIntoPixmap(VASurfaceID va_surface_id,
- Pixmap x_pixmap,
- gfx::Size dest_size) {
- 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);
-
- // Put the data into an X Pixmap.
- va_res = vaPutSurface(va_display_,
- va_surface_id,
- x_pixmap,
- 0, 0, dest_size.width(), dest_size.height(),
- 0, 0, dest_size.width(), dest_size.height(),
- NULL, 0, 0);
- VA_SUCCESS_OR_RETURN(va_res, "Failed putting surface to pixmap", false);
- return true;
-}
-
bool VaapiWrapper::GetVaImageForTesting(VASurfaceID va_surface_id,
VAImage* image,
void** mem) {
@@ -665,10 +668,22 @@ bool VaapiWrapper::DownloadAndDestroyCodedBuffer(VABufferID buffer_id,
return buffer_segment == NULL;
}
+VADisplay VaapiWrapper::GetDisplay() {
+ return va_display_;
+}
+
+
// static
bool VaapiWrapper::PostSandboxInitialization() {
StubPathMap paths;
- paths[kModuleVa].push_back(kVaLib);
+
+ paths[kModuleVa].push_back("libva.so.1");
+
+#if defined(USE_X11)
+ paths[kModuleVa_x11].push_back("libva-x11.so.1");
+#else
+ paths[kModuleVa_drm].push_back("libva-drm.so.1");
+#endif
return InitializeStubs(paths);
}

Powered by Google App Engine
This is Rietveld 408576698