This prevents flushing the packet buffer when the input format does not support seeking.
Unified · Split
| @@ -1749,10 +1749,10 @@ int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp, int f · 1748 unmodified lines | ||
| 1749 | 1749 | int ret; |
| 1750 | 1750 | AVStream *st; |
| 1751 | 1751 | |
| 1752 | − ff_read_frame_flush(s); | |
| 1753 | − | |
| 1754 | − if(flags & AVSEEK_FLAG_BYTE) | |
| 1752 | + if (flags & AVSEEK_FLAG_BYTE) { | |
| 1753 | + ff_read_frame_flush(s); | |
| 1755 | 1754 | return seek_frame_byte(s, stream_index, timestamp, flags); |
| 1755 | + } | |
| 1756 | 1756 | |
| 1757 | 1757 | if(stream_index < 0){ |
| 1758 | 1758 | stream_index= av_find_default_stream_index(s); |
| @@ -1765,18 +1765,22 @@ int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp, int f · 6 unmodified lines | ||
| 1765 | 1765 | } |
| 1766 | 1766 | |
| 1767 | 1767 | /* first, we try the format specific seek */ |
| 1768 | − if (s->iformat->read_seek) | |
| 1768 | + if (s->iformat->read_seek) { | |
| 1769 | + ff_read_frame_flush(s); | |
| 1769 | 1770 | ret = s->iformat->read_seek(s, stream_index, timestamp, flags); |
| 1770 | − else | |
| 1771 | + } else | |
| 1771 | 1772 | ret = -1; |
| 1772 | 1773 | if (ret >= 0) { |
| 1773 | 1774 | return 0; |
| 1774 | 1775 | } |
| 1775 | 1776 | |
| 1776 | − if(s->iformat->read_timestamp && !(s->iformat->flags & AVFMT_NOBINSEARCH)) | |
| 1777 | + if (s->iformat->read_timestamp && !(s->iformat->flags & AVFMT_NOBINSEARCH)) { | |
| 1778 | + ff_read_frame_flush(s); | |
| 1777 | 1779 | return av_seek_frame_binary(s, stream_index, timestamp, flags); |
| 1778 | − else if (!(s->iformat->flags & AVFMT_NOGENSEARCH)) | |
| 1780 | + } else if (!(s->iformat->flags & AVFMT_NOGENSEARCH)) { | |
| 1781 | + ff_read_frame_flush(s); | |
| 1779 | 1782 | return seek_frame_generic(s, stream_index, timestamp, flags); |
| 1783 | + } | |
| 1780 | 1784 | else |
| 1781 | 1785 | return -1; |
| 1782 | 1786 | } |
| @@ -1786,10 +1790,10 @@ int avformat_seek_file(AVFormatContext *s, int stream_index, int64_t min_ts, int · 3 unmodified lines | ||
| 1786 | 1790 | if(min_ts > ts || max_ts < ts) |
| 1787 | 1791 | return -1; |
| 1788 | 1792 | |
| 1789 | − ff_read_frame_flush(s); | |
| 1790 | − | |
| 1791 | − if (s->iformat->read_seek2) | |
| 1793 | + if (s->iformat->read_seek2) { | |
| 1794 | + ff_read_frame_flush(s); | |
| 1792 | 1795 | return s->iformat->read_seek2(s, stream_index, min_ts, ts, max_ts, flags); |
| 1796 | + } | |
| 1793 | 1797 | |
| 1794 | 1798 | if(s->iformat->read_timestamp){ |
| 1795 | 1799 | //try to seek via read_timestamp() |