diff --git a/gst/gstutils.c b/gst/gstutils.c index 52c0a86ae5..363dee04d8 100644 --- a/gst/gstutils.c +++ b/gst/gstutils.c @@ -3521,6 +3521,32 @@ gst_util_greatest_common_divisor (gint a, gint b) return ABS (a); } +/** + * 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 diff --git a/gst/gstutils.h b/gst/gstutils.h index 7bdc35038f..c3f8ec65b8 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);