mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-06-05 23:18:52 +00:00
util: Add GST_ROUND_UP_N and GST_ROUND_DOWN_N
These are generic rounding macro that works for any power of two.
This commit is contained in:
parent
96f454d0ba
commit
abddae152d
1 changed files with 19 additions and 0 deletions
|
@ -822,6 +822,15 @@ GST_WRITE_DOUBLE_BE(guint8 *data, gdouble num)
|
||||||
* Since: 1.4
|
* Since: 1.4
|
||||||
*/
|
*/
|
||||||
#define GST_ROUND_UP_128(num) (((num)+127)&~127)
|
#define GST_ROUND_UP_128(num) (((num)+127)&~127)
|
||||||
|
/**
|
||||||
|
* GST_ROUND_UP_N:
|
||||||
|
* @num: integrer value to round up
|
||||||
|
* @align: a power of two to round up to
|
||||||
|
*
|
||||||
|
* Rounds an integer value up to the next multiple of @align. @align MUST be a
|
||||||
|
* power of two.
|
||||||
|
*/
|
||||||
|
#define GST_ROUND_UP_N(num,align) ((((num) + ((align) - 1)) & ~((align) - 1)))
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -874,6 +883,16 @@ GST_WRITE_DOUBLE_BE(guint8 *data, gdouble num)
|
||||||
* Since: 1.4
|
* Since: 1.4
|
||||||
*/
|
*/
|
||||||
#define GST_ROUND_DOWN_128(num) ((num)&(~127))
|
#define GST_ROUND_DOWN_128(num) ((num)&(~127))
|
||||||
|
/**
|
||||||
|
* GST_ROUND_DOWN_N:
|
||||||
|
* @num: integrer value to round down
|
||||||
|
* @align: a power of two to round down to
|
||||||
|
*
|
||||||
|
* Rounds an integer value down to the next multiple of @align. @align MUST be a
|
||||||
|
* power of two.
|
||||||
|
*/
|
||||||
|
#define GST_ROUND_DOWN_N(num,align) (((num) & ~((align) - 1)))
|
||||||
|
|
||||||
|
|
||||||
void gst_object_default_error (GstObject * source,
|
void gst_object_default_error (GstObject * source,
|
||||||
const GError * error,
|
const GError * error,
|
||||||
|
|
Loading…
Reference in a new issue