From c335e84230916d7d7a38288031516e8b2ec1c36b Mon Sep 17 00:00:00 2001 From: Niklas Haas Date: Sat, 10 Jun 2017 14:01:25 +0200 Subject: video: refactor HDR implementation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit List of changes: 1. Kill nom_peak, since it's a pointless non-field that stores nothing of value and is _always_ derived from ref_white anyway. 2. Kill ref_white/--target-brightness, because the only case it really existed for (PQ) actually doesn't need to be this general: According to ITU-R BT.2100, PQ *always* assumes a reference monitor with a white point of 100 cd/m². 3. Improve documentation and comments surrounding this stuff. 4. Clean up some of the code in general. Move stuff where it belongs. --- video/csputils.c | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) (limited to 'video/csputils.c') diff --git a/video/csputils.c b/video/csputils.c index a41d9cf8c4..768314f938 100644 --- a/video/csputils.c +++ b/video/csputils.c @@ -110,8 +110,6 @@ void mp_colorspace_merge(struct mp_colorspace *orig, struct mp_colorspace *new) orig->primaries = new->primaries; if (!orig->gamma) orig->gamma = new->gamma; - if (!orig->nom_peak) - orig->nom_peak = new->nom_peak; if (!orig->sig_peak) orig->sig_peak = new->sig_peak; } @@ -449,30 +447,23 @@ struct mp_csp_primaries mp_get_csp_primaries(enum mp_csp_prim spc) } } -// 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) +// Get the nominal peak for a given colorspace, relative to the reference white +// level. In other words, this returns the brightest encodable value that can +// be represented by a given transfer curve. +float mp_trc_nom_peak(enum mp_csp_trc trc) { switch (trc) { - 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; + case MP_CSP_TRC_SMPTE_ST2084: return 10000.0 / MP_REF_WHITE; + case MP_CSP_TRC_ARIB_STD_B67: return 12.0; + case MP_CSP_TRC_V_LOG: return 46.0855; } - return ref_peak; + return 1.0; } bool mp_trc_is_hdr(enum mp_csp_trc trc) { - switch (trc) { - case MP_CSP_TRC_SMPTE_ST2084: - case MP_CSP_TRC_ARIB_STD_B67: - case MP_CSP_TRC_V_LOG: - return true; - } - - return false; + return mp_trc_nom_peak(trc) > 1.0; } // Compute the RGB/XYZ matrix as described here: @@ -798,8 +789,7 @@ 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.sig_peak == c2.sig_peak && - c1.nom_peak == c2.nom_peak; + c1.sig_peak == c2.sig_peak; } // Copy settings from eq into params. -- cgit v1.2.3