diff --git a/common/common.c b/common/common.c index e59db7e906..9f8230fbff 100644 --- a/common/common.c +++ b/common/common.c @@ -21,6 +21,7 @@ #include #include +#include #include "mpv_talloc.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; 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)); +} diff --git a/common/common.h b/common/common.h index a30a5d6e0c..4015f9b8c3 100644 --- a/common/common.h +++ b/common/common.h @@ -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); 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, ...) PRINTF_ATTRIBUTE(3, 4);