Rounding min_ts towards +infinity and max_ts towards -infinity can
make ts out of the [min_ts, max_ts] range, and then leads to seek
failure. For example,

max_ts = ts = -25057
time_base = (num = 1, den = 14112000)

After rescale, ts = -353604, and max_ts = -353605.
---
 libavformat/utils.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavformat/utils.c b/libavformat/utils.c
index 503e583ad0..69a0f901b2 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -2500,10 +2500,10 @@ int avformat_seek_file(AVFormatContext *s, int 
stream_index, int64_t min_ts,
             ts = av_rescale_q(ts, AV_TIME_BASE_Q, time_base);
             min_ts = av_rescale_rnd(min_ts, time_base.den,
                                     time_base.num * (int64_t)AV_TIME_BASE,
-                                    AV_ROUND_UP   | AV_ROUND_PASS_MINMAX);
+                                    AV_ROUND_DOWN | AV_ROUND_PASS_MINMAX);
             max_ts = av_rescale_rnd(max_ts, time_base.den,
                                     time_base.num * (int64_t)AV_TIME_BASE,
-                                    AV_ROUND_DOWN | AV_ROUND_PASS_MINMAX);
+                                    AV_ROUND_UP | AV_ROUND_PASS_MINMAX);
             stream_index = 0;
         }
 
-- 
2.28.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to