Skip to content

Commit 257d9f1

Browse files
haasnwm4
authored and
wm4
committed
vo_opengl: use exactly the values defined by BT.709 for CMS
I could not see any difference whatsoever, but for usage with a 3DLUT there's zero performance difference so we might as well follow the spec to the letter.
1 parent 7f744c9 commit 257d9f1

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

video/out/gl_lcms.c

+9-3
Original file line numberDiff line numberDiff line change
@@ -157,14 +157,20 @@ struct lut3d *mp_load_icc(struct mp_icc_opts *opts, struct mp_log *log,
157157
if (!profile)
158158
goto error_exit;
159159

160-
cmsCIExyY d65;
161-
cmsWhitePointFromTemp(&d65, 6504);
160+
cmsCIExyY d65 = {0.3127, 0.3290, 1.0};
162161
static const cmsCIExyYTRIPLE bt709prim = {
163162
.Red = {0.64, 0.33, 1.0},
164163
.Green = {0.30, 0.60, 1.0},
165164
.Blue = {0.15, 0.06, 1.0},
166165
};
167-
cmsToneCurve *tonecurve = cmsBuildGamma(NULL, 1.0/0.45);
166+
167+
/* Rec BT.709 defines the tone curve as:
168+
V = 1.099 * L^0.45 - 0.099 for L >= 0.018
169+
V = 4.500 * L for L < 0.018
170+
171+
The 0.18 parameter comes from inserting 0.018 into the function */
172+
cmsToneCurve *tonecurve = cmsBuildParametricToneCurve(NULL, 4,
173+
(cmsFloat64Number[5]){1/0.45, 1/1.099, 0.099, 1/4.5, 0.18});
168174
cmsHPROFILE vid_profile = cmsCreateRGBProfile(&d65, &bt709prim,
169175
(cmsToneCurve*[3]){tonecurve, tonecurve, tonecurve});
170176
cmsFreeToneCurve(tonecurve);

0 commit comments

Comments
 (0)