mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-18 07:47:17 +00:00
utils: use shift instead of division
We can use a shift for scaling the denominator instead of a divide since the denom is always positive. This avoids having the compiler generate code for the different rounding rules when scaling negative values.
This commit is contained in:
parent
6cf8948663
commit
378b1e30e7
1 changed files with 4 additions and 2 deletions
|
@ -521,7 +521,7 @@ gst_util_uint64_scale (guint64 val, guint64 num, guint64 denom)
|
|||
guint64
|
||||
gst_util_uint64_scale_round (guint64 val, guint64 num, guint64 denom)
|
||||
{
|
||||
return _gst_util_uint64_scale (val, num, denom, denom / 2);
|
||||
return _gst_util_uint64_scale (val, num, denom, denom >> 1);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -622,7 +622,9 @@ gst_util_uint64_scale_int (guint64 val, gint num, gint denom)
|
|||
guint64
|
||||
gst_util_uint64_scale_int_round (guint64 val, gint num, gint denom)
|
||||
{
|
||||
return _gst_util_uint64_scale_int (val, num, denom, denom / 2);
|
||||
/* we can use a shift to divide by 2 because denom is required to be
|
||||
* positive. */
|
||||
return _gst_util_uint64_scale_int (val, num, denom, denom >> 1);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue