[FFmpeg-cvslog] r25332 - in trunk/libavutil: avutil.h rational.c rational.h

stefano subversion
Mon Oct 4 15:41:01 CEST 2010


Author: stefano
Date: Mon Oct  4 15:41:01 2010
New Revision: 25332

Log:
Make av_d2q() manage the case in which the value to convert is inf.

Modified:
   trunk/libavutil/avutil.h
   trunk/libavutil/rational.c
   trunk/libavutil/rational.h

Modified: trunk/libavutil/avutil.h
==============================================================================
--- trunk/libavutil/avutil.h	Mon Oct  4 15:08:13 2010	(r25331)
+++ trunk/libavutil/avutil.h	Mon Oct  4 15:41:01 2010	(r25332)
@@ -41,7 +41,7 @@
 
 #define LIBAVUTIL_VERSION_MAJOR 50
 #define LIBAVUTIL_VERSION_MINOR 32
-#define LIBAVUTIL_VERSION_MICRO  0
+#define LIBAVUTIL_VERSION_MICRO  1
 
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
                                                LIBAVUTIL_VERSION_MINOR, \

Modified: trunk/libavutil/rational.c
==============================================================================
--- trunk/libavutil/rational.c	Mon Oct  4 15:08:13 2010	(r25331)
+++ trunk/libavutil/rational.c	Mon Oct  4 15:41:01 2010	(r25332)
@@ -100,6 +100,8 @@ AVRational av_d2q(double d, int max){
     int64_t den;
     if (isnan(d))
         return (AVRational){0,0};
+    if (isinf(d))
+        return (AVRational){ d<0 ? -1:1, 0 };
     exponent = FFMAX( (int)(log(fabs(d) + 1e-20)/LOG2), 0);
     den = 1LL << (61 - exponent);
     av_reduce(&a.num, &a.den, (int64_t)(d * den + 0.5), den, max);

Modified: trunk/libavutil/rational.h
==============================================================================
--- trunk/libavutil/rational.h	Mon Oct  4 15:08:13 2010	(r25331)
+++ trunk/libavutil/rational.h	Mon Oct  4 15:41:01 2010	(r25332)
@@ -107,6 +107,8 @@ AVRational av_sub_q(AVRational b, AVRati
 
 /**
  * Convert a double precision floating point number to a rational.
+ * inf is expressed as {1,0} or {-1,0} depending on the sign.
+ *
  * @param d double to convert
  * @param max the maximum allowed numerator and denominator
  * @return (AVRational) d



More information about the ffmpeg-cvslog mailing list