]> git.sesse.net Git - ffmpeg/commitdiff
lavu: add av_gcd_q().
authorNicolas George <george@nsup.org>
Thu, 16 Apr 2020 19:36:00 +0000 (21:36 +0200)
committerNicolas George <george@nsup.org>
Sat, 23 May 2020 13:51:44 +0000 (15:51 +0200)
doc/APIchanges
libavutil/rational.c
libavutil/rational.h
libavutil/version.h

index 34ca7ec1bbbf18cac7796834de7034bbe8e9209a..b3de5df0b646809239daa333075cf9d4e3d3400c 100644 (file)
@@ -15,6 +15,9 @@ libavutil:     2017-10-21
 
 API changes, most recent first:
 
+2020-05-23 - xxxxxxxxxx - lavu 56.47.100 - rational.h
+  Add av_gcd_q().
+
 2020-05-22 - xxxxxxxxxx - lavu 56.46.101 - opt.h
   Add AV_OPT_FLAG_CHILD_CONSTS.
 
index 35ee08877f3497379d383b06a7c424a1c940d1cd..eb148ddb12cc3df93e969a681ece54a2780a7b19 100644 (file)
@@ -182,3 +182,12 @@ uint32_t av_q2intfloat(AVRational q) {
 
     return sign<<31 | (150-shift)<<23 | (n - (1<<23));
 }
+
+AVRational av_gcd_q(AVRational a, AVRational b, int max_den, AVRational def)
+{
+    int64_t gcd, lcm;
+
+    gcd = av_gcd(a.den, b.den);
+    lcm = (a.den / gcd) * b.den;
+    return lcm < max_den ? av_make_q(av_gcd(a.num, b.num), lcm) : def;
+}
index 5c6b67b4e9f843ea93fc7ba305ff54a3062f4ea5..cbb08a0baf16d28c924826bd7e2af9ed18a46866 100644 (file)
@@ -207,6 +207,12 @@ int av_find_nearest_q_idx(AVRational q, const AVRational* q_list);
  */
 uint32_t av_q2intfloat(AVRational q);
 
+/**
+ * Return the best rational so that a and b are multiple of it.
+ * If the resulting denominator is larger than max_den, return def.
+ */
+AVRational av_gcd_q(AVRational a, AVRational b, int max_den, AVRational def);
+
 /**
  * @}
  */
index 20085dfde96b2f661c3bda1c00f38bb43f5fed96..f63cd4ba79a370d34101cbd947f447b2fb6398b9 100644 (file)
@@ -79,8 +79,8 @@
  */
 
 #define LIBAVUTIL_VERSION_MAJOR  56
-#define LIBAVUTIL_VERSION_MINOR  46
-#define LIBAVUTIL_VERSION_MICRO 101
+#define LIBAVUTIL_VERSION_MINOR  47
+#define LIBAVUTIL_VERSION_MICRO 100
 
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
                                                LIBAVUTIL_VERSION_MINOR, \