From f7fe43aead3fe227c1fccd99237b45d0146bff2e Mon Sep 17 00:00:00 2001 From: Martin Pulec Date: Fri, 3 Feb 2012 13:19:16 +0100 Subject: [PATCH] switched to ITU-R BT.709 color spec --- dxt_compress/compress_dxt1_fp.glsl | 6 +++--- dxt_compress/compress_dxt5ycocg_fp.glsl | 6 +++--- dxt_compress/rgba_to_yuv422.glsl | 12 ++++++------ ultragrid/src/video_display/gl.c | 6 +++--- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/dxt_compress/compress_dxt1_fp.glsl b/dxt_compress/compress_dxt1_fp.glsl index a01c3f9fd..05c1d77d0 100644 --- a/dxt_compress/compress_dxt1_fp.glsl +++ b/dxt_compress/compress_dxt1_fp.glsl @@ -15,9 +15,9 @@ vec3 ConvertYUVToRGB(vec3 color) float V = color[2] - 0.5; Y = 1.1643 * (Y - 0.0625); - float R = Y + 1.5958 * V; - float G = Y - 0.39173 * U - 0.81290 * V; - float B = Y + 2.017 * U; + float R = Y + 1.7926 * V; + float G = Y - 0.2132 * U - 0.5328 * V; + float B = Y + 1.7926 * U; return vec3(R, G, B); } diff --git a/dxt_compress/compress_dxt5ycocg_fp.glsl b/dxt_compress/compress_dxt5ycocg_fp.glsl index c42a7098b..cd19eae03 100644 --- a/dxt_compress/compress_dxt5ycocg_fp.glsl +++ b/dxt_compress/compress_dxt5ycocg_fp.glsl @@ -14,9 +14,9 @@ vec3 ConvertYUVToRGB(vec3 color) float V = color[2] - 0.5; Y = 1.1643 * (Y - 0.0625); - float R = Y + 1.5958 * V; - float G = Y - 0.39173 * U - 0.81290 * V; - float B = Y + 2.017 * U; + float R = Y + 1.7926 * V; + float G = Y - 0.2132 * U - 0.5328 * V; + float B = Y + 1.7926 * U; return vec3(R, G, B); } diff --git a/dxt_compress/rgba_to_yuv422.glsl b/dxt_compress/rgba_to_yuv422.glsl index 6e5f79902..a0a9a74b0 100644 --- a/dxt_compress/rgba_to_yuv422.glsl +++ b/dxt_compress/rgba_to_yuv422.glsl @@ -18,13 +18,13 @@ void main() rgba1 = texture2D(image, coor1); rgba2 = texture2D(image, coor2); - yuv1.x = 1.0/16.0 + (rgba1.r * 0.299 + rgba1.g * 0.587 + rgba1.b * 0.114) * 0.8588; // Y - yuv1.y = 0.5 + (-rgba1.r * 0.168736 - rgba1.g * 0.331264 + rgba1.b * 0.5) * 0.8784; - yuv1.z = 0.5 + (rgba1.r * 0.5 - rgba1.g * 0.418688 - rgba1.b * 0.081312) * 0.8784; + yuv1.x = 1.0/16.0 + (rgba1.r * 0.2126 + rgba1.g * 0.7152 + rgba1.b * 0.0722) * 0.8588; // Y + yuv1.y = 0.5 + (-rgba1.r * 0.1145 - rgba1.g * 0.3854 + rgba1.b * 0.5) * 0.8784; + yuv1.z = 0.5 + (rgba1.r * 0.5 - rgba1.g * 0.4541 - rgba1.b * 0.0458) * 0.8784; - yuv2.x = 1.0/16.0 + (rgba2.r * 0.299 + rgba2.g * 0.587 + rgba2.b * 0.114) * 0.8588; // Y - yuv2.y = 0.5 + (-rgba2.r * 0.168736 - rgba2.g * 0.331264 + rgba2.b * 0.5) * 0.8784; - yuv2.z = 0.5 + (rgba2.r * 0.5 - rgba2.g * 0.418688 - rgba2.b * 0.081312) * 0.8784; + yuv2.x = 1.0/16.0 + (rgba2.r * 0.2126 + rgba2.g * 0.7152 + rgba2.b * 0.0722) * 0.8588; // Y + yuv2.y = 0.5 + (-rgba2.r * 0.1145 - rgba2.g * 0.3854 + rgba2.b * 0.5) * 0.8784; + yuv2.z = 0.5 + (rgba2.r * 0.5 - rgba2.g * 0.4541 - rgba2.b * 0.0458) * 0.8784; U = mix(yuv1.y, yuv2.y, 0.5); V = mix(yuv1.z, yuv2.z, 0.5); diff --git a/ultragrid/src/video_display/gl.c b/ultragrid/src/video_display/gl.c index 97daae41d..1f86e7872 100644 --- a/ultragrid/src/video_display/gl.c +++ b/ultragrid/src/video_display/gl.c @@ -97,9 +97,9 @@ void main() yuv.r = 1.1643*(yuv.r-0.0625); yuv.g = yuv.g - 0.5; yuv.b = yuv.b - 0.5; - gl_FragColor.r = yuv.r + 1.5958 * yuv.b; - gl_FragColor.g = yuv.r - 0.39173* yuv.g - 0.81290 * yuv.b; - gl_FragColor.b = yuv.r + 2.017 * yuv.g; + gl_FragColor.r = yuv.r + 1.7926 * yuv.b; + gl_FragColor.g = yuv.r - 0.2132 * yuv.g - 0.5328 * yuv.b; + gl_FragColor.b = yuv.r + 1.7926 * yuv.g; }); static char * yuv422_to_rgb_vp = STRINGIFY(