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

Side by Side Diff: cc/output/gl_renderer.cc

Issue 92703003: Support videos with JPEG color range in GPU YUV convert path. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@yuv_v2
Patch Set: whoops, lost dark_grey.png during rebasing somehow. Created 6 years, 7 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 unified diff | Download patch
OLDNEW
1 // Copyright 2010 The Chromium Authors. All rights reserved. 1 // Copyright 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/output/gl_renderer.h" 5 #include "cc/output/gl_renderer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 1761 matching lines...) Expand 10 before | Expand all | Expand 10 after
1772 GLC(gl_, gl_->Uniform1i(u_texture_location, 2)); 1772 GLC(gl_, gl_->Uniform1i(u_texture_location, 2));
1773 GLC(gl_, gl_->Uniform1i(v_texture_location, 3)); 1773 GLC(gl_, gl_->Uniform1i(v_texture_location, 3));
1774 if (use_alpha_plane) 1774 if (use_alpha_plane)
1775 GLC(gl_, gl_->Uniform1i(a_texture_location, 4)); 1775 GLC(gl_, gl_->Uniform1i(a_texture_location, 4));
1776 1776
1777 // These values are magic numbers that are used in the transformation from YUV 1777 // These values are magic numbers that are used in the transformation from YUV
1778 // to RGB color values. They are taken from the following webpage: 1778 // to RGB color values. They are taken from the following webpage:
1779 // http://www.fourcc.org/fccyvrgb.php 1779 // http://www.fourcc.org/fccyvrgb.php
1780 float yuv_to_rgb[9] = {1.164f, 1.164f, 1.164f, 0.0f, -.391f, 1780 float yuv_to_rgb[9] = {1.164f, 1.164f, 1.164f, 0.0f, -.391f,
1781 2.018f, 1.596f, -.813f, 0.0f, }; 1781 2.018f, 1.596f, -.813f, 0.0f, };
1782 GLC(gl_, gl_->UniformMatrix3fv(yuv_matrix_location, 1, 0, yuv_to_rgb)); 1782 float yuv_to_rgb_jpeg[9] = {
1783 1.f, 1.f, 1.f, 0.0f, -.34414f, 1.772f, 1.402f, -.71414, 0.0f,
1784 };
1785 GLC(gl_,
1786 gl_->UniformMatrix3fv(
1787 yuv_matrix_location,
1788 1,
1789 0,
1790 quad->has_jpeg_color_range ? yuv_to_rgb_jpeg : yuv_to_rgb));
1783 1791
1784 // These values map to 16, 128, and 128 respectively, and are computed 1792 // These values map to 16, 128, and 128 respectively, and are computed
1785 // as a fraction over 256 (e.g. 16 / 256 = 0.0625). 1793 // as a fraction over 256 (e.g. 16 / 256 = 0.0625).
1786 // They are used in the YUV to RGBA conversion formula: 1794 // They are used in the YUV to RGBA conversion formula:
1787 // Y - 16 : Gives 16 values of head and footroom for overshooting 1795 // Y - 16 : Gives 16 values of head and footroom for overshooting
1788 // U - 128 : Turns unsigned U into signed U [-128,127] 1796 // U - 128 : Turns unsigned U into signed U [-128,127]
1789 // V - 128 : Turns unsigned V into signed V [-128,127] 1797 // V - 128 : Turns unsigned V into signed V [-128,127]
1790 float yuv_adjust[3] = {-0.0625f, -0.5f, -0.5f, }; 1798 float yuv_adjust[3] = {-0.0625f, -0.5f, -0.5f, };
1791 GLC(gl_, gl_->Uniform3fv(yuv_adj_location, 1, yuv_adjust)); 1799
1800 // Same as above, but without the head and footroom.
1801 float yuv_adjust_jpeg[3] = {
1802 0.0f, -0.5f, -0.5f,
1803 };
1804
1805 GLC(gl_,
1806 gl_->Uniform3fv(
1807 yuv_adj_location,
1808 1,
1809 quad->has_jpeg_color_range ? yuv_adjust_jpeg : yuv_adjust));
1792 1810
1793 SetShaderOpacity(quad->opacity(), alpha_location); 1811 SetShaderOpacity(quad->opacity(), alpha_location);
1794 DrawQuadGeometry(frame, quad->quadTransform(), quad->rect, matrix_location); 1812 DrawQuadGeometry(frame, quad->quadTransform(), quad->rect, matrix_location);
1795 } 1813 }
1796 1814
1797 void GLRenderer::DrawStreamVideoQuad(const DrawingFrame* frame, 1815 void GLRenderer::DrawStreamVideoQuad(const DrawingFrame* frame,
1798 const StreamVideoDrawQuad* quad) { 1816 const StreamVideoDrawQuad* quad) {
1799 SetBlendEnabled(quad->ShouldDrawWithBlending()); 1817 SetBlendEnabled(quad->ShouldDrawWithBlending());
1800 1818
1801 static float gl_matrix[16]; 1819 static float gl_matrix[16];
(...skipping 1393 matching lines...) Expand 10 before | Expand all | Expand 10 after
3195 context_support_->ScheduleOverlayPlane( 3213 context_support_->ScheduleOverlayPlane(
3196 overlay.plane_z_order, 3214 overlay.plane_z_order,
3197 overlay.transform, 3215 overlay.transform,
3198 pending_overlay_resources_.back()->texture_id(), 3216 pending_overlay_resources_.back()->texture_id(),
3199 overlay.display_rect, 3217 overlay.display_rect,
3200 overlay.uv_rect); 3218 overlay.uv_rect);
3201 } 3219 }
3202 } 3220 }
3203 3221
3204 } // namespace cc 3222 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698