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

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

Issue 1422563002: [Ozone] Enables overlay render format setting path and by default use UYVY (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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_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..15bcf547fb007b8de6ddf47ffbf1d301a5293361 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(int fmt) {
+ switch (fmt) {
+ case GBM_FORMAT_XRGB8888:
+ return VA_FOURCC_BGRX;
kalyank 2015/10/21 19:48:41 Hmm do we need this conversion ? GBM_FORMAT_* are
marcheu1 2015/10/21 19:58:57 Sadly, there are formats like GBM_BO_FORMAT_XRGB88
kalyank 2015/10/21 20:20:00 We shouldn't be using GBM_BO_FORMAT_XRGB8888 at al
william.xie1 2015/10/22 07:35:41 Suggested by Spang, here is gfx::BufferFormat to V
william.xie1 2015/10/22 07:35:41 Acknowledged.
+ case GBM_FORMAT_UYVY:
+ 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;
@@ -144,8 +159,7 @@ bool VaapiDrmPicture::Initialize() {
bool VaapiDrmPicture::DownloadFromSurface(
const scoped_refptr<VASurface>& va_surface) {
- return vaapi_wrapper_->BlitSurface(va_surface->id(), va_surface->size(),
- va_surface_->id(), va_surface_->size());
+ return vaapi_wrapper_->BlitSurface(va_surface, va_surface_);
}
// static
@@ -163,7 +177,7 @@ 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);
+ scaled_pixmap_ = CreateNativePixmap(new_size, gfx::BufferFormat::UYVY_422);
kalyank 2015/10/21 19:48:41 We use UYUY format when scaling is needed otherwis
kalyank 2015/10/21 21:32:23 Using YUV formats has benefits when video buffer c
seanvk 2015/10/21 21:38:34 Agree with @kalyank. We should not be assuming ha
william.xie1 2015/10/22 07:35:41 Done.
william.xie1 2015/10/22 07:35:41 Done.
if (!scaled_pixmap_) {
LOG(ERROR) << "Failed creating an Ozone NativePixmap for scaling";
scaled_va_surface_ = nullptr;
@@ -178,9 +192,8 @@ scoped_refptr<ui::NativePixmap> VaapiDrmPicture::ScalePixmap(
}
DCHECK(scaled_pixmap_);
- bool vpp_result = vaapi_wrapper_->BlitSurface(
- va_surface_->id(), va_surface_->size(), scaled_va_surface_->id(),
- scaled_va_surface_->size());
+ bool vpp_result =
+ vaapi_wrapper_->BlitSurface(va_surface_, scaled_va_surface_);
if (!vpp_result) {
LOG(ERROR) << "Failed scaling NativePixmap";
scaled_pixmap_ = nullptr;

Powered by Google App Engine
This is Rietveld 408576698