summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorThom Johansen <thomj@rockbox.org>2007-10-26 01:16:55 +0000
committerThom Johansen <thomj@rockbox.org>2007-10-26 01:16:55 +0000
commitfa971b142d794c9620b823d6b9d1937397c1f1e1 (patch)
tree55565a0765c15be5d1df4cfb1c04dc92de50fe5d /apps
parent14da611cd32d084813bb0d2e2318b81c3ea2953a (diff)
downloadrockbox-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')
-rw-r--r--apps/codecs/libspeex/README.rockbox2
-rw-r--r--apps/codecs/libspeex/SOURCES4
-rw-r--r--apps/codecs/libspeex/bits.c1
-rw-r--r--apps/codecs/libspeex/cb_search.c2
-rw-r--r--apps/codecs/libspeex/fftwrap.c1
-rw-r--r--apps/codecs/libspeex/filterbank.c1
-rw-r--r--apps/codecs/libspeex/filters_cf.S32
-rw-r--r--apps/codecs/libspeex/jitter.c1
-rw-r--r--apps/codecs/libspeex/kiss_fft.c1
-rw-r--r--apps/codecs/libspeex/kiss_fftr.c1
-rw-r--r--apps/codecs/libspeex/math_approx.c38
-rw-r--r--apps/codecs/libspeex/math_approx.h23
-rw-r--r--apps/codecs/libspeex/mdf.c1
-rw-r--r--apps/codecs/libspeex/misc.c49
-rw-r--r--apps/codecs/libspeex/misc.h133
-rw-r--r--apps/codecs/libspeex/modes.c219
-rw-r--r--apps/codecs/libspeex/modes_wb.c304
-rw-r--r--apps/codecs/libspeex/nb_celp.c11
-rw-r--r--apps/codecs/libspeex/preprocess.c1
-rw-r--r--apps/codecs/libspeex/pseudofloat.h1
-rw-r--r--apps/codecs/libspeex/quant_lsp.c1
-rw-r--r--apps/codecs/libspeex/resample.c1
-rw-r--r--apps/codecs/libspeex/sb_celp.c1
-rw-r--r--apps/codecs/libspeex/smallft.c1
-rw-r--r--apps/codecs/libspeex/speex.c24
-rw-r--r--apps/codecs/libspeex/speex/speex.h3
-rw-r--r--apps/codecs/libspeex/speex_callbacks.c1
-rw-r--r--apps/codecs/libspeex/speex_header.c1
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 @@
-Library: libspeex-1.2beta2 (SVN version 14014)
+Library: libspeex-1.2beta3 (SVN version 14054)
Imported: 2007-03-12 by Dan Everton
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
lsp.c
lsp_tables_nb.c
ltp.c
-math_approx.c
mdf.c
-medfilter.c
-misc.c
modes.c
+modes_wb.c
nb_celp.c
oggframing.c
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 @@
#include <speex/speex_bits.h>
#include "misc.h"
+#include "os_support.h"
/* Maximum size of the bit-stream (for fixed-size allocation) */
#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 @@
#include "stack_alloc.h"
#include "vq.h"
#include "misc.h"
+#include "math_approx.h"
+#include "os_support.h"
#ifdef _USE_SSE
#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 @@
#include "misc.h"
+#include "os_support.h"
#define MAX_FFT_SIZE 2048
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 @@
#include "misc.h"
#include <math.h>
#include "math_approx.h"
+#include "os_support.h"
#ifdef FIXED_POINT
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:
1: | Innerloop
move.w (%a0)+, %d3 | d3 = x11
move.w (%a1)+, %d5 | d5 = x21
- mac.w %d6u, %d3l, #1, %acc0 | acc0 += a0*x11
- msac.w %d6u, %d5l, #1, %acc0 | acc0 -= a0*x21
- mac.w %d6l, %d3l, #1, %acc1 | acc1 += a1*x11
- mac.w %d6l, %d5l, #1, %acc1 | acc1 += a1*x21
- mac.w %d6u, %d2l, #1, %acc2 | acc2 += a0*x10
- msac.w %d6u, %d4l, #1, %acc2 | acc2 -= a0*x20
- mac.w %d6l, %d2l, #1, %acc3 | acc3 += a1*x10
- mac.w %d6l, %d4l, #1, (%a2)+, %d6, %acc3 | acc3 += a1*x20
+ mac.w %d6u, %d3l, <<, %acc0 | acc0 += a0*x11
+ msac.w %d6u, %d5l, <<, %acc0 | acc0 -= a0*x21
+ mac.w %d6l, %d3l, <<, %acc1 | acc1 += a1*x11
+ mac.w %d6l, %d5l, <<, %acc1 | acc1 += a1*x21
+ mac.w %d6u, %d2l, <<, %acc2 | acc2 += a0*x10
+ msac.w %d6u, %d4l, <<, %acc2 | acc2 -= a0*x20
+ mac.w %d6l, %d2l, <<, %acc3 | acc3 += a1*x10
+ mac.w %d6l, %d4l, <<, (%a2)+, %d6, %acc3 | acc3 += a1*x20
move.w (%a0)+, %d2 | d2 = x10
move.w (%a1)+, %d4 | d4 = x20
- mac.w %d6u, %d2l, #1, %acc0 | acc0 += a0*x10
- msac.w %d6u, %d4l, #1, %acc0 | acc0 -= a0*x20
- mac.w %d6l, %d2l, #1, %acc1 | acc1 += a1*x10
- mac.w %d6l, %d4l, #1, %acc1 | acc1 += a1*x20
- mac.w %d6u, %d3l, #1, %acc2 | acc2 += a0*x11
- msac.w %d6u, %d5l, #1, %acc2 | acc2 -= a0*x21
- mac.w %d6l, %d3l, #1, %acc3 | acc3 += a1*x11
- mac.w %d6l, %d5l, #1, (%a2)+, %d6, %acc3 | acc3 += a1*x21
+ mac.w %d6u, %d2l, <<, %acc0 | acc0 += a0*x10
+ msac.w %d6u, %d4l, <<, %acc0 | acc0 -= a0*x20
+ mac.w %d6l, %d2l, <<, %acc1 | acc1 += a1*x10
+ mac.w %d6l, %d4l, <<, %acc1 | acc1 += a1*x20
+ mac.w %d6u, %d3l, <<, %acc2 | acc2 += a0*x11
+ msac.w %d6u, %d5l, <<, %acc2 | acc2 -= a0*x21
+ mac.w %d6l, %d3l, <<, %acc3 | acc3 += a1*x11
+ mac.w %d6l, %d5l, <<, (%a2)+, %d6, %acc3 | acc3 += a1*x21
subq.l #2, %d1
jne 1b
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 @@
#include <speex/speex.h>
#include <speex/speex_bits.h>
#include <speex/speex_jitter.h>
+#include "os_support.h"
#ifndef NULL
#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
#include "_kiss_fft_guts.h"
#include "misc.h"
+#include "os_support.h"
/* The guts header contains all the multiplication and addition macros that are defined for
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
#include "config-speex.h"
#endif
+#include "os_support.h"
#include "kiss_fftr.h"
#include "_kiss_fft_guts.h"
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 @@
-/* Copyright (C) 2002 Jean-Marc Valin
- File: math_approx.c
- Various math approximation functions for Speex
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
-
- - Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- - Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- - Neither the name of the Xiph.org Foundation nor the names of its
- contributors may be used to endorse or promote products derived from
- this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-#ifdef HAVE_CONFIG_H
-#include "config-speex.h"
-#endif
-
-#include "math_approx.h"
-#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 @@
#define spx_cos_norm(x) (cos((.5f*M_PI)*(x)))
#define spx_atan atan
-#endif
+/** Generate a pseudo-random number */
+static inline spx_word16_t speex_rand(spx_word16_t std, spx_int32_t *seed)
+{
+ const unsigned int jflone = 0x3f800000;
+ const unsigned int jflmsk = 0x007fffff;
+ union {int i; float f;} ran;
+ *seed = 1664525 * *seed + 1013904223;
+ ran.i = jflone | (jflmsk & *seed);
+ ran.f -= 1.5;
+ return 3.4642*std*ran.f;
+}
+
+#endif
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)
#ifdef FIXED_POINT
+/** Generate a pseudo-random number */
+static inline spx_word16_t speex_rand(spx_word16_t std, spx_int32_t *seed)
+{
+ spx_word32_t res;
+ *seed = 1664525 * *seed + 1013904223;
+ res = MULT16_16(EXTRACT16(SHR32(*seed,16)),std);
+ return EXTRACT16(PSHR32(SUB32(res, SHR32(res, 3)),14));
+}
+
/* sqrt(x) ~= 0.22178 + 1.29227*x - 0.77070*x^2 + 0.25723*x^3 (for .25 < x < 1) */
/*#define C0 3634
#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 @@
#include "fftwrap.h"
#include "pseudofloat.h"
#include "math_approx.h"
+#include "os_support.h"
#ifndef M_PI
#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 @@
-/* Copyright (C) 2002-2005 Jean-Marc Valin
- File: misc.c
- Various utility routines for Speex
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
-
- - Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- - Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- - Neither the name of the Xiph.org Foundation nor the names of its
- contributors may be used to endorse or promote products derived from
- this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-#ifdef HAVE_CONFIG_H
-#include "config-speex.h"
-#endif
-
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
-#include "misc.h"
-
-#ifdef USER_MISC
-#include "user_misc.h"
-#endif
-
-#ifdef BFIN_ASM
-#include "misc_bfin.h"
-#endif
-
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 @@
#ifndef SPEEX_VERSION
#define SPEEX_MAJOR_VERSION 1 /**< Major Speex version. */
#define SPEEX_MINOR_VERSION 1 /**< Minor Speex version. */
-#define SPEEX_MICRO_VERSION 14 /**< Micro Speex version. */
+#define SPEEX_MICRO_VERSION 15 /**< Micro Speex version. */
#define SPEEX_EXTRA_VERSION "" /**< Extra Speex version. */
-#define SPEEX_VERSION "speex-1.2beta2" /**< Speex version string. */
+#define SPEEX_VERSION "speex-1.2beta3" /**< Speex version string. */
#endif
/* A couple test to catch stupid option combinations */
@@ -71,7 +71,6 @@
#endif
#include "arch.h"
-#include "rockbox.h"
/** Convert little endian */
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)
#endif
}
-#define speex_fatal(str) _speex_fatal(str, __FILE__, __LINE__);
-#define speex_assert(cond) {if (!(cond)) {speex_fatal("assertion failed: " #cond);}}
-
-#ifndef RELEASE
-static void print_vec(float *vec, int len, char *name)
-{
- int i;
- printf ("%s ", name);
- for (i=0;i<len;i++)
- printf (" %f", vec[i]);
- printf ("\n");
-}
-#endif
#ifdef FIXED_DEBUG
long long spx_mips=0;
#endif
-/** Speex wrapper for calloc. To do your own dynamic allocation, all you need to do is replace this function, speex_realloc and speex_free */
-#ifndef OVERRIDE_SPEEX_ALLOC
-static inline void *speex_alloc (int size)
-{
- return calloc(size,1);
-}
-#endif
-
-/** Same as speex_alloc, except that the area is only needed inside a Speex call (might cause problem with wideband though) */
-#ifndef OVERRIDE_SPEEX_ALLOC_SCRATCH
-static inline void *speex_alloc_scratch (int size)
-{
- return calloc(size,1);
-}
-#endif
-
-/** Speex wrapper for realloc. To do your own dynamic allocation, all you need to do is replace this function, speex_alloc and speex_free */
-#ifndef OVERRIDE_SPEEX_REALLOC
-static inline void *speex_realloc (void *ptr, int size)
-{
- return realloc(ptr, size);
-}
-#endif
-
-/** Speex wrapper for calloc. To do your own dynamic allocation, all you need to do is replace this function, speex_realloc and speex_alloc */
-#ifndef OVERRIDE_SPEEX_FREE
-static inline void speex_free (void *ptr)
-{
- free(ptr);
-}
-#endif
-
-/** Same as speex_free, except that the area is only needed inside a Speex call (might cause problem with wideband though) */
-#ifndef OVERRIDE_SPEEX_FREE_SCRATCH
-static inline void speex_free_scratch (void *ptr)
-{
- free(ptr);
-}
-#endif
-
-/** Print warning message with integer argument to stderr */
-#ifndef OVERRIDE_SPEEX_MOVE
-static inline void *speex_move (void *dest, void *src, int n)
-{
- return memmove(dest,src,n);
-}
-#endif
-
-#ifndef OVERRIDE_SPEEX_FATAL
-static inline void _speex_fatal(const char *str, const char *file, int line)
-{
- fprintf (stderr, "Fatal (internal) error in %s, line %d: %s\n", file, line, str);
- exit(1);
-}
-#endif
-
-#ifndef OVERRIDE_SPEEX_WARNING
-static inline void speex_warning(const char *str)
-{
-#ifndef DISABLE_WARNINGS
- fprintf (stderr, "warning: %s\n", str);
-#endif
-}
-#endif
-
-#ifndef OVERRIDE_SPEEX_WARNING_INT
-static inline void speex_warning_int(const char *str, int val)
-{
-#ifndef DISABLE_WARNINGS
- fprintf (stderr, "warning: %s %d\n", str, val);
-#endif
-}
-#endif
-
-#ifndef OVERRIDE_SPEEX_NOTIFY
-static inline void speex_notify(const char *str)
-{
-#ifndef DISABLE_NOTIFICATIONS
- fprintf (stderr, "notification: %s\n", str);
-#endif
-}
-#endif
-
-#ifdef FIXED_POINT
-/** Generate a pseudo-random number */
-static inline spx_word16_t speex_rand(spx_word16_t std, spx_int32_t *seed)
-{
- spx_word32_t res;
- *seed = 1664525 * *seed + 1013904223;
- res = MULT16_16(EXTRACT16(SHR32(*seed,16)),std);
- return EXTRACT16(PSHR32(SUB32(res, SHR32(res, 3)),14));
-}
-#else
-/** Generate a pseudo-random number */
-static inline spx_word16_t speex_rand(spx_word16_t std, spx_int32_t *seed)
-{
- const unsigned int jflone = 0x3f800000;
- const unsigned int jflmsk = 0x007fffff;
- union {int i; float f;} ran;
- *seed = 1664525 * *seed + 1013904223;
- ran.i = jflone | (jflmsk & *seed);
- ran.f -= 1.5;
- return 3.4642*std*ran.f;
-}
-#endif
-
-#ifndef OVERRIDE_SPEEX_PUTC
-/** Speex wrapper for putc */
-static inline void _speex_putc(int ch, void *file)
-{
- FILE *f = (FILE *)file;
- fprintf(f, "%c", ch);
-}
-#endif
-
#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 @@
#define NULL 0
#endif
-#define MAX_IN_SAMPLES 640
-
-const SpeexMode * const speex_mode_list[SPEEX_NB_MODES] = {&speex_nb_mode, &speex_wb_mode, &speex_uwb_mode};
/* Extern declarations for all codebooks we use here */
extern const signed char gain_cdbk_nb[];
extern const signed char gain_cdbk_lbr[];
-extern const signed char hexc_table[];
extern const signed char exc_5_256_table[];
extern const signed char exc_5_64_table[];
extern const signed char exc_8_128_table[];
extern const signed char exc_10_32_table[];
extern const signed char exc_10_16_table[];
extern const signed char exc_20_32_table[];
-extern const signed char hexc_10_32_table[];
/* Parameters for Long-Term Prediction (LTP)*/
@@ -150,29 +145,8 @@ static const split_cb_params split_cb_sb = {
0,
};
-#ifndef DISABLE_WIDEBAND
-
-/* Split-VQ innovation for high-band wideband */
-static const split_cb_params split_cb_high = {
- 8, /*subvect_size*/
- 5, /*nb_subvect*/
- hexc_table, /*shape_cb*/
- 7, /*shape_bits*/
- 1,
-};
-/* Split-VQ innovation for high-band wideband */
-static const split_cb_params split_cb_high_lbr = {
- 10, /*subvect_size*/
- 4, /*nb_subvect*/
- hexc_10_32_table, /*shape_cb*/
- 5, /*shape_bits*/
- 0,
-};
-
-#endif
-
/* 2150 bps "vocoder-like" mode for comfort noise */
static const SpeexSubmode nb_submode1 = {
0,
@@ -386,189 +360,6 @@ const SpeexMode speex_nb_mode = {
/* Wideband part */
-static const SpeexSubmode wb_submode1 = {
- 0,
- 0,
- 1,
- 0,
- /*LSP quantization*/
- lsp_quant_high,
- lsp_unquant_high,
- /*Pitch quantization*/
- NULL,
- NULL,
- NULL,
- /*No innovation quantization*/
- NULL,
- NULL,
- NULL,
- -1,
- 36
-};
-
-
-static const SpeexSubmode wb_submode2 = {
- 0,
- 0,
- 1,
- 0,
- /*LSP quantization*/
- lsp_quant_high,
- lsp_unquant_high,
- /*Pitch quantization*/
- NULL,
- NULL,
- NULL,
- /*Innovation quantization*/
- split_cb_search_shape_sign,
- split_cb_shape_sign_unquant,
-#ifdef DISABLE_WIDEBAND
- NULL,
-#else
- &split_cb_high_lbr,
-#endif
- -1,
- 112
-};
-
-
-static const SpeexSubmode wb_submode3 = {
- 0,
- 0,
- 1,
- 0,
- /*LSP quantization*/
- lsp_quant_high,
- lsp_unquant_high,
- /*Pitch quantization*/
- NULL,
- NULL,
- NULL,
- /*Innovation quantization*/
- split_cb_search_shape_sign,
- split_cb_shape_sign_unquant,
-#ifdef DISABLE_WIDEBAND
- NULL,
-#else
- &split_cb_high,
-#endif
- -1,
- 192
-};
-
-static const SpeexSubmode wb_submode4 = {
- 0,
- 0,
- 1,
- 1,
- /*LSP quantization*/
- lsp_quant_high,
- lsp_unquant_high,
- /*Pitch quantization*/
- NULL,
- NULL,
- NULL,
- /*Innovation quantization*/
- split_cb_search_shape_sign,
- split_cb_shape_sign_unquant,
-#ifdef DISABLE_WIDEBAND
- NULL,
-#else
- &split_cb_high,
-#endif
- -1,
- 352
-};
-
-
-/* Split-band wideband CELP mode*/
-static const SpeexSBMode sb_wb_mode = {
- &speex_nb_mode,
- 160, /*frameSize*/
- 40, /*subframeSize*/
- 8, /*lpcSize*/
- 640, /*bufSize*/
-#ifdef FIXED_POINT
- 29491, 19661, /* gamma1, gamma2 */
-#else
- 0.9, 0.6, /* gamma1, gamma2 */
-#endif
- .012, /*lag_factor*/
- QCONST16(.0002,15), /*lpc_floor*/
- QCONST16(0.9f,15),
- {NULL, &wb_submode1, &wb_submode2, &wb_submode3, &wb_submode4, NULL, NULL, NULL},
- 3,
- {1, 8, 2, 3, 4, 5, 5, 6, 6, 7, 7},
- {1, 1, 1, 1, 1, 1, 2, 2, 3, 3, 4},
- vbr_hb_thresh,
- 5
-};
-
-
-const SpeexMode speex_wb_mode = {
- &sb_wb_mode,
- wb_mode_query,
- "wideband (sub-band CELP)",
- 1,
- 4,
- &sb_encoder_init,
- &sb_encoder_destroy,
- &sb_encode,
- &sb_decoder_init,
- &sb_decoder_destroy,
- &sb_decode,
- &sb_encoder_ctl,
- &sb_decoder_ctl,
-};
-
-
-
-/* "Ultra-wideband" mode stuff */
-
-
-
-/* Split-band "ultra-wideband" (32 kbps) CELP mode*/
-static const SpeexSBMode sb_uwb_mode = {
- &speex_wb_mode,
- 320, /*frameSize*/
- 80, /*subframeSize*/
- 8, /*lpcSize*/
- 1280, /*bufSize*/
-#ifdef FIXED_POINT
- 29491, 19661, /* gamma1, gamma2 */
-#else
- 0.9, 0.6, /* gamma1, gamma2 */
-#endif
- .012, /*lag_factor*/
- QCONST16(.0002,15), /*lpc_floor*/
- QCONST16(0.7f,15),
- {NULL, &wb_submode1, NULL, NULL, NULL, NULL, NULL, NULL},
- 1,
- {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10},
- {0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
- vbr_uhb_thresh,
- 2
-};
-
-
-const SpeexMode speex_uwb_mode = {
- &sb_uwb_mode,
- wb_mode_query,
- "ultra-wideband (sub-band CELP)",
- 2,
- 4,
- &sb_encoder_init,
- &sb_encoder_destroy,
- &sb_encode,
- &sb_decoder_init,
- &sb_decoder_destroy,
- &sb_decode,
- &sb_encoder_ctl,
- &sb_decoder_ctl,
-};
-
-
-
#ifdef EPIC_48K
@@ -656,13 +447,3 @@ int speex_mode_query(const SpeexMode *mode, int request, void *ptr)
return mode->query(mode->mode, request, ptr);
}
-const SpeexMode * speex_lib_get_mode (int mode)
-{
-#ifdef EPIC_48K
- if (mode == SPEEX_MODEID_NB_48K) return &speex_nb_48k_mode;
-#endif
-
- if (mode < 0 || mode >= SPEEX_NB_MODES) return NULL;
-
- return speex_mode_list[mode];
-}
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 @@
+/* Copyright (C) 2002-2007 Jean-Marc Valin
+ File: modes.c
+
+ Describes the wideband modes of the codec
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+
+ - Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ - Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ - Neither the name of the Xiph.org Foundation nor the names of its
+ contributors may be used to endorse or promote products derived from
+ this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include "config-speex.h"
+#endif
+
+#include "modes.h"
+#include "ltp.h"
+#include "quant_lsp.h"
+#include "cb_search.h"
+#include "sb_celp.h"
+#include "nb_celp.h"
+#include "vbr.h"
+#include "misc.h"
+#include <math.h>
+#include "os_support.h"
+
+
+#ifndef NULL
+#define NULL 0
+#endif
+
+const SpeexMode * const speex_mode_list[SPEEX_NB_MODES] = {&speex_nb_mode, &speex_wb_mode, &speex_uwb_mode};
+
+extern const signed char hexc_table[];
+extern const signed char hexc_10_32_table[];
+
+#ifndef DISABLE_WIDEBAND
+
+/* Split-VQ innovation for high-band wideband */
+static const split_cb_params split_cb_high = {
+ 8, /*subvect_size*/
+ 5, /*nb_subvect*/
+ hexc_table, /*shape_cb*/
+ 7, /*shape_bits*/
+ 1,
+};
+
+
+/* Split-VQ innovation for high-band wideband */
+static const split_cb_params split_cb_high_lbr = {
+ 10, /*subvect_size*/
+ 4, /*nb_subvect*/
+ hexc_10_32_table, /*shape_cb*/
+ 5, /*shape_bits*/
+ 0,
+};
+
+#endif
+
+
+static const SpeexSubmode wb_submode1 = {
+ 0,
+ 0,
+ 1,
+ 0,
+ /*LSP quantization*/
+ lsp_quant_high,
+ lsp_unquant_high,
+ /*Pitch quantization*/
+ NULL,
+ NULL,
+ NULL,
+ /*No innovation quantization*/
+ NULL,
+ NULL,
+ NULL,
+ -1,
+ 36
+};
+
+
+static const SpeexSubmode wb_submode2 = {
+ 0,
+ 0,
+ 1,
+ 0,
+ /*LSP quantization*/
+ lsp_quant_high,
+ lsp_unquant_high,
+ /*Pitch quantization*/
+ NULL,
+ NULL,
+ NULL,
+ /*Innovation quantization*/
+ split_cb_search_shape_sign,
+ split_cb_shape_sign_unquant,
+#ifdef DISABLE_WIDEBAND
+ NULL,
+#else
+ &split_cb_high_lbr,
+#endif
+ -1,
+ 112
+};
+
+
+static const SpeexSubmode wb_submode3 = {
+ 0,
+ 0,
+ 1,
+ 0,
+ /*LSP quantization*/
+ lsp_quant_high,
+ lsp_unquant_high,
+ /*Pitch quantization*/
+ NULL,
+ NULL,
+ NULL,
+ /*Innovation quantization*/
+ split_cb_search_shape_sign,
+ split_cb_shape_sign_unquant,
+#ifdef DISABLE_WIDEBAND
+ NULL,
+#else
+ &split_cb_high,
+#endif
+ -1,
+ 192
+};
+
+static const SpeexSubmode wb_submode4 = {
+ 0,
+ 0,
+ 1,
+ 1,
+ /*LSP quantization*/
+ lsp_quant_high,
+ lsp_unquant_high,
+ /*Pitch quantization*/
+ NULL,
+ NULL,
+ NULL,
+ /*Innovation quantization*/
+ split_cb_search_shape_sign,
+ split_cb_shape_sign_unquant,
+#ifdef DISABLE_WIDEBAND
+ NULL,
+#else
+ &split_cb_high,
+#endif
+ -1,
+ 352
+};
+
+
+/* Split-band wideband CELP mode*/
+static const SpeexSBMode sb_wb_mode = {
+ &speex_nb_mode,
+ 160, /*frameSize*/
+ 40, /*subframeSize*/
+ 8, /*lpcSize*/
+ 640, /*bufSize*/
+#ifdef FIXED_POINT
+ 29491, 19661, /* gamma1, gamma2 */
+#else
+ 0.9, 0.6, /* gamma1, gamma2 */
+#endif
+ .012, /*lag_factor*/
+ QCONST16(.0002,15), /*lpc_floor*/
+ QCONST16(0.9f,15),
+ {NULL, &wb_submode1, &wb_submode2, &wb_submode3, &wb_submode4, NULL, NULL, NULL},
+ 3,
+ {1, 8, 2, 3, 4, 5, 5, 6, 6, 7, 7},
+ {1, 1, 1, 1, 1, 1, 2, 2, 3, 3, 4},
+ vbr_hb_thresh,
+ 5
+};
+
+
+const SpeexMode speex_wb_mode = {
+ &sb_wb_mode,
+ wb_mode_query,
+ "wideband (sub-band CELP)",
+ 1,
+ 4,
+ &sb_encoder_init,
+ &sb_encoder_destroy,
+ &sb_encode,
+ &sb_decoder_init,
+ &sb_decoder_destroy,
+ &sb_decode,
+ &sb_encoder_ctl,
+ &sb_decoder_ctl,
+};
+
+
+
+/* "Ultra-wideband" mode stuff */
+
+
+
+/* Split-band "ultra-wideband" (32 kbps) CELP mode*/
+static const SpeexSBMode sb_uwb_mode = {
+ &speex_wb_mode,
+ 320, /*frameSize*/
+ 80, /*subframeSize*/
+ 8, /*lpcSize*/
+ 1280, /*bufSize*/
+#ifdef FIXED_POINT
+ 29491, 19661, /* gamma1, gamma2 */
+#else
+ 0.9, 0.6, /* gamma1, gamma2 */
+#endif
+ .012, /*lag_factor*/
+ QCONST16(.0002,15), /*lpc_floor*/
+ QCONST16(0.7f,15),
+ {NULL, &wb_submode1, NULL, NULL, NULL, NULL, NULL, NULL},
+ 1,
+ {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10},
+ {0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
+ vbr_uhb_thresh,
+ 2
+};
+
+int wb_mode_query(const void *mode, int request, void *ptr)
+{
+ const SpeexSBMode *m = (const SpeexSBMode*)mode;
+
+ switch (request)
+ {
+ case SPEEX_MODE_FRAME_SIZE:
+ *((int*)ptr)=2*m->frameSize;
+ break;
+ case SPEEX_SUBMODE_BITS_PER_FRAME:
+ if (*((int*)ptr)==0)
+ *((int*)ptr) = SB_SUBMODE_BITS+1;
+ else if (m->submodes[*((int*)ptr)]==NULL)
+ *((int*)ptr) = -1;
+ else
+ *((int*)ptr) = m->submodes[*((int*)ptr)]->bits_per_frame;
+ break;
+ default:
+ speex_warning_int("Unknown wb_mode_query request: ", request);
+ return -1;
+ }
+ return 0;
+}
+
+
+const SpeexMode speex_uwb_mode = {
+ &sb_uwb_mode,
+ wb_mode_query,
+ "ultra-wideband (sub-band CELP)",
+ 2,
+ 4,
+ &sb_encoder_init,
+ &sb_encoder_destroy,
+ &sb_encode,
+ &sb_decoder_init,
+ &sb_decoder_destroy,
+ &sb_decode,
+ &sb_encoder_ctl,
+ &sb_decoder_ctl,
+};
+
+/* We have defined speex_lib_get_mode() as a macro in speex.h */
+#undef speex_lib_get_mode
+
+const SpeexMode * speex_lib_get_mode (int mode)
+{
+#ifdef EPIC_48K
+ if (mode == SPEEX_MODEID_NB_48K) return &speex_nb_48k_mode;
+#endif
+
+ if (mode < 0 || mode >= SPEEX_NB_MODES) return NULL;
+
+ return speex_mode_list[mode];
+}
+
+
+
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 @@
#include "vbr.h"
#include "misc.h"
#include "math_approx.h"
+#include "os_support.h"
#include <speex/speex_callbacks.h>
#ifdef VORBIS_PSYCHO
@@ -1207,7 +1208,9 @@ static void nb_decode_lost(DecState *st, spx_word16_t *out, char *stack)
st->pitch_gain_buf_idx = 0;
}
-
+/* Just so we don't need to carry the complete wideband mode information */
+static const int wb_skip_table[8] = {0, 36, 112, 192, 352, 0, 0, 0};
+
int nb_decode(void *state, SpeexBits *bits, void *vout)
{
DecState *st;
@@ -1266,7 +1269,8 @@ int nb_decode(void *state, SpeexBits *bits, void *vout)
int submode;
int advance;
advance = submode = speex_bits_unpack_unsigned(bits, SB_SUBMODE_BITS);
- speex_mode_query(&speex_wb_mode, SPEEX_SUBMODE_BITS_PER_FRAME, &advance);
+ /*speex_mode_query(&speex_wb_mode, SPEEX_SUBMODE_BITS_PER_FRAME, &advance);*/
+ advance = wb_skip_table[submode];
if (advance < 0)
{
speex_notify("Invalid mode encountered. The stream is corrupted.");
@@ -1281,7 +1285,8 @@ int nb_decode(void *state, SpeexBits *bits, void *vout)
if (wideband)
{
advance = submode = speex_bits_unpack_unsigned(bits, SB_SUBMODE_BITS);
- speex_mode_query(&speex_wb_mode, SPEEX_SUBMODE_BITS_PER_FRAME, &advance);
+ /*speex_mode_query(&speex_wb_mode, SPEEX_SUBMODE_BITS_PER_FRAME, &advance);*/
+ advance = wb_skip_table[submode];
if (advance < 0)
{
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 @@
#include "fftwrap.h"
#include "filterbank.h"
#include "math_approx.h"
+#include "os_support.h"
#ifndef M_PI
#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 @@
#define PSEUDOFLOAT_H
#include "misc.h"
+#include "os_support.h"
#include "math_approx.h"
#include <math.h>
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 @@
#endif
#include "quant_lsp.h"
+#include "os_support.h"
#include <math.h>
#ifndef M_PI
#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);}
#include "speex/speex_resampler.h"
#include "misc.h"
+#include "os_support.h"
#endif /* OUTSIDE_SPEEX */
#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 @@
#include "ltp.h"
#include "misc.h"
#include "math_approx.h"
+#include "os_support.h"
#ifndef NULL
#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 @@
#include <math.h>
#include "smallft.h"
#include "misc.h"
+#include "os_support.h"
static void drfti1(int n, float *wa, int *ifac){
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 @@
#include "modes.h"
#include <math.h>
+#include "os_support.h"
#ifndef NULL
#define NULL 0
@@ -208,29 +209,6 @@ int nb_mode_query(const void *mode, int request, void *ptr)
return 0;
}
-int wb_mode_query(const void *mode, int request, void *ptr)
-{
- const SpeexSBMode *m = (const SpeexSBMode*)mode;
-
- switch (request)
- {
- case SPEEX_MODE_FRAME_SIZE:
- *((int*)ptr)=2*m->frameSize;
- break;
- case SPEEX_SUBMODE_BITS_PER_FRAME:
- if (*((int*)ptr)==0)
- *((int*)ptr) = SB_SUBMODE_BITS+1;
- else if (m->submodes[*((int*)ptr)]==NULL)
- *((int*)ptr) = -1;
- else
- *((int*)ptr) = m->submodes[*((int*)ptr)]->bits_per_frame;
- break;
- default:
- speex_warning_int("Unknown wb_mode_query request: ", request);
- return -1;
- }
- return 0;
-}
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];
/** Obtain one of the modes available */
const SpeexMode * speex_lib_get_mode (int mode);
+/* We actually override the fucntion in the narrowband case so that we can avoid linking in the wideband stuff */
+#define speex_lib_get_mode(mode) ((mode)==SPEEX_MODEID_NB ? &speex_nb_mode : speex_lib_get_mode (mode))
+
#ifdef __cplusplus
}
#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 @@
#include <speex/speex_callbacks.h>
#include "misc.h"
+#include "os_support.h"
int speex_inband_handler(SpeexBits *bits, SpeexCallback *callback_list, void *state)
{
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 @@
#include "misc.h"
#include <speex/speex_header.h>
#include <speex/speex.h>
+#include "os_support.h"
#ifndef NULL
#define NULL 0