summaryrefslogtreecommitdiffstats
path: root/video/out/gpu/video.c
diff options
context:
space:
mode:
authorNiklas Haas <git@haasn.xyz>2018-02-14 14:14:48 +0100
committerJan Ekström <jeebjp@gmail.com>2018-02-20 22:02:51 +0200
commitb9e7478760a34827ae5e4f202713509ee553dd9a (patch)
tree19b3d59b5a71908608c894ccd60dc6de1d924a44 /video/out/gpu/video.c
parent5d6fb5267d9ddc85e6084665ab6b20a06d214bbc (diff)
downloadmpv-b9e7478760a34827ae5e4f202713509ee553dd9a.tar.bz2
mpv-b9e7478760a34827ae5e4f202713509ee553dd9a.tar.xz
vo_gpu: simplify and correct color scale handling
The primary need for this change is the fact that the OOTF was incorrectly scaled, due to the fact that the application of the OOTF can itself change the required normalization peak. (Plus, an oversight in pass_inverse_ootf meant we forgot to normalize at the end of it) The linearize/delinearize functions still normalize the scale since it's used in a number of places throughout gpu/video.c, but the color management function now converts to absolute scale right away, instead of in an awkward way inside the tone mapping branch. The OOTF functions now work in absolute scale only. In addition, minor changes have been made to the way normalization is handled for tone mapping - we now divide out the dst_peak *after* peak detection, in order to make the scale of the peak detection buffer consistent even if the dst_peak were to (hypothetically) change mid-stream. In theory, we could also do this for desaturation, but doing the desaturation before tone mapping has the advantage of preserving much more brightness than the other way around - and even mid-stream changes are not that drastic here. Finally, some preparation work has been done for allowing the user to customize the `dst.sig_peak` in the future.
Diffstat (limited to 'video/out/gpu/video.c')
-rw-r--r--video/out/gpu/video.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/video/out/gpu/video.c b/video/out/gpu/video.c
index 2d4e711210..fdefc0044f 100644
--- a/video/out/gpu/video.c
+++ b/video/out/gpu/video.c
@@ -2411,6 +2411,7 @@ static void pass_colormanage(struct gl_video *p, struct mp_colorspace src, bool
if (gl_video_get_lut3d(p, prim_orig, trc_orig)) {
dst.primaries = prim_orig;
dst.gamma = trc_orig;
+ assert(dst.primaries && dst.gamma);
}
}
@@ -2445,6 +2446,11 @@ static void pass_colormanage(struct gl_video *p, struct mp_colorspace src, bool
dst.gamma = MP_CSP_TRC_GAMMA22;
}
+ // For now, just infer the dst sig peak from the gamma function always.
+ // In theory, we could allow users to configure this or detect it from the
+ // ICC profile, but avoid the complexity for now.
+ dst.sig_peak = mp_trc_nom_peak(dst.gamma);
+
bool detect_peak = p->opts.compute_hdr_peak >= 0 && mp_trc_is_hdr(src.gamma);
if (detect_peak && !p->hdr_peak_ssbo) {
struct {