From: Wim Taymans Date: Thu, 24 Nov 2005 19:06:58 +0000 (+0000) Subject: gst/base/gstbasesrc.c: Fix wrong percentage query. X-Git-Tag: RELEASE-0_9_7~122 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d0c276b717466fe7036dd7b4f2725a9963807d0d;p=platform%2Fupstream%2Fgstreamer.git gst/base/gstbasesrc.c: Fix wrong percentage query. Original commit message from CVS: * gst/base/gstbasesrc.c: (gst_base_src_query): Fix wrong percentage query. * gst/gstutils.c: (gst_util_uint64_scale), (gst_util_uint64_scale_int): Add some more common cases that can be handled efficiently to _scale. --- diff --git a/ChangeLog b/ChangeLog index a95d833..ba0dd4f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2005-11-24 Wim Taymans + + * gst/base/gstbasesrc.c: (gst_base_src_query): + Fix wrong percentage query. + + * gst/gstutils.c: (gst_util_uint64_scale), + (gst_util_uint64_scale_int): + Add some more common cases that can be handled + efficiently to _scale. + 2005-11-24 Thomas Vander Stichele * check/gst/gstminiobject.c: (thread_ref), (GST_START_TEST), diff --git a/gst/base/gstbasesrc.c b/gst/base/gstbasesrc.c index 146d9ca..02111c3 100644 --- a/gst/base/gstbasesrc.c +++ b/gst/base/gstbasesrc.c @@ -352,7 +352,7 @@ gst_base_src_query (GstPad * pad, GstQuery * query) guint64 ui64; b = gst_base_src_get_size (src, &ui64); - if (b && src->offset > ui64) + if (b && src->offset < ui64) i64 = gst_util_uint64_scale (GST_FORMAT_PERCENT_MAX, src->offset, ui64); else diff --git a/gst/gstutils.c b/gst/gstutils.c index 7944006..aaf00be 100644 --- a/gst/gstutils.c +++ b/gst/gstutils.c @@ -369,19 +369,30 @@ typedef union guint64 gst_util_uint64_scale (guint64 val, guint64 num, guint64 denom) { - guint64 result; - g_return_val_if_fail (denom != 0, G_MAXUINT64); - if (num <= G_MAXINT32 && denom <= G_MAXINT32) { - result = gst_util_uint64_scale_int (val, (gint) num, (gint) denom); - } else { - /* implement me with fixed point, if you care */ - result = gst_gdouble_to_guint64 (gst_guint64_to_gdouble (val) * - ((gst_guint64_to_gdouble (num)) / gst_guint64_to_gdouble (denom))); - } + /* if the denom is high, we need to do a 64 muldiv */ + if (denom > G_MAXINT32) + goto do_int64; - return result; + /* if num and denom are low we can do a 32 bit muldiv */ + if (num <= G_MAXINT32) + goto do_int32; + + /* val and num are high, we need 64 muldiv */ + if (val > G_MAXINT32) + goto do_int64; + + /* val is low and num is high, we can swap them and do 32 muldiv */ + return gst_util_uint64_scale_int (num, (gint) val, (gint) denom); + +do_int32: + return gst_util_uint64_scale_int (val, (gint) num, (gint) denom); + +do_int64: + /* implement me with fixed point, if you care */ + return gst_gdouble_to_guint64 (gst_guint64_to_gdouble (val) * + ((gst_guint64_to_gdouble (num)) / gst_guint64_to_gdouble (denom))); } /** diff --git a/libs/gst/base/gstbasesrc.c b/libs/gst/base/gstbasesrc.c index 146d9ca..02111c3 100644 --- a/libs/gst/base/gstbasesrc.c +++ b/libs/gst/base/gstbasesrc.c @@ -352,7 +352,7 @@ gst_base_src_query (GstPad * pad, GstQuery * query) guint64 ui64; b = gst_base_src_get_size (src, &ui64); - if (b && src->offset > ui64) + if (b && src->offset < ui64) i64 = gst_util_uint64_scale (GST_FORMAT_PERCENT_MAX, src->offset, ui64); else