Commit a917b3da authored by rileya's avatar rileya Committed by Commit bot

Add support for the Rec709 YUV color space to the hardware composited video path.

Also makes jpeg color space enum naming more correct.

BUG=333619

Review URL: https://codereview.chromium.org/819713005

Cr-Commit-Position: refs/heads/master@{#317147}
parent fed13697
...@@ -222,10 +222,13 @@ void VideoLayerImpl::AppendQuads(RenderPass* render_pass, ...@@ -222,10 +222,13 @@ void VideoLayerImpl::AppendQuads(RenderPass* render_pass,
DCHECK_GE(frame_resources_.size(), 3u); DCHECK_GE(frame_resources_.size(), 3u);
if (frame_resources_.size() < 3u) if (frame_resources_.size() < 3u)
break; break;
YUVVideoDrawQuad::ColorSpace color_space = YUVVideoDrawQuad::ColorSpace color_space = YUVVideoDrawQuad::REC_601;
frame_->format() == media::VideoFrame::YV12J if (frame_->format() == media::VideoFrame::YV12J) {
? YUVVideoDrawQuad::REC_601_JPEG color_space = YUVVideoDrawQuad::JPEG;
: YUVVideoDrawQuad::REC_601; } else if (frame_->format() == media::VideoFrame::YV12HD) {
color_space = YUVVideoDrawQuad::REC_709;
}
gfx::RectF tex_coord_rect( gfx::RectF tex_coord_rect(
tex_x_offset, tex_y_offset, tex_width_scale, tex_height_scale); tex_x_offset, tex_y_offset, tex_width_scale, tex_height_scale);
YUVVideoDrawQuad* yuv_video_quad = YUVVideoDrawQuad* yuv_video_quad =
......
...@@ -1901,9 +1901,12 @@ void GLRenderer::DrawYUVVideoQuad(const DrawingFrame* frame, ...@@ -1901,9 +1901,12 @@ void GLRenderer::DrawYUVVideoQuad(const DrawingFrame* frame,
float yuv_to_rgb_rec601[9] = { float yuv_to_rgb_rec601[9] = {
1.164f, 1.164f, 1.164f, 0.0f, -.391f, 2.018f, 1.596f, -.813f, 0.0f, 1.164f, 1.164f, 1.164f, 0.0f, -.391f, 2.018f, 1.596f, -.813f, 0.0f,
}; };
float yuv_to_rgb_rec601_jpeg[9] = { float yuv_to_rgb_jpeg[9] = {
1.f, 1.f, 1.f, 0.0f, -.34414f, 1.772f, 1.402f, -.71414f, 0.0f, 1.f, 1.f, 1.f, 0.0f, -.34414f, 1.772f, 1.402f, -.71414f, 0.0f,
}; };
float yuv_to_rgb_rec709[9] = {
1.164f, 1.164f, 1.164f, 0.0f, -0.213f, 2.112f, 1.793f, -0.533f, 0.0f,
};
// These values map to 16, 128, and 128 respectively, and are computed // These values map to 16, 128, and 128 respectively, and are computed
// as a fraction over 256 (e.g. 16 / 256 = 0.0625). // as a fraction over 256 (e.g. 16 / 256 = 0.0625).
...@@ -1911,12 +1914,12 @@ void GLRenderer::DrawYUVVideoQuad(const DrawingFrame* frame, ...@@ -1911,12 +1914,12 @@ void GLRenderer::DrawYUVVideoQuad(const DrawingFrame* frame,
// Y - 16 : Gives 16 values of head and footroom for overshooting // Y - 16 : Gives 16 values of head and footroom for overshooting
// U - 128 : Turns unsigned U into signed U [-128,127] // U - 128 : Turns unsigned U into signed U [-128,127]
// V - 128 : Turns unsigned V into signed V [-128,127] // V - 128 : Turns unsigned V into signed V [-128,127]
float yuv_adjust_rec601[3] = { float yuv_adjust_constrained[3] = {
-0.0625f, -0.5f, -0.5f, -0.0625f, -0.5f, -0.5f,
}; };
// Same as above, but without the head and footroom. // Same as above, but without the head and footroom.
float yuv_adjust_rec601_jpeg[3] = { float yuv_adjust_full[3] = {
0.0f, -0.5f, -0.5f, 0.0f, -0.5f, -0.5f,
}; };
...@@ -1926,11 +1929,15 @@ void GLRenderer::DrawYUVVideoQuad(const DrawingFrame* frame, ...@@ -1926,11 +1929,15 @@ void GLRenderer::DrawYUVVideoQuad(const DrawingFrame* frame,
switch (quad->color_space) { switch (quad->color_space) {
case YUVVideoDrawQuad::REC_601: case YUVVideoDrawQuad::REC_601:
yuv_to_rgb = yuv_to_rgb_rec601; yuv_to_rgb = yuv_to_rgb_rec601;
yuv_adjust = yuv_adjust_rec601; yuv_adjust = yuv_adjust_constrained;
break;
case YUVVideoDrawQuad::REC_709:
yuv_to_rgb = yuv_to_rgb_rec709;
yuv_adjust = yuv_adjust_constrained;
break; break;
case YUVVideoDrawQuad::REC_601_JPEG: case YUVVideoDrawQuad::JPEG:
yuv_to_rgb = yuv_to_rgb_rec601_jpeg; yuv_to_rgb = yuv_to_rgb_jpeg;
yuv_adjust = yuv_adjust_rec601_jpeg; yuv_adjust = yuv_adjust_full;
break; break;
} }
......
...@@ -570,7 +570,7 @@ class VideoGLRendererPixelTest : public GLRendererPixelTest { ...@@ -570,7 +570,7 @@ class VideoGLRendererPixelTest : public GLRendererPixelTest {
const bool with_alpha = (video_frame->format() == media::VideoFrame::YV12A); const bool with_alpha = (video_frame->format() == media::VideoFrame::YV12A);
const YUVVideoDrawQuad::ColorSpace color_space = const YUVVideoDrawQuad::ColorSpace color_space =
(video_frame->format() == media::VideoFrame::YV12J (video_frame->format() == media::VideoFrame::YV12J
? YUVVideoDrawQuad::REC_601_JPEG ? YUVVideoDrawQuad::JPEG
: YUVVideoDrawQuad::REC_601); : YUVVideoDrawQuad::REC_601);
const gfx::Rect rect(shared_state->content_bounds); const gfx::Rect rect(shared_state->content_bounds);
const gfx::Rect opaque_rect(0, 0, 0, 0); const gfx::Rect opaque_rect(0, 0, 0, 0);
......
...@@ -643,7 +643,7 @@ TEST(DrawQuadTest, CopyYUVVideoDrawQuad) { ...@@ -643,7 +643,7 @@ TEST(DrawQuadTest, CopyYUVVideoDrawQuad) {
ResourceProvider::ResourceId u_plane_resource_id = 532; ResourceProvider::ResourceId u_plane_resource_id = 532;
ResourceProvider::ResourceId v_plane_resource_id = 4; ResourceProvider::ResourceId v_plane_resource_id = 4;
ResourceProvider::ResourceId a_plane_resource_id = 63; ResourceProvider::ResourceId a_plane_resource_id = 63;
YUVVideoDrawQuad::ColorSpace color_space = YUVVideoDrawQuad::REC_601_JPEG; YUVVideoDrawQuad::ColorSpace color_space = YUVVideoDrawQuad::JPEG;
CREATE_SHARED_STATE(); CREATE_SHARED_STATE();
CREATE_QUAD_9_NEW(YUVVideoDrawQuad, opaque_rect, visible_rect, tex_coord_rect, CREATE_QUAD_9_NEW(YUVVideoDrawQuad, opaque_rect, visible_rect, tex_coord_rect,
...@@ -899,7 +899,7 @@ TEST_F(DrawQuadIteratorTest, YUVVideoDrawQuad) { ...@@ -899,7 +899,7 @@ TEST_F(DrawQuadIteratorTest, YUVVideoDrawQuad) {
ResourceProvider::ResourceId u_plane_resource_id = 532; ResourceProvider::ResourceId u_plane_resource_id = 532;
ResourceProvider::ResourceId v_plane_resource_id = 4; ResourceProvider::ResourceId v_plane_resource_id = 4;
ResourceProvider::ResourceId a_plane_resource_id = 63; ResourceProvider::ResourceId a_plane_resource_id = 63;
YUVVideoDrawQuad::ColorSpace color_space = YUVVideoDrawQuad::REC_601_JPEG; YUVVideoDrawQuad::ColorSpace color_space = YUVVideoDrawQuad::JPEG;
CREATE_SHARED_STATE(); CREATE_SHARED_STATE();
CREATE_QUAD_9_NEW(YUVVideoDrawQuad, opaque_rect, visible_rect, tex_coord_rect, CREATE_QUAD_9_NEW(YUVVideoDrawQuad, opaque_rect, visible_rect, tex_coord_rect,
......
...@@ -16,9 +16,10 @@ namespace cc { ...@@ -16,9 +16,10 @@ namespace cc {
class CC_EXPORT YUVVideoDrawQuad : public DrawQuad { class CC_EXPORT YUVVideoDrawQuad : public DrawQuad {
public: public:
enum ColorSpace { enum ColorSpace {
REC_601, // SDTV standard with restricted "studio swing" color range. REC_601, // SDTV standard with restricted "studio swing" color range.
REC_601_JPEG, // Full color range [0, 255] variant of the above. REC_709, // HDTV standard with restricted "studio swing" color range.
COLOR_SPACE_LAST = REC_601_JPEG JPEG, // Full color range [0, 255] JPEG color space.
COLOR_SPACE_LAST = JPEG
}; };
~YUVVideoDrawQuad() override; ~YUVVideoDrawQuad() override;
......
...@@ -43,10 +43,8 @@ COMPILE_ASSERT( ...@@ -43,10 +43,8 @@ COMPILE_ASSERT(
cc::YUVVideoDrawQuad::REC_601 == cc::YUVVideoDrawQuad::REC_601 ==
static_cast<cc::YUVVideoDrawQuad::ColorSpace>(YUV_COLOR_SPACE_REC_601), static_cast<cc::YUVVideoDrawQuad::ColorSpace>(YUV_COLOR_SPACE_REC_601),
rec_601_enum_matches); rec_601_enum_matches);
COMPILE_ASSERT(cc::YUVVideoDrawQuad::REC_601_JPEG == // TODO(jamesr): Add REC_709 and JPEG to the YUVColorSpace enum upstream in
static_cast<cc::YUVVideoDrawQuad::ColorSpace>( // mojo.
YUV_COLOR_SPACE_REC_601_JPEG),
rec_601_jpeg_enum_matches);
namespace { namespace {
......
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