Skip to content
Snippets Groups Projects
Commit e9add0d8 authored by Michael Niedermayer's avatar Michael Niedermayer
Browse files

av_add_stable: Add fast special case where step can be represented exactly

parent 4956d0e5
Branches
Tags
No related merge requests found
...@@ -188,9 +188,17 @@ simple_round: ...@@ -188,9 +188,17 @@ simple_round:
int64_t av_add_stable(AVRational ts_tb, int64_t ts, AVRational inc_tb, int64_t inc) int64_t av_add_stable(AVRational ts_tb, int64_t ts, AVRational inc_tb, int64_t inc)
{ {
int64_t m, d;
if (inc != 1) if (inc != 1)
inc_tb = av_mul_q(inc_tb, (AVRational) {inc, 1}); inc_tb = av_mul_q(inc_tb, (AVRational) {inc, 1});
m = inc_tb.num * (int64_t)ts_tb.den;
d = inc_tb.den * (int64_t)ts_tb.num;
if (m % d == 0)
return ts + m / d;
if (av_cmp_q(inc_tb, ts_tb) < 0) { if (av_cmp_q(inc_tb, ts_tb) < 0) {
//increase step is too small for even 1 step to be representable //increase step is too small for even 1 step to be representable
return ts; return ts;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment