summaryrefslogtreecommitdiff
path: root/libavformat/vplayerdec.c
diff options
context:
space:
mode:
authorClément Bœsch <u@pkh.me>2016-03-07 12:43:42 +0100
committerClément Bœsch <clement@stupeflix.com>2016-03-07 12:52:11 +0100
commit920f592b81c750d30dd87c752b110bddb430c4bc (patch)
treeede2701b38b17c8481f02fd3e03d8350f2e07caa /libavformat/vplayerdec.c
parent81f14884b59334b765eddb64b0dc8ca5dec7f9bd (diff)
downloadffmpeg-920f592b81c750d30dd87c752b110bddb430c4bc.tar.gz
lavf/vplayerdec: support time durations with no ms specified
Example found in the wild: 0:00:03:25.000 0:01:47:A legend is sung 0:01:50:Of when England was young 0:01:53:And knights|were brave and bold 0:01:59:The good king had died Reported-by: wm4
Diffstat (limited to 'libavformat/vplayerdec.c')
-rw-r--r--libavformat/vplayerdec.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/libavformat/vplayerdec.c b/libavformat/vplayerdec.c
index 860b7785c9..2bb7f32829 100644
--- a/libavformat/vplayerdec.c
+++ b/libavformat/vplayerdec.c
@@ -36,7 +36,8 @@ static int vplayer_probe(AVProbeData *p)
char c;
const unsigned char *ptr = p->buf;
- if (sscanf(ptr, "%*d:%*d:%*d.%*d%c", &c) == 1 && strchr(": =", c))
+ if ((sscanf(ptr, "%*d:%*d:%*d.%*d%c", &c) == 1 ||
+ sscanf(ptr, "%*d:%*d:%*d%c", &c) == 1) && strchr(": =", c))
return AVPROBE_SCORE_MAX;
return 0;
}
@@ -44,12 +45,12 @@ static int vplayer_probe(AVProbeData *p)
static int64_t read_ts(char **line)
{
char c;
- int hh, mm, ss, ms, len;
+ int hh, mm, ss, ms, n, len;
- if (sscanf(*line, "%d:%d:%d.%d%c%n",
- &hh, &mm, &ss, &ms, &c, &len) >= 5) {
+ if (((n = sscanf(*line, "%d:%d:%d.%d%c%n", &hh, &mm, &ss, &ms, &c, &len)) >= 5 ||
+ (n = sscanf(*line, "%d:%d:%d%c%n", &hh, &mm, &ss, &c, &len)) >= 4) && strchr(": =", c)) {
*line += len;
- return (hh*3600LL + mm*60LL + ss) * 100LL + ms;
+ return (hh*3600LL + mm*60LL + ss) * 100LL + (n < 5 ? 0 : ms);
}
return AV_NOPTS_VALUE;
}