aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat
diff options
context:
space:
mode:
authorJustin Ruggles <justin.ruggles@gmail.com>2011-09-16 19:02:23 -0400
committerJustin Ruggles <justin.ruggles@gmail.com>2011-10-13 16:31:15 -0400
commit0041cdba98d5b636a8d912352dd3d8ca72bba4ce (patch)
treec0dddf4c537945786cd61e89d052b9ba49eaf91a /libavformat
parentc6ac30c84b1d6a21af49b72f13ba2248e6b2844d (diff)
downloadffmpeg-0041cdba98d5b636a8d912352dd3d8ca72bba4ce.tar.gz
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.
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/utils.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/libavformat/utils.c b/libavformat/utils.c
index e4e6d24e53..fc17f18464 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -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()