diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2014-01-03 17:35:09 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2014-01-04 15:10:14 +0100 |
commit | cd7037dd7ac14823619cf1649922b0ef31310291 (patch) | |
tree | 8698f58164e8c49b5f8969b8e2bb183163dc6518 /libavutil/rational.c | |
parent | b317f9459f4c8f96b01bf20ce33a7f243d33a02c (diff) | |
download | ffmpeg-cd7037dd7ac14823619cf1649922b0ef31310291.tar.gz |
avutil/rational: av_add_stable() test code
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavutil/rational.c')
-rw-r--r-- | libavutil/rational.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/libavutil/rational.c b/libavutil/rational.c index ec2f2e5386..55a8dd5897 100644 --- a/libavutil/rational.c +++ b/libavutil/rational.c @@ -171,6 +171,36 @@ int main(void) } } } + + for (a.num = 1; a.num <= 10; a.num++) { + for (a.den = 1; a.den <= 10; a.den++) { + if (av_gcd(a.num, a.den) > 1) + continue; + for (b.num = 1; b.num <= 10; b.num++) { + for (b.den = 1; b.den <= 10; b.den++) { + int start; + if (av_gcd(b.num, b.den) > 1) + continue; + if (av_cmp_q(b, a) < 0) + continue; + for (start = 0; start < 10 ; start++) { + int acc= start; + int i; + + for (i = 0; i<100; i++) { + int exact = start + av_rescale_q(i+1, b, a); + acc = av_add_stable(a, acc, b, 1); + if (FFABS(acc - exact) > 2) { + av_log(NULL, AV_LOG_ERROR, "%d/%d %d/%d, %d %d\n", a.num, + a.den, b.num, b.den, acc, exact); + return 1; + } + } + } + } + } + } + } return 0; } #endif |