diff options
author | Nils Wallménius <nils@rockbox.org> | 2014-01-19 16:31:59 +0100 |
---|---|---|
committer | Nils Wallménius <nils@rockbox.org> | 2014-07-13 11:12:40 +0200 |
commit | 9b7ec42403073ee887efc531c153e6b1b6c15bab (patch) | |
tree | 07e72fe9d817c65a6fede22955344a870842d5e6 /lib/rbcodec/codecs/libopus/celt/entcode.h | |
parent | e557951c94c1efa769900257e466900f0ffeb53b (diff) | |
download | rockbox-9b7ec42403073ee887efc531c153e6b1b6c15bab.tar.gz rockbox-9b7ec42403073ee887efc531c153e6b1b6c15bab.zip |
Sync to upstream libopus
Sync to commit bb4b6885a139644cf3ac14e7deda9f633ec2d93c
This brings in a bunch of optimizations to decode speed
and memory usage. Allocations are switched from using
the pseudostack to using the real stack. Enabled hacks
to reduce stack usage.
This should fix crashes on sansa clip, although some
files will not play due to failing allocations in the
codec buffer.
Speeds up decoding of the following test files:
H300 (cf) C200 (arm7tdmi) ipod classic (arm9e)
16 kbps (silk) 14.28 MHz 4.00 MHz 2.61 MHz
64 kbps (celt) 4.09 MHz 8.08 MHz 6.24 MHz
128 kbps (celt) 1.93 MHz 8.83 MHz 6.53 MHz
Change-Id: I851733a8a5824b61feb363a173091bc7e6629b58
Diffstat (limited to 'lib/rbcodec/codecs/libopus/celt/entcode.h')
-rw-r--r-- | lib/rbcodec/codecs/libopus/celt/entcode.h | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/lib/rbcodec/codecs/libopus/celt/entcode.h b/lib/rbcodec/codecs/libopus/celt/entcode.h index dd13e49e50..13d6c84ef0 100644 --- a/lib/rbcodec/codecs/libopus/celt/entcode.h +++ b/lib/rbcodec/codecs/libopus/celt/entcode.h | |||
@@ -34,6 +34,12 @@ | |||
34 | # include <stddef.h> | 34 | # include <stddef.h> |
35 | # include "ecintrin.h" | 35 | # include "ecintrin.h" |
36 | 36 | ||
37 | extern const opus_uint32 SMALL_DIV_TABLE[129]; | ||
38 | |||
39 | #ifdef OPUS_ARM_ASM | ||
40 | #define USE_SMALL_DIV_TABLE | ||
41 | #endif | ||
42 | |||
37 | /*OPT: ec_window must be at least 32 bits, but if you have fast arithmetic on a | 43 | /*OPT: ec_window must be at least 32 bits, but if you have fast arithmetic on a |
38 | larger type, you can speed up the decoder by using it here.*/ | 44 | larger type, you can speed up the decoder by using it here.*/ |
39 | typedef opus_uint32 ec_window; | 45 | typedef opus_uint32 ec_window; |
@@ -114,4 +120,33 @@ static OPUS_INLINE int ec_tell(ec_ctx *_this){ | |||
114 | rounding error is in the positive direction).*/ | 120 | rounding error is in the positive direction).*/ |
115 | opus_uint32 ec_tell_frac(ec_ctx *_this); | 121 | opus_uint32 ec_tell_frac(ec_ctx *_this); |
116 | 122 | ||
123 | /* Tested exhaustively for all n and for 1<=d<=256 */ | ||
124 | static OPUS_INLINE opus_uint32 celt_udiv(opus_uint32 n, opus_uint32 d) { | ||
125 | celt_assert(d>0); | ||
126 | #ifdef USE_SMALL_DIV_TABLE | ||
127 | if (d>256) | ||
128 | return n/d; | ||
129 | else { | ||
130 | opus_uint32 t, q; | ||
131 | t = EC_ILOG(d&-d); | ||
132 | q = (opus_uint64)SMALL_DIV_TABLE[d>>t]*(n>>(t-1))>>32; | ||
133 | return q+(n-q*d >= d); | ||
134 | } | ||
135 | #else | ||
136 | return n/d; | ||
137 | #endif | ||
138 | } | ||
139 | |||
140 | static OPUS_INLINE opus_int32 celt_sudiv(opus_int32 n, opus_int32 d) { | ||
141 | celt_assert(d>0); | ||
142 | #ifdef USE_SMALL_DIV_TABLE | ||
143 | if (n<0) | ||
144 | return -(opus_int32)celt_udiv(-n, d); | ||
145 | else | ||
146 | return celt_udiv(n, d); | ||
147 | #else | ||
148 | return n/d; | ||
149 | #endif | ||
150 | } | ||
151 | |||
117 | #endif | 152 | #endif |