projects
/
ffmpeg.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
4956d0e
)
av_add_stable: Add fast special case where step can be represented exactly
author
Michael Niedermayer
<michaelni@gmx.at>
Mon, 2 Jun 2014 17:00:18 +0000
(19:00 +0200)
committer
Michael Niedermayer
<michaelni@gmx.at>
Mon, 2 Jun 2014 17:00:18 +0000
(19:00 +0200)
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavutil/mathematics.c
patch
|
blob
|
history
diff --git
a/libavutil/mathematics.c
b/libavutil/mathematics.c
index
c8f1e1c
..
df7d0d8
100644
(file)
--- a/
libavutil/mathematics.c
+++ b/
libavutil/mathematics.c
@@
-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 m, d;
+
if (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) {
//increase step is too small for even 1 step to be representable
return ts;