summaryrefslogtreecommitdiffstats
path: root/video/out
diff options
context:
space:
mode:
authorNiklas Haas <git@nand.wakku.to>2014-03-25 18:45:08 +0100
committerwm4 <wm4@nowhere>2014-06-22 19:00:38 +0200
commit86d3d11a68510764504a2a3c5987ab8e059d6df5 (patch)
tree9db725a7fadd4790c3cd0ec492fcd005888d1b44 /video/out
parent082fbe39e8b67043f4a5aec1b7396eca14403791 (diff)
downloadmpv-86d3d11a68510764504a2a3c5987ab8e059d6df5.tar.bz2
mpv-86d3d11a68510764504a2a3c5987ab8e059d6df5.tar.xz
video: Add BT.2020-NCL colorspace and transfer function
Source: http://www.itu.int/dms_pubrec/itu-r/rec/bt/R-REC-BT.2020-0-201208-I!!PDF-E.pdf
Diffstat (limited to 'video/out')
-rw-r--r--video/out/gl_video_shaders.glsl23
1 files changed, 14 insertions, 9 deletions
diff --git a/video/out/gl_video_shaders.glsl b/video/out/gl_video_shaders.glsl
index 15bb600e61..b0058f8ca6 100644
--- a/video/out/gl_video_shaders.glsl
+++ b/video/out/gl_video_shaders.glsl
@@ -49,10 +49,10 @@ vec3 srgb_compand(vec3 v)
lessThanEqual(vec3(0.0031308), v));
}
-vec3 bt709_expand(vec3 v)
+vec3 bt2020_expand(vec3 v)
{
- return mix(v / 4.5, pow((v + vec3(0.099))/1.099, vec3(1/0.45)),
- lessThanEqual(vec3(0.0812), v));
+ return mix(v / 4.5, pow((v + vec3(0.0993))/1.0993, vec3(1/0.45)),
+ lessThanEqual(vec3(0.08145), v));
}
#endif
@@ -85,8 +85,8 @@ void main() {
// Although we are not scaling in linear light, both 3DLUT and SRGB still
// operate on linear light inputs so we have to convert to it before
// either step can be applied.
- color.rgb = bt709_expand(color.rgb);
- // NOTE: This always applies the true BT709, maybe we need to use
+ color.rgb = bt2020_expand(color.rgb);
+ // NOTE: This always applies the true BT2020, maybe we need to use
// approx-gamma here too?
#endif
#ifdef USE_OSD_3DLUT
@@ -387,13 +387,18 @@ void main() {
#endif
#ifdef USE_LINEAR_LIGHT
// If we are scaling in linear light (SRGB or 3DLUT option enabled), we
- // expand our source colors before scaling
+ // expand our source colors before scaling. This shader currently just
+ // assumes everything uses the BT.2020 12-bit gamma function, since the
+ // difference between this and BT.601, BT.709 and BT.2020 10-bit is well
+ // below the rounding error threshold for both 8-bit and even 10-bit
+ // content. It only makes a difference for 12-bit sources, so it should be
+ // fine to use here.
#ifdef USE_APPROX_GAMMA
- // We differentiate between approximate BT.709 (gamma 1.95) ...
+ // We differentiate between approximate BT.2020 (gamma 1.95) ...
color = pow(color, vec3(1.95));
#else
- // ... and actual BT709 (two-part function)
- color = bt709_expand(color);
+ // ... and actual BT.2020 (two-part function)
+ color = bt2020_expand(color);
#endif
#endif
// Image upscaling happens roughly here