mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
Add av_compare_mod()
Originally committed as revision 23551 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
parent
130b096aea
commit
65db0587a8
@ -144,6 +144,13 @@ int av_compare_ts(int64_t ts_a, AVRational tb_a, int64_t ts_b, AVRational tb_b){
|
||||
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
|
||||
|
@ -94,5 +94,14 @@ int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq) av_const;
|
||||
*/
|
||||
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 */
|
||||
|
Loading…
Reference in New Issue
Block a user