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

Unified 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: Use ColorSpace enum, rather than a boolean for jpeg. Created 6 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: cc/output/gl_renderer.cc
diff --git a/cc/output/gl_renderer.cc b/cc/output/gl_renderer.cc
index bb1ecbf6bc61f6691d5eb5fd55690d0448eee2ae..a76befe765c213cfcaabf4c7df35ffd845d29adb 100644
--- a/cc/output/gl_renderer.cc
+++ b/cc/output/gl_renderer.cc
@@ -1777,9 +1777,12 @@ void GLRenderer::DrawYUVVideoQuad(const DrawingFrame* frame,
// These values are magic numbers that are used in the transformation from YUV
// to RGB color values. They are taken from the following webpage:
// http://www.fourcc.org/fccyvrgb.php
- float yuv_to_rgb[9] = {1.164f, 1.164f, 1.164f, 0.0f, -.391f,
- 2.018f, 1.596f, -.813f, 0.0f, };
- GLC(gl_, gl_->UniformMatrix3fv(yuv_matrix_location, 1, 0, yuv_to_rgb));
+ float yuv_to_rgb_rec601[9] = {
rileya (GONE FROM CHROMIUM) 2014/05/01 23:25:09 Is there a header these might be better off being
piman 2014/05/02 00:37:28 I don't think one exists. We could create one, pos
+ 1.164f, 1.164f, 1.164f, 0.0f, -.391f, 2.018f, 1.596f, -.813f, 0.0f,
+ };
+ float yuv_to_rgb_rec601_jpeg[9] = {
+ 1.f, 1.f, 1.f, 0.0f, -.34414f, 1.772f, 1.402f, -.71414, 0.0f,
fbarchard 2014/05/02 02:39:29 FYI I found fourcc sometimes inconsistent with oth
+ };
// These values map to 16, 128, and 128 respectively, and are computed
// as a fraction over 256 (e.g. 16 / 256 = 0.0625).
@@ -1787,7 +1790,32 @@ void GLRenderer::DrawYUVVideoQuad(const DrawingFrame* frame,
// Y - 16 : Gives 16 values of head and footroom for overshooting
// U - 128 : Turns unsigned U into signed U [-128,127]
// V - 128 : Turns unsigned V into signed V [-128,127]
- float yuv_adjust[3] = {-0.0625f, -0.5f, -0.5f, };
+ float yuv_adjust_rec601[3] = {
+ -0.0625f, -0.5f, -0.5f,
+ };
+
+ // Same as above, but without the head and footroom.
+ float yuv_adjust_rec601_jpeg[3] = {
+ 0.0f, -0.5f, -0.5f,
+ };
+
+ float* yuv_to_rgb;
+ float* yuv_adjust;
piman 2014/05/02 00:37:28 nit: initialize both.
+
+ switch (quad->color_space) {
+ case YUVVideoDrawQuad::kRec601:
+ yuv_to_rgb = yuv_to_rgb_rec601;
+ yuv_adjust = yuv_adjust_rec601;
+ break;
+ case YUVVideoDrawQuad::kRec601_Jpeg:
+ yuv_to_rgb = yuv_to_rgb_rec601_jpeg;
+ yuv_adjust = yuv_adjust_rec601_jpeg;
+ break;
+ default:
piman 2014/05/02 00:37:28 nit: skip the default case, relying instead on com
+ NOTREACHED();
+ }
+
+ GLC(gl_, gl_->UniformMatrix3fv(yuv_matrix_location, 1, 0, yuv_to_rgb));
GLC(gl_, gl_->Uniform3fv(yuv_adj_location, 1, yuv_adjust));
SetShaderOpacity(quad->opacity(), alpha_location);

Powered by Google App Engine
This is Rietveld 408576698