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>
|
2005-12-02 Wim Taymans <wim@fluendo.com>
|
||||||
|
|
||||||
* gst/gstregistry.c: (gst_registry_add_path):
|
* 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
|
/* work around error C2520: conversion from unsigned __int64 to double
|
||||||
* not implemented, use signed __int64 */
|
* not implemented, use signed __int64 */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gst_guint64_to_gdouble:
|
* gst_util_guint64_to_gdouble:
|
||||||
* @value: the value to convert
|
* @value: the #guint64 value to convert
|
||||||
*
|
*
|
||||||
* Convert @value to a gdouble. This is implemented as a function
|
* Convert @value to a gdouble. This is implemented as a function
|
||||||
* because on some platforms a 64bit int to double conversion is
|
* because on some platforms a 64bit int to double conversion is
|
||||||
* not defined/implemented.
|
* not defined/implemented.
|
||||||
*
|
*
|
||||||
* Returns: @value converted to a double.
|
* Returns: @value converted to a #gdouble.
|
||||||
*/
|
*/
|
||||||
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.;
|
return (gdouble) ((gint64) value) + (gdouble) 18446744073709551616.;
|
||||||
else
|
else
|
||||||
return (gdouble) ((gint64) value);
|
return (gdouble) ((gint64) value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gst_gdouble_to_guint64:
|
* gst_util_gdouble_to_guint64:
|
||||||
* @value: the value to convert
|
* @value: the #gdouble value to convert
|
||||||
*
|
*
|
||||||
* Convert @value to a guint64. This is implemented as a function
|
* Convert @value to a guint64. This is implemented as a function
|
||||||
* because on some platforms a double to guint64 conversion is not
|
* because on some platforms a double to guint64 conversion is not
|
||||||
* defined/implemented.
|
* defined/implemented.
|
||||||
*
|
*
|
||||||
* Returns: @value converted to a double.
|
* Returns: @value converted to a #guint64.
|
||||||
*/
|
*/
|
||||||
guint64
|
guint64
|
||||||
gst_gdouble_to_guint64 (gdouble value)
|
gst_util_gdouble_to_guint64 (gdouble value)
|
||||||
{
|
{
|
||||||
if (value < (gdouble) 9223372036854775808.) /* 1 << 63 */
|
if (value < (gdouble) 9223372036854775808.) /* 1 << 63 */
|
||||||
return ((guint64) ((gint64) value));
|
return ((guint64) ((gint64) value));
|
||||||
|
@ -338,10 +338,8 @@ gst_gdouble_to_guint64 (gdouble value)
|
||||||
value -= (gdouble) 18446744073709551616.;
|
value -= (gdouble) 18446744073709551616.;
|
||||||
return ((guint64) ((gint64) value));
|
return ((guint64) ((gint64) value));
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
|
/* convenience struct for getting high and low uint32 parts of
|
||||||
/* convenience struct for getting high an low uint32 parts of
|
|
||||||
* a guint64 */
|
* a guint64 */
|
||||||
typedef union
|
typedef union
|
||||||
{
|
{
|
||||||
|
@ -434,7 +432,7 @@ gst_util_uint64_scale_int64 (guint64 val, guint64 num, guint64 denom)
|
||||||
v.ll = val;
|
v.ll = val;
|
||||||
n.ll = num;
|
n.ll = num;
|
||||||
|
|
||||||
/* do 128 bits multiply
|
/* do 128 bits multiply
|
||||||
* nh nl
|
* nh nl
|
||||||
* * vh vl
|
* * vh vl
|
||||||
* ----------
|
* ----------
|
||||||
|
|
|
@ -33,12 +33,32 @@ 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_set_object_arg (GObject *object, const gchar *name, const gchar *value);
|
||||||
void gst_util_dump_mem (const guchar *mem, guint size);
|
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
|
#ifdef WIN32
|
||||||
guint64 gst_gdouble_to_guint64 (gdouble value);
|
#define gst_gdouble_to_guint64(v) gst_util_gdouble_to_guint64(v)
|
||||||
gdouble gst_guint64_to_gdouble (guint64 value);
|
#define gst_guint64_to_gdouble(v) gst_util_guint64_to_gdouble(v)
|
||||||
#else
|
#else
|
||||||
#define gst_gdouble_to_guint64(value) ((guint64) (value))
|
#define gst_gdouble_to_guint64(value) ((guint64) (value))
|
||||||
#define gst_guint64_to_gdouble(value) ((gdouble) (value))
|
#define gst_guint64_to_gdouble(value) ((gdouble) (value))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
guint64 gst_util_uint64_scale (guint64 val, guint64 num, guint64 denom);
|
guint64 gst_util_uint64_scale (guint64 val, guint64 num, guint64 denom);
|
||||||
|
|
Loading…
Reference in a new issue