From d81fb97f4587f73f62a760b99f686139f9b8d966 Mon Sep 17 00:00:00 2001 From: Niklas Haas Date: Wed, 29 Jun 2016 09:16:13 +0200 Subject: mp_image: split colorimetry metadata into its own struct MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- video/csputils.h | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'video/csputils.h') diff --git a/video/csputils.h b/video/csputils.h index 274b548381..0743f2bee5 100644 --- a/video/csputils.h +++ b/video/csputils.h @@ -116,11 +116,17 @@ extern const struct m_opt_choice_alternatives mp_stereo3d_names[]; #define MP_STEREO3D_NAME_DEF(x, def) \ (MP_STEREO3D_NAME(x) ? MP_STEREO3D_NAME(x) : (def)) -struct mp_csp_params { - enum mp_csp colorspace; - enum mp_csp_levels levels_in; // encoded video - enum mp_csp_levels levels_out; // output device +struct mp_colorspace { + enum mp_csp space; + enum mp_csp_levels levels; enum mp_csp_prim primaries; + enum mp_csp_trc gamma; + float peak; // 0 = auto/unknown +}; + +struct mp_csp_params { + struct mp_colorspace color; // input colorspace + enum mp_csp_levels levels_out; // output device float brightness; float contrast; float hue; @@ -134,9 +140,8 @@ 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, \ + .color = { .space = MP_CSP_BT_601, \ + .levels = MP_CSP_LEVELS_TV }, \ .levels_out = MP_CSP_LEVELS_PC, \ .brightness = 0, .contrast = 1, .hue = 0, .saturation = 1, \ .gamma = 1, .texture_bits = 8, .input_bits = 8} @@ -145,6 +150,8 @@ struct mp_image_params; void mp_csp_set_image_params(struct mp_csp_params *params, const struct mp_image_params *imgparams); +bool mp_colorspace_equal(struct mp_colorspace c1, struct mp_colorspace c2); + enum mp_chroma_location { MP_CHROMA_AUTO, MP_CHROMA_LEFT, // mpeg2/4, h264 -- cgit v1.2.3