diff options
author | Niklas Haas <git@haasn.dev> | 2023-10-19 17:58:28 +0200 |
---|---|---|
committer | Niklas Haas <github-daiK1o@haasn.dev> | 2023-10-19 18:26:05 +0200 |
commit | d67b0022aa691bb7879be5841e4720f3c4b5c009 (patch) | |
tree | abbd70e3db732fe19cd7ae1bac8a722b52a92b3d | |
parent | 227e1fef434abf15f261bd5429d3f0ab615d4b7c (diff) | |
download | mpv-d67b0022aa691bb7879be5841e4720f3c4b5c009.tar.bz2 mpv-d67b0022aa691bb7879be5841e4720f3c4b5c009.tar.xz |
common: add mp_lcm helper
-rw-r--r-- | common/common.c | 7 | ||||
-rw-r--r-- | common/common.h | 1 |
2 files changed, 8 insertions, 0 deletions
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 <libavutil/common.h> #include <libavutil/error.h> +#include <libavutil/mathematics.h> #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); |