Skip to content

Commit

Permalink
lavf/vplayerdec: support time durations with no ms specified
Browse files Browse the repository at this point in the history
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
  • Loading branch information
ubitux committed Mar 7, 2016
1 parent 81f1488 commit 920f592
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions libavformat/vplayerdec.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,21 @@ 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;
}

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;
}
Expand Down

0 comments on commit 920f592

Please sign in to comment.