Index: content/common/gpu/media/vaapi_drm_picture.cc |
diff --git a/content/common/gpu/media/vaapi_drm_picture.cc b/content/common/gpu/media/vaapi_drm_picture.cc |
index 45cd8b3083bb57a2c926de54ae75e53c3e3d4fca..84b485e1582e26d91805f908b2e13fce9dc08990 100644 |
--- a/content/common/gpu/media/vaapi_drm_picture.cc |
+++ b/content/common/gpu/media/vaapi_drm_picture.cc |
@@ -19,6 +19,18 @@ |
namespace content { |
+int GetVASurfaceFormatFromPixmapFormat(gfx::BufferFormat fmt) { |
+ switch (fmt) { |
+ case gfx::BufferFormat::BGRX_8888: |
+ return VA_FOURCC_BGRX; |
+ case gfx::BufferFormat::UYVY_422: |
+ return VA_FOURCC_UYVY; |
+ default: |
+ NOTREACHED(); |
+ return 0; |
+ } |
+} |
+ |
VaapiDrmPicture::VaapiDrmPicture( |
VaapiWrapper* vaapi_wrapper, |
const base::Callback<bool(void)>& make_context_current, |
@@ -54,7 +66,8 @@ scoped_refptr<VASurface> VaapiDrmPicture::CreateVASurfaceForPixmap( |
// Create a VASurface out of the created buffer using the dmabuf. |
VASurfaceAttribExternalBuffers va_attrib_extbuf; |
memset(&va_attrib_extbuf, 0, sizeof(va_attrib_extbuf)); |
- va_attrib_extbuf.pixel_format = VA_FOURCC_BGRX; |
+ va_attrib_extbuf.pixel_format = |
+ GetVASurfaceFormatFromPixmapFormat(pixmap->GetPixelFormat()); |
va_attrib_extbuf.width = pixmap_size.width(); |
va_attrib_extbuf.height = pixmap_size.height(); |
va_attrib_extbuf.data_size = pixmap_size.height() * dmabuf_pitch; |
@@ -80,7 +93,9 @@ scoped_refptr<VASurface> VaapiDrmPicture::CreateVASurfaceForPixmap( |
va_attribs[1].value.value.p = &va_attrib_extbuf; |
scoped_refptr<VASurface> va_surface = vaapi_wrapper_->CreateUnownedSurface( |
- VA_RT_FORMAT_RGB32, pixmap_size, va_attribs); |
+ va_attrib_extbuf.pixel_format == VA_FOURCC_UYVY ? VA_RT_FORMAT_YUV422 |
+ : VA_RT_FORMAT_RGB32, |
+ pixmap_size, va_attribs); |
if (!va_surface) { |
LOG(ERROR) << "Failed to create VASurface for an Ozone NativePixmap"; |
return nullptr; |
@@ -90,13 +105,13 @@ scoped_refptr<VASurface> VaapiDrmPicture::CreateVASurfaceForPixmap( |
} |
scoped_refptr<ui::NativePixmap> VaapiDrmPicture::CreateNativePixmap( |
- gfx::Size size) { |
+ gfx::Size size, |
+ gfx::BufferFormat format) { |
ui::OzonePlatform* platform = ui::OzonePlatform::GetInstance(); |
ui::SurfaceFactoryOzone* factory = platform->GetSurfaceFactoryOzone(); |
// Create a buffer from Ozone. |
- return factory->CreateNativePixmap(gfx::kNullAcceleratedWidget, size, |
- gfx::BufferFormat::BGRX_8888, |
+ return factory->CreateNativePixmap(gfx::kNullAcceleratedWidget, size, format, |
gfx::BufferUsage::SCANOUT); |
} |
@@ -104,7 +119,7 @@ bool VaapiDrmPicture::Initialize() { |
// We want to create a VASurface and an EGLImage out of the same |
// memory buffer, so we can output decoded pictures to it using |
// VAAPI and also use it to paint with GL. |
- pixmap_ = CreateNativePixmap(size()); |
+ pixmap_ = CreateNativePixmap(size(), gfx::BufferFormat::BGRX_8888); |
if (!pixmap_) { |
LOG(ERROR) << "Failed creating an Ozone NativePixmap"; |
return false; |
@@ -163,7 +178,11 @@ scoped_refptr<ui::NativePixmap> VaapiDrmPicture::CallScalePixmap( |
scoped_refptr<ui::NativePixmap> VaapiDrmPicture::ScalePixmap( |
gfx::Size new_size) { |
if (!scaled_va_surface_.get() || scaled_va_surface_->size() != new_size) { |
- scaled_pixmap_ = CreateNativePixmap(new_size); |
+ // Fallback to RGB format is hardware overlay is not allowed as YUV format |
alexst (slow to review)
2015/10/22 13:00:19
Apologies, I find this comment a bit confusing. Co
william.xie1
2015/10/22 14:18:10
Dear Alex,
Actually it's safe to always create UYV
kalyank
2015/10/22 15:39:59
ScalePixmap is called only when we need to scale o
|
+ // has no benifit on main plane. |
+ scaled_pixmap_ = CreateNativePixmap( |
+ new_size, AllowOverlay() ? gfx::BufferFormat::UYVY_422 |
+ : gfx::BufferFormat::BGRX_8888); |
if (!scaled_pixmap_) { |
LOG(ERROR) << "Failed creating an Ozone NativePixmap for scaling"; |
scaled_va_surface_ = nullptr; |