mirror of https://github.com/mpv-player/mpv
common: add mp_lcm helper
This commit is contained in:
parent
227e1fef43
commit
d67b0022aa
|
@ -21,6 +21,7 @@
|
||||||
|
|
||||||
#include <libavutil/common.h>
|
#include <libavutil/common.h>
|
||||||
#include <libavutil/error.h>
|
#include <libavutil/error.h>
|
||||||
|
#include <libavutil/mathematics.h>
|
||||||
|
|
||||||
#include "mpv_talloc.h"
|
#include "mpv_talloc.h"
|
||||||
#include "misc/bstr.h"
|
#include "misc/bstr.h"
|
||||||
|
@ -404,3 +405,9 @@ uint32_t mp_round_next_power_of_2(uint32_t v)
|
||||||
int l = mp_log2(v) + 1;
|
int l = mp_log2(v) + 1;
|
||||||
return l == 32 ? 0 : (uint32_t)1 << l;
|
return l == 32 ? 0 : (uint32_t)1 << l;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int mp_lcm(int x, int y)
|
||||||
|
{
|
||||||
|
assert(x && y);
|
||||||
|
return x * (y / av_gcd(x, y));
|
||||||
|
}
|
||||||
|
|
|
@ -113,6 +113,7 @@ void mp_rect_rotate(struct mp_rect *rc, int w, int h, int rotation);
|
||||||
|
|
||||||
unsigned int mp_log2(uint32_t v);
|
unsigned int mp_log2(uint32_t v);
|
||||||
uint32_t mp_round_next_power_of_2(uint32_t v);
|
uint32_t mp_round_next_power_of_2(uint32_t v);
|
||||||
|
int mp_lcm(int x, int y);
|
||||||
|
|
||||||
int mp_snprintf_cat(char *str, size_t size, const char *format, ...)
|
int mp_snprintf_cat(char *str, size_t size, const char *format, ...)
|
||||||
PRINTF_ATTRIBUTE(3, 4);
|
PRINTF_ATTRIBUTE(3, 4);
|
||||||
|
|
Loading…
Reference in New Issue