aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZhao Zhili <zhilizhao@tencent.com>2025-01-24 15:31:20 +0800
committerZhao Zhili <zhilizhao@tencent.com>2025-02-04 01:24:23 +0800
commit1c5961e4b42565bb6573fe013e2db8036b4e9ae6 (patch)
tree2ea2e3705e40360b585fd0aac994ecdc0063425d
parentef3ffd8c5c75995132a0fb6d7c59b6a85e019028 (diff)
downloadffmpeg-1c5961e4b42565bb6573fe013e2db8036b4e9ae6.tar.gz
avformat/seek: Remove always true condition
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
-rw-r--r--libavformat/seek.c22
1 files 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. */