diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/m_option.c | 12 | ||||
-rw-r--r-- | core/m_option.h | 1 | ||||
-rw-r--r-- | core/mplayer.c | 4 |
3 files changed, 16 insertions, 1 deletions
diff --git a/core/m_option.c b/core/m_option.c index dcb849a34d..58e93dfff9 100644 --- a/core/m_option.c +++ b/core/m_option.c @@ -1268,6 +1268,16 @@ static int parse_rel_time(const m_option_t *opt, struct bstr name, } } + // Chapter pos + if (bstr_startswith0(param, "#")) { + int chapter = bstrtoll(bstr_cut(param, 1), ¶m, 10); + if (param.len == 0 && chapter >= 1) { + t.type = REL_TIME_CHAPTER; + t.pos = chapter - 1; + goto out; + } + } + bool sign = bstr_eatstart0(¶m, "-"); double time; if (parse_timestring(param, &time, 0)) { @@ -1277,7 +1287,7 @@ static int parse_rel_time(const m_option_t *opt, struct bstr name, } mp_msg(MSGT_CFGPARSER, MSGL_ERR, - "Option %.*s: invalid time or size: '%.*s'\n", + "Option %.*s: invalid time or position: '%.*s'\n", BSTR_P(name), BSTR_P(param)); return M_OPT_INVALID; diff --git a/core/m_option.h b/core/m_option.h index d7041f9cf4..ed9cc33f5f 100644 --- a/core/m_option.h +++ b/core/m_option.h @@ -63,6 +63,7 @@ enum m_rel_time_type { REL_TIME_ABSOLUTE, REL_TIME_NEGATIVE, REL_TIME_PERCENT, + REL_TIME_CHAPTER, }; struct m_rel_time { diff --git a/core/mplayer.c b/core/mplayer.c index a48bd4b37c..8f974c5bc2 100644 --- a/core/mplayer.c +++ b/core/mplayer.c @@ -270,6 +270,10 @@ static double rel_time_to_abs(struct MPContext *mpctx, struct m_rel_time t, if (length != 0) return length * (t.pos / 100.0); break; + case REL_TIME_CHAPTER: + if (chapter_start_time(mpctx, t.pos) >= 0) + return chapter_start_time(mpctx, t.pos); + break; } return fallback_time; } |