[FFmpeg-cvslog] r21671 - in trunk/libavutil: mathematics.c mathematics.h

michael subversion
Sun Feb 7 17:26:50 CET 2010


Author: michael
Date: Sun Feb  7 17:26:50 2010
New Revision: 21671

Log:
av_compare_ts()

Modified:
   trunk/libavutil/mathematics.c
   trunk/libavutil/mathematics.h

Modified: trunk/libavutil/mathematics.c
==============================================================================
--- trunk/libavutil/mathematics.c	Sun Feb  7 16:46:18 2010	(r21670)
+++ trunk/libavutil/mathematics.c	Sun Feb  7 17:26:50 2010	(r21671)
@@ -136,6 +136,14 @@ int64_t av_rescale_q(int64_t a, AVRation
     return av_rescale_rnd(a, b, c, AV_ROUND_NEAR_INF);
 }
 
+int av_compare_ts(int64_t ts_a, AVRational tb_a, int64_t ts_b, AVRational tb_b){
+    int64_t a= tb_a.num * (int64_t)tb_b.den;
+    int64_t b= tb_b.num * (int64_t)tb_a.den;
+    if (av_rescale_rnd(ts_a, a, b, AV_ROUND_DOWN) < ts_b) return -1;
+    if (av_rescale_rnd(ts_b, b, a, AV_ROUND_DOWN) < ts_a) return  1;
+    return 0;
+}
+
 #ifdef TEST
 #include "integer.h"
 #undef printf

Modified: trunk/libavutil/mathematics.h
==============================================================================
--- trunk/libavutil/mathematics.h	Sun Feb  7 16:46:18 2010	(r21670)
+++ trunk/libavutil/mathematics.h	Sun Feb  7 17:26:50 2010	(r21671)
@@ -80,4 +80,13 @@ int64_t av_rescale_rnd(int64_t a, int64_
  */
 int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq) av_const;
 
+/**
+ * Compares 2 timestamps each in its own timebases.
+ * The result of the function is undefined if one of the timestamps
+ * is outside the int64_t range when represented in the others timebase.
+ * @returns -1 if ts_a is before ts_b, 1 if ts_a is after ts_b or 0 if they represent the same position
+ */
+int av_compare_ts(int64_t ts_a, AVRational tb_a, int64_t ts_b, AVRational tb_b);
+
+
 #endif /* AVUTIL_MATHEMATICS_H */



More information about the ffmpeg-cvslog mailing list