comparison mathematics.c @ 933:93bd29f34e99 libavutil

Add av_compare_mod()
author michael
date Wed, 09 Jun 2010 17:27:42 +0000
parents 0795a743bda1
children c0a0cf0c61c7
comparison
equal deleted inserted replaced
932:be49bac1a894 933:93bd29f34e99
142 if (av_rescale_rnd(ts_a, a, b, AV_ROUND_DOWN) < ts_b) return -1; 142 if (av_rescale_rnd(ts_a, a, b, AV_ROUND_DOWN) < ts_b) return -1;
143 if (av_rescale_rnd(ts_b, b, a, AV_ROUND_DOWN) < ts_a) return 1; 143 if (av_rescale_rnd(ts_b, b, a, AV_ROUND_DOWN) < ts_a) return 1;
144 return 0; 144 return 0;
145 } 145 }
146 146
147 int64_t av_compare_mod(uint64_t a, uint64_t b, uint64_t mod){
148 int64_t c= (a-b) & (mod-1);
149 if(c > (mod>>1))
150 c-= mod;
151 return c;
152 }
153
147 #ifdef TEST 154 #ifdef TEST
148 #include "integer.h" 155 #include "integer.h"
149 #undef printf 156 #undef printf
150 int main(void){ 157 int main(void){
151 int64_t a,b,c,d,e; 158 int64_t a,b,c,d,e;