Revision 65db0587

View differences:

libavutil/mathematics.c
144 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 154
#ifdef TEST
148 155
#include "integer.h"
149 156
#undef printf
libavutil/mathematics.h
94 94
 */
95 95
int av_compare_ts(int64_t ts_a, AVRational tb_a, int64_t ts_b, AVRational tb_b);
96 96

  
97
/**
98
 * Compare 2 integers modulo mod.
99
 * That is we compare integers a and b for which only the least significant log2(mod) bits are known
100
 * @param mod must be a power of 2
101
 * @returns a negative value if a is smaller than b
102
 *          a positiv  value if a is greater than b
103
 *          0                if a equals          b
104
 */
105
int64_t av_compare_mod(uint64_t a, uint64_t b, uint64_t mod);
97 106

  
98 107
#endif /* AVUTIL_MATHEMATICS_H */

Also available in: Unified diff