]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/subfile.c
lavf/webm_chunk: Correct duration if start time > 0
[ffmpeg] / libavformat / subfile.c
index b527f2bee17e1e6d8d4d416b0e6fbfa8037e949c..2f162e0a34df936f8a0fe9c463595c636e3b42f8 100644 (file)
@@ -116,11 +116,17 @@ static int subfile_read(URLContext *h, unsigned char *buf, int size)
 static int64_t subfile_seek(URLContext *h, int64_t pos, int whence)
 {
     SubfileContext *c = h->priv_data;
-    int64_t new_pos = -1;
+    int64_t new_pos = -1, end;
     int ret;
 
+    if (whence == AVSEEK_SIZE || whence == SEEK_END) {
+        end = c->end;
+        if (end == INT64_MAX && (end = ffurl_seek(c->h, 0, AVSEEK_SIZE)) < 0)
+            return end;
+    }
+
     if (whence == AVSEEK_SIZE)
-        return c->end - c->start;
+        return end - c->start;
     switch (whence) {
     case SEEK_SET:
         new_pos = c->start + pos;
@@ -129,7 +135,7 @@ static int64_t subfile_seek(URLContext *h, int64_t pos, int whence)
         new_pos += pos;
         break;
     case SEEK_END:
-        new_pos = c->end + c->pos;
+        new_pos = end + c->pos;
         break;
     }
     if (new_pos < c->start)