mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-12 18:35:35 +00:00
gstutils: add a 64 bit version of GCD calculation
https://bugzilla.gnome.org/show_bug.cgi?id=665294
This commit is contained in:
parent
b6abb9794c
commit
7319b52a2e
2 changed files with 27 additions and 0 deletions
|
@ -3521,6 +3521,32 @@ gst_util_greatest_common_divisor (gint a, gint b)
|
||||||
return ABS (a);
|
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:
|
* gst_util_fraction_to_double:
|
||||||
* @src_n: Fraction numerator as #gint
|
* @src_n: Fraction numerator as #gint
|
||||||
|
|
|
@ -957,6 +957,7 @@ gpointer gst_util_array_binary_search (gpointer array, guint num_eleme
|
||||||
|
|
||||||
/* fraction operations */
|
/* fraction operations */
|
||||||
gint gst_util_greatest_common_divisor (gint a, gint b);
|
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_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);
|
void gst_util_double_to_fraction (gdouble src, gint *dest_n, gint *dest_d);
|
||||||
|
|
Loading…
Reference in a new issue