pfd->have_header = 1;
i = 0;
if (u == FEC_GROUP_USABLE_SKIP_HEADER) {
- i = ROUND_UP(fg->h.audio_header_size, fg->h.slice_bytes)
- / fg->h.slice_bytes;
+ i = DIV_ROUND_UP(fg->h.audio_header_size, fg->h.slice_bytes);
PARA_DEBUG_LOG("skipping %d header slices\n", i);
}
PARA_DEBUG_LOG("writing group %d (%d/%d decoded data bytes)\n",
return ((max + 0.0) * (random() / (RAND_MAX + 1.0)));
}
-/** Round up x to a multiple of y */
-#define ROUND_UP(x, y) ((((x) + ((y) - 1)) / (y)) * (y))
-
+#define DIV_ROUND_UP(x, y) ({ \
+ typeof(y) _divisor = y; \
+ ((x) + _divisor - 1) / _divisor; })
/** Get the size of an array */
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
assert(m > 0);
assert(rs > 0);
- ret = (bytes + m - 1) / m;
+ ret = DIV_ROUND_UP(bytes, m);
if (ret + rs > 255)
return -E_BAD_CT;
return ret;
};
#define EXPVLCBITS 8
-#define EXPMAX ((19 + EXPVLCBITS - 1) / EXPVLCBITS)
+#define EXPMAX DIV_ROUND_UP(19, EXPVLCBITS)
#define HGAINVLCBITS 9
-#define HGAINMAX ((13 + HGAINVLCBITS - 1) / HGAINVLCBITS)
+#define HGAINMAX DIV_ROUND_UP(13, HGAINVLCBITS)
#define VLCBITS 9
-#define VLCMAX ((22 + VLCBITS - 1) / VLCBITS)
+#define VLCMAX DIV_ROUND_UP(22, VLCBITS)
#define SINE_WINDOW(x) float sine_ ## x[x] __a_aligned(16)