summaryrefslogtreecommitdiffstats
path: root/video/csputils.c
diff options
context:
space:
mode:
authorNiklas Haas <git@nand.wakku.to>2016-06-29 09:16:13 +0200
committerwm4 <wm4@nowhere>2016-07-03 19:42:52 +0200
commitd81fb97f4587f73f62a760b99f686139f9b8d966 (patch)
treef97ec972e64160e1a479c1b31daf73af32ca54e1 /video/csputils.c
parent3abf9c9204e2fcbc1910deb102efab4ab9d8c149 (diff)
downloadmpv-d81fb97f4587f73f62a760b99f686139f9b8d966.tar.bz2
mpv-d81fb97f4587f73f62a760b99f686139f9b8d966.tar.xz
mp_image: split colorimetry metadata into its own struct
This has two reasons: 1. I tend to add new fields to this metadata, and every time I've done so I've consistently forgotten to update all of the dozens of places in which this colorimetry metadata might end up getting used. While most usages don't really care about most of the metadata, sometimes the intend was simply to “copy” the colorimetry metadata from one struct to another. With this being inside a substruct, those lines of code can now simply read a.color = b.color without having to care about added or removed fields. 2. It makes the type definitions nicer for upcoming refactors. In going through all of the usages, I also expanded a few where I felt that omitting the “young” fields was a bug.
Diffstat (limited to 'video/csputils.c')
-rw-r--r--video/csputils.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/video/csputils.c b/video/csputils.c
index d419152e2c..4c9cfbeebd 100644
--- a/video/csputils.c
+++ b/video/csputils.c
@@ -581,7 +581,7 @@ void mp_get_cms_matrix(struct mp_csp_primaries src, struct mp_csp_primaries dest
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);
+ struct mp_csp_primaries prim = mp_get_csp_primaries(params->color.primaries);
float brightness = params->brightness;
mp_get_rgb2xyz_matrix(prim, m->m);
mp_invert_matrix3x3(m->m);
@@ -658,10 +658,10 @@ static void luma_coeffs(struct mp_cmat *mat, float lr, float lg, float lb)
// get the coefficients of the yuv -> rgb conversion matrix
void mp_get_csp_matrix(struct mp_csp_params *params, struct mp_cmat *m)
{
- int colorspace = params->colorspace;
+ enum mp_csp colorspace = params->color.space;
if (colorspace <= MP_CSP_AUTO || colorspace >= MP_CSP_COUNT)
colorspace = MP_CSP_BT_601;
- int levels_in = params->levels_in;
+ enum mp_csp_levels levels_in = params->color.levels;
if (levels_in <= MP_CSP_LEVELS_AUTO || levels_in >= MP_CSP_LEVELS_COUNT)
levels_in = MP_CSP_LEVELS_TV;
@@ -772,9 +772,16 @@ void mp_csp_set_image_params(struct mp_csp_params *params,
{
struct mp_image_params p = *imgparams;
mp_image_params_guess_csp(&p); // ensure consistency
- params->colorspace = p.colorspace;
- params->levels_in = p.colorlevels;
- params->primaries = p.primaries;
+ params->color = p.color;
+}
+
+bool mp_colorspace_equal(struct mp_colorspace c1, struct mp_colorspace c2)
+{
+ return c1.space == c2.space &&
+ c1.levels == c2.levels &&
+ c1.primaries == c2.primaries &&
+ c1.gamma == c2.gamma &&
+ c1.peak == c2.peak;
}
// Copy settings from eq into params.