diff --git a/libavutil/mathematics.c b/libavutil/mathematics.c index 16c6e4db03..da0fc17b2e 100644 --- a/libavutil/mathematics.c +++ b/libavutil/mathematics.c @@ -210,6 +210,6 @@ int64_t av_add_stable(AVRational ts_tb, int64_t ts, AVRational inc_tb, int64_t i if (old == INT64_MAX || old == AV_NOPTS_VALUE || old_ts == AV_NOPTS_VALUE) return ts; - return av_rescale_q(old + 1, inc_tb, ts_tb) + (ts - old_ts); + return av_sat_add64(av_rescale_q(old + 1, inc_tb, ts_tb), ts - old_ts); } }