diff options
author | Niklas Haas <git@nand.wakku.to> | 2014-03-31 04:51:47 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2014-06-22 19:02:06 +0200 |
commit | 7f3ea1280228175664241ba5b8edaee48fd33439 (patch) | |
tree | 5871bc9e91fbf9f2ff7a9aae28518d7295d536d5 /video/csputils.c | |
parent | 17762a1919947db0e66e025bd2084de896eaa3fa (diff) | |
download | mpv-7f3ea1280228175664241ba5b8edaee48fd33439.tar.bz2 mpv-7f3ea1280228175664241ba5b8edaee48fd33439.tar.xz |
video: Better support for XYZ input
With this change, XYZ input is directly converted to the output
colorspace wherever possible, and to the colorspace specified by the
tags and/or --primaries option, otherwise.
This commit also restructures some of the CMS code in gl_video.c to
hopefully make it clearer which decision is being done where and why.
Diffstat (limited to 'video/csputils.c')
-rw-r--r-- | video/csputils.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/video/csputils.c b/video/csputils.c index 8b36615de6..bd56a1e29f 100644 --- a/video/csputils.c +++ b/video/csputils.c @@ -436,6 +436,36 @@ static void luma_coeffs(float m[3][4], float lr, float lg, float lb) } /** + * \brief get the coefficients of an xyz -> rgb conversion matrix + * \param params parameters for the conversion, only brightness is used + * \param prim primaries of the RGB space to transform to + * \param m array to store the coefficients into + */ +void mp_get_xyz2rgb_coeffs(struct mp_csp_params *params, struct mp_csp_primaries prim, float m[3][4]) +{ + float tmp[3][3], brightness = params->brightness; + mp_get_rgb2xyz_matrix(prim, tmp); + mp_invert_matrix3x3(tmp); + + // Since this outputs linear RGB rather than companded RGB, we + // want to linearize any brightness additions. 2 is a reasonable + // approximation for any sort of gamma function that could be in use. + // As this is an aesthetic setting only, any exact values do not matter. + if (brightness < 0) { + brightness *= -brightness; + } else { + brightness *= brightness; + } + + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 3; j++) + m[i][j] = tmp[i][j]; + + m[i][COL_C] = brightness; + } +} + +/** * \brief get the coefficients of the yuv -> rgb conversion matrix * \param params struct specifying the properties of the conversion like * brightness, ... |