diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2012-02-18 00:16:58 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2012-02-21 23:55:47 +0100 |
commit | 92b5f71a7d30974250918b12e93c974b9b555d11 (patch) | |
tree | 2d1358265f31d9525cadc6b29a2159c168870c22 /libavformat | |
parent | e6380afa6aa7b78a7b5c37039a8ca52e0f87a4e5 (diff) | |
download | ffmpeg-92b5f71a7d30974250918b12e93c974b9b555d11.tar.gz |
lavf: Reimplement new seek API emulation
This fixes seeking to before and after files with ffplay.
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat')
-rw-r--r-- | libavformat/utils.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/libavformat/utils.c b/libavformat/utils.c index 155ba67757..16a74f2ad9 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -1819,8 +1819,16 @@ int avformat_seek_file(AVFormatContext *s, int stream_index, int64_t min_ts, int //Fallback to old API if new is not implemented but old is //Note the old has somewat different sematics AV_NOWARN_DEPRECATED( - if(s->iformat->read_seek || 1) - return av_seek_frame(s, stream_index, ts, flags | (ts - min_ts > (uint64_t)(max_ts - ts) ? AVSEEK_FLAG_BACKWARD : 0)); + if (s->iformat->read_seek || 1) { + int dir = (ts - min_ts > (uint64_t)(max_ts - ts) ? AVSEEK_FLAG_BACKWARD : 0); + int ret = av_seek_frame(s, stream_index, ts, flags | dir); + if (ret<0 && ts != min_ts && max_ts != ts) { + ret = av_seek_frame(s, stream_index, dir ? max_ts : min_ts, flags | dir); + if (ret >= 0) + ret = av_seek_frame(s, stream_index, ts, flags | (dir^AVSEEK_FLAG_BACKWARD)); + } + return ret; + } ) // try some generic seek like seek_frame_generic() but with new ts semantics |