X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavformat%2Fsubfile.c;h=5d8659c8c428e4c4e4f976a93f5ade20f1dc1581;hb=09fd1b18f041b725be6f78bc787140eb5cb25d2e;hp=b527f2bee17e1e6d8d4d416b0e6fbfa8037e949c;hpb=b2f32d60eeaf883bb7d9e1b8cc2fb9a983d08f72;p=ffmpeg diff --git a/libavformat/subfile.c b/libavformat/subfile.c index b527f2bee17..5d8659c8c42 100644 --- a/libavformat/subfile.c +++ b/libavformat/subfile.c @@ -116,20 +116,26 @@ 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, 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; break; case SEEK_CUR: - new_pos += pos; + new_pos = c->pos + pos; break; case SEEK_END: - new_pos = c->end + c->pos; + new_pos = end + pos; break; } if (new_pos < c->start)