+2005-12-04 Thomas Vander Stichele <thomas at apestaart dot org>
+
+ * gst/gstutils.c: (gst_util_guint64_to_gdouble),
+ (gst_util_gdouble_to_guint64), (gst_util_uint64_scale_int64):
+ * gst/gstutils.h:
+ * tests/check/gst/gstutils.c: (GST_START_TEST), (gst_utils_suite):
+ add tests that seem to show that the guint64/gdouble conversions
+ are correct.
+
2005-12-02 Wim Taymans <wim@fluendo.com>
* gst/gstregistry.c: (gst_registry_add_path):
}
}
-#ifdef WIN32
/* work around error C2520: conversion from unsigned __int64 to double
* not implemented, use signed __int64 */
+
/**
- * gst_guint64_to_gdouble:
- * @value: the value to convert
+ * gst_util_guint64_to_gdouble:
+ * @value: the #guint64 value to convert
*
* Convert @value to a gdouble. This is implemented as a function
* because on some platforms a 64bit int to double conversion is
* not defined/implemented.
*
- * Returns: @value converted to a double.
+ * Returns: @value converted to a #gdouble.
*/
gdouble
-gst_guint64_to_gdouble (guint64 value)
+gst_util_guint64_to_gdouble (guint64 value)
{
- if (value & 0x8000000000000000)
+ if (value & G_GINT64_CONSTANT (0x8000000000000000))
return (gdouble) ((gint64) value) + (gdouble) 18446744073709551616.;
else
return (gdouble) ((gint64) value);
}
/**
- * gst_gdouble_to_guint64:
- * @value: the value to convert
+ * gst_util_gdouble_to_guint64:
+ * @value: the #gdouble value to convert
*
* Convert @value to a guint64. This is implemented as a function
* because on some platforms a double to guint64 conversion is not
* defined/implemented.
*
- * Returns: @value converted to a double.
+ * Returns: @value converted to a #guint64.
*/
guint64
-gst_gdouble_to_guint64 (gdouble value)
+gst_util_gdouble_to_guint64 (gdouble value)
{
if (value < (gdouble) 9223372036854775808.) /* 1 << 63 */
return ((guint64) ((gint64) value));
value -= (gdouble) 18446744073709551616.;
return ((guint64) ((gint64) value));
}
-#endif
-
-/* convenience struct for getting high an low uint32 parts of
+/* convenience struct for getting high and low uint32 parts of
* a guint64 */
typedef union
{
v.ll = val;
n.ll = num;
- /* do 128 bits multiply
+ /* do 128 bits multiply
* nh nl
* * vh vl
* ----------
void gst_util_set_object_arg (GObject *object, const gchar *name, const gchar *value);
void gst_util_dump_mem (const guchar *mem, guint size);
+guint64 gst_util_gdouble_to_guint64 (gdouble value);
+gdouble gst_util_guint64_to_gdouble (guint64 value);
+
+/**
+ * gst_guint64_to_gdouble:
+ * @value: the #guint64 value to convert
+ *
+ * Convert @value to a gdouble.
+ *
+ * Returns: @value converted to a #gdouble.
+ */
+
+/**
+ * gst_gdouble_to_guint64:
+ * @value: the #gdouble value to convert
+ *
+ * Convert @value to a guint64.
+ *
+ * Returns: @value converted to a #guint64.
+ */
#ifdef WIN32
-guint64 gst_gdouble_to_guint64 (gdouble value);
-gdouble gst_guint64_to_gdouble (guint64 value);
+#define gst_gdouble_to_guint64(v) gst_util_gdouble_to_guint64(v)
+#define gst_guint64_to_gdouble(v) gst_util_guint64_to_gdouble(v)
#else
-#define gst_gdouble_to_guint64(value) ((guint64) (value))
-#define gst_guint64_to_gdouble(value) ((gdouble) (value))
+#define gst_gdouble_to_guint64(value) ((guint64) (value))
+#define gst_guint64_to_gdouble(value) ((gdouble) (value))
#endif
guint64 gst_util_uint64_scale (guint64 val, guint64 num, guint64 denom);