From d42d60bc1e0a1c3b472b21d3cd203279879f7d95 Mon Sep 17 00:00:00 2001 From: wm4 Date: Tue, 6 Jan 2015 16:49:53 +0100 Subject: csputils: replace float[3][4] with a struct Not being able to use the 3x3 part of the matrix was annoying, so split it into a float[3][3] matrix and a separate float[3] constant vector. --- video/csputils.h | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) (limited to 'video/csputils.h') diff --git a/video/csputils.h b/video/csputils.h index 51de50c4b6..8e8d18e7df 100644 --- a/video/csputils.h +++ b/video/csputils.h @@ -214,28 +214,41 @@ int mp_chroma_location_to_av(enum mp_chroma_location mploc); void mp_get_chroma_location(enum mp_chroma_location loc, int *x, int *y); void mp_gen_gamma_map(unsigned char *map, int size, float gamma); -#define ROW_R 0 -#define ROW_G 1 -#define ROW_B 2 -#define COL_Y 0 -#define COL_U 1 -#define COL_V 2 -#define COL_C 3 + struct mp_csp_primaries mp_get_csp_primaries(enum mp_csp_prim csp); -void mp_apply_chromatic_adaptation(struct mp_csp_col_xy src, struct mp_csp_col_xy dest, float m[3][3]); +/* Color conversion matrix: RGB = m * YUV + c + * m is in row-major matrix, with m[row][col], e.g.: + * [ a11 a12 a13 ] float m[3][3] = { { a11, a12, a13 }, + * [ a21 a22 a23 ] { a21, a22, a23 }, + * [ a31 a32 a33 ] { a31, a32, a33 } }; + * This is accessed as e.g.: m[2-1][1-1] = a21 + * In particular, each row contains all the coefficients for one of R, G, B, + * while each column contains all the coefficients for one of Y, U, V: + * m[r,g,b][y,u,v] = ... + * The matrix could also be viewed as group of 3 vectors, e.g. the 1st column + * is the Y vector (1, 1, 1), the 2nd is the U vector, the 3rd the V vector. + * The matrix might also be used for other conversions and colorspaces. + */ +struct mp_cmat { + float m[3][3]; + float c[3]; +}; + +void mp_apply_chromatic_adaptation(struct mp_csp_col_xy src, + struct mp_csp_col_xy dest, 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]); void mp_get_rgb2xyz_matrix(struct mp_csp_primaries space, float m[3][3]); void mp_get_xyz2rgb_coeffs(struct mp_csp_params *params, struct mp_csp_primaries prim, - enum mp_render_intent intent, float xyz2rgb[3][4]); -void mp_get_yuv2rgb_coeffs(struct mp_csp_params *params, float yuv2rgb[3][4]); + enum mp_render_intent intent, struct mp_cmat *xyz2rgb); +void mp_get_yuv2rgb_coeffs(struct mp_csp_params *params, struct mp_cmat *yuv2rgb); void mp_gen_yuv2rgb_map(struct mp_csp_params *params, uint8_t *map, int size); void mp_mul_matrix3x3(float a[3][3], float b[3][3]); void mp_invert_matrix3x3(float m[3][3]); -void mp_invert_yuv2rgb(float out[3][4], float in[3][4]); -void mp_map_int_color(float matrix[3][4], int clip_bits, int c[3]); +void mp_invert_yuv2rgb(struct mp_cmat *out, struct mp_cmat *in); +void mp_map_int_color(struct mp_cmat *matrix, int clip_bits, int c[3]); #endif /* MPLAYER_CSPUTILS_H */ -- cgit v1.2.3