summaryrefslogtreecommitdiff
path: root/lib/rbcodec/codecs/libopus/celt/mathops.h
diff options
context:
space:
mode:
authorNils Wallménius <nils@rockbox.org>2013-05-20 22:25:57 +0200
committerNils Wallménius <nils@rockbox.org>2013-08-31 08:30:51 +0200
commit580b307fd791c0997a8831bc800bba87797bfb7e (patch)
tree807846056f06fd944a750ce41217a877910ebd59 /lib/rbcodec/codecs/libopus/celt/mathops.h
parent74761b70acd96cecc0d35450dd56a98ad9ee7d3d (diff)
downloadrockbox-580b307fd791c0997a8831bc800bba87797bfb7e.tar.gz
rockbox-580b307fd791c0997a8831bc800bba87797bfb7e.zip
Sync opus codec to upstream git
Sync opus codec to upstream commit 02fed471a4568852d6618e041c4f2af0d7730ee2 (August 30 2013) This brings in a lot of optimizations but also makes the diff between our codec and the upstream much smaller as most of our optimizations have been upstreamed or supeceded. Speedups across the board for CELT mode files: 64kbps 128kbps H300 9.82MHz 15.48MHz c200 4.86MHz 9.63MHz fuze v1 10.32MHz 15.92MHz For the silk mode test file (16kbps) arm targets get a speedup of about 2MHz while the H300 is 7.8MHz slower, likely because it's now using the pseudostack more rather than the real stack which is in iram. Patches to get around that are upcomming. Change-Id: Ifecf963e461c51ac42e09dac1e91bc4bc3b12fa3
Diffstat (limited to 'lib/rbcodec/codecs/libopus/celt/mathops.h')
-rw-r--r--lib/rbcodec/codecs/libopus/celt/mathops.h66
1 files changed, 43 insertions, 23 deletions
diff --git a/lib/rbcodec/codecs/libopus/celt/mathops.h b/lib/rbcodec/codecs/libopus/celt/mathops.h
index 4e97795606..44fa97c697 100644
--- a/lib/rbcodec/codecs/libopus/celt/mathops.h
+++ b/lib/rbcodec/codecs/libopus/celt/mathops.h
@@ -43,6 +43,41 @@
43 43
44unsigned isqrt32(opus_uint32 _val); 44unsigned isqrt32(opus_uint32 _val);
45 45
46#ifndef OVERRIDE_CELT_MAXABS16
47static inline opus_val32 celt_maxabs16(const opus_val16 *x, int len)
48{
49 int i;
50 opus_val16 maxval = 0;
51 opus_val16 minval = 0;
52 for (i=0;i<len;i++)
53 {
54 maxval = MAX16(maxval, x[i]);
55 minval = MIN16(minval, x[i]);
56 }
57 return MAX32(EXTEND32(maxval),-EXTEND32(minval));
58}
59#endif
60
61#ifndef OVERRIDE_CELT_MAXABS32
62#ifdef FIXED_POINT
63static inline opus_val32 celt_maxabs32(const opus_val32 *x, int len)
64{
65 int i;
66 opus_val32 maxval = 0;
67 opus_val32 minval = 0;
68 for (i=0;i<len;i++)
69 {
70 maxval = MAX32(maxval, x[i]);
71 minval = MIN32(minval, x[i]);
72 }
73 return MAX32(maxval, -minval);
74}
75#else
76#define celt_maxabs32(x,len) celt_maxabs16(x,len)
77#endif
78#endif
79
80
46#ifndef FIXED_POINT 81#ifndef FIXED_POINT
47 82
48#define PI 3.141592653f 83#define PI 3.141592653f
@@ -117,27 +152,6 @@ static inline opus_int16 celt_ilog2(opus_int32 x)
117} 152}
118#endif 153#endif
119 154
120#ifndef OVERRIDE_CELT_MAXABS16
121static inline opus_val16 celt_maxabs16(opus_val16 *x, int len)
122{
123 int i;
124 opus_val16 maxval = 0;
125 for (i=0;i<len;i++)
126 maxval = MAX16(maxval, ABS16(x[i]));
127 return maxval;
128}
129#endif
130
131#ifndef OVERRIDE_CELT_MAXABS32
132static inline opus_val32 celt_maxabs32(opus_val32 *x, int len)
133{
134 int i;
135 opus_val32 maxval = 0;
136 for (i=0;i<len;i++)
137 maxval = MAX32(maxval, ABS32(x[i]));
138 return maxval;
139}
140#endif
141 155
142/** Integer log in base2. Defined for zero, but not for negative numbers */ 156/** Integer log in base2. Defined for zero, but not for negative numbers */
143static inline opus_int16 celt_zlog2(opus_val32 x) 157static inline opus_int16 celt_zlog2(opus_val32 x)
@@ -176,6 +190,13 @@ static inline opus_val16 celt_log2(opus_val32 x)
176#define D1 22804 190#define D1 22804
177#define D2 14819 191#define D2 14819
178#define D3 10204 192#define D3 10204
193
194static inline opus_val32 celt_exp2_frac(opus_val16 x)
195{
196 opus_val16 frac;
197 frac = SHL16(x, 4);
198 return ADD16(D0, MULT16_16_Q15(frac, ADD16(D1, MULT16_16_Q15(frac, ADD16(D2 , MULT16_16_Q15(D3,frac))))));
199}
179/** Base-2 exponential approximation (2^x). (Q10 input, Q16 output) */ 200/** Base-2 exponential approximation (2^x). (Q10 input, Q16 output) */
180static inline opus_val32 celt_exp2(opus_val16 x) 201static inline opus_val32 celt_exp2(opus_val16 x)
181{ 202{
@@ -186,8 +207,7 @@ static inline opus_val32 celt_exp2(opus_val16 x)
186 return 0x7f000000; 207 return 0x7f000000;
187 else if (integer < -15) 208 else if (integer < -15)
188 return 0; 209 return 0;
189 frac = SHL16(x-SHL16(integer,10),4); 210 frac = celt_exp2_frac(x-SHL16(integer,10));
190 frac = ADD16(D0, MULT16_16_Q15(frac, ADD16(D1, MULT16_16_Q15(frac, ADD16(D2 , MULT16_16_Q15(D3,frac))))));
191 return VSHR32(EXTEND32(frac), -integer-2); 211 return VSHR32(EXTEND32(frac), -integer-2);
192} 212}
193 213