diff options
author | Niklas Haas <git@haasn.xyz> | 2018-02-14 16:10:51 +0100 |
---|---|---|
committer | Jan Ekström <jeebjp@gmail.com> | 2018-02-20 22:02:51 +0200 |
commit | 441e384390f1cd1b1b1c159cb797429432a09493 (patch) | |
tree | 1c6cefb9d64c3298a461723da0fc4f148fe10deb /video/out/gpu/video_shaders.c | |
parent | 1f881eca656127d5235d44acf1562091864e07c7 (diff) | |
download | mpv-441e384390f1cd1b1b1c159cb797429432a09493.tar.bz2 mpv-441e384390f1cd1b1b1c159cb797429432a09493.tar.xz |
vo_gpu: introduce --target-peak
This solves a number of problems simultaneously:
1. When outputting HLG, this allows tuning the OOTF based on the display
characteristics.
2. When outputting PQ or other HDR curves, this allows soft-limiting the
output brightness using the tone mapping algorithm.
3. When outputting SDR, this allows HDR-in-SDR style output, by
controlling the output brightness directly.
Closes #5521
Diffstat (limited to 'video/out/gpu/video_shaders.c')
-rw-r--r-- | video/out/gpu/video_shaders.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/video/out/gpu/video_shaders.c b/video/out/gpu/video_shaders.c index d8a26542b0..b588b8e500 100644 --- a/video/out/gpu/video_shaders.c +++ b/video/out/gpu/video_shaders.c @@ -812,8 +812,14 @@ void pass_color_map(struct gl_shader_cache *sc, if (need_ootf) pass_inverse_ootf(sc, dst.light, dst.sig_peak); - // Post-scale the outgoing values from absolute scale to normalized - GLSLF("color.rgb *= vec3(%f);\n", 1.0 / mp_trc_nom_peak(dst.gamma)); + // Post-scale the outgoing values from absolute scale to normalized. + // For SDR, we normalize to the chosen signal peak. For HDR, we normalize + // to the encoding range of the transfer function. + float dst_range = dst.sig_peak; + if (mp_trc_is_hdr(dst.gamma)) + dst_range = mp_trc_nom_peak(dst.gamma); + + GLSLF("color.rgb *= vec3(%f);\n", 1.0 / dst_range); // Warn for remaining out-of-gamut colors is enabled if (gamut_warning) { |