[FFmpeg-cvslog] av_d2q: Add a special case for |value| > MAX and |value| < 1/MAX

Michael Niedermayer git at videolan.org
Fri May 31 17:26:23 CEST 2013


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Sat May 25 15:39:02 2013 +0200| [887d74c47efa70d7d1513e9492d41cf7f88dee0b] | committer: Michael Niedermayer

av_d2q: Add a special case for |value| > MAX and |value| < 1/MAX

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=887d74c47efa70d7d1513e9492d41cf7f88dee0b
---

 libavutil/rational.c      |    2 ++
 tests/ref/fate/parseutils |    2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavutil/rational.c b/libavutil/rational.c
index 7abf54c..aabe58f 100644
--- a/libavutil/rational.c
+++ b/libavutil/rational.c
@@ -115,6 +115,8 @@ AVRational av_d2q(double d, int max)
     exponent = FFMAX( (int)(log(fabs(d) + 1e-20)/LOG2), 0);
     den = 1LL << (61 - exponent);
     av_reduce(&a.num, &a.den, rint(d * den), den, max);
+    if ((!a.num || !a.den) && d && max>0 && max<INT_MAX)
+        av_reduce(&a.num, &a.den, llrint(d * den), den, INT_MAX);
 
     return a;
 }
diff --git a/tests/ref/fate/parseutils b/tests/ref/fate/parseutils
index 5fa3bf4..1482452 100644
--- a/tests/ref/fate/parseutils
+++ b/tests/ref/fate/parseutils
@@ -21,7 +21,7 @@ Testing av_parse_video_rate()
 '.23' -> 23/100 OK
 '-.23' -> -23/100 ERROR
 '-0.234' -> -117/500 ERROR
-'-0.0000001' -> 0/1 ERROR
+'-0.0000001' -> -1/10000000 ERROR
 '  21332.2324   ' -> 917286/43 OK
 ' -21332.2324   ' -> -917286/43 ERROR
 



More information about the ffmpeg-cvslog mailing list