summaryrefslogtreecommitdiffstats
path: root/video/mp_image.c
diff options
context:
space:
mode:
authorNiklas Haas <git@haasn.xyz>2017-06-14 20:06:56 +0200
committerwm4 <wm4@nowhere>2017-06-18 20:54:44 +0200
commit1f3000b03c5ca8208858634ba57833d7dbb009cc (patch)
tree9bc913987fed190f4425030cc360248616b56e6b /video/mp_image.c
parentfe1227883a865b845c0c271bafd281f288404acb (diff)
downloadmpv-1f3000b03c5ca8208858634ba57833d7dbb009cc.tar.bz2
mpv-1f3000b03c5ca8208858634ba57833d7dbb009cc.tar.xz
vo_opengl: implement support for OOTFs and non-display referred content
This introduces (yet another..) mp_colorspace members, an enum `light` (for lack of a better name) which basically tells us whether we're dealing with scene-referred or display-referred light, but also a bit more metadata (in which way is the scene-referred light expected to be mapped to the display?). The addition of this parameter accomplishes two goals: 1. Allows us to actually support HLG more-or-less correctly[1] 2. Allows people playing back direct “camera” content (e.g. v-log or s-log2) to treat it as scene-referred instead of display-referred [1] Even better would be to use the display-referred OOTF instead of the idealized OOTF, but this would require either native HLG support in LittleCMS (unlikely) or more communication between lcms.c and video_shaders.c than I'm remotely comfortable with That being said, in principle we could switch our usage of the BT.1886 EOTF to the BT.709 OETF instead and treat BT.709 content as being scene-referred under application of the 709+1886 OOTF; which moves that particular conversion from the 3dlut to the shader code; but also allows a) users like UliZappe to turn it off and b) supporting the full HLG OOTF in the same framework. But I think I prefer things as they are right now.
Diffstat (limited to 'video/mp_image.c')
-rw-r--r--video/mp_image.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/video/mp_image.c b/video/mp_image.c
index ae0fc02e49..f088e18b36 100644
--- a/video/mp_image.c
+++ b/video/mp_image.c
@@ -409,6 +409,7 @@ void mp_image_copy_attributes(struct mp_image *dst, struct mp_image *src)
dst->params.color.primaries = src->params.color.primaries;
dst->params.color.gamma = src->params.color.gamma;
dst->params.color.sig_peak = src->params.color.sig_peak;
+ dst->params.color.light = src->params.color.light;
if ((dst->fmt.flags & MP_IMGFLAG_YUV) == (src->fmt.flags & MP_IMGFLAG_YUV)) {
dst->params.color.space = src->params.color.space;
dst->params.color.levels = src->params.color.levels;
@@ -688,6 +689,16 @@ void mp_image_params_guess_csp(struct mp_image_params *params)
// range as the signal peak to prevent clipping
if (!params->color.sig_peak)
params->color.sig_peak = mp_trc_nom_peak(params->color.gamma);
+
+ if (params->color.light == MP_CSP_LIGHT_AUTO) {
+ // HLG is always scene-referred (using its own OOTF), everything else
+ // we assume is display-refered by default.
+ if (params->color.gamma == MP_CSP_TRC_HLG) {
+ params->color.light = MP_CSP_LIGHT_SCENE_HLG;
+ } else {
+ params->color.light = MP_CSP_LIGHT_DISPLAY;
+ }
+ }
}
// Copy properties and data of the AVFrame into the mp_image, without taking