From e56d454fbd865f34cb5e043ff43585754631b079 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Sat, 7 Aug 2010 17:07:12 +0200 Subject: [PATCH] Replace ROUND_UP by DIV_ROUND_UP and use it everywhere. --- fecdec_filter.c | 3 +-- para.h | 6 +++--- vss.c | 2 +- wmadec_filter.c | 6 +++--- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/fecdec_filter.c b/fecdec_filter.c index 939f7e3d..30696c10 100644 --- a/fecdec_filter.c +++ b/fecdec_filter.c @@ -306,8 +306,7 @@ static int decode_group(struct fecdec_group *fg, struct filter_node *fn) 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", diff --git a/para.h b/para.h index afb63821..305707da 100644 --- a/para.h +++ b/para.h @@ -165,9 +165,9 @@ _static_inline_ long int para_random(unsigned max) 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])) diff --git a/vss.c b/vss.c index 30b03c69..25082834 100644 --- a/vss.c +++ b/vss.c @@ -238,7 +238,7 @@ static int num_slices(long unsigned bytes, int mps, int rs) 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; diff --git a/wmadec_filter.c b/wmadec_filter.c index 1f722932..bb534df5 100644 --- a/wmadec_filter.c +++ b/wmadec_filter.c @@ -142,13 +142,13 @@ struct private_wmadec_data { }; #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) -- 2.39.2