diff mbox series

[FFmpeg-devel,v2] avformat/utils: prevent ts out of [min_ts, max_ts] interval due to rouding

Message ID tencent_4C4D9301A85B73EA736B95C0A9080EB04505@qq.com
State New
Headers show
Series [FFmpeg-devel,v2] avformat/utils: prevent ts out of [min_ts, max_ts] interval due to rouding
Related show


Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Zhao Zhili Jan. 10, 2021, 8:57 a.m. UTC
Rounding min_ts towards +infinity and max_ts towards -infinity can
make ts out of the [min_ts, max_ts] interval, and then leads to seek
failure. Fix it by using the simple rounding as ts for both min_ts
and max_ts.
 libavformat/utils.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff mbox series


diff --git a/libavformat/utils.c b/libavformat/utils.c
index 503e583ad0..88221c5ac4 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_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_PASS_MINMAX);
             stream_index = 0;