summaryrefslogtreecommitdiffstats
path: root/video
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-03-30 23:52:28 +0200
committerwm4 <wm4@nowhere>2015-03-31 00:09:03 +0200
commit27715b7dd18c4a393b8483b8048cb957172e776b (patch)
tree1a0c9fbcab9591fd451f1525f5fe6613d15a7b7e /video
parent273afdc3a4dc775e427b282f0e30c9a6ae167e06 (diff)
downloadmpv-27715b7dd18c4a393b8483b8048cb957172e776b.tar.bz2
mpv-27715b7dd18c4a393b8483b8048cb957172e776b.tar.xz
video: move colorspace overrides to vf_format, simplify
Remove the colorspace-related top-level options, add them to vf_format. They are rather obscure and not needed often, so it's better to get them out of the way. In particular, this gets rid of the semi-complicated logic in command.c (most of which was needed for OSD display and the direct feedback from the VO). It removes the duplicated color-related name mappings. This removes the ability to write the colormatrix and related properties. Since filters can be changed at runtime, there's no loss of functionality, except that you can't cycle automatically through the color constants anymore (but who needs to do this). This also changes the type of the mp_csp_names and related variables, so they can directly be used with OPT_CHOICE. This probably ended up a bit awkward, for the sake of not adding a new option type which would have used the previous format.
Diffstat (limited to 'video')
-rw-r--r--video/csputils.c57
-rw-r--r--video/csputils.h13
-rw-r--r--video/decode/dec_video.c10
-rw-r--r--video/filter/vf_format.c31
-rw-r--r--video/mp_image.c14
5 files changed, 75 insertions, 50 deletions
diff --git a/video/csputils.c b/video/csputils.c
index c10cfe5a7c..f8613399c8 100644
--- a/video/csputils.c
+++ b/video/csputils.c
@@ -37,32 +37,36 @@
#include "mp_image.h"
#include "csputils.h"
-
-const char *const mp_csp_names[MP_CSP_COUNT] = {
- "auto",
- "bt.601",
- "bt.709",
- "smpte-240m",
- "bt.2020-ncl",
- "bt.2020-cl",
- "rgb",
- "xyz",
- "ycgco",
+#include "options/m_option.h"
+
+const struct m_opt_choice_alternatives mp_csp_names[] = {
+ {"auto", MP_CSP_AUTO},
+ {"bt.601", MP_CSP_BT_601},
+ {"bt.709", MP_CSP_BT_709},
+ {"smpte-240m", MP_CSP_SMPTE_240M},
+ {"bt.2020-ncl", MP_CSP_BT_2020_NC},
+ {"bt.2020-cl", MP_CSP_BT_2020_C},
+ {"rgb", MP_CSP_RGB},
+ {"xyz", MP_CSP_XYZ},
+ {"ycgco", MP_CSP_YCGCO},
+ {0}
};
-const char *const mp_csp_levels_names[MP_CSP_LEVELS_COUNT] = {
- "auto",
- "limited",
- "full",
+const struct m_opt_choice_alternatives mp_csp_levels_names[] = {
+ {"auto", MP_CSP_LEVELS_AUTO},
+ {"limited", MP_CSP_LEVELS_TV},
+ {"full", MP_CSP_LEVELS_PC},
+ {0}
};
-const char *const mp_csp_prim_names[MP_CSP_PRIM_COUNT] = {
- "auto",
- "bt.601-525",
- "bt.601-625",
- "bt.709",
- "bt.2020",
- "bt.470 m",
+const struct m_opt_choice_alternatives mp_csp_prim_names[] = {
+ {"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},
+ {"bt.470m", MP_CSP_PRIM_BT_470M},
+ {0}
};
const char *const mp_csp_trc_names[MP_CSP_TRC_COUNT] = {
@@ -81,10 +85,11 @@ const char *const mp_csp_equalizer_names[MP_CSP_EQ_COUNT] = {
"gamma",
};
-const char *const mp_chroma_names[MP_CHROMA_COUNT] = {
- "unknown",
- "mpeg2/4/h264",
- "mpeg1/jpeg",
+const struct m_opt_choice_alternatives mp_chroma_names[] = {
+ {"unknown", MP_CHROMA_AUTO},
+ {"mpeg2/4/h264",MP_CHROMA_LEFT},
+ {"mpeg1/jpeg", MP_CHROMA_CENTER},
+ {0}
};
// The short name _must_ match with what vf_stereo3d accepts (if supported).
diff --git a/video/csputils.h b/video/csputils.h
index a68c106549..14acf03be5 100644
--- a/video/csputils.h
+++ b/video/csputils.h
@@ -27,6 +27,8 @@
#include <stdbool.h>
#include <stdint.h>
+#include "options/m_option.h"
+
/* NOTE: the csp and levels AUTO values are converted to specific ones
* above vf/vo level. At least vf_scale relies on all valid settings being
* nonzero at vf/vo level.
@@ -45,8 +47,7 @@ enum mp_csp {
MP_CSP_COUNT
};
-// Any enum mp_csp value is a valid index (except MP_CSP_COUNT)
-extern const char *const mp_csp_names[MP_CSP_COUNT];
+extern const struct m_opt_choice_alternatives mp_csp_names[];
enum mp_csp_levels {
MP_CSP_LEVELS_AUTO,
@@ -55,8 +56,7 @@ enum mp_csp_levels {
MP_CSP_LEVELS_COUNT,
};
-// Any enum mp_csp_levels value is a valid index (except MP_CSP_LEVELS_COUNT)
-extern const char *const mp_csp_levels_names[MP_CSP_LEVELS_COUNT];
+extern const struct m_opt_choice_alternatives mp_csp_levels_names[];
enum mp_csp_prim {
MP_CSP_PRIM_AUTO,
@@ -68,8 +68,7 @@ enum mp_csp_prim {
MP_CSP_PRIM_COUNT
};
-// Any enum mp_csp_prim value is a valid index (except MP_CSP_PRIM_COUNT)
-extern const char *const mp_csp_prim_names[MP_CSP_PRIM_COUNT];
+extern const struct m_opt_choice_alternatives mp_csp_prim_names[];
enum mp_csp_trc {
MP_CSP_TRC_AUTO,
@@ -149,7 +148,7 @@ enum mp_chroma_location {
MP_CHROMA_COUNT,
};
-extern const char *const mp_chroma_names[MP_CHROMA_COUNT];
+extern const struct m_opt_choice_alternatives mp_chroma_names[];
enum mp_csp_equalizer_param {
MP_CSP_EQ_BRIGHTNESS,
diff --git a/video/decode/dec_video.c b/video/decode/dec_video.c
index c578ccadcc..11a36bb7ef 100644
--- a/video/decode/dec_video.c
+++ b/video/decode/dec_video.c
@@ -412,17 +412,7 @@ int video_reconfig_filters(struct dec_video *d_video,
if (force_aspect >= 0.0)
vf_set_dar(&p.d_w, &p.d_h, p.w, p.h, force_aspect);
- // Apply user overrides
- if (opts->requested_colorspace != MP_CSP_AUTO)
- p.colorspace = opts->requested_colorspace;
- 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.).
mp_image_params_guess_csp(&p);
// Time to config libvo!
diff --git a/video/filter/vf_format.c b/video/filter/vf_format.c
index a638cb37a1..8b86c35489 100644
--- a/video/filter/vf_format.c
+++ b/video/filter/vf_format.c
@@ -33,6 +33,11 @@
struct vf_priv_s {
int fmt;
int outfmt;
+ int colormatrix;
+ int colorlevels;
+ int outputlevels;
+ int primaries;
+ int chroma_location;
};
static bool is_compatible(int fmt1, int fmt2)
@@ -69,9 +74,26 @@ static int query_format(struct vf_instance *vf, unsigned int fmt)
static int reconfig(struct vf_instance *vf, struct mp_image_params *in,
struct mp_image_params *out)
{
+ struct vf_priv_s *p = vf->priv;
+
*out = *in;
- if (vf->priv->outfmt)
- out->imgfmt = vf->priv->outfmt;
+
+ if (p->outfmt)
+ out->imgfmt = p->outfmt;
+ if (p->colormatrix)
+ out->colorspace = p->colormatrix;
+ if (p->colorlevels)
+ out->colorlevels = p->colorlevels;
+ if (p->outputlevels)
+ out->outputlevels = p->outputlevels;
+ if (p->primaries)
+ out->primaries = p->primaries;
+ if (p->chroma_location)
+ out->chroma_location = p->chroma_location;
+
+ // Make sure the user-overrides are consistent (no RGB csp for YUV, etc.).
+ mp_image_params_guess_csp(out);
+
return 0;
}
@@ -94,6 +116,11 @@ static int vf_open(vf_instance_t *vf)
static const m_option_t vf_opts_fields[] = {
OPT_IMAGEFORMAT("fmt", fmt, 0),
OPT_IMAGEFORMAT("outfmt", outfmt, 0),
+ OPT_CHOICE_C("colormatrix", colormatrix, 0, mp_csp_names),
+ OPT_CHOICE_C("colorlevels", colorlevels, 0, mp_csp_levels_names),
+ OPT_CHOICE_C("outputlevels", outputlevels, 0, mp_csp_levels_names),
+ OPT_CHOICE_C("primaries", primaries, 0, mp_csp_prim_names),
+ OPT_CHOICE_C("chroma-location", chroma_location, 0, mp_chroma_names),
{0}
};
diff --git a/video/mp_image.c b/video/mp_image.c
index 0e378cb311..da644d57fe 100644
--- a/video/mp_image.c
+++ b/video/mp_image.c
@@ -446,11 +446,15 @@ char *mp_image_params_to_str_buf(char *b, size_t bs,
if (p->w != p->d_w || p->h != p->d_h)
mp_snprintf_cat(b, bs, "->%dx%d", p->d_w, p->d_h);
mp_snprintf_cat(b, bs, " %s", mp_imgfmt_to_name(p->imgfmt));
- mp_snprintf_cat(b, bs, " %s/%s", mp_csp_names[p->colorspace],
- mp_csp_levels_names[p->colorlevels]);
- mp_snprintf_cat(b, bs, " CL=%s", mp_chroma_names[p->chroma_location]);
- if (p->outputlevels)
- mp_snprintf_cat(b, bs, " out=%s", mp_csp_levels_names[p->outputlevels]);
+ mp_snprintf_cat(b, bs, " %s/%s",
+ m_opt_choice_str(mp_csp_names, p->colorspace),
+ m_opt_choice_str(mp_csp_levels_names, p->colorlevels));
+ mp_snprintf_cat(b, bs, " CL=%s",
+ m_opt_choice_str(mp_chroma_names, p->chroma_location));
+ if (p->outputlevels) {
+ mp_snprintf_cat(b, bs, " out=%s",
+ m_opt_choice_str(mp_csp_levels_names, p->outputlevels));
+ }
if (p->rotate)
mp_snprintf_cat(b, bs, " rot=%d", p->rotate);
if (p->stereo_in > 0 || p->stereo_out > 0) {