From fe9d2edbdbceed1c1328a5f65f3b3ce29f679b4f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Reimar=20D=C3=B6ffinger?= <Reimar.Doeffinger@gmx.de>
Date: Sat, 27 Nov 2010 14:40:12 +0000
Subject: [PATCH] DV: use data_offset to fix seeking in badly cut files where
 the first complete frame does not start at position 0.

Originally committed as revision 25833 to svn://svn.ffmpeg.org/ffmpeg/trunk
---
 libavformat/dv.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavformat/dv.c b/libavformat/dv.c
index b6f9c6ae542..d7f54d6c557 100644
--- a/libavformat/dv.c
+++ b/libavformat/dv.c
@@ -370,7 +370,7 @@ static int64_t dv_frame_offset(AVFormatContext *s, DVDemuxContext *c,
     // FIXME: sys may be wrong if last dv_read_packet() failed (buffer is junk)
     const DVprofile* sys = ff_dv_codec_profile(c->vst->codec);
     int64_t offset;
-    int64_t size = url_fsize(s->pb);
+    int64_t size = url_fsize(s->pb) - s->data_offset;
     int64_t max_offset = ((size-1) / sys->frame_size) * sys->frame_size;
 
     offset = sys->frame_size * timestamp;
@@ -378,7 +378,7 @@ static int64_t dv_frame_offset(AVFormatContext *s, DVDemuxContext *c,
     if (size >= 0 && offset > max_offset) offset = max_offset;
     else if (offset < 0) offset = 0;
 
-    return offset;
+    return offset + s->data_offset;
 }
 
 void dv_offset_reset(DVDemuxContext *c, int64_t frame_offset)
-- 
GitLab