]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
Replace ROUND_UP by DIV_ROUND_UP and use it everywhere.
authorAndre Noll <maan@systemlinux.org>
Sat, 7 Aug 2010 15:07:12 +0000 (17:07 +0200)
committerAndre Noll <maan@systemlinux.org>
Sun, 31 Oct 2010 11:06:57 +0000 (12:06 +0100)
fecdec_filter.c
para.h
vss.c
wmadec_filter.c

index 939f7e3d06b5061e70275244ddcc3e112b7ce1ea..30696c10f4d0f74d86f15fde206a6f976f41d715 100644 (file)
@@ -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 afb638213e0819a5188f2365a82cc29dcd76fe18..305707da8d5194856fe34c520428dd8410843997 100644 (file)
--- 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 30b03c69724465a925f7634f8e92c04caa84f58b..25082834eb0160de013dd11639f3354160ee261b 100644 (file)
--- 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;
index 1f72293273f32cac61b39ad669af2b0310b146ff..bb534df528c5278198da5c116eb324bfe099da85 100644 (file)
@@ -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)