History

avformat/seek: Remove always true condition

Zhao Zhili committed 1 year ago

Commit 1c5961e1 parent ef3ffd81 file · +10 −12Browse files

Showing the changes to libavformat (1 of 1 file). Show all

Unified · Split

libavformat/seek.c+10−12
@@ -664,6 +664,9 @@ int av_seek_frame(AVFormatContext *s, int stream_index, · 663 unmodified lines
664664 int avformat_seek_file(AVFormatContext *s, int stream_index, int64_t min_ts,
665665 int64_t ts, int64_t max_ts, int flags)
666666 {
667+ int dir;
668+ int ret;
669+
667670 if (min_ts > ts || max_ts < ts)
668671 return -1;
669672 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, · 29 unmodified lines
699702
700703 // Fall back on old API if new is not implemented but old is.
701704 // Note the old API has somewhat different semantics.
702− if (ffifmt(s->iformat)->read_seek || 1) {
703− int dir = (ts - (uint64_t)min_ts > (uint64_t)max_ts - ts ? AVSEEK_FLAG_BACKWARD : 0);
704− int ret = av_seek_frame(s, stream_index, ts, flags | dir);
705− if (ret < 0 && ts != min_ts && max_ts != ts) {
706− ret = av_seek_frame(s, stream_index, dir ? max_ts : min_ts, flags | dir);
707− if (ret >= 0)
708− ret = av_seek_frame(s, stream_index, ts, flags | (dir^AVSEEK_FLAG_BACKWARD));
709− }
710− return ret;
705+ dir = (ts - (uint64_t)min_ts > (uint64_t)max_ts - ts ? AVSEEK_FLAG_BACKWARD : 0);
706+ ret = av_seek_frame(s, stream_index, ts, flags | dir);
707+ if (ret < 0 && ts != min_ts && max_ts != ts) {
708+ ret = av_seek_frame(s, stream_index, dir ? max_ts : min_ts, flags | dir);
709+ if (ret >= 0)
710+ ret = av_seek_frame(s, stream_index, ts, flags | (dir^AVSEEK_FLAG_BACKWARD));
711711 }
712−
713− // try some generic seek like seek_frame_generic() but with new ts semantics
714− return -1; //unreachable
712+ return ret;
715713 }
716714
717715 /** Flush the frame reader. */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t