summaryrefslogtreecommitdiffstats
path: root/video/out/gl_lcms.c
diff options
context:
space:
mode:
authorNiklas Haas <git@nand.wakku.to>2014-03-26 01:46:38 +0100
committerwm4 <wm4@nowhere>2014-06-22 19:00:38 +0200
commit70f50ddc5e97020d64ea0702748a00eddebc2473 (patch)
treef115668aa97cf11770459a169cc777ffca113840 /video/out/gl_lcms.c
parent86d3d11a68510764504a2a3c5987ab8e059d6df5 (diff)
downloadmpv-70f50ddc5e97020d64ea0702748a00eddebc2473.tar.bz2
mpv-70f50ddc5e97020d64ea0702748a00eddebc2473.tar.xz
video: Add support for non-BT.709 primaries
This add support for reading primary information from lavc, categorized into BT.601-525, BT.601-625, BT.709 and BT.2020; and passes it on to the vo. In vo_opengl, we always generate the 3dlut against the wider BT.2020 and transform our source into this colorspace in the shader.
Diffstat (limited to 'video/out/gl_lcms.c')
-rw-r--r--video/out/gl_lcms.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/video/out/gl_lcms.c b/video/out/gl_lcms.c
index 75388ada05..b1967ebf0e 100644
--- a/video/out/gl_lcms.c
+++ b/video/out/gl_lcms.c
@@ -46,7 +46,7 @@ static bool parse_3dlut_size(const char *arg, int *p1, int *p2, int *p3)
return false;
for (int n = 0; n < 3; n++) {
int s = ((int[]) { *p1, *p2, *p3 })[n];
- if (s < 2 || s > 256 || ((s - 1) & s))
+ if (s < 2 || s > 512 || ((s - 1) & s))
return false;
}
return true;
@@ -135,8 +135,8 @@ struct lut3d *mp_load_icc(struct mp_icc_opts *opts, struct mp_log *log,
char *cache_info =
// Gamma is included in the header to help uniquely identify it,
// because we may change the parameter in the future or make it
- // customizable.
- talloc_asprintf(tmp, "intent=%d, size=%dx%dx%d, gamma=2.4",
+ // customizable, same for the primaries.
+ talloc_asprintf(tmp, "intent=%d, size=%dx%dx%d, gamma=2.4, prim=bt2020\n",
opts->intent, s_r, s_g, s_b);
// check cache
@@ -165,17 +165,19 @@ struct lut3d *mp_load_icc(struct mp_icc_opts *opts, struct mp_log *log,
if (!profile)
goto error_exit;
- cmsCIExyY d65 = {0.3127, 0.3290, 1.0};
- static const cmsCIExyYTRIPLE bt709prim = {
- .Red = {0.64, 0.33, 1.0},
- .Green = {0.30, 0.60, 1.0},
- .Blue = {0.15, 0.06, 1.0},
+ // 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},
};
// 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, &bt709prim,
+ cmsHPROFILE vid_profile = cmsCreateRGBProfileTHR(cms, &d65, &bt2020prim,
(cmsToneCurve*[3]){tonecurve, tonecurve, tonecurve});
cmsFreeToneCurve(tonecurve);
cmsHTRANSFORM trafo = cmsCreateTransformTHR(cms, vid_profile, TYPE_RGB_16,