gst/base/gstbasesrc.c: use conversions

Original commit message from CVS:

* 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
This commit is contained in:
Thomas Vander Stichele 2005-10-10 18:16:37 +00:00
parent 78c180ea28
commit e2af9ca6c6
5 changed files with 28 additions and 12 deletions

View file

@ -1,3 +1,13 @@
2005-10-10 Thomas Vander Stichele <thomas at apestaart dot org>
* 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 <wim@fluendo.com>
* tests/sched/Makefile.am:

View file

@ -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;

View file

@ -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)));
}
/* -----------------------------------------------------

View file

@ -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);

View file

@ -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;