1
0
mirror of https://github.com/mpv-player/mpv synced 2025-01-03 13:32:16 +00:00

options: fix conversion of flags to strings

This flags stuff tried to be too clever - if there are overlapping flags
(e.g. exclusive or combined flags), the one matching with most bits has
to be chosen.

This fixes logging of the seek command. E.g. "relative" and "absolute"
overlap to make them exclusive, but "relative" was always printed as it
happened to match first.
This commit is contained in:
wm4 2015-07-01 23:05:11 +02:00
parent e3d85ad46d
commit 89f05dc7d1

View File

@ -743,13 +743,18 @@ static int apply_flag(const struct m_option *opt, int *val, bstr flag)
static const char *find_next_flag(const struct m_option *opt, int *val)
{
struct m_opt_choice_alternatives *best = NULL;
struct m_opt_choice_alternatives *alt;
for (alt = opt->priv; alt->name; alt++) {
if (alt->value && (alt->value & (*val)) == alt->value) {
*val = *val & ~(unsigned)alt->value;
return alt->name;
if (!best || av_popcount64(alt->value) > av_popcount64(best->value))
best = alt;
}
}
if (best) {
*val = *val & ~(unsigned)best->value;
return best->name;
}
*val = 0; // if there are still flags left, there's not much we can do
return NULL;
}