1234567891011121314151617181920212223242526272829303132 |
- #include <audio_utils/roundup.h>
- unsigned roundup(unsigned v)
- {
-
- if (v == 0) {
- v = 1;
- }
- int lz = __builtin_clz((int) v);
- unsigned rounded = ((unsigned) 0x80000000) >> lz;
-
- if (v > rounded && lz > 0) {
- rounded <<= 1;
- }
- return rounded;
- }
|