path: root/video/csputils.h
diff options
authorNiklas Haas <>2017-06-10 14:01:25 +0200
committerwm4 <wm4@nowhere>2017-06-18 20:48:23 +0200
commitc335e84230916d7d7a38288031516e8b2ec1c36b (patch)
tree009b92a90285b7fae212d82caec588dd6ef709d8 /video/csputils.h
parent642e963c86040350ac8f06b9731e6126f4d55316 (diff)
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.h')
1 files changed, 8 insertions, 3 deletions
diff --git a/video/csputils.h b/video/csputils.h
index 9eaafbe75d..ec7369fa67 100644
--- a/video/csputils.h
+++ b/video/csputils.h
@@ -121,10 +121,15 @@ struct mp_colorspace {
enum mp_csp_levels levels;
enum mp_csp_prim primaries;
enum mp_csp_trc gamma;
- float nom_peak; // nominal (absolute) peak. 0 = auto/unknown
- float sig_peak; // signal peak, highest value that occurs in the source
+ float sig_peak; // highest relative value in signal. 0 = unknown/auto
+// For many colorspace conversions, in particular those involving HDR, an
+// implicit reference white level is needed. Since this magic constant shows up
+// a lot, give it an explicit name. The value of 100 cd/m² comes from ITU-R
+// documents such as ITU-R BT.2100
+#define MP_REF_WHITE 100.0
// Replaces unknown values in the first struct by those of the second struct
void mp_colorspace_merge(struct mp_colorspace *orig, struct mp_colorspace *new);
@@ -230,7 +235,7 @@ int mp_chroma_location_to_av(enum mp_chroma_location mploc);
void mp_get_chroma_location(enum mp_chroma_location loc, int *x, int *y);
struct mp_csp_primaries mp_get_csp_primaries(enum mp_csp_prim csp);
-float mp_csp_trc_nom_peak(enum mp_csp_trc trc, float ref_peak);
+float mp_trc_nom_peak(enum mp_csp_trc trc);
bool mp_trc_is_hdr(enum mp_csp_trc trc);
/* Color conversion matrix: RGB = m * YUV + c