Commit 0041cdba authored by Justin Ruggles's avatar Justin Ruggles

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.
parent c6ac30c8
...@@ -1749,10 +1749,10 @@ int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp, int f ...@@ -1749,10 +1749,10 @@ int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp, int f
int ret; int ret;
AVStream *st; AVStream *st;
if (flags & AVSEEK_FLAG_BYTE) {
ff_read_frame_flush(s); ff_read_frame_flush(s);
if(flags & AVSEEK_FLAG_BYTE)
return seek_frame_byte(s, stream_index, timestamp, flags); return seek_frame_byte(s, stream_index, timestamp, flags);
}
if(stream_index < 0){ if(stream_index < 0){
stream_index= av_find_default_stream_index(s); 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 ...@@ -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 */ /* 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); ret = s->iformat->read_seek(s, stream_index, timestamp, flags);
else } else
ret = -1; ret = -1;
if (ret >= 0) { if (ret >= 0) {
return 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); 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); return seek_frame_generic(s, stream_index, timestamp, flags);
}
else else
return -1; return -1;
} }
...@@ -1786,10 +1790,10 @@ int avformat_seek_file(AVFormatContext *s, int stream_index, int64_t min_ts, int ...@@ -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) if(min_ts > ts || max_ts < ts)
return -1; return -1;
if (s->iformat->read_seek2) {
ff_read_frame_flush(s); ff_read_frame_flush(s);
if (s->iformat->read_seek2)
return s->iformat->read_seek2(s, stream_index, min_ts, ts, max_ts, flags); return s->iformat->read_seek2(s, stream_index, min_ts, ts, max_ts, flags);
}
if(s->iformat->read_timestamp){ if(s->iformat->read_timestamp){
//try to seek via read_timestamp() //try to seek via read_timestamp()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment