mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-08 15:32:32 +00:00
gst/gstutils.c: Optimisations, remove unneeded vars.
Original commit message from CVS: * gst/gstutils.c: (gst_util_uint64_scale_int64), (gst_util_uint64_scale_int): Optimisations, remove unneeded vars.
This commit is contained in:
parent
fb7302fc41
commit
7386cce105
2 changed files with 16 additions and 12 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
2005-11-25 Wim Taymans <wim@fluendo.com>
|
||||||
|
|
||||||
|
* gst/gstutils.c: (gst_util_uint64_scale_int64),
|
||||||
|
(gst_util_uint64_scale_int):
|
||||||
|
Optimisations, remove unneeded vars.
|
||||||
|
|
||||||
2005-11-25 Wim Taymans <wim@fluendo.com>
|
2005-11-25 Wim Taymans <wim@fluendo.com>
|
||||||
|
|
||||||
* check/gst/gstutils.c: (GST_START_TEST), (gst_utils_suite):
|
* check/gst/gstutils.c: (GST_START_TEST), (gst_utils_suite):
|
||||||
|
|
|
@ -504,24 +504,22 @@ gst_util_uint64_scale_int (guint64 val, gint num, gint denom)
|
||||||
/* simple case */
|
/* simple case */
|
||||||
result.ll = val * num / denom;
|
result.ll = val * num / denom;
|
||||||
} else {
|
} else {
|
||||||
GstUInt64 gval, low, high, temp;
|
GstUInt64 low, high;
|
||||||
|
|
||||||
/* do 96 bits mult/div */
|
/* do 96 bits mult/div */
|
||||||
gval.ll = val;
|
low.ll = val;
|
||||||
low.ll = ((guint64) gval.l.low) * num;
|
result.ll = ((guint64) low.l.low) * num;
|
||||||
high.ll = ((guint64) gval.l.high) * num + (low.l.high);
|
high.ll = ((guint64) low.l.high) * num + (result.l.high);
|
||||||
result.ll = (high.ll / denom);
|
|
||||||
temp.l.high = (high.ll % denom);
|
low.ll = high.ll / denom;
|
||||||
temp.l.low = (low.l.low);
|
result.l.high = high.ll % denom;
|
||||||
temp.ll /= denom;
|
result.ll /= denom;
|
||||||
|
|
||||||
/* avoid overflow */
|
/* avoid overflow */
|
||||||
if (result.ll + temp.l.high > G_MAXUINT32)
|
if (low.ll + result.l.high > G_MAXUINT32)
|
||||||
goto overflow;
|
goto overflow;
|
||||||
|
|
||||||
result.l.high = result.l.low;
|
result.l.high += low.l.low;
|
||||||
result.l.low = 0;
|
|
||||||
result.ll += temp.ll;
|
|
||||||
}
|
}
|
||||||
return result.ll;
|
return result.ll;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue