From fa971b142d794c9620b823d6b9d1937397c1f1e1 Mon Sep 17 00:00:00 2001 From: Thom Johansen Date: Fri, 26 Oct 2007 01:16:55 +0000 Subject: 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 --- apps/codecs/libspeex/README.rockbox | 2 +- apps/codecs/libspeex/SOURCES | 4 +- apps/codecs/libspeex/bits.c | 1 + apps/codecs/libspeex/cb_search.c | 2 + apps/codecs/libspeex/fftwrap.c | 1 + apps/codecs/libspeex/filterbank.c | 1 + apps/codecs/libspeex/filters_cf.S | 32 ++-- apps/codecs/libspeex/jitter.c | 1 + apps/codecs/libspeex/kiss_fft.c | 1 + apps/codecs/libspeex/kiss_fftr.c | 1 + apps/codecs/libspeex/math_approx.c | 38 ----- apps/codecs/libspeex/math_approx.h | 23 ++- apps/codecs/libspeex/mdf.c | 1 + apps/codecs/libspeex/misc.c | 49 ------ apps/codecs/libspeex/misc.h | 133 +-------------- apps/codecs/libspeex/modes.c | 219 ------------------------ apps/codecs/libspeex/modes_wb.c | 304 +++++++++++++++++++++++++++++++++ apps/codecs/libspeex/nb_celp.c | 11 +- apps/codecs/libspeex/preprocess.c | 1 + apps/codecs/libspeex/pseudofloat.h | 1 + apps/codecs/libspeex/quant_lsp.c | 1 + apps/codecs/libspeex/resample.c | 1 + apps/codecs/libspeex/sb_celp.c | 1 + apps/codecs/libspeex/smallft.c | 1 + apps/codecs/libspeex/speex.c | 24 +-- apps/codecs/libspeex/speex/speex.h | 3 + apps/codecs/libspeex/speex_callbacks.c | 1 + apps/codecs/libspeex/speex_header.c | 1 + 28 files changed, 375 insertions(+), 484 deletions(-) delete mode 100644 apps/codecs/libspeex/math_approx.c delete mode 100644 apps/codecs/libspeex/misc.c create mode 100644 apps/codecs/libspeex/modes_wb.c (limited to 'apps/codecs') 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 #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 #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 #include #include +#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 -#include -#include -#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;iquery(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 +#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 #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 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 #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 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 #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 +#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 #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 #include +#include "os_support.h" #ifndef NULL #define NULL 0 -- cgit v1.2.3