1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-08-04 22:03:09 +02:00

avformat/seek: Remove always true condition

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
This commit is contained in:
Zhao Zhili
2025-01-24 15:31:20 +08:00
parent ef3ffd8c5c
commit 1c5961e4b4

View File

@ -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, int avformat_seek_file(AVFormatContext *s, int stream_index, int64_t min_ts,
int64_t ts, int64_t max_ts, int flags) int64_t ts, int64_t max_ts, int flags)
{ {
int dir;
int ret;
if (min_ts > ts || max_ts < ts) if (min_ts > ts || max_ts < ts)
return -1; return -1;
if (stream_index < -1 || stream_index >= (int)s->nb_streams) if (stream_index < -1 || stream_index >= (int)s->nb_streams)
@ -699,9 +702,8 @@ 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. // Fall back on old API if new is not implemented but old is.
// Note the old API has somewhat different semantics. // Note the old API has somewhat different semantics.
if (ffifmt(s->iformat)->read_seek || 1) { dir = (ts - (uint64_t)min_ts > (uint64_t)max_ts - ts ? AVSEEK_FLAG_BACKWARD : 0);
int 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);
int ret = av_seek_frame(s, stream_index, ts, flags | dir);
if (ret < 0 && ts != min_ts && max_ts != ts) { if (ret < 0 && ts != min_ts && max_ts != ts) {
ret = av_seek_frame(s, stream_index, dir ? max_ts : min_ts, flags | dir); ret = av_seek_frame(s, stream_index, dir ? max_ts : min_ts, flags | dir);
if (ret >= 0) if (ret >= 0)
@ -710,10 +712,6 @@ int avformat_seek_file(AVFormatContext *s, int stream_index, int64_t min_ts,
return ret; return ret;
} }
// try some generic seek like seek_frame_generic() but with new ts semantics
return -1; //unreachable
}
/** Flush the frame reader. */ /** Flush the frame reader. */
void ff_read_frame_flush(AVFormatContext *s) void ff_read_frame_flush(AVFormatContext *s)
{ {