mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-23 08:46:40 +00:00
add tests that seem to show that the guint64/gdouble conversions are correct.
Original commit message from CVS: * 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.
This commit is contained in:
parent
524be39cf7
commit
057de1f845
3 changed files with 45 additions and 18 deletions
|
@ -1,3 +1,12 @@
|
|||
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):
|
||||
|
|
|
@ -297,40 +297,40 @@ 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 */
|
||||
|
||||
/**
|
||||
* 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));
|
||||
|
@ -338,10 +338,8 @@ gst_gdouble_to_guint64 (gdouble 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
|
||||
{
|
||||
|
|
|
@ -33,9 +33,29 @@ void gst_util_set_value_from_string (GValue *value, const gchar *value_str);
|
|||
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))
|
||||
|
|
Loading…
Reference in a new issue