Commit 02c39fa7 authored by Miguel Casas's avatar Miguel Casas Committed by Commit Bot

Support XR30 in GpuMemoryBufferVideoFramePool - Linux

This CL allows XR30 for GpuMemoryBufferVideoFramePool output
format in Linux (not CrOs yet), and teaches GLImageMemory how
to manipulate this format.

Unittests are extended, tested also with high bit depth
videos e.g.:
'http://crosvideo.appspot.com?codec=vp9.2&loop=true'
and media/test/data/...
- bear-320x180-hi10p-vp9.webm
- bear-320x180-hi10p.mp4 (this is an H.264 part 10, 10bpc)
- blackwhite_yuv420p_hi10p.mp4
- bear-320x180-hi12p-vp9.webm

Bug: 803975
Cq-Include-Trybots: master.tryserver.chromium.android:android_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel
Change-Id: Ie5fb3fa60036591fabdfcf774fcb0878b1ebca07
Reviewed-on: https://chromium-review.googlesource.com/881665
Commit-Queue: Miguel Casas <mcasas@chromium.org>
Reviewed-by: default avatarAntoine Labour <piman@chromium.org>
Reviewed-by: default avatarDaniele Castagna <dcastagna@chromium.org>
Cr-Commit-Position: refs/heads/master@{#533045}
parent f7a5c741
...@@ -305,9 +305,9 @@ GpuVideoAcceleratorFactoriesImpl::VideoFrameOutputFormat(size_t bit_depth) { ...@@ -305,9 +305,9 @@ GpuVideoAcceleratorFactoriesImpl::VideoFrameOutputFormat(size_t bit_depth) {
if (rendering_color_space_.IsHDR()) if (rendering_color_space_.IsHDR())
return media::GpuVideoAcceleratorFactories::OutputFormat::UNDEFINED; return media::GpuVideoAcceleratorFactories::OutputFormat::UNDEFINED;
#if defined(OS_MACOSX) #if defined(OS_MACOSX) || defined(OS_LINUX)
// TODO(mcasas): enable other platforms https://crbug.com/776093 // TODO(mcasas): enable other platforms https://crbug.com/776093
// https://crbug.com/803451, https://crbug.com/803975. // https://crbug.com/803451.
// TODO(mcasas): remove the |bit_depth| check when libyuv supports more than // TODO(mcasas): remove the |bit_depth| check when libyuv supports more than
// just x010ToAR30 conversions, https://crbug.com/libyuv/751. // just x010ToAR30 conversions, https://crbug.com/libyuv/751.
if (capabilities.image_xr30 && bit_depth == 10) if (capabilities.image_xr30 && bit_depth == 10)
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "ui/gfx/buffer_format_util.h" #include "ui/gfx/buffer_format_util.h"
#include "ui/gl/gl_bindings.h" #include "ui/gl/gl_bindings.h"
#include "ui/gl/gl_context.h" #include "ui/gl/gl_context.h"
#include "ui/gl/gl_enums.h"
#include "ui/gl/gl_version_info.h" #include "ui/gl/gl_version_info.h"
using gfx::BufferFormat; using gfx::BufferFormat;
...@@ -30,6 +31,7 @@ bool ValidInternalFormat(unsigned internalformat) { ...@@ -30,6 +31,7 @@ bool ValidInternalFormat(unsigned internalformat) {
case GL_RG: case GL_RG:
case GL_RGB: case GL_RGB:
case GL_RGBA: case GL_RGBA:
case GL_RGB10_A2_EXT:
case GL_BGRA_EXT: case GL_BGRA_EXT:
return true; return true;
default: default:
...@@ -52,10 +54,10 @@ bool ValidFormat(gfx::BufferFormat format) { ...@@ -52,10 +54,10 @@ bool ValidFormat(gfx::BufferFormat format) {
case gfx::BufferFormat::RGBX_8888: case gfx::BufferFormat::RGBX_8888:
case gfx::BufferFormat::RGBA_8888: case gfx::BufferFormat::RGBA_8888:
case gfx::BufferFormat::BGRX_8888: case gfx::BufferFormat::BGRX_8888:
case gfx::BufferFormat::BGRX_1010102:
case gfx::BufferFormat::BGRA_8888: case gfx::BufferFormat::BGRA_8888:
case gfx::BufferFormat::RGBA_F16: case gfx::BufferFormat::RGBA_F16:
return true; return true;
case gfx::BufferFormat::BGRX_1010102:
case gfx::BufferFormat::YVU_420: case gfx::BufferFormat::YVU_420:
case gfx::BufferFormat::YUV_420_BIPLANAR: case gfx::BufferFormat::YUV_420_BIPLANAR:
case gfx::BufferFormat::UYVY_422: case gfx::BufferFormat::UYVY_422:
...@@ -82,10 +84,10 @@ bool IsCompressedFormat(gfx::BufferFormat format) { ...@@ -82,10 +84,10 @@ bool IsCompressedFormat(gfx::BufferFormat format) {
case gfx::BufferFormat::RGBX_8888: case gfx::BufferFormat::RGBX_8888:
case gfx::BufferFormat::RGBA_8888: case gfx::BufferFormat::RGBA_8888:
case gfx::BufferFormat::BGRX_8888: case gfx::BufferFormat::BGRX_8888:
case gfx::BufferFormat::BGRX_1010102:
case gfx::BufferFormat::BGRA_8888: case gfx::BufferFormat::BGRA_8888:
case gfx::BufferFormat::RGBA_F16: case gfx::BufferFormat::RGBA_F16:
return false; return false;
case gfx::BufferFormat::BGRX_1010102:
case gfx::BufferFormat::YVU_420: case gfx::BufferFormat::YVU_420:
case gfx::BufferFormat::YUV_420_BIPLANAR: case gfx::BufferFormat::YUV_420_BIPLANAR:
case gfx::BufferFormat::UYVY_422: case gfx::BufferFormat::UYVY_422:
...@@ -126,6 +128,9 @@ GLenum TextureFormat(gfx::BufferFormat format) { ...@@ -126,6 +128,9 @@ GLenum TextureFormat(gfx::BufferFormat format) {
case gfx::BufferFormat::BGRX_8888: case gfx::BufferFormat::BGRX_8888:
return GL_RGB; return GL_RGB;
case gfx::BufferFormat::BGRX_1010102: case gfx::BufferFormat::BGRX_1010102:
// Technically speaking we should use an opaque format, but neither
// OpenGLES nor OpenGL supports the hypothetical GL_RGB10_EXT.
return GL_RGB10_A2_EXT;
case gfx::BufferFormat::YVU_420: case gfx::BufferFormat::YVU_420:
case gfx::BufferFormat::YUV_420_BIPLANAR: case gfx::BufferFormat::YUV_420_BIPLANAR:
case gfx::BufferFormat::UYVY_422: case gfx::BufferFormat::UYVY_422:
...@@ -142,6 +147,7 @@ GLenum DataFormat(gfx::BufferFormat format) { ...@@ -142,6 +147,7 @@ GLenum DataFormat(gfx::BufferFormat format) {
case gfx::BufferFormat::RGBX_8888: case gfx::BufferFormat::RGBX_8888:
return GL_RGBA; return GL_RGBA;
case gfx::BufferFormat::BGRX_8888: case gfx::BufferFormat::BGRX_8888:
case gfx::BufferFormat::BGRX_1010102:
return GL_BGRA_EXT; return GL_BGRA_EXT;
case gfx::BufferFormat::BGR_565: case gfx::BufferFormat::BGR_565:
case gfx::BufferFormat::RGBA_4444: case gfx::BufferFormat::RGBA_4444:
...@@ -157,7 +163,6 @@ GLenum DataFormat(gfx::BufferFormat format) { ...@@ -157,7 +163,6 @@ GLenum DataFormat(gfx::BufferFormat format) {
case gfx::BufferFormat::DXT5: case gfx::BufferFormat::DXT5:
case gfx::BufferFormat::ETC1: case gfx::BufferFormat::ETC1:
return TextureFormat(format); return TextureFormat(format);
case gfx::BufferFormat::BGRX_1010102:
case gfx::BufferFormat::YVU_420: case gfx::BufferFormat::YVU_420:
case gfx::BufferFormat::YUV_420_BIPLANAR: case gfx::BufferFormat::YUV_420_BIPLANAR:
case gfx::BufferFormat::UYVY_422: case gfx::BufferFormat::UYVY_422:
...@@ -186,12 +191,13 @@ GLenum DataType(gfx::BufferFormat format) { ...@@ -186,12 +191,13 @@ GLenum DataType(gfx::BufferFormat format) {
return GL_UNSIGNED_SHORT; return GL_UNSIGNED_SHORT;
case gfx::BufferFormat::RGBA_F16: case gfx::BufferFormat::RGBA_F16:
return GL_HALF_FLOAT_OES; return GL_HALF_FLOAT_OES;
case gfx::BufferFormat::BGRX_1010102:
return GL_UNSIGNED_INT_2_10_10_10_REV;
case gfx::BufferFormat::ATC: case gfx::BufferFormat::ATC:
case gfx::BufferFormat::ATCIA: case gfx::BufferFormat::ATCIA:
case gfx::BufferFormat::DXT1: case gfx::BufferFormat::DXT1:
case gfx::BufferFormat::DXT5: case gfx::BufferFormat::DXT5:
case gfx::BufferFormat::ETC1: case gfx::BufferFormat::ETC1:
case gfx::BufferFormat::BGRX_1010102:
case gfx::BufferFormat::YVU_420: case gfx::BufferFormat::YVU_420:
case gfx::BufferFormat::YUV_420_BIPLANAR: case gfx::BufferFormat::YUV_420_BIPLANAR:
case gfx::BufferFormat::UYVY_422: case gfx::BufferFormat::UYVY_422:
...@@ -213,6 +219,7 @@ GLint DataRowLength(size_t stride, gfx::BufferFormat format) { ...@@ -213,6 +219,7 @@ GLint DataRowLength(size_t stride, gfx::BufferFormat format) {
case gfx::BufferFormat::RGBX_8888: case gfx::BufferFormat::RGBX_8888:
case gfx::BufferFormat::RGBA_8888: case gfx::BufferFormat::RGBA_8888:
case gfx::BufferFormat::BGRX_8888: case gfx::BufferFormat::BGRX_8888:
case gfx::BufferFormat::BGRX_1010102:
case gfx::BufferFormat::BGRA_8888: case gfx::BufferFormat::BGRA_8888:
return base::checked_cast<GLint>(stride) / 4; return base::checked_cast<GLint>(stride) / 4;
case gfx::BufferFormat::RGBA_F16: case gfx::BufferFormat::RGBA_F16:
...@@ -224,7 +231,6 @@ GLint DataRowLength(size_t stride, gfx::BufferFormat format) { ...@@ -224,7 +231,6 @@ GLint DataRowLength(size_t stride, gfx::BufferFormat format) {
case gfx::BufferFormat::DXT1: case gfx::BufferFormat::DXT1:
case gfx::BufferFormat::DXT5: case gfx::BufferFormat::DXT5:
case gfx::BufferFormat::ETC1: case gfx::BufferFormat::ETC1:
case gfx::BufferFormat::BGRX_1010102:
case gfx::BufferFormat::YVU_420: case gfx::BufferFormat::YVU_420:
case gfx::BufferFormat::YUV_420_BIPLANAR: case gfx::BufferFormat::YUV_420_BIPLANAR:
case gfx::BufferFormat::UYVY_422: case gfx::BufferFormat::UYVY_422:
...@@ -330,6 +336,7 @@ std::unique_ptr<uint8_t[]> GLES2Data(const gfx::Size& size, ...@@ -330,6 +336,7 @@ std::unique_ptr<uint8_t[]> GLES2Data(const gfx::Size& size,
data_format, data_type, data_row_length); data_format, data_type, data_row_length);
case gfx::BufferFormat::RGBA_4444: case gfx::BufferFormat::RGBA_4444:
case gfx::BufferFormat::RGBA_8888: case gfx::BufferFormat::RGBA_8888:
case gfx::BufferFormat::BGRX_1010102:
case gfx::BufferFormat::BGRA_8888: case gfx::BufferFormat::BGRA_8888:
case gfx::BufferFormat::RGBA_F16: case gfx::BufferFormat::RGBA_F16:
case gfx::BufferFormat::R_8: case gfx::BufferFormat::R_8:
...@@ -356,11 +363,10 @@ std::unique_ptr<uint8_t[]> GLES2Data(const gfx::Size& size, ...@@ -356,11 +363,10 @@ std::unique_ptr<uint8_t[]> GLES2Data(const gfx::Size& size,
case gfx::BufferFormat::DXT5: case gfx::BufferFormat::DXT5:
case gfx::BufferFormat::ETC1: case gfx::BufferFormat::ETC1:
return nullptr; // No data conversion needed return nullptr; // No data conversion needed
case gfx::BufferFormat::BGRX_1010102:
case gfx::BufferFormat::YVU_420: case gfx::BufferFormat::YVU_420:
case gfx::BufferFormat::YUV_420_BIPLANAR: case gfx::BufferFormat::YUV_420_BIPLANAR:
case gfx::BufferFormat::UYVY_422: case gfx::BufferFormat::UYVY_422:
NOTREACHED(); NOTREACHED() << gfx::BufferFormatToString(format);
return nullptr; return nullptr;
} }
...@@ -390,12 +396,13 @@ bool GLImageMemory::Initialize(const unsigned char* memory, ...@@ -390,12 +396,13 @@ bool GLImageMemory::Initialize(const unsigned char* memory,
gfx::BufferFormat format, gfx::BufferFormat format,
size_t stride) { size_t stride) {
if (!ValidInternalFormat(internalformat_)) { if (!ValidInternalFormat(internalformat_)) {
LOG(ERROR) << "Invalid internalformat: " << internalformat_; LOG(ERROR) << "Invalid internalformat: "
<< GLEnums::GetStringEnum(internalformat_);
return false; return false;
} }
if (!ValidFormat(format)) { if (!ValidFormat(format)) {
LOG(ERROR) << "Invalid format: " << static_cast<int>(format); LOG(ERROR) << "Invalid format: " << gfx::BufferFormatToString(format);
return false; return false;
} }
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "base/memory/shared_memory.h" #include "base/memory/shared_memory.h"
#include "base/sys_info.h" #include "base/sys_info.h"
#include "build/build_config.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "ui/gl/gl_image_shared_memory.h" #include "ui/gl/gl_image_shared_memory.h"
#include "ui/gl/test/gl_image_test_template.h" #include "ui/gl/test/gl_image_test_template.h"
...@@ -50,6 +51,12 @@ using GLImageTestTypes = testing::Types< ...@@ -50,6 +51,12 @@ using GLImageTestTypes = testing::Types<
GLImageSharedMemoryTestDelegate<gfx::BufferFormat::RGBX_8888>, GLImageSharedMemoryTestDelegate<gfx::BufferFormat::RGBX_8888>,
GLImageSharedMemoryTestDelegate<gfx::BufferFormat::RGBA_8888>, GLImageSharedMemoryTestDelegate<gfx::BufferFormat::RGBA_8888>,
GLImageSharedMemoryTestDelegate<gfx::BufferFormat::BGRX_8888>, GLImageSharedMemoryTestDelegate<gfx::BufferFormat::BGRX_8888>,
#if defined(OS_LINUX)
// Fails on Win nVidia and linux android: the test writes nothing (we read
// back the color used to clear the buffer).
// TODO(mcasas): enable those paltforms https://crbug.com/803451.
GLImageSharedMemoryTestDelegate<gfx::BufferFormat::BGRX_1010102>,
#endif
GLImageSharedMemoryTestDelegate<gfx::BufferFormat::BGRA_8888>>; GLImageSharedMemoryTestDelegate<gfx::BufferFormat::BGRA_8888>>;
INSTANTIATE_TYPED_TEST_CASE_P(GLImageSharedMemory, INSTANTIATE_TYPED_TEST_CASE_P(GLImageSharedMemory,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment