Commit d0c276b7 authored by Wim Taymans's avatar Wim Taymans
Browse files

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.
parent 42515292
2005-11-24 Wim Taymans <wim@fluendo.com>
* 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 <thomas at apestaart dot org> 2005-11-24 Thomas Vander Stichele <thomas at apestaart dot org>
* check/gst/gstminiobject.c: (thread_ref), (GST_START_TEST), * check/gst/gstminiobject.c: (thread_ref), (GST_START_TEST),
......
...@@ -352,7 +352,7 @@ gst_base_src_query (GstPad * pad, GstQuery * query) ...@@ -352,7 +352,7 @@ gst_base_src_query (GstPad * pad, GstQuery * query)
guint64 ui64; guint64 ui64;
b = gst_base_src_get_size (src, &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, i64 = gst_util_uint64_scale (GST_FORMAT_PERCENT_MAX, src->offset,
ui64); ui64);
else else
......
...@@ -369,19 +369,30 @@ typedef union ...@@ -369,19 +369,30 @@ typedef union
guint64 guint64
gst_util_uint64_scale (guint64 val, guint64 num, guint64 denom) gst_util_uint64_scale (guint64 val, guint64 num, guint64 denom)
{ {
guint64 result;
g_return_val_if_fail (denom != 0, G_MAXUINT64); g_return_val_if_fail (denom != 0, G_MAXUINT64);
if (num <= G_MAXINT32 && denom <= G_MAXINT32) { /* if the denom is high, we need to do a 64 muldiv */
result = gst_util_uint64_scale_int (val, (gint) num, (gint) denom); if (denom > G_MAXINT32)
} else { goto do_int64;
/* 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 */ /* implement me with fixed point, if you care */
result = gst_gdouble_to_guint64 (gst_guint64_to_gdouble (val) * return gst_gdouble_to_guint64 (gst_guint64_to_gdouble (val) *
((gst_guint64_to_gdouble (num)) / gst_guint64_to_gdouble (denom))); ((gst_guint64_to_gdouble (num)) / gst_guint64_to_gdouble (denom)));
}
return result;
} }
/** /**
......
...@@ -352,7 +352,7 @@ gst_base_src_query (GstPad * pad, GstQuery * query) ...@@ -352,7 +352,7 @@ gst_base_src_query (GstPad * pad, GstQuery * query)
guint64 ui64; guint64 ui64;
b = gst_base_src_get_size (src, &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, i64 = gst_util_uint64_scale (GST_FORMAT_PERCENT_MAX, src->offset,
ui64); ui64);
else else
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment