summaryrefslogtreecommitdiffstats
path: root/video/csputils.c
diff options
context:
space:
mode:
authorNiklas Haas <git@nand.wakku.to>2016-06-29 09:28:17 +0200
committerwm4 <wm4@nowhere>2016-07-03 19:42:52 +0200
commit923e3c7b20f0a238062b0ac538a751c6c363a8cb (patch)
treed86988c4fe3a603df877e7cf91216ccc20b09a27 /video/csputils.c
parentd81fb97f4587f73f62a760b99f686139f9b8d966 (diff)
downloadmpv-923e3c7b20f0a238062b0ac538a751c6c363a8cb.tar.bz2
mpv-923e3c7b20f0a238062b0ac538a751c6c363a8cb.tar.xz
vo_opengl: generalize HDR tone mapping mechanism
This involves multiple changes: 1. Brightness metadata is split into nominal peak and signal peak. For a quick and dirty explanation: nominal peak is the brightest value that your color space can represent (i.e. the brightness of an encoded 1.0), and signal peak is the brightest value that actually occurs in the video (i.e. the brightest thing that's displayed). 2. vo_opengl uses a new decision logic to figure out the right nom_peak and sig_peak for all situations. It also does a better job of picking the right target gamut/colorspace to use for the OSD. (Which still is and still should be treated as sRGB). This change in logic also fixes #3293 en passant. 3. Since it was growing rapidly, the logic for auto-guessing / inferring the right colorimetry configuration (in pass_colormanage) was split from the logic for actually performing the adaptation (now pass_color_map). Right now, the new logic doesn't do a whole lot since HDR metadata is still ignored (but not for long).
Diffstat (limited to 'video/csputils.c')
-rw-r--r--video/csputils.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/video/csputils.c b/video/csputils.c
index 4c9cfbeebd..8ed3b289b1 100644
--- a/video/csputils.c
+++ b/video/csputils.c
@@ -437,17 +437,18 @@ struct mp_csp_primaries mp_get_csp_primaries(enum mp_csp_prim spc)
}
}
-// Get the relative peak of a transfer curve, that is: (source reference /
-// display reference), or 0 if there is none (i.e. source has an absolute peak)
-float mp_csp_trc_rel_peak(enum mp_csp_trc trc)
+// Get the nominal peak for a given colorspace, based on a known reference peak
+// (i.e. the display of a reference white illuminant. This may or may not
+// be the actual signal peak)
+float mp_csp_trc_nom_peak(enum mp_csp_trc trc, float ref_peak)
{
switch (trc) {
- case MP_CSP_TRC_SMPTE_ST2084: return 0.0; // This has a fixed peak
- case MP_CSP_TRC_ARIB_STD_B67: return 12.0;
- case MP_CSP_TRC_V_LOG: return 46.0855;
+ case MP_CSP_TRC_SMPTE_ST2084: return 10000; // fixed peak
+ case MP_CSP_TRC_ARIB_STD_B67: return 12.0 * ref_peak;
+ case MP_CSP_TRC_V_LOG: return 46.0855 * ref_peak;
}
- return 1.0;
+ return ref_peak;
}
bool mp_trc_is_hdr(enum mp_csp_trc trc)
@@ -781,7 +782,8 @@ bool mp_colorspace_equal(struct mp_colorspace c1, struct mp_colorspace c2)
c1.levels == c2.levels &&
c1.primaries == c2.primaries &&
c1.gamma == c2.gamma &&
- c1.peak == c2.peak;
+ c1.sig_peak == c2.sig_peak &&
+ c1.nom_peak == c2.nom_peak;
}
// Copy settings from eq into params.