summaryrefslogtreecommitdiffstats
path: root/options
diff options
context:
space:
mode:
Diffstat (limited to 'options')
-rw-r--r--options/m_config_core.c13
-rw-r--r--options/m_config_core.h4
-rw-r--r--options/m_config_frontend.c19
-rw-r--r--options/m_option.c99
-rw-r--r--options/m_option.h4
-rw-r--r--options/options.c14
-rw-r--r--options/options.h3
7 files changed, 118 insertions, 38 deletions
diff --git a/options/m_config_core.c b/options/m_config_core.c
index 2c9979688a..3be11468e0 100644
--- a/options/m_config_core.c
+++ b/options/m_config_core.c
@@ -227,6 +227,19 @@ const char *m_config_shadow_get_opt_name(struct m_config_shadow *shadow,
g->group->opts[opt_index].name);
}
+const char *m_config_shadow_get_alias_from_opt(struct m_config_shadow *shadow, int32_t id,
+ char *buf, size_t buf_size)
+{
+ int group_index, opt_index;
+ get_opt_from_id(shadow, id, &group_index, &opt_index);
+
+ struct m_config_group *g = &shadow->groups[group_index];
+ const struct m_option *opt = &shadow->groups[group_index].group->opts[opt_index];
+ if (opt->alias_use_prefix)
+ return concat_name_buf(buf, buf_size, g->prefix, (const char *)opt->priv);
+ return (const char *)opt->priv;
+}
+
const void *m_config_shadow_get_opt_default(struct m_config_shadow *shadow,
int32_t id)
{
diff --git a/options/m_config_core.h b/options/m_config_core.h
index a9558423d8..738858b41a 100644
--- a/options/m_config_core.h
+++ b/options/m_config_core.h
@@ -175,6 +175,10 @@ const struct m_option *m_config_shadow_get_opt(struct m_config_shadow *shadow,
const char *m_config_shadow_get_opt_name(struct m_config_shadow *shadow,
int32_t id, char *buf, size_t buf_size);
+// Resolve alias mapping from opt.
+const char *m_config_shadow_get_alias_from_opt(struct m_config_shadow *shadow, int32_t id,
+ char *buf, size_t buf_size);
+
// Pointer to default value, using m_option.type. NULL if option without data.
// id must be a valid option ID as returned by m_config_shadow_get_next_opt() or
// m_config_cache_get_next_opt().
diff --git a/options/m_config_frontend.c b/options/m_config_frontend.c
index 6f0aa22d3b..16dba07a68 100644
--- a/options/m_config_frontend.c
+++ b/options/m_config_frontend.c
@@ -302,7 +302,9 @@ static struct m_config_option *m_config_get_co_any(const struct m_config *config
const char *prefix = config->is_toplevel ? "--" : "";
if (co->opt->type == &m_option_type_alias) {
- const char *alias = (const char *)co->opt->priv;
+ char buf[M_CONFIG_MAX_OPT_NAME_LEN];
+ const char *alias = m_config_shadow_get_alias_from_opt(config->shadow, co->opt_id,
+ buf, sizeof(buf));
if (co->opt->deprecation_message && !co->warning_was_printed) {
if (co->opt->deprecation_message[0]) {
MP_WARN(config, "Warning: option %s%s was replaced with "
@@ -881,8 +883,12 @@ void m_config_print_option_list(const struct m_config *config, const char *name)
MP_INFO(config, " [file]");
if (opt->deprecation_message)
MP_INFO(config, " [deprecated]");
- if (opt->type == &m_option_type_alias)
- MP_INFO(config, " for %s", (char *)opt->priv);
+ if (opt->type == &m_option_type_alias) {
+ char buf[M_CONFIG_MAX_OPT_NAME_LEN];
+ const char *alias = m_config_shadow_get_alias_from_opt(config->shadow, co->opt_id,
+ buf, sizeof(buf));
+ MP_INFO(config, " for %s", alias);
+ }
if (opt->type == &m_option_type_cli_alias)
MP_INFO(config, " for --%s (CLI/config files only)", (char *)opt->priv);
MP_INFO(config, "\n");
@@ -990,6 +996,11 @@ static struct m_profile *find_check_profile(struct m_config *config, char *name)
int m_config_set_profile(struct m_config *config, char *name, int flags)
{
+ if ((flags & M_SETOPT_FROM_CONFIG_FILE) && !strcmp(name, "default")) {
+ MP_WARN(config, "Ignoring profile=%s from config file.\n", name);
+ return 0;
+ }
+
MP_VERBOSE(config, "Applying profile '%s'...\n", name);
struct m_profile *p = find_check_profile(config, name);
if (!p)
@@ -1040,7 +1051,7 @@ int m_config_restore_profile(struct m_config *config, char *name)
void m_config_finish_default_profile(struct m_config *config, int flags)
{
struct m_profile *p = m_config_add_profile(config, NULL);
- m_config_set_profile(config, p->name, flags);
+ m_config_set_profile(config, p->name, flags & ~M_SETOPT_FROM_CONFIG_FILE);
p->num_opts = 0;
}
diff --git a/options/m_option.c b/options/m_option.c
index b4bf68fee4..64e383936f 100644
--- a/options/m_option.c
+++ b/options/m_option.c
@@ -2654,7 +2654,8 @@ const m_option_type_t m_option_type_channels = {
static int parse_timestring(struct bstr str, double *time, char endchar)
{
- int h, m, len;
+ int len;
+ unsigned h, m;
double s;
*time = 0; /* ensure initialization for error cases */
bool neg = bstr_eatstart0(&str, "-");
@@ -2662,14 +2663,14 @@ static int parse_timestring(struct bstr str, double *time, char endchar)
bstr_eatstart0(&str, "+");
if (bstrchr(str, '-') >= 0 || bstrchr(str, '+') >= 0)
return 0; /* the timestamp shouldn't contain anymore +/- after this point */
- if (bstr_sscanf(str, "%d:%d:%lf%n", &h, &m, &s, &len) >= 3) {
+ if (bstr_sscanf(str, "%u:%u:%lf%n", &h, &m, &s, &len) >= 3) {
if (m >= 60 || s >= 60)
return 0; /* minutes or seconds are out of range */
- *time = 3600 * h + 60 * m + s;
- } else if (bstr_sscanf(str, "%d:%lf%n", &m, &s, &len) >= 2) {
+ *time = 3600.0 * h + 60 * m + s;
+ } else if (bstr_sscanf(str, "%u:%lf%n", &m, &s, &len) >= 2) {
if (s >= 60)
return 0; /* seconds are out of range */
- *time = 60 * m + s;
+ *time = 60.0 * m + s;
} else if (bstr_sscanf(str, "%lf%n", &s, &len) >= 1) {
*time = s;
} else {
@@ -2917,10 +2918,18 @@ static void obj_settings_list_del_at(m_obj_settings_t **p_obj_list, int idx)
// Insert such that *p_obj_list[idx] is set to item.
// If idx < 0, set idx = count + idx + 1 (i.e. -1 inserts it as last element).
// Memory referenced by *item is not copied.
-static void obj_settings_list_insert_at(m_obj_settings_t **p_obj_list, int idx,
+static bool obj_settings_list_insert_at(struct mp_log *log,
+ m_obj_settings_t **p_obj_list, int idx,
m_obj_settings_t *item)
{
int num = obj_settings_list_num_items(*p_obj_list);
+ // Limit list entries to 100. obj_settings_list is not designed to hold more
+ // items, and it quickly starts taking ages to add all items.
+ if (num > 100) {
+ mp_warn(log, "Object settings list capacity exceeded: "
+ "a maximum of 100 elements is allowed.");
+ return false;
+ }
if (idx < 0)
idx = num + idx + 1;
assert(idx >= 0 && idx <= num);
@@ -2930,6 +2939,7 @@ static void obj_settings_list_insert_at(m_obj_settings_t **p_obj_list, int idx,
(num - idx) * sizeof(m_obj_settings_t));
(*p_obj_list)[idx] = *item;
(*p_obj_list)[num + 1] = (m_obj_settings_t){0};
+ return true;
}
static int obj_settings_list_find_by_label(m_obj_settings_t *obj_list,
@@ -3266,7 +3276,8 @@ done: ;
.enabled = enabled,
.attribs = plist,
};
- obj_settings_list_insert_at(_ret, -1, &item);
+ if (!obj_settings_list_insert_at(log, _ret, -1, &item))
+ obj_setting_free(&item);
return 1;
}
@@ -3308,6 +3319,7 @@ static int parse_obj_settings_list(struct mp_log *log, const m_option_t *opt,
bool *mark_del = NULL;
int num_items = obj_settings_list_num_items(dst ? VAL(dst) : 0);
const struct m_obj_list *ol = opt->priv;
+ int ret = 1;
assert(opt->priv);
@@ -3345,7 +3357,8 @@ static int parse_obj_settings_list(struct mp_log *log, const m_option_t *opt,
opt->name, opt->name, opt->name, opt->name, opt->name,
opt->name, opt->name, opt->name);
- return M_OPT_EXIT;
+ ret = M_OPT_EXIT;
+ goto done;
}
if (!bstrcmp0(param, "help")) {
@@ -3366,24 +3379,29 @@ static int parse_obj_settings_list(struct mp_log *log, const m_option_t *opt,
mp_info(log, "Get help on individual entries via: --%s=entry=help\n",
opt->name);
}
- return M_OPT_EXIT;
+ ret = M_OPT_EXIT;
+ goto done;
}
if (op == OP_CLR) {
if (param.len) {
mp_err(log, "Option %.*s: -clr does not take an argument.\n",
BSTR_P(name));
- return M_OPT_INVALID;
+ ret = M_OPT_INVALID;
+ goto done;
}
if (dst)
free_obj_settings_list(dst);
- return 0;
+ ret = 0;
+ goto done;
} else if (op == OP_REMOVE) {
mark_del = talloc_zero_array(NULL, bool, num_items + 1);
}
- if (op != OP_NONE && param.len == 0)
- return M_OPT_MISSING_PARAM;
+ if (op != OP_NONE && param.len == 0) {
+ ret = M_OPT_MISSING_PARAM;
+ goto done;
+ }
while (param.len > 0) {
int r = 0;
@@ -3394,24 +3412,28 @@ static int parse_obj_settings_list(struct mp_log *log, const m_option_t *opt,
}
if (r < 0) {
free_obj_settings_list(&res);
- return r;
+ ret = r;
+ goto done;
}
if (param.len > 0) {
const char sep[2] = {OPTION_LIST_SEPARATOR, 0};
if (!bstr_eatstart0(&param, sep)) {
free_obj_settings_list(&res);
- return M_OPT_INVALID;
+ ret = M_OPT_INVALID;
+ goto done;
}
if (param.len == 0) {
if (!ol->allow_trailer) {
free_obj_settings_list(&res);
- return M_OPT_INVALID;
+ ret = M_OPT_INVALID;
+ goto done;
}
if (dst) {
m_obj_settings_t item = {
.name = talloc_strdup(NULL, ""),
};
- obj_settings_list_insert_at(&res, -1, &item);
+ if (!obj_settings_list_insert_at(log, &res, -1, &item))
+ obj_setting_free(&item);
}
}
}
@@ -3422,7 +3444,8 @@ static int parse_obj_settings_list(struct mp_log *log, const m_option_t *opt,
mp_err(log, "Option %.*s: -append takes only 1 item (no ',').\n",
BSTR_P(name));
free_obj_settings_list(&res);
- return M_OPT_INVALID;
+ ret = M_OPT_INVALID;
+ goto done;
}
mp_warn(log, "Passing more than 1 argument to %.*s is deprecated!\n",
BSTR_P(name));
@@ -3435,7 +3458,8 @@ static int parse_obj_settings_list(struct mp_log *log, const m_option_t *opt,
for (int n = 0; res && res[n].name; n++) {
int label = obj_settings_list_find_by_label0(list, res[n].label);
if (label < 0) {
- obj_settings_list_insert_at(&list, prepend_counter, &res[n]);
+ if (!obj_settings_list_insert_at(log, &list, prepend_counter, &res[n]))
+ obj_setting_free(&res[n]);
prepend_counter++;
} else {
// Prefer replacement semantics, instead of actually
@@ -3449,7 +3473,8 @@ static int parse_obj_settings_list(struct mp_log *log, const m_option_t *opt,
for (int n = 0; res && res[n].name; n++) {
int label = obj_settings_list_find_by_label0(list, res[n].label);
if (label < 0) {
- obj_settings_list_insert_at(&list, -1, &res[n]);
+ if (!obj_settings_list_insert_at(log, &list, -1, &res[n]))
+ obj_setting_free(&res[n]);
} else {
// Prefer replacement semantics, instead of actually
// appending.
@@ -3474,7 +3499,8 @@ static int parse_obj_settings_list(struct mp_log *log, const m_option_t *opt,
} else {
int found = obj_settings_find_by_content(list, &res[n]);
if (found < 0) {
- obj_settings_list_insert_at(&list, -1, &res[n]);
+ if (!obj_settings_list_insert_at(log, &list, -1, &res[n]))
+ obj_setting_free(&res[n]);
} else {
obj_settings_list_del_at(&list, found);
obj_setting_free(&res[n]);
@@ -3501,8 +3527,9 @@ static int parse_obj_settings_list(struct mp_log *log, const m_option_t *opt,
VAL(dst) = list;
}
+done:
talloc_free(mark_del);
- return 1;
+ return ret;
}
static void append_param(char **res, char *param)
@@ -3852,6 +3879,34 @@ const m_option_type_t m_option_type_node = {
.equal = node_equal,
};
+static int parse_cycle_dir(struct mp_log *log, const struct m_option *opt,
+ struct bstr name, struct bstr param, void *dst)
+{
+ double val;
+ if (bstrcmp0(param, "up") == 0) {
+ val = +1;
+ } else if (bstrcmp0(param, "down") == 0) {
+ val = -1;
+ } else {
+ return m_option_type_double.parse(log, opt, name, param, dst);
+ }
+ *(double *)dst = val;
+ return 1;
+}
+
+static char *print_cycle_dir(const m_option_t *opt, const void *val)
+{
+ return talloc_asprintf(NULL, "%f", *(double *)val);
+}
+
+const m_option_type_t m_option_type_cycle_dir = {
+ .name = "up|down",
+ .parse = parse_cycle_dir,
+ .print = print_cycle_dir,
+ .copy = copy_opt,
+ .size = sizeof(double),
+};
+
// Special-cased by m_config.c.
const m_option_type_t m_option_type_alias = {
.name = "alias",
diff --git a/options/m_option.h b/options/m_option.h
index 9a5058ccaf..1cc6304562 100644
--- a/options/m_option.h
+++ b/options/m_option.h
@@ -68,6 +68,7 @@ extern const m_option_type_t m_option_type_aspect;
extern const m_option_type_t m_option_type_obj_settings_list;
extern const m_option_type_t m_option_type_node;
extern const m_option_type_t m_option_type_rect;
+extern const m_option_type_t m_option_type_cycle_dir;
// Used internally by m_config.c
extern const m_option_type_t m_option_type_alias;
@@ -389,6 +390,9 @@ struct m_option {
// Always force an option update even if the written value does not change.
bool force_update;
+ // If the option is an alias, use the prefix of sub option.
+ bool alias_use_prefix;
+
int offset;
// Most numeric types restrict the range to [min, max] if min<max (this
diff --git a/options/options.c b/options/options.c
index a0d00dde38..b0987a414f 100644
--- a/options/options.c
+++ b/options/options.c
@@ -70,7 +70,6 @@ extern const struct m_sub_options demux_rawvideo_conf;
extern const struct m_sub_options demux_playlist_conf;
extern const struct m_sub_options demux_lavf_conf;
extern const struct m_sub_options demux_mkv_conf;
-extern const struct m_sub_options demux_cue_conf;
extern const struct m_sub_options vd_lavc_conf;
extern const struct m_sub_options ad_lavc_conf;
extern const struct m_sub_options input_config;
@@ -632,7 +631,6 @@ static const m_option_t mp_opts[] = {
#if HAVE_CDDA
{"cdda", OPT_SUBSTRUCT(stream_cdda_opts, stream_cdda_conf)},
- {"cdrom-device", OPT_REPLACED("cdda-device")},
#endif
// demuxer.c - select audio/sub file/demuxer
@@ -684,7 +682,6 @@ static const m_option_t mp_opts[] = {
{"demuxer-rawvideo", OPT_SUBSTRUCT(demux_rawvideo, demux_rawvideo_conf)},
{"", OPT_SUBSTRUCT(demux_playlist, demux_playlist_conf)},
{"demuxer-mkv", OPT_SUBSTRUCT(demux_mkv, demux_mkv_conf)},
- {"demuxer-cue", OPT_SUBSTRUCT(demux_cue, demux_cue_conf)},
// ------------------------- subtitles options --------------------
@@ -737,11 +734,7 @@ static const m_option_t mp_opts[] = {
{"volume-gain-min", OPT_FLOAT(softvol_gain_min), M_RANGE(-150, 0)},
{"volume-gain", OPT_FLOAT(softvol_gain), .flags = UPDATE_VOL,
M_RANGE(-150, 150)},
- {"mute", OPT_CHOICE(softvol_mute,
- {"no", 0},
- {"auto", 0},
- {"yes", 1}),
- .flags = UPDATE_VOL},
+ {"mute", OPT_BOOL(softvol_mute), .flags = UPDATE_VOL},
{"replaygain", OPT_CHOICE(rgain_mode,
{"no", 0},
{"track", 1},
@@ -959,7 +952,6 @@ static const m_option_t mp_opts[] = {
{"", OPT_SUBSTRUCT(encode_opts, encode_config)},
{"play-dir", OPT_REPLACED("play-direction")},
- {"sub-forced-only", OPT_REPLACED("sub-forced-events-only")},
{0}
};
@@ -1131,13 +1123,15 @@ static const struct MPOpts mp_default_opts = {
"sub-delay",
"sub-speed",
"sub-pos",
- "secondary-sub-pos",
"sub-visibility",
"sub-scale",
"sub-use-margins",
"sub-ass-force-margins",
"sub-ass-vsfilter-aspect-compat",
"sub-ass-override",
+ "secondary-sid",
+ "secondary-sub-delay",
+ "secondary-sub-pos",
"secondary-sub-ass-override",
"secondary-sub-visibility",
"ab-loop-a",
diff --git a/options/options.h b/options/options.h
index b80a128b21..3356eac28b 100644
--- a/options/options.h
+++ b/options/options.h
@@ -189,7 +189,7 @@ typedef struct MPOpts {
float rgain_preamp; // Set replaygain pre-amplification
bool rgain_clip; // Enable/disable clipping prevention
float rgain_fallback;
- int softvol_mute;
+ bool softvol_mute;
float softvol_max;
float softvol_gain;
float softvol_gain_min;
@@ -351,7 +351,6 @@ typedef struct MPOpts {
struct demux_playlist_opts *demux_playlist;
struct demux_lavf_opts *demux_lavf;
struct demux_mkv_opts *demux_mkv;
- struct demux_cue_opts *demux_cue;
struct demux_opts *demux_opts;
struct demux_cache_opts *demux_cache_opts;