diff options
author | Niklas Haas <git@nand.wakku.to> | 2014-06-22 08:33:43 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2014-06-22 19:02:06 +0200 |
commit | 17762a1919947db0e66e025bd2084de896eaa3fa (patch) | |
tree | 86aaf7c3c7bf37c9bf7a3c7f19eac9bacf7cd07e /video/out/gl_lcms.c | |
parent | 204fed4d5b4aa20b5a6b5824f5d4e71ccbaf87fb (diff) | |
download | mpv-17762a1919947db0e66e025bd2084de896eaa3fa.tar.bz2 mpv-17762a1919947db0e66e025bd2084de896eaa3fa.tar.xz |
video: Generate an accurate CMS matrix instead of hard-coding
This also avoids an extra matrix multiplication when using :srgb, making
that path both more efficient and also eliminating more hard-coded
values.
In addition, the previously hard-coded XYZ to RGB matrix will be
dynamically generated.
Diffstat (limited to 'video/out/gl_lcms.c')
-rw-r--r-- | video/out/gl_lcms.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/video/out/gl_lcms.c b/video/out/gl_lcms.c index b1967ebf0e..b8416bea30 100644 --- a/video/out/gl_lcms.c +++ b/video/out/gl_lcms.c @@ -167,17 +167,19 @@ struct lut3d *mp_load_icc(struct mp_icc_opts *opts, struct mp_log *log, // We always generate the 3DLUT against BT.2020, and transform into this // space inside the shader if the source differs. - static const cmsCIExyY d65 = {0.3127, 0.3290, 1.0}; - static const cmsCIExyYTRIPLE bt2020prim = { - .Red = {0.708, 0.292, 1.0}, - .Green = {0.170, 0.797, 1.0}, - .Blue = {0.131, 0.046, 1.0}, + struct mp_csp_primaries csp = mp_get_csp_primaries(MP_CSP_PRIM_BT_2020); + + cmsCIExyY wp = {csp.white.x, csp.white.y, 1.0}; + cmsCIExyYTRIPLE prim = { + .Red = {csp.red.x, csp.red.y, 1.0}, + .Green = {csp.green.x, csp.green.y, 1.0}, + .Blue = {csp.blue.x, csp.blue.y, 1.0}, }; // 2.4 is arbitrarily used as a gamma compression factor for the 3DLUT, // reducing artifacts due to rounding errors on wide gamut profiles cmsToneCurve *tonecurve = cmsBuildGamma(cms, 2.4); - cmsHPROFILE vid_profile = cmsCreateRGBProfileTHR(cms, &d65, &bt2020prim, + cmsHPROFILE vid_profile = cmsCreateRGBProfileTHR(cms, &wp, &prim, (cmsToneCurve*[3]){tonecurve, tonecurve, tonecurve}); cmsFreeToneCurve(tonecurve); cmsHTRANSFORM trafo = cmsCreateTransformTHR(cms, vid_profile, TYPE_RGB_16, |