summaryrefslogtreecommitdiffstats
path: root/options/m_option.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2016-08-31 18:10:11 +0200
committerwm4 <wm4@nowhere>2016-08-31 22:17:21 +0200
commitc55d85992078e465f9e0b7b6998ccdc5f5e77703 (patch)
treedb6a4939daa1c3c0b810710b5d268592a8c29262 /options/m_option.c
parent2057209057555dc138422daa354fe8db816c629c (diff)
downloadmpv-c55d85992078e465f9e0b7b6998ccdc5f5e77703.tar.bz2
mpv-c55d85992078e465f9e0b7b6998ccdc5f5e77703.tar.xz
m_option: replace --no-video-aspect alias
Instead, add a hacky OPT_ASPECT option type, which only exists to accept a "no" parameter, which in combination with the "--no-..." handling code makes --no-video-aspect work again. We can also remove the code in m_config.c, which only existed to make "--no-aspect" (a deprecated alias) to work.
Diffstat (limited to 'options/m_option.c')
-rw-r--r--options/m_option.c63
1 files changed, 24 insertions, 39 deletions
diff --git a/options/m_option.c b/options/m_option.c
index 45709b9c16..cc8d818eec 100644
--- a/options/m_option.c
+++ b/options/m_option.c
@@ -234,45 +234,6 @@ const m_option_type_t m_option_type_store = {
.set = store_set,
};
-// Same for float types
-
-#undef VAL
-#define VAL(x) (*(float *)(x))
-
-static int parse_store_float(struct mp_log *log, const m_option_t *opt,
- struct bstr name, struct bstr param, void *dst)
-{
- if (param.len == 0) {
- if (dst)
- VAL(dst) = opt->max;
- return 0;
- } else {
- mp_err(log, "Invalid parameter for %.*s flag: %.*s\n",
- BSTR_P(name), BSTR_P(param));
- return M_OPT_DISALLOW_PARAM;
- }
-}
-
-static int store_float_set(const m_option_t *opt, void *dst, struct mpv_node *src)
-{
- if (src->format != MPV_FORMAT_FLAG)
- return M_OPT_UNKNOWN;
- if (!src->u.flag)
- return M_OPT_INVALID;
- VAL(dst) = opt->max;
- return 1;
-}
-
-const m_option_type_t m_option_type_float_store = {
- // can only be activated
- .name = "Flag",
- .size = sizeof(float),
- .flags = M_OPT_TYPE_OPTIONAL_PARAM,
- .parse = parse_store_float,
- .copy = copy_opt,
- .set = store_float_set,
-};
-
// Integer
#undef VAL
@@ -1038,6 +999,30 @@ const m_option_type_t m_option_type_float = {
.get = float_get,
};
+static int parse_float_aspect(struct mp_log *log, const m_option_t *opt,
+ struct bstr name, struct bstr param, void *dst)
+{
+ if (bstr_equals0(param, "no")) {
+ if (dst)
+ VAL(dst) = 0.0f;
+ return 1;
+ }
+ return parse_float(log, opt, name, param, dst);
+}
+
+const m_option_type_t m_option_type_aspect = {
+ .name = "Aspect",
+ .size = sizeof(float),
+ .parse = parse_float_aspect,
+ .print = print_float,
+ .pretty_print = print_float_f3,
+ .copy = copy_opt,
+ .add = add_float,
+ .multiply = multiply_float,
+ .set = float_set,
+ .get = float_get,
+};
+
///////////// String
#undef VAL