-
Notifications
You must be signed in to change notification settings - Fork 78
Enable zero buffer copy method for wayland VDA. #260
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
Alexis Menard <[email protected]> | ||
Changbin Shao <[email protected]> | ||
Daniel Narvaez <[email protected]> | ||
Dongseong Hwang <[email protected]> | ||
Eduardo Lima (Etrunko) <[email protected]> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ | |
#include "media/media/va_stubs.h" | ||
|
||
#include "third_party/libva/va/wayland/va_wayland.h" | ||
#include "third_party/libva/va/va_drmcommon.h" | ||
|
||
using media_media::kModuleVa_wayland; | ||
using media_media::InitializeStubs; | ||
|
@@ -23,6 +24,9 @@ using media_media::StubPathMap; | |
static const base::FilePath::CharType kVaLib[] = | ||
FILE_PATH_LITERAL("libva-wayland.so.1"); | ||
|
||
static const char kVaLockBufferSymbol[] = "vaLockBuffer"; | ||
static const char kVaUnlockBufferSymbol[] = "vaUnlockBuffer"; | ||
|
||
#define LOG_VA_ERROR_AND_REPORT(va_error, err_msg) \ | ||
do { \ | ||
DVLOG(1) << err_msg \ | ||
|
@@ -370,14 +374,15 @@ bool VaapiWrapper::CreateRGBImage(gfx::Size size, VAImage* image) { | |
base::AutoLock auto_lock(va_lock_); | ||
VAStatus va_res; | ||
VAImageFormat format; | ||
format.fourcc = VA_FOURCC_RGBX; | ||
format.fourcc = VA_FOURCC_BGRX; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why is this really needed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Previous solution use GL_RGBA format to create GL texture, so it declares VA_FOURCC_RGBX('X' takes 'A' - alpha position) here. The new solution uses format EGL_DRM_BUFFER_FORMAT_ARGB32_MESA to create EGL image, so need to use VA_FOURCC_BGRX instead. Otherwise, color is not correct when video playback. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. care to change the name of the function as well then? |
||
format.byte_order = VA_LSB_FIRST; | ||
format.bits_per_pixel = 32; | ||
format.depth = 24; | ||
format.red_mask = 0xff; | ||
format.green_mask = 0xff00; | ||
format.red_mask = 0x0000ff; | ||
format.green_mask = 0x00ff00; | ||
format.blue_mask = 0xff0000; | ||
format.alpha_mask = 0; | ||
|
||
va_res = vaCreateImage(va_display_, | ||
&format, | ||
size.width(), | ||
|
@@ -421,6 +426,32 @@ bool VaapiWrapper::PutSurfaceIntoImage(VASurfaceID va_surface_id, | |
VA_SUCCESS_OR_RETURN(va_res, "Failed to put surface into image", false); | ||
return true; | ||
} | ||
|
||
bool VaapiWrapper::LockBuffer(VASurfaceID va_surface_id, | ||
VABufferID buf_id, | ||
VABufferInfo* buf_info) { | ||
DCHECK(buf_info); | ||
base::AutoLock auto_lock(va_lock_); | ||
|
||
buf_info->mem_type = VA_SURFACE_ATTRIB_MEM_TYPE_KERNEL_DRM; | ||
VAStatus va_res = vaLockBuffer(va_display_, buf_id, buf_info); | ||
VA_SUCCESS_OR_RETURN(va_res, "Failed to lock vabuffer", false); | ||
|
||
return true; | ||
} | ||
|
||
bool VaapiWrapper::UnlockBuffer(VASurfaceID va_surface_id, | ||
VABufferID buf_id, | ||
VABufferInfo* buf_info) { | ||
DCHECK(buf_info); | ||
base::AutoLock auto_lock(va_lock_); | ||
VAStatus va_res = vaUnlockBuffer(va_display_, buf_id, buf_info); | ||
VA_SUCCESS_OR_RETURN(va_res, "Failed to unlock vabuffer", false); | ||
|
||
return true; | ||
} | ||
|
||
|
||
bool VaapiWrapper::GetVaImageForTesting(VASurfaceID va_surface_id, | ||
VAImage* image, | ||
void** mem) { | ||
|
@@ -462,4 +493,14 @@ bool VaapiWrapper::PostSandboxInitialization() { | |
return ret; | ||
} | ||
|
||
bool VaapiWrapper::SupportsVaLockBufferApis() { | ||
void* handle = dlopen(kVaLib, RTLD_LAZY); | ||
if (!handle) { | ||
LOG(ERROR) << "Could not open " << kVaLib; | ||
return false; | ||
} | ||
return dlsym(handle, kVaLockBufferSymbol) && | ||
dlsym(handle, kVaUnlockBufferSymbol); | ||
} | ||
|
||
} // namespace media |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why destroy egl_image_, if it's already null? What's the case that it falls in this conditional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
EGL_NO_IMAGE_KHR equals NULL here. There is GL mapping of eglCreateImageKHR and eglDestroyImageKHR, so release an EGL image first before create a new one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fine. thanks.