summaryrefslogtreecommitdiff
path: root/celt/mathops.h
diff options
context:
space:
mode:
authorJean-Marc Valin <jmvalin@jmvalin.ca>2013-06-16 21:56:41 -0400
committerJean-Marc Valin <jmvalin@jmvalin.ca>2013-06-16 21:56:41 -0400
commit7fd98c571f781c32d5de0ec83be3f38b678e73fe (patch)
tree42ad0868b475294a72206ee1a1a7a814c94d8f1d /celt/mathops.h
parentee2506b2c7e9a0ef05eb489ed554d38d9b71a3e5 (diff)
downloadopus-7fd98c571f781c32d5de0ec83be3f38b678e73fe.tar.gz
Converts denormalise_bands() to use 16-bit multiplications
Diffstat (limited to 'celt/mathops.h')
-rw-r--r--celt/mathops.h10
1 files changed, 8 insertions, 2 deletions
diff --git a/celt/mathops.h b/celt/mathops.h
index 18a66be1..44fa97c6 100644
--- a/celt/mathops.h
+++ b/celt/mathops.h
@@ -190,6 +190,13 @@ static inline opus_val16 celt_log2(opus_val32 x)
#define D1 22804
#define D2 14819
#define D3 10204
+
+static inline opus_val32 celt_exp2_frac(opus_val16 x)
+{
+ opus_val16 frac;
+ frac = SHL16(x, 4);
+ return ADD16(D0, MULT16_16_Q15(frac, ADD16(D1, MULT16_16_Q15(frac, ADD16(D2 , MULT16_16_Q15(D3,frac))))));
+}
/** Base-2 exponential approximation (2^x). (Q10 input, Q16 output) */
static inline opus_val32 celt_exp2(opus_val16 x)
{
@@ -200,8 +207,7 @@ static inline opus_val32 celt_exp2(opus_val16 x)
return 0x7f000000;
else if (integer < -15)
return 0;
- frac = SHL16(x-SHL16(integer,10),4);
- frac = ADD16(D0, MULT16_16_Q15(frac, ADD16(D1, MULT16_16_Q15(frac, ADD16(D2 , MULT16_16_Q15(D3,frac))))));
+ frac = celt_exp2_frac(x-SHL16(integer,10));
return VSHR32(EXTEND32(frac), -integer-2);
}