Browse Source

avformat: don't unconditionally call ff_read_frame_flush() when trying to seek.

This prevents flushing the packet buffer when the input format does not
support seeking.
tags/n0.9
Justin Ruggles 13 years ago
parent
commit
0041cdba98
1 changed files with 14 additions and 10 deletions
  1. +14
    -10
      libavformat/utils.c

+ 14
- 10
libavformat/utils.c View File

@@ -1749,10 +1749,10 @@ int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp, int f
int ret;
AVStream *st;

ff_read_frame_flush(s);

if(flags & AVSEEK_FLAG_BYTE)
if (flags & AVSEEK_FLAG_BYTE) {
ff_read_frame_flush(s);
return seek_frame_byte(s, stream_index, timestamp, flags);
}

if(stream_index < 0){
stream_index= av_find_default_stream_index(s);
@@ -1765,18 +1765,22 @@ int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp, int f
}

/* first, we try the format specific seek */
if (s->iformat->read_seek)
if (s->iformat->read_seek) {
ff_read_frame_flush(s);
ret = s->iformat->read_seek(s, stream_index, timestamp, flags);
else
} else
ret = -1;
if (ret >= 0) {
return 0;
}

if(s->iformat->read_timestamp && !(s->iformat->flags & AVFMT_NOBINSEARCH))
if (s->iformat->read_timestamp && !(s->iformat->flags & AVFMT_NOBINSEARCH)) {
ff_read_frame_flush(s);
return av_seek_frame_binary(s, stream_index, timestamp, flags);
else if (!(s->iformat->flags & AVFMT_NOGENSEARCH))
} else if (!(s->iformat->flags & AVFMT_NOGENSEARCH)) {
ff_read_frame_flush(s);
return seek_frame_generic(s, stream_index, timestamp, flags);
}
else
return -1;
}
@@ -1786,10 +1790,10 @@ int avformat_seek_file(AVFormatContext *s, int stream_index, int64_t min_ts, int
if(min_ts > ts || max_ts < ts)
return -1;

ff_read_frame_flush(s);

if (s->iformat->read_seek2)
if (s->iformat->read_seek2) {
ff_read_frame_flush(s);
return s->iformat->read_seek2(s, stream_index, min_ts, ts, max_ts, flags);
}

if(s->iformat->read_timestamp){
//try to seek via read_timestamp()


Loading…
Cancel
Save