summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNiklas Haas <git@nand.wakku.to>2014-03-26 14:03:24 +0100
committerwm4 <wm4@nowhere>2014-06-22 19:01:25 +0200
commitef6db24366da2974cdee1d9578cf91910b5faa9c (patch)
treee06720ce263fc8c15630f49ebd8901139610ce21
parent70f50ddc5e97020d64ea0702748a00eddebc2473 (diff)
downloadmpv-ef6db24366da2974cdee1d9578cf91910b5faa9c.tar.bz2
mpv-ef6db24366da2974cdee1d9578cf91910b5faa9c.tar.xz
options: Expose --colormatrix-primaries to the user
Signed-off-by: wm4 <wm4@nowhere>
-rw-r--r--DOCS/man/input.rst6
-rw-r--r--DOCS/man/options.rst18
-rw-r--r--options/options.c6
-rw-r--r--options/options.h1
-rw-r--r--player/command.c29
-rw-r--r--video/decode/dec_video.c2
6 files changed, 62 insertions, 0 deletions
diff --git a/DOCS/man/input.rst b/DOCS/man/input.rst
index 9e9863b9db..befa41b709 100644
--- a/DOCS/man/input.rst
+++ b/DOCS/man/input.rst
@@ -872,6 +872,9 @@ Property list
``colormatrix-output-range`` (RW)
See ``--colormatrix-output-range``.
+``colormatrix-primaries`` (RW)
+ See ``--colormatrix-primaries``.
+
``ontop`` (RW)
See ``--ontop``.
@@ -949,6 +952,9 @@ Property list
``video-params/colorlevels``
The colorlevels as string. (Exact values subject to change.)
+ ``video-params/primaries``
+ The primaries in use as string. (Exact values subject to change.)
+
``video-params/chroma-location``
Chroma location as string. (Exact values subject to change.)
diff --git a/DOCS/man/options.rst b/DOCS/man/options.rst
index 6e96c9c541..92dd35d0cf 100644
--- a/DOCS/man/options.rst
+++ b/DOCS/man/options.rst
@@ -574,6 +574,24 @@ OPTIONS
It is advisable to use your graphics driver's color range option
instead, if available.
+``--colormatrix-primaries=<primaries>``
+ RGB primaries the source file was encoded with. Normally this should be set
+ in the file header, but when playing broken or mistagged files this can be
+ used to override the setting. By default, when unset, BT.709 is used for
+ all files except those tagged with a BT.2020 color matrix.
+
+ This option only affects video output drivers that perform color
+ management, for example ``opengl`` with the ``srgb`` or ``icc-profile``
+ suboptions set.
+
+ Available primaries are:
+
+ :auto: automatic selection (default)
+ :BT.601-525: ITU-R BT.601 (SD) 525-line systems (NTSC)
+ :BT.601-625: ITU-R BT.601 (SD) 625-line systems (PAL, SECAM)
+ :BT.709: ITU-R BT.709 (HD)
+ :BT.2020: ITU-R BT.2020 (UHD)
+
``--config-dir=<path>``
Force a different configuration directory. If this is set, the given
directory is used to load configuration files, and all other configuration
diff --git a/options/options.c b/options/options.c
index ea79a7d609..d5f751b9cf 100644
--- a/options/options.c
+++ b/options/options.c
@@ -399,6 +399,12 @@ const m_option_t mp_opts[] = {
({"auto", MP_CSP_LEVELS_AUTO},
{"limited", MP_CSP_LEVELS_TV},
{"full", MP_CSP_LEVELS_PC})),
+ OPT_CHOICE("colormatrix-primaries", requested_primaries, 0,
+ ({"auto", MP_CSP_PRIM_AUTO},
+ {"BT.601-525", MP_CSP_PRIM_BT_601_525},
+ {"BT.601-625", MP_CSP_PRIM_BT_601_625},
+ {"BT.709", MP_CSP_PRIM_BT_709},
+ {"BT.2020", MP_CSP_PRIM_BT_2020})),
OPT_CHOICE_OR_INT("video-rotate", video_rotate, 0, 0, 359,
({"no", -1})),
diff --git a/options/options.h b/options/options.h
index 83b44c1e3d..100fded4a3 100644
--- a/options/options.h
+++ b/options/options.h
@@ -97,6 +97,7 @@ typedef struct MPOpts {
int requested_colorspace;
int requested_input_range;
int requested_output_range;
+ int requested_primaries;
int video_rotate;
diff --git a/player/command.c b/player/command.c
index 85823371f3..af82a775da 100644
--- a/player/command.c
+++ b/player/command.c
@@ -1839,6 +1839,31 @@ static int mp_property_colormatrix_output_range(void *ctx, struct m_property *pr
return M_PROPERTY_OK;
}
+static int mp_property_primaries(void *ctx, struct m_property *prop,
+ int action, void *arg)
+{
+ MPContext *mpctx = ctx;
+ if (action != M_PROPERTY_PRINT)
+ return video_refresh_property_helper(prop, action, arg, mpctx);
+
+ struct MPOpts *opts = mpctx->opts;
+
+ struct mp_image_params vo_csp = {0};
+ if (mpctx->video_out)
+ vo_control(mpctx->video_out, VOCTRL_GET_COLORSPACE, &vo_csp);
+
+ struct mp_image_params vd_csp = {0};
+ if (mpctx->d_video)
+ vd_csp = mpctx->d_video->decoder_output;
+
+ char *res = talloc_strdup(NULL, "");
+ append_csp(&res, "*Requested", mp_csp_prim_names, opts->requested_primaries);
+ append_csp(&res, "Video decoder", mp_csp_prim_names, vd_csp.primaries);
+ append_csp(&res, "Video output", mp_csp_prim_names, vo_csp.primaries);
+ *(char **)arg = res;
+ return M_PROPERTY_OK;
+}
+
// Update options which are managed through VOCTRL_GET/SET_PANSCAN.
static int panscan_property_helper(void *ctx, struct m_property *prop,
int action, void *arg)
@@ -1978,6 +2003,7 @@ static int property_imgparams(struct mp_image_params p, int action, void *arg)
{"par", SUB_PROP_FLOAT(dar / sar)},
{"colormatrix", SUB_PROP_STR(mp_csp_names[p.colorspace])},
{"colorlevels", SUB_PROP_STR(mp_csp_levels_names[p.colorlevels])},
+ {"primaries", SUB_PROP_STR(mp_csp_prim_names[p.primaries])},
{"chroma-location", SUB_PROP_STR(mp_chroma_names[p.chroma_location])},
{"rotate", SUB_PROP_INT(p.rotate)},
{0}
@@ -2615,6 +2641,7 @@ static const struct m_property mp_properties[] = {
{"colormatrix", mp_property_colormatrix},
{"colormatrix-input-range", mp_property_colormatrix_input_range},
{"colormatrix-output-range", mp_property_colormatrix_output_range},
+ {"colormatrix-primaries", mp_property_primaries},
{"ontop", mp_property_ontop},
{"border", mp_property_border},
{"framedrop", mp_property_framedrop},
@@ -2825,6 +2852,8 @@ static const struct property_osd_display {
.msg = "YUV input range:\n${colormatrix-input-range}" },
{ "colormatrix-output-range",
.msg = "RGB output range:\n${colormatrix-output-range}" },
+ { "colormatrix-primaries",
+ .msg = "Colorspace primaries:\n${colormatrix-primaries}", },
{ "gamma", "Gamma", .osd_progbar = OSD_BRIGHTNESS },
{ "brightness", "Brightness", .osd_progbar = OSD_BRIGHTNESS },
{ "contrast", "Contrast", .osd_progbar = OSD_CONTRAST },
diff --git a/video/decode/dec_video.c b/video/decode/dec_video.c
index f69206ccfc..807ce2013c 100644
--- a/video/decode/dec_video.c
+++ b/video/decode/dec_video.c
@@ -428,6 +428,8 @@ int video_reconfig_filters(struct dec_video *d_video,
if (opts->requested_input_range != MP_CSP_LEVELS_AUTO)
p.colorlevels = opts->requested_input_range;
p.outputlevels = opts->requested_output_range;
+ if (opts->requested_primaries != MP_CSP_PRIM_AUTO)
+ p.primaries = opts->requested_primaries;
// Detect colorspace from resolution.
// Make sure the user-overrides are consistent (no RGB csp for YUV, etc.).