diff options
author | Thom Johansen <thomj@rockbox.org> | 2007-10-26 01:16:55 +0000 |
---|---|---|
committer | Thom Johansen <thomj@rockbox.org> | 2007-10-26 01:16:55 +0000 |
commit | fa971b142d794c9620b823d6b9d1937397c1f1e1 (patch) | |
tree | 55565a0765c15be5d1df4cfb1c04dc92de50fe5d /apps | |
parent | 14da611cd32d084813bb0d2e2318b81c3ea2953a (diff) | |
download | rockbox-fa971b142d794c9620b823d6b9d1937397c1f1e1.tar.gz rockbox-fa971b142d794c9620b823d6b9d1937397c1f1e1.zip |
Sync with Speex SVN. Syntactic change in filters_cf.S.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15310 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
28 files changed, 375 insertions, 484 deletions
diff --git a/apps/codecs/libspeex/README.rockbox b/apps/codecs/libspeex/README.rockbox index 00915918dd..84fff59b60 100644 --- a/apps/codecs/libspeex/README.rockbox +++ b/apps/codecs/libspeex/README.rockbox | |||
@@ -1,4 +1,4 @@ | |||
1 | Library: libspeex-1.2beta2 (SVN version 14014) | 1 | Library: libspeex-1.2beta3 (SVN version 14054) |
2 | Imported: 2007-03-12 by Dan Everton | 2 | Imported: 2007-03-12 by Dan Everton |
3 | 3 | ||
4 | 4 | ||
diff --git a/apps/codecs/libspeex/SOURCES b/apps/codecs/libspeex/SOURCES index c90d11805d..73c8c8bff7 100644 --- a/apps/codecs/libspeex/SOURCES +++ b/apps/codecs/libspeex/SOURCES | |||
@@ -22,11 +22,9 @@ lpc.c | |||
22 | lsp.c | 22 | lsp.c |
23 | lsp_tables_nb.c | 23 | lsp_tables_nb.c |
24 | ltp.c | 24 | ltp.c |
25 | math_approx.c | ||
26 | mdf.c | 25 | mdf.c |
27 | medfilter.c | ||
28 | misc.c | ||
29 | modes.c | 26 | modes.c |
27 | modes_wb.c | ||
30 | nb_celp.c | 28 | nb_celp.c |
31 | oggframing.c | 29 | oggframing.c |
32 | preprocess.c | 30 | preprocess.c |
diff --git a/apps/codecs/libspeex/bits.c b/apps/codecs/libspeex/bits.c index 379fe748d4..834bf5d78d 100644 --- a/apps/codecs/libspeex/bits.c +++ b/apps/codecs/libspeex/bits.c | |||
@@ -38,6 +38,7 @@ | |||
38 | 38 | ||
39 | #include <speex/speex_bits.h> | 39 | #include <speex/speex_bits.h> |
40 | #include "misc.h" | 40 | #include "misc.h" |
41 | #include "os_support.h" | ||
41 | 42 | ||
42 | /* Maximum size of the bit-stream (for fixed-size allocation) */ | 43 | /* Maximum size of the bit-stream (for fixed-size allocation) */ |
43 | #ifndef MAX_CHARS_PER_FRAME | 44 | #ifndef MAX_CHARS_PER_FRAME |
diff --git a/apps/codecs/libspeex/cb_search.c b/apps/codecs/libspeex/cb_search.c index ad883cc07f..f7ecca4a62 100644 --- a/apps/codecs/libspeex/cb_search.c +++ b/apps/codecs/libspeex/cb_search.c | |||
@@ -38,6 +38,8 @@ | |||
38 | #include "stack_alloc.h" | 38 | #include "stack_alloc.h" |
39 | #include "vq.h" | 39 | #include "vq.h" |
40 | #include "misc.h" | 40 | #include "misc.h" |
41 | #include "math_approx.h" | ||
42 | #include "os_support.h" | ||
41 | 43 | ||
42 | #ifdef _USE_SSE | 44 | #ifdef _USE_SSE |
43 | #include "cb_search_sse.h" | 45 | #include "cb_search_sse.h" |
diff --git a/apps/codecs/libspeex/fftwrap.c b/apps/codecs/libspeex/fftwrap.c index 38ff9c000c..e4cf3b028b 100644 --- a/apps/codecs/libspeex/fftwrap.c +++ b/apps/codecs/libspeex/fftwrap.c | |||
@@ -41,6 +41,7 @@ | |||
41 | 41 | ||
42 | 42 | ||
43 | #include "misc.h" | 43 | #include "misc.h" |
44 | #include "os_support.h" | ||
44 | 45 | ||
45 | #define MAX_FFT_SIZE 2048 | 46 | #define MAX_FFT_SIZE 2048 |
46 | 47 | ||
diff --git a/apps/codecs/libspeex/filterbank.c b/apps/codecs/libspeex/filterbank.c index 00391ebf7f..f50c70e0ad 100644 --- a/apps/codecs/libspeex/filterbank.c +++ b/apps/codecs/libspeex/filterbank.c | |||
@@ -39,6 +39,7 @@ | |||
39 | #include "misc.h" | 39 | #include "misc.h" |
40 | #include <math.h> | 40 | #include <math.h> |
41 | #include "math_approx.h" | 41 | #include "math_approx.h" |
42 | #include "os_support.h" | ||
42 | 43 | ||
43 | #ifdef FIXED_POINT | 44 | #ifdef FIXED_POINT |
44 | 45 | ||
diff --git a/apps/codecs/libspeex/filters_cf.S b/apps/codecs/libspeex/filters_cf.S index 48804eb571..c9aa742b6f 100644 --- a/apps/codecs/libspeex/filters_cf.S +++ b/apps/codecs/libspeex/filters_cf.S | |||
@@ -245,25 +245,25 @@ qmf_synth: | |||
245 | 1: | Innerloop | 245 | 1: | Innerloop |
246 | move.w (%a0)+, %d3 | d3 = x11 | 246 | move.w (%a0)+, %d3 | d3 = x11 |
247 | move.w (%a1)+, %d5 | d5 = x21 | 247 | move.w (%a1)+, %d5 | d5 = x21 |
248 | mac.w %d6u, %d3l, #1, %acc0 | acc0 += a0*x11 | 248 | mac.w %d6u, %d3l, <<, %acc0 | acc0 += a0*x11 |
249 | msac.w %d6u, %d5l, #1, %acc0 | acc0 -= a0*x21 | 249 | msac.w %d6u, %d5l, <<, %acc0 | acc0 -= a0*x21 |
250 | mac.w %d6l, %d3l, #1, %acc1 | acc1 += a1*x11 | 250 | mac.w %d6l, %d3l, <<, %acc1 | acc1 += a1*x11 |
251 | mac.w %d6l, %d5l, #1, %acc1 | acc1 += a1*x21 | 251 | mac.w %d6l, %d5l, <<, %acc1 | acc1 += a1*x21 |
252 | mac.w %d6u, %d2l, #1, %acc2 | acc2 += a0*x10 | 252 | mac.w %d6u, %d2l, <<, %acc2 | acc2 += a0*x10 |
253 | msac.w %d6u, %d4l, #1, %acc2 | acc2 -= a0*x20 | 253 | msac.w %d6u, %d4l, <<, %acc2 | acc2 -= a0*x20 |
254 | mac.w %d6l, %d2l, #1, %acc3 | acc3 += a1*x10 | 254 | mac.w %d6l, %d2l, <<, %acc3 | acc3 += a1*x10 |
255 | mac.w %d6l, %d4l, #1, (%a2)+, %d6, %acc3 | acc3 += a1*x20 | 255 | mac.w %d6l, %d4l, <<, (%a2)+, %d6, %acc3 | acc3 += a1*x20 |
256 | 256 | ||
257 | move.w (%a0)+, %d2 | d2 = x10 | 257 | move.w (%a0)+, %d2 | d2 = x10 |
258 | move.w (%a1)+, %d4 | d4 = x20 | 258 | move.w (%a1)+, %d4 | d4 = x20 |
259 | mac.w %d6u, %d2l, #1, %acc0 | acc0 += a0*x10 | 259 | mac.w %d6u, %d2l, <<, %acc0 | acc0 += a0*x10 |
260 | msac.w %d6u, %d4l, #1, %acc0 | acc0 -= a0*x20 | 260 | msac.w %d6u, %d4l, <<, %acc0 | acc0 -= a0*x20 |
261 | mac.w %d6l, %d2l, #1, %acc1 | acc1 += a1*x10 | 261 | mac.w %d6l, %d2l, <<, %acc1 | acc1 += a1*x10 |
262 | mac.w %d6l, %d4l, #1, %acc1 | acc1 += a1*x20 | 262 | mac.w %d6l, %d4l, <<, %acc1 | acc1 += a1*x20 |
263 | mac.w %d6u, %d3l, #1, %acc2 | acc2 += a0*x11 | 263 | mac.w %d6u, %d3l, <<, %acc2 | acc2 += a0*x11 |
264 | msac.w %d6u, %d5l, #1, %acc2 | acc2 -= a0*x21 | 264 | msac.w %d6u, %d5l, <<, %acc2 | acc2 -= a0*x21 |
265 | mac.w %d6l, %d3l, #1, %acc3 | acc3 += a1*x11 | 265 | mac.w %d6l, %d3l, <<, %acc3 | acc3 += a1*x11 |
266 | mac.w %d6l, %d5l, #1, (%a2)+, %d6, %acc3 | acc3 += a1*x21 | 266 | mac.w %d6l, %d5l, <<, (%a2)+, %d6, %acc3 | acc3 += a1*x21 |
267 | subq.l #2, %d1 | 267 | subq.l #2, %d1 |
268 | jne 1b | 268 | jne 1b |
269 | 269 | ||
diff --git a/apps/codecs/libspeex/jitter.c b/apps/codecs/libspeex/jitter.c index 5d1fc6a2b3..57bb4c2958 100644 --- a/apps/codecs/libspeex/jitter.c +++ b/apps/codecs/libspeex/jitter.c | |||
@@ -41,6 +41,7 @@ | |||
41 | #include <speex/speex.h> | 41 | #include <speex/speex.h> |
42 | #include <speex/speex_bits.h> | 42 | #include <speex/speex_bits.h> |
43 | #include <speex/speex_jitter.h> | 43 | #include <speex/speex_jitter.h> |
44 | #include "os_support.h" | ||
44 | 45 | ||
45 | #ifndef NULL | 46 | #ifndef NULL |
46 | #define NULL 0 | 47 | #define NULL 0 |
diff --git a/apps/codecs/libspeex/kiss_fft.c b/apps/codecs/libspeex/kiss_fft.c index c5c0345820..599ba66845 100644 --- a/apps/codecs/libspeex/kiss_fft.c +++ b/apps/codecs/libspeex/kiss_fft.c | |||
@@ -20,6 +20,7 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | |||
20 | 20 | ||
21 | #include "_kiss_fft_guts.h" | 21 | #include "_kiss_fft_guts.h" |
22 | #include "misc.h" | 22 | #include "misc.h" |
23 | #include "os_support.h" | ||
23 | 24 | ||
24 | /* The guts header contains all the multiplication and addition macros that are defined for | 25 | /* The guts header contains all the multiplication and addition macros that are defined for |
25 | fixed or floating point complex numbers. It also delares the kf_ internal functions. | 26 | fixed or floating point complex numbers. It also delares the kf_ internal functions. |
diff --git a/apps/codecs/libspeex/kiss_fftr.c b/apps/codecs/libspeex/kiss_fftr.c index 9bb4763169..1c694b195d 100644 --- a/apps/codecs/libspeex/kiss_fftr.c +++ b/apps/codecs/libspeex/kiss_fftr.c | |||
@@ -16,6 +16,7 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | |||
16 | #include "config-speex.h" | 16 | #include "config-speex.h" |
17 | #endif | 17 | #endif |
18 | 18 | ||
19 | #include "os_support.h" | ||
19 | #include "kiss_fftr.h" | 20 | #include "kiss_fftr.h" |
20 | #include "_kiss_fft_guts.h" | 21 | #include "_kiss_fft_guts.h" |
21 | 22 | ||
diff --git a/apps/codecs/libspeex/math_approx.c b/apps/codecs/libspeex/math_approx.c deleted file mode 100644 index cf5853e313..0000000000 --- a/apps/codecs/libspeex/math_approx.c +++ /dev/null | |||
@@ -1,38 +0,0 @@ | |||
1 | /* Copyright (C) 2002 Jean-Marc Valin | ||
2 | File: math_approx.c | ||
3 | Various math approximation functions for Speex | ||
4 | |||
5 | Redistribution and use in source and binary forms, with or without | ||
6 | modification, are permitted provided that the following conditions | ||
7 | are met: | ||
8 | |||
9 | - Redistributions of source code must retain the above copyright | ||
10 | notice, this list of conditions and the following disclaimer. | ||
11 | |||
12 | - Redistributions in binary form must reproduce the above copyright | ||
13 | notice, this list of conditions and the following disclaimer in the | ||
14 | documentation and/or other materials provided with the distribution. | ||
15 | |||
16 | - Neither the name of the Xiph.org Foundation nor the names of its | ||
17 | contributors may be used to endorse or promote products derived from | ||
18 | this software without specific prior written permission. | ||
19 | |||
20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
21 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
22 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
23 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR | ||
24 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
25 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
26 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
27 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
28 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
29 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
30 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
31 | */ | ||
32 | |||
33 | #ifdef HAVE_CONFIG_H | ||
34 | #include "config-speex.h" | ||
35 | #endif | ||
36 | |||
37 | #include "math_approx.h" | ||
38 | #include "misc.h" | ||
diff --git a/apps/codecs/libspeex/math_approx.h b/apps/codecs/libspeex/math_approx.h index 8421d634bb..4f61e8645a 100644 --- a/apps/codecs/libspeex/math_approx.h +++ b/apps/codecs/libspeex/math_approx.h | |||
@@ -45,8 +45,20 @@ | |||
45 | #define spx_cos_norm(x) (cos((.5f*M_PI)*(x))) | 45 | #define spx_cos_norm(x) (cos((.5f*M_PI)*(x))) |
46 | #define spx_atan atan | 46 | #define spx_atan atan |
47 | 47 | ||
48 | #endif | 48 | /** Generate a pseudo-random number */ |
49 | static inline spx_word16_t speex_rand(spx_word16_t std, spx_int32_t *seed) | ||
50 | { | ||
51 | const unsigned int jflone = 0x3f800000; | ||
52 | const unsigned int jflmsk = 0x007fffff; | ||
53 | union {int i; float f;} ran; | ||
54 | *seed = 1664525 * *seed + 1013904223; | ||
55 | ran.i = jflone | (jflmsk & *seed); | ||
56 | ran.f -= 1.5; | ||
57 | return 3.4642*std*ran.f; | ||
58 | } | ||
59 | |||
49 | 60 | ||
61 | #endif | ||
50 | 62 | ||
51 | 63 | ||
52 | static inline spx_int16_t spx_ilog2(spx_uint32_t x) | 64 | static inline spx_int16_t spx_ilog2(spx_uint32_t x) |
@@ -106,6 +118,15 @@ static inline spx_int16_t spx_ilog4(spx_uint32_t x) | |||
106 | 118 | ||
107 | #ifdef FIXED_POINT | 119 | #ifdef FIXED_POINT |
108 | 120 | ||
121 | /** Generate a pseudo-random number */ | ||
122 | static inline spx_word16_t speex_rand(spx_word16_t std, spx_int32_t *seed) | ||
123 | { | ||
124 | spx_word32_t res; | ||
125 | *seed = 1664525 * *seed + 1013904223; | ||
126 | res = MULT16_16(EXTRACT16(SHR32(*seed,16)),std); | ||
127 | return EXTRACT16(PSHR32(SUB32(res, SHR32(res, 3)),14)); | ||
128 | } | ||
129 | |||
109 | /* sqrt(x) ~= 0.22178 + 1.29227*x - 0.77070*x^2 + 0.25723*x^3 (for .25 < x < 1) */ | 130 | /* sqrt(x) ~= 0.22178 + 1.29227*x - 0.77070*x^2 + 0.25723*x^3 (for .25 < x < 1) */ |
110 | /*#define C0 3634 | 131 | /*#define C0 3634 |
111 | #define C1 21173 | 132 | #define C1 21173 |
diff --git a/apps/codecs/libspeex/mdf.c b/apps/codecs/libspeex/mdf.c index e9ea0fadba..8840c34e08 100644 --- a/apps/codecs/libspeex/mdf.c +++ b/apps/codecs/libspeex/mdf.c | |||
@@ -74,6 +74,7 @@ | |||
74 | #include "fftwrap.h" | 74 | #include "fftwrap.h" |
75 | #include "pseudofloat.h" | 75 | #include "pseudofloat.h" |
76 | #include "math_approx.h" | 76 | #include "math_approx.h" |
77 | #include "os_support.h" | ||
77 | 78 | ||
78 | #ifndef M_PI | 79 | #ifndef M_PI |
79 | #define M_PI 3.14159265358979323846 | 80 | #define M_PI 3.14159265358979323846 |
diff --git a/apps/codecs/libspeex/misc.c b/apps/codecs/libspeex/misc.c deleted file mode 100644 index e33b910850..0000000000 --- a/apps/codecs/libspeex/misc.c +++ /dev/null | |||
@@ -1,49 +0,0 @@ | |||
1 | /* Copyright (C) 2002-2005 Jean-Marc Valin | ||
2 | File: misc.c | ||
3 | Various utility routines for Speex | ||
4 | |||
5 | Redistribution and use in source and binary forms, with or without | ||
6 | modification, are permitted provided that the following conditions | ||
7 | are met: | ||
8 | |||
9 | - Redistributions of source code must retain the above copyright | ||
10 | notice, this list of conditions and the following disclaimer. | ||
11 | |||
12 | - Redistributions in binary form must reproduce the above copyright | ||
13 | notice, this list of conditions and the following disclaimer in the | ||
14 | documentation and/or other materials provided with the distribution. | ||
15 | |||
16 | - Neither the name of the Xiph.org Foundation nor the names of its | ||
17 | contributors may be used to endorse or promote products derived from | ||
18 | this software without specific prior written permission. | ||
19 | |||
20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
21 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
22 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
23 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR | ||
24 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
25 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
26 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
27 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
28 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
29 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
30 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
31 | */ | ||
32 | |||
33 | #ifdef HAVE_CONFIG_H | ||
34 | #include "config-speex.h" | ||
35 | #endif | ||
36 | |||
37 | #include <stdlib.h> | ||
38 | #include <string.h> | ||
39 | #include <stdio.h> | ||
40 | #include "misc.h" | ||
41 | |||
42 | #ifdef USER_MISC | ||
43 | #include "user_misc.h" | ||
44 | #endif | ||
45 | |||
46 | #ifdef BFIN_ASM | ||
47 | #include "misc_bfin.h" | ||
48 | #endif | ||
49 | |||
diff --git a/apps/codecs/libspeex/misc.h b/apps/codecs/libspeex/misc.h index 8702919b7b..7dcc4f25f9 100644 --- a/apps/codecs/libspeex/misc.h +++ b/apps/codecs/libspeex/misc.h | |||
@@ -40,9 +40,9 @@ | |||
40 | #ifndef SPEEX_VERSION | 40 | #ifndef SPEEX_VERSION |
41 | #define SPEEX_MAJOR_VERSION 1 /**< Major Speex version. */ | 41 | #define SPEEX_MAJOR_VERSION 1 /**< Major Speex version. */ |
42 | #define SPEEX_MINOR_VERSION 1 /**< Minor Speex version. */ | 42 | #define SPEEX_MINOR_VERSION 1 /**< Minor Speex version. */ |
43 | #define SPEEX_MICRO_VERSION 14 /**< Micro Speex version. */ | 43 | #define SPEEX_MICRO_VERSION 15 /**< Micro Speex version. */ |
44 | #define SPEEX_EXTRA_VERSION "" /**< Extra Speex version. */ | 44 | #define SPEEX_EXTRA_VERSION "" /**< Extra Speex version. */ |
45 | #define SPEEX_VERSION "speex-1.2beta2" /**< Speex version string. */ | 45 | #define SPEEX_VERSION "speex-1.2beta3" /**< Speex version string. */ |
46 | #endif | 46 | #endif |
47 | 47 | ||
48 | /* A couple test to catch stupid option combinations */ | 48 | /* A couple test to catch stupid option combinations */ |
@@ -71,7 +71,6 @@ | |||
71 | #endif | 71 | #endif |
72 | 72 | ||
73 | #include "arch.h" | 73 | #include "arch.h" |
74 | #include "rockbox.h" | ||
75 | 74 | ||
76 | /** Convert little endian */ | 75 | /** Convert little endian */ |
77 | static inline spx_int32_t le_int(spx_int32_t i) | 76 | static inline spx_int32_t le_int(spx_int32_t i) |
@@ -91,138 +90,10 @@ static inline spx_int32_t le_int(spx_int32_t i) | |||
91 | #endif | 90 | #endif |
92 | } | 91 | } |
93 | 92 | ||
94 | #define speex_fatal(str) _speex_fatal(str, __FILE__, __LINE__); | ||
95 | #define speex_assert(cond) {if (!(cond)) {speex_fatal("assertion failed: " #cond);}} | ||
96 | |||
97 | #ifndef RELEASE | ||
98 | static void print_vec(float *vec, int len, char *name) | ||
99 | { | ||
100 | int i; | ||
101 | printf ("%s ", name); | ||
102 | for (i=0;i<len;i++) | ||
103 | printf (" %f", vec[i]); | ||
104 | printf ("\n"); | ||
105 | } | ||
106 | #endif | ||
107 | 93 | ||
108 | #ifdef FIXED_DEBUG | 94 | #ifdef FIXED_DEBUG |
109 | long long spx_mips=0; | 95 | long long spx_mips=0; |
110 | #endif | 96 | #endif |
111 | 97 | ||
112 | 98 | ||
113 | /** Speex wrapper for calloc. To do your own dynamic allocation, all you need to do is replace this function, speex_realloc and speex_free */ | ||
114 | #ifndef OVERRIDE_SPEEX_ALLOC | ||
115 | static inline void *speex_alloc (int size) | ||
116 | { | ||
117 | return calloc(size,1); | ||
118 | } | ||
119 | #endif | ||
120 | |||
121 | /** Same as speex_alloc, except that the area is only needed inside a Speex call (might cause problem with wideband though) */ | ||
122 | #ifndef OVERRIDE_SPEEX_ALLOC_SCRATCH | ||
123 | static inline void *speex_alloc_scratch (int size) | ||
124 | { | ||
125 | return calloc(size,1); | ||
126 | } | ||
127 | #endif | ||
128 | |||
129 | /** Speex wrapper for realloc. To do your own dynamic allocation, all you need to do is replace this function, speex_alloc and speex_free */ | ||
130 | #ifndef OVERRIDE_SPEEX_REALLOC | ||
131 | static inline void *speex_realloc (void *ptr, int size) | ||
132 | { | ||
133 | return realloc(ptr, size); | ||
134 | } | ||
135 | #endif | ||
136 | |||
137 | /** Speex wrapper for calloc. To do your own dynamic allocation, all you need to do is replace this function, speex_realloc and speex_alloc */ | ||
138 | #ifndef OVERRIDE_SPEEX_FREE | ||
139 | static inline void speex_free (void *ptr) | ||
140 | { | ||
141 | free(ptr); | ||
142 | } | ||
143 | #endif | ||
144 | |||
145 | /** Same as speex_free, except that the area is only needed inside a Speex call (might cause problem with wideband though) */ | ||
146 | #ifndef OVERRIDE_SPEEX_FREE_SCRATCH | ||
147 | static inline void speex_free_scratch (void *ptr) | ||
148 | { | ||
149 | free(ptr); | ||
150 | } | ||
151 | #endif | ||
152 | |||
153 | /** Print warning message with integer argument to stderr */ | ||
154 | #ifndef OVERRIDE_SPEEX_MOVE | ||
155 | static inline void *speex_move (void *dest, void *src, int n) | ||
156 | { | ||
157 | return memmove(dest,src,n); | ||
158 | } | ||
159 | #endif | ||
160 | |||
161 | #ifndef OVERRIDE_SPEEX_FATAL | ||
162 | static inline void _speex_fatal(const char *str, const char *file, int line) | ||
163 | { | ||
164 | fprintf (stderr, "Fatal (internal) error in %s, line %d: %s\n", file, line, str); | ||
165 | exit(1); | ||
166 | } | ||
167 | #endif | ||
168 | |||
169 | #ifndef OVERRIDE_SPEEX_WARNING | ||
170 | static inline void speex_warning(const char *str) | ||
171 | { | ||
172 | #ifndef DISABLE_WARNINGS | ||
173 | fprintf (stderr, "warning: %s\n", str); | ||
174 | #endif | ||
175 | } | ||
176 | #endif | ||
177 | |||
178 | #ifndef OVERRIDE_SPEEX_WARNING_INT | ||
179 | static inline void speex_warning_int(const char *str, int val) | ||
180 | { | ||
181 | #ifndef DISABLE_WARNINGS | ||
182 | fprintf (stderr, "warning: %s %d\n", str, val); | ||
183 | #endif | ||
184 | } | ||
185 | #endif | ||
186 | |||
187 | #ifndef OVERRIDE_SPEEX_NOTIFY | ||
188 | static inline void speex_notify(const char *str) | ||
189 | { | ||
190 | #ifndef DISABLE_NOTIFICATIONS | ||
191 | fprintf (stderr, "notification: %s\n", str); | ||
192 | #endif | ||
193 | } | ||
194 | #endif | ||
195 | |||
196 | #ifdef FIXED_POINT | ||
197 | /** Generate a pseudo-random number */ | ||
198 | static inline spx_word16_t speex_rand(spx_word16_t std, spx_int32_t *seed) | ||
199 | { | ||
200 | spx_word32_t res; | ||
201 | *seed = 1664525 * *seed + 1013904223; | ||
202 | res = MULT16_16(EXTRACT16(SHR32(*seed,16)),std); | ||
203 | return EXTRACT16(PSHR32(SUB32(res, SHR32(res, 3)),14)); | ||
204 | } | ||
205 | #else | ||
206 | /** Generate a pseudo-random number */ | ||
207 | static inline spx_word16_t speex_rand(spx_word16_t std, spx_int32_t *seed) | ||
208 | { | ||
209 | const unsigned int jflone = 0x3f800000; | ||
210 | const unsigned int jflmsk = 0x007fffff; | ||
211 | union {int i; float f;} ran; | ||
212 | *seed = 1664525 * *seed + 1013904223; | ||
213 | ran.i = jflone | (jflmsk & *seed); | ||
214 | ran.f -= 1.5; | ||
215 | return 3.4642*std*ran.f; | ||
216 | } | ||
217 | #endif | ||
218 | |||
219 | #ifndef OVERRIDE_SPEEX_PUTC | ||
220 | /** Speex wrapper for putc */ | ||
221 | static inline void _speex_putc(int ch, void *file) | ||
222 | { | ||
223 | FILE *f = (FILE *)file; | ||
224 | fprintf(f, "%c", ch); | ||
225 | } | ||
226 | #endif | ||
227 | |||
228 | #endif | 99 | #endif |
diff --git a/apps/codecs/libspeex/modes.c b/apps/codecs/libspeex/modes.c index 1d30ce4a15..7906ab5faa 100644 --- a/apps/codecs/libspeex/modes.c +++ b/apps/codecs/libspeex/modes.c | |||
@@ -50,21 +50,16 @@ | |||
50 | #define NULL 0 | 50 | #define NULL 0 |
51 | #endif | 51 | #endif |
52 | 52 | ||
53 | #define MAX_IN_SAMPLES 640 | ||
54 | |||
55 | const SpeexMode * const speex_mode_list[SPEEX_NB_MODES] = {&speex_nb_mode, &speex_wb_mode, &speex_uwb_mode}; | ||
56 | 53 | ||
57 | /* Extern declarations for all codebooks we use here */ | 54 | /* Extern declarations for all codebooks we use here */ |
58 | extern const signed char gain_cdbk_nb[]; | 55 | extern const signed char gain_cdbk_nb[]; |
59 | extern const signed char gain_cdbk_lbr[]; | 56 | extern const signed char gain_cdbk_lbr[]; |
60 | extern const signed char hexc_table[]; | ||
61 | extern const signed char exc_5_256_table[]; | 57 | extern const signed char exc_5_256_table[]; |
62 | extern const signed char exc_5_64_table[]; | 58 | extern const signed char exc_5_64_table[]; |
63 | extern const signed char exc_8_128_table[]; | 59 | extern const signed char exc_8_128_table[]; |
64 | extern const signed char exc_10_32_table[]; | 60 | extern const signed char exc_10_32_table[]; |
65 | extern const signed char exc_10_16_table[]; | 61 | extern const signed char exc_10_16_table[]; |
66 | extern const signed char exc_20_32_table[]; | 62 | extern const signed char exc_20_32_table[]; |
67 | extern const signed char hexc_10_32_table[]; | ||
68 | 63 | ||
69 | 64 | ||
70 | /* Parameters for Long-Term Prediction (LTP)*/ | 65 | /* Parameters for Long-Term Prediction (LTP)*/ |
@@ -150,29 +145,8 @@ static const split_cb_params split_cb_sb = { | |||
150 | 0, | 145 | 0, |
151 | }; | 146 | }; |
152 | 147 | ||
153 | #ifndef DISABLE_WIDEBAND | ||
154 | |||
155 | /* Split-VQ innovation for high-band wideband */ | ||
156 | static const split_cb_params split_cb_high = { | ||
157 | 8, /*subvect_size*/ | ||
158 | 5, /*nb_subvect*/ | ||
159 | hexc_table, /*shape_cb*/ | ||
160 | 7, /*shape_bits*/ | ||
161 | 1, | ||
162 | }; | ||
163 | 148 | ||
164 | 149 | ||
165 | /* Split-VQ innovation for high-band wideband */ | ||
166 | static const split_cb_params split_cb_high_lbr = { | ||
167 | 10, /*subvect_size*/ | ||
168 | 4, /*nb_subvect*/ | ||
169 | hexc_10_32_table, /*shape_cb*/ | ||
170 | 5, /*shape_bits*/ | ||
171 | 0, | ||
172 | }; | ||
173 | |||
174 | #endif | ||
175 | |||
176 | /* 2150 bps "vocoder-like" mode for comfort noise */ | 150 | /* 2150 bps "vocoder-like" mode for comfort noise */ |
177 | static const SpeexSubmode nb_submode1 = { | 151 | static const SpeexSubmode nb_submode1 = { |
178 | 0, | 152 | 0, |
@@ -386,189 +360,6 @@ const SpeexMode speex_nb_mode = { | |||
386 | 360 | ||
387 | /* Wideband part */ | 361 | /* Wideband part */ |
388 | 362 | ||
389 | static const SpeexSubmode wb_submode1 = { | ||
390 | 0, | ||
391 | 0, | ||
392 | 1, | ||
393 | 0, | ||
394 | /*LSP quantization*/ | ||
395 | lsp_quant_high, | ||
396 | lsp_unquant_high, | ||
397 | /*Pitch quantization*/ | ||
398 | NULL, | ||
399 | NULL, | ||
400 | NULL, | ||
401 | /*No innovation quantization*/ | ||
402 | NULL, | ||
403 | NULL, | ||
404 | NULL, | ||
405 | -1, | ||
406 | 36 | ||
407 | }; | ||
408 | |||
409 | |||
410 | static const SpeexSubmode wb_submode2 = { | ||
411 | 0, | ||
412 | 0, | ||
413 | 1, | ||
414 | 0, | ||
415 | /*LSP quantization*/ | ||
416 | lsp_quant_high, | ||
417 | lsp_unquant_high, | ||
418 | /*Pitch quantization*/ | ||
419 | NULL, | ||
420 | NULL, | ||
421 | NULL, | ||
422 | /*Innovation quantization*/ | ||
423 | split_cb_search_shape_sign, | ||
424 | split_cb_shape_sign_unquant, | ||
425 | #ifdef DISABLE_WIDEBAND | ||
426 | NULL, | ||
427 | #else | ||
428 | &split_cb_high_lbr, | ||
429 | #endif | ||
430 | -1, | ||
431 | 112 | ||
432 | }; | ||
433 | |||
434 | |||
435 | static const SpeexSubmode wb_submode3 = { | ||
436 | 0, | ||
437 | 0, | ||
438 | 1, | ||
439 | 0, | ||
440 | /*LSP quantization*/ | ||
441 | lsp_quant_high, | ||
442 | lsp_unquant_high, | ||
443 | /*Pitch quantization*/ | ||
444 | NULL, | ||
445 | NULL, | ||
446 | NULL, | ||
447 | /*Innovation quantization*/ | ||
448 | split_cb_search_shape_sign, | ||
449 | split_cb_shape_sign_unquant, | ||
450 | #ifdef DISABLE_WIDEBAND | ||
451 | NULL, | ||
452 | #else | ||
453 | &split_cb_high, | ||
454 | #endif | ||
455 | -1, | ||
456 | 192 | ||
457 | }; | ||
458 | |||
459 | static const SpeexSubmode wb_submode4 = { | ||
460 | 0, | ||
461 | 0, | ||
462 | 1, | ||
463 | 1, | ||
464 | /*LSP quantization*/ | ||
465 | lsp_quant_high, | ||
466 | lsp_unquant_high, | ||
467 | /*Pitch quantization*/ | ||
468 | NULL, | ||
469 | NULL, | ||
470 | NULL, | ||
471 | /*Innovation quantization*/ | ||
472 | split_cb_search_shape_sign, | ||
473 | split_cb_shape_sign_unquant, | ||
474 | #ifdef DISABLE_WIDEBAND | ||
475 | NULL, | ||
476 | #else | ||
477 | &split_cb_high, | ||
478 | #endif | ||
479 | -1, | ||
480 | 352 | ||
481 | }; | ||
482 | |||
483 | |||
484 | /* Split-band wideband CELP mode*/ | ||
485 | static const SpeexSBMode sb_wb_mode = { | ||
486 | &speex_nb_mode, | ||
487 | 160, /*frameSize*/ | ||
488 | 40, /*subframeSize*/ | ||
489 | 8, /*lpcSize*/ | ||
490 | 640, /*bufSize*/ | ||
491 | #ifdef FIXED_POINT | ||
492 | 29491, 19661, /* gamma1, gamma2 */ | ||
493 | #else | ||
494 | 0.9, 0.6, /* gamma1, gamma2 */ | ||
495 | #endif | ||
496 | .012, /*lag_factor*/ | ||
497 | QCONST16(.0002,15), /*lpc_floor*/ | ||
498 | QCONST16(0.9f,15), | ||
499 | {NULL, &wb_submode1, &wb_submode2, &wb_submode3, &wb_submode4, NULL, NULL, NULL}, | ||
500 | 3, | ||
501 | {1, 8, 2, 3, 4, 5, 5, 6, 6, 7, 7}, | ||
502 | {1, 1, 1, 1, 1, 1, 2, 2, 3, 3, 4}, | ||
503 | vbr_hb_thresh, | ||
504 | 5 | ||
505 | }; | ||
506 | |||
507 | |||
508 | const SpeexMode speex_wb_mode = { | ||
509 | &sb_wb_mode, | ||
510 | wb_mode_query, | ||
511 | "wideband (sub-band CELP)", | ||
512 | 1, | ||
513 | 4, | ||
514 | &sb_encoder_init, | ||
515 | &sb_encoder_destroy, | ||
516 | &sb_encode, | ||
517 | &sb_decoder_init, | ||
518 | &sb_decoder_destroy, | ||
519 | &sb_decode, | ||
520 | &sb_encoder_ctl, | ||
521 | &sb_decoder_ctl, | ||
522 | }; | ||
523 | |||
524 | |||
525 | |||
526 | /* "Ultra-wideband" mode stuff */ | ||
527 | |||
528 | |||
529 | |||
530 | /* Split-band "ultra-wideband" (32 kbps) CELP mode*/ | ||
531 | static const SpeexSBMode sb_uwb_mode = { | ||
532 | &speex_wb_mode, | ||
533 | 320, /*frameSize*/ | ||
534 | 80, /*subframeSize*/ | ||
535 | 8, /*lpcSize*/ | ||
536 | 1280, /*bufSize*/ | ||
537 | #ifdef FIXED_POINT | ||
538 | 29491, 19661, /* gamma1, gamma2 */ | ||
539 | #else | ||
540 | 0.9, 0.6, /* gamma1, gamma2 */ | ||
541 | #endif | ||
542 | .012, /*lag_factor*/ | ||
543 | QCONST16(.0002,15), /*lpc_floor*/ | ||
544 | QCONST16(0.7f,15), | ||
545 | {NULL, &wb_submode1, NULL, NULL, NULL, NULL, NULL, NULL}, | ||
546 | 1, | ||
547 | {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, | ||
548 | {0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, | ||
549 | vbr_uhb_thresh, | ||
550 | 2 | ||
551 | }; | ||
552 | |||
553 | |||
554 | const SpeexMode speex_uwb_mode = { | ||
555 | &sb_uwb_mode, | ||
556 | wb_mode_query, | ||
557 | "ultra-wideband (sub-band CELP)", | ||
558 | 2, | ||
559 | 4, | ||
560 | &sb_encoder_init, | ||
561 | &sb_encoder_destroy, | ||
562 | &sb_encode, | ||
563 | &sb_decoder_init, | ||
564 | &sb_decoder_destroy, | ||
565 | &sb_decode, | ||
566 | &sb_encoder_ctl, | ||
567 | &sb_decoder_ctl, | ||
568 | }; | ||
569 | |||
570 | |||
571 | |||
572 | 363 | ||
573 | #ifdef EPIC_48K | 364 | #ifdef EPIC_48K |
574 | 365 | ||
@@ -656,13 +447,3 @@ int speex_mode_query(const SpeexMode *mode, int request, void *ptr) | |||
656 | return mode->query(mode->mode, request, ptr); | 447 | return mode->query(mode->mode, request, ptr); |
657 | } | 448 | } |
658 | 449 | ||
659 | const SpeexMode * speex_lib_get_mode (int mode) | ||
660 | { | ||
661 | #ifdef EPIC_48K | ||
662 | if (mode == SPEEX_MODEID_NB_48K) return &speex_nb_48k_mode; | ||
663 | #endif | ||
664 | |||
665 | if (mode < 0 || mode >= SPEEX_NB_MODES) return NULL; | ||
666 | |||
667 | return speex_mode_list[mode]; | ||
668 | } | ||
diff --git a/apps/codecs/libspeex/modes_wb.c b/apps/codecs/libspeex/modes_wb.c new file mode 100644 index 0000000000..862bd6fa31 --- /dev/null +++ b/apps/codecs/libspeex/modes_wb.c | |||
@@ -0,0 +1,304 @@ | |||
1 | /* Copyright (C) 2002-2007 Jean-Marc Valin | ||
2 | File: modes.c | ||
3 | |||
4 | Describes the wideband modes of the codec | ||
5 | |||
6 | Redistribution and use in source and binary forms, with or without | ||
7 | modification, are permitted provided that the following conditions | ||
8 | are met: | ||
9 | |||
10 | - Redistributions of source code must retain the above copyright | ||
11 | notice, this list of conditions and the following disclaimer. | ||
12 | |||
13 | - Redistributions in binary form must reproduce the above copyright | ||
14 | notice, this list of conditions and the following disclaimer in the | ||
15 | documentation and/or other materials provided with the distribution. | ||
16 | |||
17 | - Neither the name of the Xiph.org Foundation nor the names of its | ||
18 | contributors may be used to endorse or promote products derived from | ||
19 | this software without specific prior written permission. | ||
20 | |||
21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
22 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
23 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
24 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR | ||
25 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
26 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
27 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
28 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
29 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
30 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
31 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
32 | |||
33 | */ | ||
34 | |||
35 | #ifdef HAVE_CONFIG_H | ||
36 | #include "config-speex.h" | ||
37 | #endif | ||
38 | |||
39 | #include "modes.h" | ||
40 | #include "ltp.h" | ||
41 | #include "quant_lsp.h" | ||
42 | #include "cb_search.h" | ||
43 | #include "sb_celp.h" | ||
44 | #include "nb_celp.h" | ||
45 | #include "vbr.h" | ||
46 | #include "misc.h" | ||
47 | #include <math.h> | ||
48 | #include "os_support.h" | ||
49 | |||
50 | |||
51 | #ifndef NULL | ||
52 | #define NULL 0 | ||
53 | #endif | ||
54 | |||
55 | const SpeexMode * const speex_mode_list[SPEEX_NB_MODES] = {&speex_nb_mode, &speex_wb_mode, &speex_uwb_mode}; | ||
56 | |||
57 | extern const signed char hexc_table[]; | ||
58 | extern const signed char hexc_10_32_table[]; | ||
59 | |||
60 | #ifndef DISABLE_WIDEBAND | ||
61 | |||
62 | /* Split-VQ innovation for high-band wideband */ | ||
63 | static const split_cb_params split_cb_high = { | ||
64 | 8, /*subvect_size*/ | ||
65 | 5, /*nb_subvect*/ | ||
66 | hexc_table, /*shape_cb*/ | ||
67 | 7, /*shape_bits*/ | ||
68 | 1, | ||
69 | }; | ||
70 | |||
71 | |||
72 | /* Split-VQ innovation for high-band wideband */ | ||
73 | static const split_cb_params split_cb_high_lbr = { | ||
74 | 10, /*subvect_size*/ | ||
75 | 4, /*nb_subvect*/ | ||
76 | hexc_10_32_table, /*shape_cb*/ | ||
77 | 5, /*shape_bits*/ | ||
78 | 0, | ||
79 | }; | ||
80 | |||
81 | #endif | ||
82 | |||
83 | |||
84 | static const SpeexSubmode wb_submode1 = { | ||
85 | 0, | ||
86 | 0, | ||
87 | 1, | ||
88 | 0, | ||
89 | /*LSP quantization*/ | ||
90 | lsp_quant_high, | ||
91 | lsp_unquant_high, | ||
92 | /*Pitch quantization*/ | ||
93 | NULL, | ||
94 | NULL, | ||
95 | NULL, | ||
96 | /*No innovation quantization*/ | ||
97 | NULL, | ||
98 | NULL, | ||
99 | NULL, | ||
100 | -1, | ||
101 | 36 | ||
102 | }; | ||
103 | |||
104 | |||
105 | static const SpeexSubmode wb_submode2 = { | ||
106 | 0, | ||
107 | 0, | ||
108 | 1, | ||
109 | 0, | ||
110 | /*LSP quantization*/ | ||
111 | lsp_quant_high, | ||
112 | lsp_unquant_high, | ||
113 | /*Pitch quantization*/ | ||
114 | NULL, | ||
115 | NULL, | ||
116 | NULL, | ||
117 | /*Innovation quantization*/ | ||
118 | split_cb_search_shape_sign, | ||
119 | split_cb_shape_sign_unquant, | ||
120 | #ifdef DISABLE_WIDEBAND | ||
121 | NULL, | ||
122 | #else | ||
123 | &split_cb_high_lbr, | ||
124 | #endif | ||
125 | -1, | ||
126 | 112 | ||
127 | }; | ||
128 | |||
129 | |||
130 | static const SpeexSubmode wb_submode3 = { | ||
131 | 0, | ||
132 | 0, | ||
133 | 1, | ||
134 | 0, | ||
135 | /*LSP quantization*/ | ||
136 | lsp_quant_high, | ||
137 | lsp_unquant_high, | ||
138 | /*Pitch quantization*/ | ||
139 | NULL, | ||
140 | NULL, | ||
141 | NULL, | ||
142 | /*Innovation quantization*/ | ||
143 | split_cb_search_shape_sign, | ||
144 | split_cb_shape_sign_unquant, | ||
145 | #ifdef DISABLE_WIDEBAND | ||
146 | NULL, | ||
147 | #else | ||
148 | &split_cb_high, | ||
149 | #endif | ||
150 | -1, | ||
151 | 192 | ||
152 | }; | ||
153 | |||
154 | static const SpeexSubmode wb_submode4 = { | ||
155 | 0, | ||
156 | 0, | ||
157 | 1, | ||
158 | 1, | ||
159 | /*LSP quantization*/ | ||
160 | lsp_quant_high, | ||
161 | lsp_unquant_high, | ||
162 | /*Pitch quantization*/ | ||
163 | NULL, | ||
164 | NULL, | ||
165 | NULL, | ||
166 | /*Innovation quantization*/ | ||
167 | split_cb_search_shape_sign, | ||
168 | split_cb_shape_sign_unquant, | ||
169 | #ifdef DISABLE_WIDEBAND | ||
170 | NULL, | ||
171 | #else | ||
172 | &split_cb_high, | ||
173 | #endif | ||
174 | -1, | ||
175 | 352 | ||
176 | }; | ||
177 | |||
178 | |||
179 | /* Split-band wideband CELP mode*/ | ||
180 | static const SpeexSBMode sb_wb_mode = { | ||
181 | &speex_nb_mode, | ||
182 | 160, /*frameSize*/ | ||
183 | 40, /*subframeSize*/ | ||
184 | 8, /*lpcSize*/ | ||
185 | 640, /*bufSize*/ | ||
186 | #ifdef FIXED_POINT | ||
187 | 29491, 19661, /* gamma1, gamma2 */ | ||
188 | #else | ||
189 | 0.9, 0.6, /* gamma1, gamma2 */ | ||
190 | #endif | ||
191 | .012, /*lag_factor*/ | ||
192 | QCONST16(.0002,15), /*lpc_floor*/ | ||
193 | QCONST16(0.9f,15), | ||
194 | {NULL, &wb_submode1, &wb_submode2, &wb_submode3, &wb_submode4, NULL, NULL, NULL}, | ||
195 | 3, | ||
196 | {1, 8, 2, 3, 4, 5, 5, 6, 6, 7, 7}, | ||
197 | {1, 1, 1, 1, 1, 1, 2, 2, 3, 3, 4}, | ||
198 | vbr_hb_thresh, | ||
199 | 5 | ||
200 | }; | ||
201 | |||
202 | |||
203 | const SpeexMode speex_wb_mode = { | ||
204 | &sb_wb_mode, | ||
205 | wb_mode_query, | ||
206 | "wideband (sub-band CELP)", | ||
207 | 1, | ||
208 | 4, | ||
209 | &sb_encoder_init, | ||
210 | &sb_encoder_destroy, | ||
211 | &sb_encode, | ||
212 | &sb_decoder_init, | ||
213 | &sb_decoder_destroy, | ||
214 | &sb_decode, | ||
215 | &sb_encoder_ctl, | ||
216 | &sb_decoder_ctl, | ||
217 | }; | ||
218 | |||
219 | |||
220 | |||
221 | /* "Ultra-wideband" mode stuff */ | ||
222 | |||
223 | |||
224 | |||
225 | /* Split-band "ultra-wideband" (32 kbps) CELP mode*/ | ||
226 | static const SpeexSBMode sb_uwb_mode = { | ||
227 | &speex_wb_mode, | ||
228 | 320, /*frameSize*/ | ||
229 | 80, /*subframeSize*/ | ||
230 | 8, /*lpcSize*/ | ||
231 | 1280, /*bufSize*/ | ||
232 | #ifdef FIXED_POINT | ||
233 | 29491, 19661, /* gamma1, gamma2 */ | ||
234 | #else | ||
235 | 0.9, 0.6, /* gamma1, gamma2 */ | ||
236 | #endif | ||
237 | .012, /*lag_factor*/ | ||
238 | QCONST16(.0002,15), /*lpc_floor*/ | ||
239 | QCONST16(0.7f,15), | ||
240 | {NULL, &wb_submode1, NULL, NULL, NULL, NULL, NULL, NULL}, | ||
241 | 1, | ||
242 | {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, | ||
243 | {0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, | ||
244 | vbr_uhb_thresh, | ||
245 | 2 | ||
246 | }; | ||
247 | |||
248 | int wb_mode_query(const void *mode, int request, void *ptr) | ||
249 | { | ||
250 | const SpeexSBMode *m = (const SpeexSBMode*)mode; | ||
251 | |||
252 | switch (request) | ||
253 | { | ||
254 | case SPEEX_MODE_FRAME_SIZE: | ||
255 | *((int*)ptr)=2*m->frameSize; | ||
256 | break; | ||
257 | case SPEEX_SUBMODE_BITS_PER_FRAME: | ||
258 | if (*((int*)ptr)==0) | ||
259 | *((int*)ptr) = SB_SUBMODE_BITS+1; | ||
260 | else if (m->submodes[*((int*)ptr)]==NULL) | ||
261 | *((int*)ptr) = -1; | ||
262 | else | ||
263 | *((int*)ptr) = m->submodes[*((int*)ptr)]->bits_per_frame; | ||
264 | break; | ||
265 | default: | ||
266 | speex_warning_int("Unknown wb_mode_query request: ", request); | ||
267 | return -1; | ||
268 | } | ||
269 | return 0; | ||
270 | } | ||
271 | |||
272 | |||
273 | const SpeexMode speex_uwb_mode = { | ||
274 | &sb_uwb_mode, | ||
275 | wb_mode_query, | ||
276 | "ultra-wideband (sub-band CELP)", | ||
277 | 2, | ||
278 | 4, | ||
279 | &sb_encoder_init, | ||
280 | &sb_encoder_destroy, | ||
281 | &sb_encode, | ||
282 | &sb_decoder_init, | ||
283 | &sb_decoder_destroy, | ||
284 | &sb_decode, | ||
285 | &sb_encoder_ctl, | ||
286 | &sb_decoder_ctl, | ||
287 | }; | ||
288 | |||
289 | /* We have defined speex_lib_get_mode() as a macro in speex.h */ | ||
290 | #undef speex_lib_get_mode | ||
291 | |||
292 | const SpeexMode * speex_lib_get_mode (int mode) | ||
293 | { | ||
294 | #ifdef EPIC_48K | ||
295 | if (mode == SPEEX_MODEID_NB_48K) return &speex_nb_48k_mode; | ||
296 | #endif | ||
297 | |||
298 | if (mode < 0 || mode >= SPEEX_NB_MODES) return NULL; | ||
299 | |||
300 | return speex_mode_list[mode]; | ||
301 | } | ||
302 | |||
303 | |||
304 | |||
diff --git a/apps/codecs/libspeex/nb_celp.c b/apps/codecs/libspeex/nb_celp.c index 5d167a2aa3..aab0b722dc 100644 --- a/apps/codecs/libspeex/nb_celp.c +++ b/apps/codecs/libspeex/nb_celp.c | |||
@@ -47,6 +47,7 @@ | |||
47 | #include "vbr.h" | 47 | #include "vbr.h" |
48 | #include "misc.h" | 48 | #include "misc.h" |
49 | #include "math_approx.h" | 49 | #include "math_approx.h" |
50 | #include "os_support.h" | ||
50 | #include <speex/speex_callbacks.h> | 51 | #include <speex/speex_callbacks.h> |
51 | 52 | ||
52 | #ifdef VORBIS_PSYCHO | 53 | #ifdef VORBIS_PSYCHO |
@@ -1207,7 +1208,9 @@ static void nb_decode_lost(DecState *st, spx_word16_t *out, char *stack) | |||
1207 | st->pitch_gain_buf_idx = 0; | 1208 | st->pitch_gain_buf_idx = 0; |
1208 | } | 1209 | } |
1209 | 1210 | ||
1210 | 1211 | /* Just so we don't need to carry the complete wideband mode information */ | |
1212 | static const int wb_skip_table[8] = {0, 36, 112, 192, 352, 0, 0, 0}; | ||
1213 | |||
1211 | int nb_decode(void *state, SpeexBits *bits, void *vout) | 1214 | int nb_decode(void *state, SpeexBits *bits, void *vout) |
1212 | { | 1215 | { |
1213 | DecState *st; | 1216 | DecState *st; |
@@ -1266,7 +1269,8 @@ int nb_decode(void *state, SpeexBits *bits, void *vout) | |||
1266 | int submode; | 1269 | int submode; |
1267 | int advance; | 1270 | int advance; |
1268 | advance = submode = speex_bits_unpack_unsigned(bits, SB_SUBMODE_BITS); | 1271 | advance = submode = speex_bits_unpack_unsigned(bits, SB_SUBMODE_BITS); |
1269 | speex_mode_query(&speex_wb_mode, SPEEX_SUBMODE_BITS_PER_FRAME, &advance); | 1272 | /*speex_mode_query(&speex_wb_mode, SPEEX_SUBMODE_BITS_PER_FRAME, &advance);*/ |
1273 | advance = wb_skip_table[submode]; | ||
1270 | if (advance < 0) | 1274 | if (advance < 0) |
1271 | { | 1275 | { |
1272 | speex_notify("Invalid mode encountered. The stream is corrupted."); | 1276 | speex_notify("Invalid mode encountered. The stream is corrupted."); |
@@ -1281,7 +1285,8 @@ int nb_decode(void *state, SpeexBits *bits, void *vout) | |||
1281 | if (wideband) | 1285 | if (wideband) |
1282 | { | 1286 | { |
1283 | advance = submode = speex_bits_unpack_unsigned(bits, SB_SUBMODE_BITS); | 1287 | advance = submode = speex_bits_unpack_unsigned(bits, SB_SUBMODE_BITS); |
1284 | speex_mode_query(&speex_wb_mode, SPEEX_SUBMODE_BITS_PER_FRAME, &advance); | 1288 | /*speex_mode_query(&speex_wb_mode, SPEEX_SUBMODE_BITS_PER_FRAME, &advance);*/ |
1289 | advance = wb_skip_table[submode]; | ||
1285 | if (advance < 0) | 1290 | if (advance < 0) |
1286 | { | 1291 | { |
1287 | speex_notify("Invalid mode encountered. The stream is corrupted."); | 1292 | speex_notify("Invalid mode encountered. The stream is corrupted."); |
diff --git a/apps/codecs/libspeex/preprocess.c b/apps/codecs/libspeex/preprocess.c index a720e88479..da2da4a599 100644 --- a/apps/codecs/libspeex/preprocess.c +++ b/apps/codecs/libspeex/preprocess.c | |||
@@ -66,6 +66,7 @@ | |||
66 | #include "fftwrap.h" | 66 | #include "fftwrap.h" |
67 | #include "filterbank.h" | 67 | #include "filterbank.h" |
68 | #include "math_approx.h" | 68 | #include "math_approx.h" |
69 | #include "os_support.h" | ||
69 | 70 | ||
70 | #ifndef M_PI | 71 | #ifndef M_PI |
71 | #define M_PI 3.14159263 | 72 | #define M_PI 3.14159263 |
diff --git a/apps/codecs/libspeex/pseudofloat.h b/apps/codecs/libspeex/pseudofloat.h index 9d588642a8..a237e32620 100644 --- a/apps/codecs/libspeex/pseudofloat.h +++ b/apps/codecs/libspeex/pseudofloat.h | |||
@@ -45,6 +45,7 @@ | |||
45 | #define PSEUDOFLOAT_H | 45 | #define PSEUDOFLOAT_H |
46 | 46 | ||
47 | #include "misc.h" | 47 | #include "misc.h" |
48 | #include "os_support.h" | ||
48 | #include "math_approx.h" | 49 | #include "math_approx.h" |
49 | #include <math.h> | 50 | #include <math.h> |
50 | 51 | ||
diff --git a/apps/codecs/libspeex/quant_lsp.c b/apps/codecs/libspeex/quant_lsp.c index b2f4f85497..9a6afa2ca0 100644 --- a/apps/codecs/libspeex/quant_lsp.c +++ b/apps/codecs/libspeex/quant_lsp.c | |||
@@ -35,6 +35,7 @@ | |||
35 | #endif | 35 | #endif |
36 | 36 | ||
37 | #include "quant_lsp.h" | 37 | #include "quant_lsp.h" |
38 | #include "os_support.h" | ||
38 | #include <math.h> | 39 | #include <math.h> |
39 | #ifndef M_PI | 40 | #ifndef M_PI |
40 | #define M_PI 3.14159265358979323846 | 41 | #define M_PI 3.14159265358979323846 |
diff --git a/apps/codecs/libspeex/resample.c b/apps/codecs/libspeex/resample.c index 51270c572d..ae134ea783 100644 --- a/apps/codecs/libspeex/resample.c +++ b/apps/codecs/libspeex/resample.c | |||
@@ -71,6 +71,7 @@ static void speex_free (void *ptr) {free(ptr);} | |||
71 | 71 | ||
72 | #include "speex/speex_resampler.h" | 72 | #include "speex/speex_resampler.h" |
73 | #include "misc.h" | 73 | #include "misc.h" |
74 | #include "os_support.h" | ||
74 | #endif /* OUTSIDE_SPEEX */ | 75 | #endif /* OUTSIDE_SPEEX */ |
75 | 76 | ||
76 | #include <math.h> | 77 | #include <math.h> |
diff --git a/apps/codecs/libspeex/sb_celp.c b/apps/codecs/libspeex/sb_celp.c index 766fe57719..c67197144c 100644 --- a/apps/codecs/libspeex/sb_celp.c +++ b/apps/codecs/libspeex/sb_celp.c | |||
@@ -45,6 +45,7 @@ | |||
45 | #include "ltp.h" | 45 | #include "ltp.h" |
46 | #include "misc.h" | 46 | #include "misc.h" |
47 | #include "math_approx.h" | 47 | #include "math_approx.h" |
48 | #include "os_support.h" | ||
48 | 49 | ||
49 | #ifndef NULL | 50 | #ifndef NULL |
50 | #define NULL 0 | 51 | #define NULL 0 |
diff --git a/apps/codecs/libspeex/smallft.c b/apps/codecs/libspeex/smallft.c index 079e773659..980b7ac735 100644 --- a/apps/codecs/libspeex/smallft.c +++ b/apps/codecs/libspeex/smallft.c | |||
@@ -35,6 +35,7 @@ | |||
35 | #include <math.h> | 35 | #include <math.h> |
36 | #include "smallft.h" | 36 | #include "smallft.h" |
37 | #include "misc.h" | 37 | #include "misc.h" |
38 | #include "os_support.h" | ||
38 | 39 | ||
39 | static void drfti1(int n, float *wa, int *ifac){ | 40 | static void drfti1(int n, float *wa, int *ifac){ |
40 | static int ntryh[4] = { 4,2,3,5 }; | 41 | static int ntryh[4] = { 4,2,3,5 }; |
diff --git a/apps/codecs/libspeex/speex.c b/apps/codecs/libspeex/speex.c index 17a987fde0..2a42e274a7 100644 --- a/apps/codecs/libspeex/speex.c +++ b/apps/codecs/libspeex/speex.c | |||
@@ -38,6 +38,7 @@ | |||
38 | 38 | ||
39 | #include "modes.h" | 39 | #include "modes.h" |
40 | #include <math.h> | 40 | #include <math.h> |
41 | #include "os_support.h" | ||
41 | 42 | ||
42 | #ifndef NULL | 43 | #ifndef NULL |
43 | #define NULL 0 | 44 | #define NULL 0 |
@@ -208,29 +209,6 @@ int nb_mode_query(const void *mode, int request, void *ptr) | |||
208 | return 0; | 209 | return 0; |
209 | } | 210 | } |
210 | 211 | ||
211 | int wb_mode_query(const void *mode, int request, void *ptr) | ||
212 | { | ||
213 | const SpeexSBMode *m = (const SpeexSBMode*)mode; | ||
214 | |||
215 | switch (request) | ||
216 | { | ||
217 | case SPEEX_MODE_FRAME_SIZE: | ||
218 | *((int*)ptr)=2*m->frameSize; | ||
219 | break; | ||
220 | case SPEEX_SUBMODE_BITS_PER_FRAME: | ||
221 | if (*((int*)ptr)==0) | ||
222 | *((int*)ptr) = SB_SUBMODE_BITS+1; | ||
223 | else if (m->submodes[*((int*)ptr)]==NULL) | ||
224 | *((int*)ptr) = -1; | ||
225 | else | ||
226 | *((int*)ptr) = m->submodes[*((int*)ptr)]->bits_per_frame; | ||
227 | break; | ||
228 | default: | ||
229 | speex_warning_int("Unknown wb_mode_query request: ", request); | ||
230 | return -1; | ||
231 | } | ||
232 | return 0; | ||
233 | } | ||
234 | 212 | ||
235 | 213 | ||
236 | int speex_lib_ctl(int request, void *ptr) | 214 | int speex_lib_ctl(int request, void *ptr) |
diff --git a/apps/codecs/libspeex/speex/speex.h b/apps/codecs/libspeex/speex/speex.h index 9ac1d2da6c..05123d21b2 100644 --- a/apps/codecs/libspeex/speex/speex.h +++ b/apps/codecs/libspeex/speex/speex.h | |||
@@ -421,6 +421,9 @@ extern const SpeexMode * const speex_mode_list[SPEEX_NB_MODES]; | |||
421 | /** Obtain one of the modes available */ | 421 | /** Obtain one of the modes available */ |
422 | const SpeexMode * speex_lib_get_mode (int mode); | 422 | const SpeexMode * speex_lib_get_mode (int mode); |
423 | 423 | ||
424 | /* We actually override the fucntion in the narrowband case so that we can avoid linking in the wideband stuff */ | ||
425 | #define speex_lib_get_mode(mode) ((mode)==SPEEX_MODEID_NB ? &speex_nb_mode : speex_lib_get_mode (mode)) | ||
426 | |||
424 | #ifdef __cplusplus | 427 | #ifdef __cplusplus |
425 | } | 428 | } |
426 | #endif | 429 | #endif |
diff --git a/apps/codecs/libspeex/speex_callbacks.c b/apps/codecs/libspeex/speex_callbacks.c index c7ac3b5544..9883d72e50 100644 --- a/apps/codecs/libspeex/speex_callbacks.c +++ b/apps/codecs/libspeex/speex_callbacks.c | |||
@@ -38,6 +38,7 @@ | |||
38 | 38 | ||
39 | #include <speex/speex_callbacks.h> | 39 | #include <speex/speex_callbacks.h> |
40 | #include "misc.h" | 40 | #include "misc.h" |
41 | #include "os_support.h" | ||
41 | 42 | ||
42 | int speex_inband_handler(SpeexBits *bits, SpeexCallback *callback_list, void *state) | 43 | int speex_inband_handler(SpeexBits *bits, SpeexCallback *callback_list, void *state) |
43 | { | 44 | { |
diff --git a/apps/codecs/libspeex/speex_header.c b/apps/codecs/libspeex/speex_header.c index 5719eb1298..2e7c415686 100644 --- a/apps/codecs/libspeex/speex_header.c +++ b/apps/codecs/libspeex/speex_header.c | |||
@@ -38,6 +38,7 @@ | |||
38 | #include "misc.h" | 38 | #include "misc.h" |
39 | #include <speex/speex_header.h> | 39 | #include <speex/speex_header.h> |
40 | #include <speex/speex.h> | 40 | #include <speex/speex.h> |
41 | #include "os_support.h" | ||
41 | 42 | ||
42 | #ifndef NULL | 43 | #ifndef NULL |
43 | #define NULL 0 | 44 | #define NULL 0 |