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..e1880a9cd4ce3f8a978e5098e3671989be8a9082 100644 |
--- a/content/common/gpu/media/vaapi_drm_picture.cc |
+++ b/content/common/gpu/media/vaapi_drm_picture.cc |
@@ -19,6 +19,35 @@ |
namespace content { |
+// Format for storing the video decoded pictures |
Pawel Osciak
2015/10/30 02:38:34
Nit: please use dots at the end of sentences.
Also
william.xie1
2015/10/30 08:52:17
Done.
|
+const gfx::BufferFormat kPictureStorageFormat = gfx::BufferFormat::BGRX_8888; |
+// Format for renderring the video pictures |
Pawel Osciak
2015/10/30 02:38:34
This is also not precise enough. We don't use this
william.xie1
2015/10/30 08:52:17
Done.
|
+const gfx::BufferFormat kPictureRenderFormat = gfx::BufferFormat::UYVY_422; |
+ |
+uint32_t BufferFormatToVAFourCC(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; |
+ } |
+} |
+ |
+uint32_t VAFourCCToVARTFormat(uint32_t fourcc) { |
+ switch (fourcc) { |
+ case VA_FOURCC_UYVY: |
+ return VA_RT_FORMAT_YUV422; |
+ case VA_FOURCC_BGRX: |
+ return VA_RT_FORMAT_RGB32; |
+ default: |
+ NOTREACHED(); |
+ return 0; |
+ } |
+} |
+ |
VaapiDrmPicture::VaapiDrmPicture( |
VaapiWrapper* vaapi_wrapper, |
const base::Callback<bool(void)>& make_context_current, |
@@ -54,7 +83,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 = |
+ BufferFormatToVAFourCC(pixmap->GetBufferFormat()); |
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 +110,8 @@ 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); |
+ VAFourCCToVARTFormat(va_attrib_extbuf.pixel_format), pixmap_size, |
+ va_attribs); |
if (!va_surface) { |
LOG(ERROR) << "Failed to create VASurface for an Ozone NativePixmap"; |
return nullptr; |
@@ -90,13 +121,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 +135,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(), kPictureStorageFormat); |
if (!pixmap_) { |
LOG(ERROR) << "Failed creating an Ozone NativePixmap"; |
return false; |
@@ -163,7 +194,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, kPictureRenderFormat); |
kalyank
2015/10/29 17:49:40
Sorry, if I wasn't clear earlier, hardcoding the f
Pawel Osciak
2015/10/30 02:38:34
+1 to this, this is basically what I was hoping fo
william.xie1
2015/10/30 08:52:17
Done.
william.xie1
2015/10/30 08:52:17
Done.
william.xie1
2015/10/30 08:52:17
We get the optimal format from ozone platform, cur
seanvk
2015/10/30 15:20:43
Keep in mind too that SoC x86 platforms may use ot
|
if (!scaled_pixmap_) { |
LOG(ERROR) << "Failed creating an Ozone NativePixmap for scaling"; |
scaled_va_surface_ = nullptr; |