diff --git a/ChangeLog b/ChangeLog index d54ed53d16f..d205c6043e9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2005-10-10 Thomas Vander Stichele + + * gst/base/gstbasesrc.c: (gst_base_src_query): + use conversions + * gst/gstutils.c: (gst_guint64_to_gdouble), + (gst_gdouble_to_guint64), (gst_util_uint64_scale): + * gst/gstutils.h: + externalize, basesrc uses it + obviously the implementation needs testing + 2005-10-10 Wim Taymans * tests/sched/Makefile.am: diff --git a/gst/base/gstbasesrc.c b/gst/base/gstbasesrc.c index 3459fd12a91..d0ea047f571 100644 --- a/gst/base/gstbasesrc.c +++ b/gst/base/gstbasesrc.c @@ -338,7 +338,7 @@ gst_base_src_query (GstPad * pad, GstQuery * query) case GST_FORMAT_PERCENT: b = gst_base_src_get_size (src, &ui64); i64 = GST_FORMAT_PERCENT_MAX; - i64 *= b ? (src->offset / (gdouble) ui64) : 1.0; + i64 *= b ? (src->offset / gst_guint64_to_gdouble (ui64)) : 1.0; gst_query_set_position (query, GST_FORMAT_PERCENT, i64, GST_FORMAT_PERCENT_MAX); return TRUE; diff --git a/gst/gstutils.c b/gst/gstutils.c index e620991803f..76d71ae3b3d 100644 --- a/gst/gstutils.c +++ b/gst/gstutils.c @@ -302,8 +302,8 @@ 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) +gdouble +gst_guint64_to_gdouble (guint64 value) { if (value & 0x8000000000000000) return (gdouble) ((gint64) value) + (gdouble) 18446744073709551616.; @@ -311,18 +311,15 @@ guint64_to_gdouble (guint64 value) return (gdouble) ((gint64) value); } -static gdouble -gdouble_to_guint64 (gdouble value) +guint64 +gst_gdouble_to_guint64 (gdouble value) { if (value < (gdouble) 9223372036854775808.) /* 1 << 63 */ return ((guint64) ((gint64) value)); - value -= 9223372036854775808.; - return ((guint64) ((gint64) value)) + 1LL << 63; + value -= (gdouble) 18446744073709551616.; + return ((guint64) ((gint64) value)); } -#else -#define gdouble_to_guint64(value) ((guint64) (value)) -#define guint64_to_gdouble(value) ((gdouble) (value)) #endif /** @@ -339,7 +336,8 @@ guint64 gst_util_uint64_scale (guint64 val, guint64 num, guint64 denom) { /* implement me with fixed point, if you care */ - return val * ((guint64_to_gdouble (num)) / guint64_to_gdouble (denom)); + return gst_gdouble_to_guint64 (gst_guint64_to_gdouble (val) * + ((gst_guint64_to_gdouble (num)) / gst_guint64_to_gdouble (denom))); } /* ----------------------------------------------------- diff --git a/gst/gstutils.h b/gst/gstutils.h index eb0b724f346..1a300c31474 100644 --- a/gst/gstutils.h +++ b/gst/gstutils.h @@ -33,6 +33,14 @@ 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); +#ifdef WIN32 +guint64 gst_gdouble_to_guint64 (gdouble value); +gdouble gst_guint64_to_gdouble (guint64 value); +#else +#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); void gst_print_pad_caps (GString *buf, gint indent, GstPad *pad); diff --git a/libs/gst/base/gstbasesrc.c b/libs/gst/base/gstbasesrc.c index 3459fd12a91..d0ea047f571 100644 --- a/libs/gst/base/gstbasesrc.c +++ b/libs/gst/base/gstbasesrc.c @@ -338,7 +338,7 @@ gst_base_src_query (GstPad * pad, GstQuery * query) case GST_FORMAT_PERCENT: b = gst_base_src_get_size (src, &ui64); i64 = GST_FORMAT_PERCENT_MAX; - i64 *= b ? (src->offset / (gdouble) ui64) : 1.0; + i64 *= b ? (src->offset / gst_guint64_to_gdouble (ui64)) : 1.0; gst_query_set_position (query, GST_FORMAT_PERCENT, i64, GST_FORMAT_PERCENT_MAX); return TRUE;