[0.11] gstreamer: gstutils: add a 64 bit version of GCD calculation

Vincent Penquerc'h vincent at kemper.freedesktop.org
Tue Jan 24 06:16:26 PST 2012


Module: gstreamer
Branch: 0.11
Commit: 7319b52a2e2236d14c5c85bdb745ced3839309f2
URL:    http://cgit.freedesktop.org/gstreamer/gstreamer/commit/?id=7319b52a2e2236d14c5c85bdb745ced3839309f2

Author: Vincent Penquerc'h <vincent.penquerch at collabora.co.uk>
Date:   Wed Nov 30 17:58:07 2011 +0000

gstutils: add a 64 bit version of GCD calculation

https://bugzilla.gnome.org/show_bug.cgi?id=665294

---

 gst/gstutils.c |   26 ++++++++++++++++++++++++++
 gst/gstutils.h |    1 +
 2 files changed, 27 insertions(+), 0 deletions(-)

diff --git a/gst/gstutils.c b/gst/gstutils.c
index 52c0a86..363dee0 100644
--- a/gst/gstutils.c
+++ b/gst/gstutils.c
@@ -3522,6 +3522,32 @@ gst_util_greatest_common_divisor (gint a, gint b)
 }
 
 /**
+ * gst_util_greatest_common_divisor_int64:
+ * @a: First value as #gint64
+ * @b: Second value as #gint64
+ *
+ * Calculates the greatest common divisor of @a
+ * and @b.
+ *
+ * Returns: Greatest common divisor of @a and @b
+ *
+ * Since: 0.11.0
+ */
+gint64
+gst_util_greatest_common_divisor_int64 (gint64 a, gint64 b)
+{
+  while (b != 0) {
+    gint64 temp = a;
+
+    a = b;
+    b = temp % b;
+  }
+
+  return ABS (a);
+}
+
+
+/**
  * gst_util_fraction_to_double:
  * @src_n: Fraction numerator as #gint
  * @src_d: Fraction denominator #gint
diff --git a/gst/gstutils.h b/gst/gstutils.h
index 7bdc350..c3f8ec6 100644
--- a/gst/gstutils.h
+++ b/gst/gstutils.h
@@ -957,6 +957,7 @@ gpointer      gst_util_array_binary_search      (gpointer array, guint num_eleme
 
 /* fraction operations */
 gint          gst_util_greatest_common_divisor  (gint a, gint b);
+gint64        gst_util_greatest_common_divisor_int64 (gint64 a, gint64 b);
 
 void          gst_util_fraction_to_double       (gint src_n, gint src_d, gdouble *dest);
 void          gst_util_double_to_fraction       (gdouble src, gint *dest_n, gint *dest_d);



More information about the gstreamer-commits mailing list