From d9fb8a6651ea66f18f034fc70a51cfed17d3e12f Mon Sep 17 00:00:00 2001 From: Jean-Marc Valin Date: Thu, 30 Jan 2014 11:16:24 -0500 Subject: [PATCH] Optimizing divisions with a signed numerator --- celt/bands.c | 5 +++-- celt/entcode.h | 12 ++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/celt/bands.c b/celt/bands.c index 75f40787..0acb25c4 100644 --- a/celt/bands.c +++ b/celt/bands.c @@ -630,7 +630,8 @@ static int compute_qn(int N, int b, int offset, int pulse_cap, int stereo) /* The upper limit ensures that in a stereo split with itheta==16384, we'll always have enough bits left over to code at least one pulse in the side; otherwise it would collapse, since it doesn't get folded. */ - qb = IMIN(b-pulse_cap-(4<0); +#ifdef USE_SMALL_DIV_TABLE + if (n<0) + return -(opus_int32)celt_udiv(-n, d); + else + return celt_udiv(n, d); +#else + return n/d; +#endif +} + #endif