diff mathematics.c @ 933:93bd29f34e99 libavutil

Add av_compare_mod()
author michael
date Wed, 09 Jun 2010 17:27:42 +0000
parents 0795a743bda1
children c0a0cf0c61c7
line wrap: on
line diff
--- a/mathematics.c	Sat Jun 05 12:01:28 2010 +0000
+++ b/mathematics.c	Wed Jun 09 17:27:42 2010 +0000
@@ -144,6 +144,13 @@
     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