diff options
author | Baptiste Coudurier <baptiste.coudurier@gmail.com> | 2009-03-21 10:35:52 +0300 |
---|---|---|
committer | Baptiste Coudurier <baptiste.coudurier@gmail.com> | 2009-03-21 10:35:52 +0300 |
commit | 92a0f338786b629c5661f5b552e32c6154c3389d (patch) | |
tree | 1bcde662fcc7f5bea202c239c595cff36460779b /libavformat/ffmdec.c | |
parent | 7e24aa0c13879963684400f9aad9df44c2614bd9 (diff) |
fix valid seeking range
Originally committed as revision 18098 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/ffmdec.c')
-rw-r--r-- | libavformat/ffmdec.c | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/libavformat/ffmdec.c b/libavformat/ffmdec.c index cf04264dd5..95b186ed3e 100644 --- a/libavformat/ffmdec.c +++ b/libavformat/ffmdec.c @@ -165,17 +165,16 @@ static int ffm_read_data(AVFormatContext *s, //#define DEBUG_SEEK -/* pos is between 0 and file_size - FFM_PACKET_SIZE. It is translated - by the write position inside this function */ +/* ensure that acutal seeking happens between FFM_PACKET_SIZE + and file_size - FFM_PACKET_SIZE */ static void ffm_seek1(AVFormatContext *s, int64_t pos1) { FFMContext *ffm = s->priv_data; ByteIOContext *pb = s->pb; int64_t pos; - pos = pos1 + ffm->write_index; - if (pos >= ffm->file_size) - pos -= (ffm->file_size - FFM_PACKET_SIZE); + pos = FFMIN(pos1, ffm->file_size - FFM_PACKET_SIZE); + pos = FFMAX(pos, FFM_PACKET_SIZE); #ifdef DEBUG_SEEK av_log(s, AV_LOG_DEBUG, "seek to %"PRIx64" -> %"PRIx64"\n", pos1, pos); #endif @@ -454,8 +453,8 @@ static int ffm_seek(AVFormatContext *s, int stream_index, int64_t wanted_pts, in #endif /* find the position using linear interpolation (better than dichotomy in typical cases) */ - pos_min = 0; - pos_max = ffm->file_size - 2 * FFM_PACKET_SIZE; + pos_min = FFM_PACKET_SIZE; + pos_max = ffm->file_size - FFM_PACKET_SIZE; while (pos_min <= pos_max) { pts_min = get_dts(s, pos_min); pts_max = get_dts(s, pos_max); @@ -478,8 +477,7 @@ static int ffm_seek(AVFormatContext *s, int stream_index, int64_t wanted_pts, in } } pos = (flags & AVSEEK_FLAG_BACKWARD) ? pos_min : pos_max; - if (pos > 0) - pos -= FFM_PACKET_SIZE; + found: ffm_seek1(s, pos); |