gst/gstutils.c: apparently converting from guint64 to double is not implemented on...
authorThomas Vander Stichele <thomas@apestaart.org>
Mon, 10 Oct 2005 16:38:59 +0000 (16:38 +0000)
committerThomas Vander Stichele <thomas@apestaart.org>
Mon, 10 Oct 2005 16:38:59 +0000 (16:38 +0000)
Original commit message from CVS:

* gst/gstutils.c: (guint64_to_gdouble), (gst_util_uint64_scale):
apparently converting from guint64 to double is not implemented
on MSVC

ChangeLog
gst/gstutils.c

index e3d96e7..7e2f4ce 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2005-10-10  Thomas Vander Stichele  <thomas at apestaart dot org>
+
+       * gst/gstutils.c: (guint64_to_gdouble), (gst_util_uint64_scale):
+         apparently converting from guint64 to double is not implemented
+         on MSVC
+
 2005-10-10  Wim Taymans  <wim@fluendo.com>
 
        * check/Makefile.am:
index a366d6a..697b618 100644 (file)
@@ -299,6 +299,21 @@ gst_util_set_object_arg (GObject * object, const gchar * name,
   }
 }
 
+#ifdef WIN32
+/* work around error C2520: conversion from unsigned __int64 to double
+ * not implemented, use signed __int64 */
+static gdouble
+guint64_to_gdouble (guint64 value)
+{
+  if (value & 0x8000000000000000)
+    return (gdouble) ((gint64) value) + (gdouble) 18446744073709551616.;
+  else
+    return (gdouble) ((gint64) value);
+}
+#else
+#define guint64_to_gdouble(value) ((gdouble) value)
+#endif
+
 /**
  * gst_util_uint64_scale:
  * @val: the number to scale
@@ -313,7 +328,7 @@ guint64
 gst_util_uint64_scale (guint64 val, guint64 num, guint64 denom)
 {
   /* implement me with fixed point, if you care */
-  return val * (((double) num) / denom);
+  return val * ((guint64_to_gdouble (num)) / denom);
 }
 
 /* -----------------------------------------------------