options: fix ab-loop-* properties

These used ".min = MP_NOPTS_VALUE" to indicate certain exceptions. This
broke with the recent change to how min/max are handled, which made
setting min or max mean that a value range is used, thus setting max=0.

Fix this by not using magic a value in .min; replace it with a proper
flag.

Fixes: #7596
This commit is contained in:
wm4 2020-04-09 11:08:03 +02:00
parent a67bda2840
commit 9d32d62b61
3 changed files with 7 additions and 4 deletions

View File

@ -2639,7 +2639,7 @@ static int parse_timestring(struct bstr str, double *time, char endchar)
return len;
}
#define HAS_NOPTS(opt) ((opt)->min == MP_NOPTS_VALUE)
#define HAS_NOPTS(opt) ((opt)->flags & M_OPT_ALLOW_NO)
static int parse_time(struct mp_log *log, const m_option_t *opt,
struct bstr name, struct bstr param, void *dst)

View File

@ -427,7 +427,10 @@ char *format_file_size(int64_t size);
(((UPDATE_OPT_LAST << 1) - 1) & ~(unsigned)(UPDATE_OPT_FIRST - 1))
// type_float/type_double: string "default" is parsed as NaN (and reverse)
#define M_OPT_DEFAULT_NAN (1 << 29)
#define M_OPT_DEFAULT_NAN (1 << 25)
// type time: string "no" maps to MP_NOPTS_VALUE (if unset, NOPTS is rejected)
#define M_OPT_ALLOW_NO (1 << 26)
// Like M_OPT_TYPE_OPTIONAL_PARAM.
#define M_OPT_OPTIONAL_PARAM (1 << 30)

View File

@ -447,8 +447,8 @@ static const m_option_t mp_opts[] = {
{"rebase-start-time", OPT_FLAG(rebase_start_time)},
{"ab-loop-a", OPT_TIME(ab_loop[0]), .min = MP_NOPTS_VALUE},
{"ab-loop-b", OPT_TIME(ab_loop[1]), .min = MP_NOPTS_VALUE},
{"ab-loop-a", OPT_TIME(ab_loop[0]), .flags = M_OPT_ALLOW_NO},
{"ab-loop-b", OPT_TIME(ab_loop[1]), .flags = M_OPT_ALLOW_NO},
{"ab-loop-count", OPT_CHOICE(ab_loop_count, {"inf", -1}),
M_RANGE(0, INT_MAX)},