From c3f32f3a6e3486093eb17518146a6459a34c0c41 Mon Sep 17 00:00:00 2001 From: Niklas Haas Date: Sat, 17 Jun 2017 01:55:08 +0200 Subject: vo_opengl: tone map in linear XYZ instead of RGB This preserves channel balance better and helps reduce discoloration due to nonlinear tone mapping. I wasn't sure whether to stuff this inside pass_color_manage or pass_tone_map but decided for the former because adding the extra mp_csp_prim would have made the signature of the latter longer than 80col, and also because the `mp_get_cms_matrix` below it basically does the same thing anyway, so it doesn't look that out of place. Also why is this justification longer than the actual description of the algorithm and what it's good for? --- video/csputils.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'video/csputils.h') diff --git a/video/csputils.h b/video/csputils.h index 9e81c90ebf..8b63ac3905 100644 --- a/video/csputils.h +++ b/video/csputils.h @@ -218,6 +218,14 @@ struct mp_csp_col_xy { float x, y; }; +static inline float mp_xy_X(struct mp_csp_col_xy xy) { + return xy.x / xy.y; +} + +static inline float mp_xy_Z(struct mp_csp_col_xy xy) { + return (1 - xy.x - xy.y) / xy.y; +} + struct mp_csp_primaries { struct mp_csp_col_xy red, green, blue, white; }; @@ -268,6 +276,7 @@ struct mp_cmat { float c[3]; }; +void mp_get_rgb2xyz_matrix(struct mp_csp_primaries space, float m[3][3]); void mp_get_cms_matrix(struct mp_csp_primaries src, struct mp_csp_primaries dest, enum mp_render_intent intent, float cms_matrix[3][3]); -- cgit v1.2.3