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

michael subversion
Wed Jun 9 19:27:42 CEST 2010


Author: michael
Date: Wed Jun  9 19:27:42 2010
New Revision: 23551

Log:
Add av_compare_mod()

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

Modified: trunk/libavutil/mathematics.c
==============================================================================
--- trunk/libavutil/mathematics.c	Wed Jun  9 17:55:02 2010	(r23550)
+++ trunk/libavutil/mathematics.c	Wed Jun  9 19:27:42 2010	(r23551)
@@ -144,6 +144,13 @@ int av_compare_ts(int64_t ts_a, AVRation
     return 0;
 }
 
+int64_t av_compare_mod(uint64_t a, uint64_t b, uint64_t mod){
+    int64_t c= (a-b) & (mod-1);
+    if(c > (mod>>1))
+        c-= mod;
+    return c;
+}
+
 #ifdef TEST
 #include "integer.h"
 #undef printf

Modified: trunk/libavutil/mathematics.h
==============================================================================
--- trunk/libavutil/mathematics.h	Wed Jun  9 17:55:02 2010	(r23550)
+++ trunk/libavutil/mathematics.h	Wed Jun  9 19:27:42 2010	(r23551)
@@ -94,5 +94,14 @@ int64_t av_rescale_q(int64_t a, AVRation
  */
 int av_compare_ts(int64_t ts_a, AVRational tb_a, int64_t ts_b, AVRational tb_b);
 
+/**
+ * Compare 2 integers modulo mod.
+ * That is we compare integers a and b for which only the least significant log2(mod) bits are known
+ * @param mod must be a power of 2
+ * @returns a negative value if a is smaller than b
+ *          a positiv  value if a is greater than b
+ *          0                if a equals          b
+ */
+int64_t av_compare_mod(uint64_t a, uint64_t b, uint64_t mod);
 
 #endif /* AVUTIL_MATHEMATICS_H */



More information about the ffmpeg-cvslog mailing list