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

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: Add missing 'f' to float literal to make VS happy 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
« no previous file with comments | « cc/layers/video_layer_impl.cc ('k') | cc/output/renderer_pixeltest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1759 matching lines...) Expand 10 before | Expand all | Expand 10 after
1770 quad->tex_coord_rect.y())); 1770 quad->tex_coord_rect.y()));
1771 GLC(gl_, gl_->Uniform1i(y_texture_location, 1)); 1771 GLC(gl_, gl_->Uniform1i(y_texture_location, 1));
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_rec601[9] = {
1781 2.018f, 1.596f, -.813f, 0.0f, }; 1781 1.164f, 1.164f, 1.164f, 0.0f, -.391f, 2.018f, 1.596f, -.813f, 0.0f,
1782 GLC(gl_, gl_->UniformMatrix3fv(yuv_matrix_location, 1, 0, yuv_to_rgb)); 1782 };
1783 float yuv_to_rgb_rec601_jpeg[9] = {
1784 1.f, 1.f, 1.f, 0.0f, -.34414f, 1.772f, 1.402f, -.71414f, 0.0f,
1785 };
1783 1786
1784 // These values map to 16, 128, and 128 respectively, and are computed 1787 // These values map to 16, 128, and 128 respectively, and are computed
1785 // as a fraction over 256 (e.g. 16 / 256 = 0.0625). 1788 // as a fraction over 256 (e.g. 16 / 256 = 0.0625).
1786 // They are used in the YUV to RGBA conversion formula: 1789 // They are used in the YUV to RGBA conversion formula:
1787 // Y - 16 : Gives 16 values of head and footroom for overshooting 1790 // Y - 16 : Gives 16 values of head and footroom for overshooting
1788 // U - 128 : Turns unsigned U into signed U [-128,127] 1791 // U - 128 : Turns unsigned U into signed U [-128,127]
1789 // V - 128 : Turns unsigned V into signed V [-128,127] 1792 // V - 128 : Turns unsigned V into signed V [-128,127]
1790 float yuv_adjust[3] = {-0.0625f, -0.5f, -0.5f, }; 1793 float yuv_adjust_rec601[3] = {
1794 -0.0625f, -0.5f, -0.5f,
1795 };
1796
1797 // Same as above, but without the head and footroom.
1798 float yuv_adjust_rec601_jpeg[3] = {
1799 0.0f, -0.5f, -0.5f,
1800 };
1801
1802 float* yuv_to_rgb = NULL;
1803 float* yuv_adjust = NULL;
1804
1805 switch (quad->color_space) {
1806 case YUVVideoDrawQuad::REC_601:
1807 yuv_to_rgb = yuv_to_rgb_rec601;
1808 yuv_adjust = yuv_adjust_rec601;
1809 break;
1810 case YUVVideoDrawQuad::REC_601_JPEG:
1811 yuv_to_rgb = yuv_to_rgb_rec601_jpeg;
1812 yuv_adjust = yuv_adjust_rec601_jpeg;
1813 break;
1814 }
1815
1816 GLC(gl_, gl_->UniformMatrix3fv(yuv_matrix_location, 1, 0, yuv_to_rgb));
1791 GLC(gl_, gl_->Uniform3fv(yuv_adj_location, 1, yuv_adjust)); 1817 GLC(gl_, gl_->Uniform3fv(yuv_adj_location, 1, yuv_adjust));
1792 1818
1793 SetShaderOpacity(quad->opacity(), alpha_location); 1819 SetShaderOpacity(quad->opacity(), alpha_location);
1794 DrawQuadGeometry(frame, quad->quadTransform(), quad->rect, matrix_location); 1820 DrawQuadGeometry(frame, quad->quadTransform(), quad->rect, matrix_location);
1795 } 1821 }
1796 1822
1797 void GLRenderer::DrawStreamVideoQuad(const DrawingFrame* frame, 1823 void GLRenderer::DrawStreamVideoQuad(const DrawingFrame* frame,
1798 const StreamVideoDrawQuad* quad) { 1824 const StreamVideoDrawQuad* quad) {
1799 SetBlendEnabled(quad->ShouldDrawWithBlending()); 1825 SetBlendEnabled(quad->ShouldDrawWithBlending());
1800 1826
(...skipping 1394 matching lines...) Expand 10 before | Expand all | Expand 10 after
3195 context_support_->ScheduleOverlayPlane( 3221 context_support_->ScheduleOverlayPlane(
3196 overlay.plane_z_order, 3222 overlay.plane_z_order,
3197 overlay.transform, 3223 overlay.transform,
3198 pending_overlay_resources_.back()->texture_id(), 3224 pending_overlay_resources_.back()->texture_id(),
3199 overlay.display_rect, 3225 overlay.display_rect,
3200 overlay.uv_rect); 3226 overlay.uv_rect);
3201 } 3227 }
3202 } 3228 }
3203 3229
3204 } // namespace cc 3230 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/video_layer_impl.cc ('k') | cc/output/renderer_pixeltest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698