[FFmpeg-cvslog] avformat/seek: Remove always true condition
Zhao Zhili
git at videolan.org
Mon Feb 3 19:40:46 EET 2025
ffmpeg | branch: master | Zhao Zhili <zhilizhao at tencent.com> | Fri Jan 24 15:31:20 2025 +0800| [1c5961e4b42565bb6573fe013e2db8036b4e9ae6] | committer: Zhao Zhili
avformat/seek: Remove always true condition
Signed-off-by: Zhao Zhili <zhilizhao at tencent.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=1c5961e4b42565bb6573fe013e2db8036b4e9ae6
---
libavformat/seek.c | 22 ++++++++++------------
1 file changed, 10 insertions(+), 12 deletions(-)
diff --git a/libavformat/seek.c b/libavformat/seek.c
index a7e5ac9a63..a096d5e5b3 100644
--- a/libavformat/seek.c
+++ b/libavformat/seek.c
@@ -664,6 +664,9 @@ int av_seek_frame(AVFormatContext *s, int stream_index,
int avformat_seek_file(AVFormatContext *s, int stream_index, int64_t min_ts,
int64_t ts, int64_t max_ts, int flags)
{
+ int dir;
+ int ret;
+
if (min_ts > ts || max_ts < ts)
return -1;
if (stream_index < -1 || stream_index >= (int)s->nb_streams)
@@ -699,19 +702,14 @@ int avformat_seek_file(AVFormatContext *s, int stream_index, int64_t min_ts,
// Fall back on old API if new is not implemented but old is.
// Note the old API has somewhat different semantics.
- if (ffifmt(s->iformat)->read_seek || 1) {
- int dir = (ts - (uint64_t)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;
+ dir = (ts - (uint64_t)min_ts > (uint64_t)max_ts - ts ? AVSEEK_FLAG_BACKWARD : 0);
+ 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));
}
-
- // try some generic seek like seek_frame_generic() but with new ts semantics
- return -1; //unreachable
+ return ret;
}
/** Flush the frame reader. */
More information about the ffmpeg-cvslog
mailing list