summaryrefslogtreecommitdiff
path: root/libavformat/srtdec.c
diff options
context:
space:
mode:
authorClément Bœsch <ubitux@gmail.com>2012-10-20 21:21:34 +0200
committerClément Bœsch <ubitux@gmail.com>2012-10-24 23:56:43 +0200
commita96b39de622592cb595bf20ae009ed415b98cde9 (patch)
treed40a632a10139446b7ebdd51c65c3ada8f0715ca /libavformat/srtdec.c
parenta945607a78ce2ab46e0ebca17d1999ba12b4efc3 (diff)
downloadffmpeg-a96b39de622592cb595bf20ae009ed415b98cde9.tar.gz
lavf/srtdec: simplify start/end computation.
Also fix potential overflow (CID733778)
Diffstat (limited to 'libavformat/srtdec.c')
-rw-r--r--libavformat/srtdec.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/libavformat/srtdec.c b/libavformat/srtdec.c
index a66ced377e..056165e311 100644
--- a/libavformat/srtdec.c
+++ b/libavformat/srtdec.c
@@ -53,19 +53,16 @@ static int srt_read_header(AVFormatContext *s)
static int64_t get_pts(const char *buf, int *duration)
{
- int i, hour, min, sec, hsec;
- int he, me, se, mse;
+ int i;
for (i=0; i<2; i++) {
- int64_t start, end;
+ int hh1, mm1, ss1, ms1;
+ int hh2, mm2, ss2, ms2;
if (sscanf(buf, "%d:%2d:%2d%*1[,.]%3d --> %d:%2d:%2d%*1[,.]%3d",
- &hour, &min, &sec, &hsec, &he, &me, &se, &mse) == 8) {
- min += 60*hour;
- sec += 60*min;
- start = sec*1000+hsec;
- me += 60*he;
- se += 60*me;
- end = se*1000+mse;
+ &hh1, &mm1, &ss1, &ms1,
+ &hh2, &mm2, &ss2, &ms2) == 8) {
+ int64_t start = (hh1*3600LL + mm1*60LL + ss1) * 1000LL + ms1;
+ int64_t end = (hh2*3600LL + mm2*60LL + ss2) * 1000LL + ms2;
*duration = end - start;
return start;
}