From 95e4e1382d14079f85174ff4d2e0270d42145ae6 Mon Sep 17 00:00:00 2001 From: Andy Wingo Date: Mon, 29 Aug 2005 16:10:36 +0000 Subject: [PATCH] gst/gstutils.c (gst_util_uint64_scale): New 3733t funct10n. Original commit message from CVS: 2005-08-29 Andy Wingo * gst/gstutils.c (gst_util_uint64_scale): New 3733t funct10n. --- ChangeLog | 4 ++++ common | 2 +- gst/gstutils.c | 17 +++++++++++++++++ gst/gstutils.h | 2 ++ 4 files changed, 24 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index ab5302254a..b6754d2c69 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2005-08-29 Andy Wingo + + * gst/gstutils.c (gst_util_uint64_scale): New 3733t funct10n. + 2005-08-28 Andy Wingo * gst/gstutils.h (GST_BOILERPLATE_FULL): Prototype instance_init diff --git a/common b/common index 7c93670c50..89d82b662d 160000 --- a/common +++ b/common @@ -1 +1 @@ -Subproject commit 7c93670c50de2b6e9d8edd31737c636192fbd831 +Subproject commit 89d82b662da00096b70e70a7a102b294acaae6dd diff --git a/gst/gstutils.c b/gst/gstutils.c index f04ae15bf2..3a8561e10e 100644 --- a/gst/gstutils.c +++ b/gst/gstutils.c @@ -273,6 +273,23 @@ gst_util_set_object_arg (GObject * object, const gchar * name, } } +/** + * gst_util_uint64_scale: + * @val: the number to scale + * @num: the numerator of the scale ratio + * @denom: the denominator of the scale ratio + * + * Scale @val by @num / @denom, trying to avoid overflows. + * + * Returns: @val * @num / @denom, trying to avoid overflows. + */ +guint64 +gst_util_uint64_scale (guint64 val, guint64 num, guint64 denom) +{ + /* implement me with fixed point, if you care */ + return val * (((double) num) / denom); +} + /* ----------------------------------------------------- * * The following code will be moved out of the main diff --git a/gst/gstutils.h b/gst/gstutils.h index 7bb16d12ec..501b855243 100644 --- a/gst/gstutils.h +++ b/gst/gstutils.h @@ -34,6 +34,8 @@ void gst_util_set_object_arg (GObject *object, const gchar *name, const gchar void gst_util_dump_mem (const guchar *mem, guint size); +guint64 gst_util_uint64_scale (guint64 val, guint64 num, guint64 denom); + void gst_print_pad_caps (GString *buf, gint indent, GstPad *pad); void gst_print_element_args (GString *buf, gint indent, GstElement *element);