summaryrefslogtreecommitdiffstats
path: root/video/csputils.c
diff options
context:
space:
mode:
authorNiklas Haas <git@haasn.xyz>2017-06-10 14:01:25 +0200
committerwm4 <wm4@nowhere>2017-06-18 20:48:23 +0200
commitc335e84230916d7d7a38288031516e8b2ec1c36b (patch)
tree009b92a90285b7fae212d82caec588dd6ef709d8 /video/csputils.c
parent642e963c86040350ac8f06b9731e6126f4d55316 (diff)
downloadmpv-c335e84230916d7d7a38288031516e8b2ec1c36b.tar.bz2
mpv-c335e84230916d7d7a38288031516e8b2ec1c36b.tar.xz
video: refactor HDR implementation
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.
Diffstat (limited to 'video/csputils.c')
-rw-r--r--video/csputils.c30
1 files changed, 10 insertions, 20 deletions
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.