diff options
author | wm4 <wm4@nowhere> | 2015-01-06 16:49:53 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2015-01-06 16:51:06 +0100 |
commit | d42d60bc1e0a1c3b472b21d3cd203279879f7d95 (patch) | |
tree | 5e3cc92bc64309acae00dc67312b56cc5873822c /video/out | |
parent | 5410a5b2c55b5c7d9889451c1d6e56c697325a2c (diff) | |
download | mpv-d42d60bc1e0a1c3b472b21d3cd203279879f7d95.tar.bz2 mpv-d42d60bc1e0a1c3b472b21d3cd203279879f7d95.tar.xz |
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.
Diffstat (limited to 'video/out')
-rw-r--r-- | video/out/gl_video.c | 16 | ||||
-rw-r--r-- | video/out/vo_opengl_old.c | 13 |
2 files changed, 14 insertions, 15 deletions
diff --git a/video/out/gl_video.c b/video/out/gl_video.c index 672fb5dafb..88de5eeffb 100644 --- a/video/out/gl_video.c +++ b/video/out/gl_video.c @@ -661,24 +661,20 @@ static void update_uniforms(struct gl_video *p, GLuint program) loc = gl->GetUniformLocation(program, "colormatrix"); if (loc >= 0) { - float m[3][4] = {{0}}; + struct mp_cmat m = {{{0}}}; if (p->image_desc.flags & MP_IMGFLAG_XYZ) { // Hard-coded as relative colorimetric for now, since this transforms // from the source file's D55 material to whatever color space our // projector/display lives in, which should be D55 for a proper // home cinema setup either way. - mp_get_xyz2rgb_coeffs(&cparams, p->csp_src, MP_INTENT_RELATIVE_COLORIMETRIC, m); + mp_get_xyz2rgb_coeffs(&cparams, p->csp_src, + MP_INTENT_RELATIVE_COLORIMETRIC, &m); } else { - mp_get_yuv2rgb_coeffs(&cparams, m); + mp_get_yuv2rgb_coeffs(&cparams, &m); } - float transposed[3][3]; - for (int a = 0; a < 3; a++) { - for (int b = 0; b < 3; b++) - transposed[a][b] = m[b][a]; - } - gl->UniformMatrix3fv(loc, 1, GL_FALSE, &transposed[0][0]); + gl->UniformMatrix3fv(loc, 1, GL_TRUE, &m.m[0][0]); loc = gl->GetUniformLocation(program, "colormatrix_c"); - gl->Uniform3f(loc, m[0][3], m[1][3], m[2][3]); + gl->Uniform3f(loc, m.c[0], m.c[1], m.c[2]); } gl->Uniform1f(gl->GetUniformLocation(program, "input_gamma"), diff --git a/video/out/vo_opengl_old.c b/video/out/vo_opengl_old.c index 6c9bfb62a0..f39f5709cf 100644 --- a/video/out/vo_opengl_old.c +++ b/video/out/vo_opengl_old.c @@ -1070,7 +1070,7 @@ static void glSetupYUVFragprog(struct vo *vo, GL *gl, GLint i; // this is the conversion matrix, with y, u, v factors // for red, green, blue and the constant offsets - float yuv2rgb[3][4]; + struct mp_cmat yuv2rgb; int noise = params->noise_strength != 0; create_conv_textures(vo, gl, params, &cur_texu, conv_texs); create_scaler_textures(vo, gl, YUV_LUM_SCALER(type), &cur_texu, lum_scale_texs); @@ -1102,7 +1102,7 @@ static void glSetupYUVFragprog(struct vo *vo, GL *gl, add_scaler(YUV_CHROM_SCALER(type), prog, chrom_scale_texs, '2', 'b', rect, params->chrom_texw, params->chrom_texh, params->filter_strength); - mp_get_yuv2rgb_coeffs(¶ms->csp_params, yuv2rgb); + mp_get_yuv2rgb_coeffs(¶ms->csp_params, &yuv2rgb); switch (YUV_CONVERSION(type)) { case YUV_CONVERSION_FRAGMENT: append_template(prog, yuv_prog_template); @@ -1121,11 +1121,14 @@ static void glSetupYUVFragprog(struct vo *vo, GL *gl, break; } for (int r = 0; r < 3; r++) { - for (int c = 0; c < 4; c++) { - // "cmRC" + for (int c = 0; c < 3; c++) { + // "mRC" char var[] = { 'c', 'm', '1' + r, '1' + c, '\0' }; - replace_var_float(prog, var, yuv2rgb[r][c]); + replace_var_float(prog, var, yuv2rgb.m[r][c]); } + // "mR4" + char var[] = { 'c', 'm', '1' + r, '4', '\0' }; + replace_var_float(prog, var, yuv2rgb.c[r]); } replace_var_float(prog, "gamma_r", (float)1.0 / params->csp_params.rgamma); replace_var_float(prog, "gamma_g", (float)1.0 / params->csp_params.ggamma); |