summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--video/csputils.c10
-rw-r--r--video/csputils.h5
-rw-r--r--video/out/opengl/video.c7
3 files changed, 8 insertions, 14 deletions
diff --git a/video/csputils.c b/video/csputils.c
index 71ab0513a5..ff5ae3870d 100644
--- a/video/csputils.c
+++ b/video/csputils.c
@@ -527,10 +527,10 @@ void mp_get_cms_matrix(struct mp_csp_primaries src, struct mp_csp_primaries dest
// get the coefficients of an SMPTE 428-1 xyz -> rgb conversion matrix
// intent = the rendering intent used to convert to the target primaries
-void mp_get_xyz2rgb_coeffs(struct mp_csp_params *params,
- struct mp_csp_primaries prim,
- enum mp_render_intent intent, struct mp_cmat *m)
+static void mp_get_xyz2rgb_coeffs(struct mp_csp_params *params,
+ enum mp_render_intent intent, struct mp_cmat *m)
{
+ struct mp_csp_primaries prim = mp_get_csp_primaries(params->primaries);
float brightness = params->brightness;
mp_get_rgb2xyz_matrix(prim, m->m);
mp_invert_matrix3x3(m->m);
@@ -636,8 +636,7 @@ void mp_get_yuv2rgb_coeffs(struct mp_csp_params *params, struct mp_cmat *m)
// The vo should probably not be using a matrix generated by this
// function for XYZ sources, but if it does, let's just assume it
// wants BT.709 with D65 white point (virtually all other content).
- mp_get_xyz2rgb_coeffs(params, mp_get_csp_primaries(MP_CSP_PRIM_BT_709),
- MP_INTENT_RELATIVE_COLORIMETRIC, m);
+ mp_get_xyz2rgb_coeffs(params, MP_INTENT_RELATIVE_COLORIMETRIC, m);
levels_in = -1;
break;
}
@@ -720,6 +719,7 @@ void mp_csp_set_image_params(struct mp_csp_params *params,
mp_image_params_guess_csp(&p); // ensure consistency
params->colorspace = p.colorspace;
params->levels_in = p.colorlevels;
+ params->primaries = p.primaries;
}
// Copy settings from eq into params.
diff --git a/video/csputils.h b/video/csputils.h
index bc43a146a8..811f6bbef1 100644
--- a/video/csputils.h
+++ b/video/csputils.h
@@ -120,6 +120,7 @@ struct mp_csp_params {
enum mp_csp colorspace;
enum mp_csp_levels levels_in; // encoded video
enum mp_csp_levels levels_out; // output device
+ enum mp_csp_prim primaries;
float brightness;
float contrast;
float hue;
@@ -135,6 +136,7 @@ struct mp_csp_params {
#define MP_CSP_PARAMS_DEFAULTS { \
.colorspace = MP_CSP_BT_601, \
.levels_in = MP_CSP_LEVELS_TV, \
+ .primaries = MP_CSP_PRIM_AUTO, \
.levels_out = MP_CSP_LEVELS_PC, \
.brightness = 0, .contrast = 1, .hue = 0, .saturation = 1, \
.gamma = 1, .texture_bits = 8, .input_bits = 8}
@@ -249,9 +251,6 @@ 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]);
double mp_get_csp_mul(enum mp_csp csp, int input_bits, int texture_bits);
-
-void mp_get_xyz2rgb_coeffs(struct mp_csp_params *params, struct mp_csp_primaries prim,
- 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_invert_matrix3x3(float m[3][3]);
diff --git a/video/out/opengl/video.c b/video/out/opengl/video.c
index 018a7f8286..7ac56cb414 100644
--- a/video/out/opengl/video.c
+++ b/video/out/opengl/video.c
@@ -1491,12 +1491,7 @@ static void pass_convert_yuv(struct gl_video *p)
// Conversion to RGB. For RGB itself, this still applies e.g. brightness
// and contrast controls, or expansion of e.g. LSB-packed 10 bit data.
struct mp_cmat m = {{{0}}};
- if (p->image_desc.flags & MP_IMGFLAG_XYZ) {
- struct mp_csp_primaries csp = mp_get_csp_primaries(p->image_params.primaries);
- mp_get_xyz2rgb_coeffs(&cparams, csp, MP_INTENT_RELATIVE_COLORIMETRIC, &m);
- } else {
- mp_get_yuv2rgb_coeffs(&cparams, &m);
- }
+ mp_get_yuv2rgb_coeffs(&cparams, &m);
gl_sc_uniform_mat3(sc, "colormatrix", true, &m.m[0][0]);
gl_sc_uniform_vec3(sc, "colormatrix_c", m.c);