mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-03 05:59:10 +00:00
utils: Add gst_util_floor_log2 helper function
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5003>
This commit is contained in:
parent
a2e44d94aa
commit
df7a0d0fec
2 changed files with 48 additions and 0 deletions
|
@ -4518,6 +4518,51 @@ gst_util_ceil_log2 (guint32 v)
|
|||
return y;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_util_floor_log2:
|
||||
* @v: a #guint32 value.
|
||||
*
|
||||
* Returns smallest integral value not bigger than log2(v).
|
||||
*
|
||||
* Returns: a computed #guint val.
|
||||
*
|
||||
* Since: 1.26
|
||||
*/
|
||||
guint
|
||||
gst_util_floor_log2 (guint32 v)
|
||||
{
|
||||
guint32 result = 0;
|
||||
|
||||
g_return_val_if_fail (v != 0, -1);
|
||||
|
||||
if (v & 0xffff0000) {
|
||||
v >>= 16;
|
||||
result += 16;
|
||||
}
|
||||
|
||||
if (v & 0xff00) {
|
||||
v >>= 8;
|
||||
result += 8;
|
||||
}
|
||||
|
||||
if (v & 0xf0) {
|
||||
v >>= 4;
|
||||
result += 4;
|
||||
}
|
||||
|
||||
if (v & 0xc) {
|
||||
v >>= 2;
|
||||
result += 2;
|
||||
}
|
||||
|
||||
if (v & 0x2) {
|
||||
v >>= 1;
|
||||
result += 1;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_calculate_linear_regression: (skip)
|
||||
* @xy: Pairs of (x,y) values
|
||||
|
|
|
@ -1243,6 +1243,9 @@ gboolean gst_type_is_plugin_api (GType type, GstPluginAPIFlags *
|
|||
GST_API
|
||||
guint gst_util_ceil_log2 (guint32 v);
|
||||
|
||||
GST_API
|
||||
guint gst_util_floor_log2 (guint32 x);
|
||||
|
||||
GST_API
|
||||
gint gst_util_filename_compare (const gchar *a, const gchar *b);
|
||||
|
||||
|
|
Loading…
Reference in a new issue