├── main.c ├── timer.c ├── debugLeds.c ├── README.md ├── Git speex_codec.lnk ├── libPDMFilter_GCC.a ├── cmsis_boot ├── stm32f4xx.h ├── system_stm32f4xx.h └── stm32f4xx_conf.h ├── cmsis_lib ├── source │ └── stm32f4xx_rcc.c └── include │ └── misc.h ├── speex_codec └── Debug │ └── bin │ ├── speex_codec.bin │ └── speex_codec.elf ├── speex_codec.comemgui ├── debugLeds.h ├── SndMic.h ├── timer.h ├── codec.h ├── SndPlay.h ├── codec.c ├── syscalls └── syscalls.c ├── speex ├── libspeex │ ├── lpc.h │ ├── exc_10_16_table.c │ ├── gain_table_lbr.c │ ├── vbr.h │ ├── vq.h │ ├── lsp.h │ ├── exc_10_32_table.c │ ├── quant_lsp.h │ ├── exc_5_64_table.c │ ├── hexc_10_32_table.c │ ├── exc_20_32_table.c │ ├── stack_alloc.h │ ├── cb_search.h │ ├── filters.h │ ├── gain_table.c │ ├── modes.c │ ├── speex_callbacks.c │ ├── vq.c │ ├── fixed_generic.h │ ├── exc_8_128_table.c │ ├── high_lsp_tables.c │ ├── window.c │ ├── os_support.h │ ├── ltp.h │ ├── lpc.c │ ├── sb_celp.h │ └── hexc_table.c ├── STM32 │ ├── config.h │ └── libspeex │ │ ├── gcc │ │ ├── ltp_cortexM3.h │ │ ├── vq_cortexm3.s │ │ ├── filters_cortexM3.h │ │ └── ltp_cortexM3.s │ │ ├── iar │ │ ├── ltp_cortexM3.h │ │ ├── vq_cortexm3.s │ │ ├── filters_cortexM3.h │ │ └── ltp_cortexM3.s │ │ ├── arm │ │ └── vq_cortexM3.h │ │ ├── modes.c │ │ └── vq.c └── include │ └── speex │ ├── speex_types.h │ └── speex_callbacks.h ├── speex_codec.comarker ├── main.h ├── pdm_filter.h └── SndMic.c /main.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SrgShv/speex_stm32/HEAD/main.c -------------------------------------------------------------------------------- /timer.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SrgShv/speex_stm32/HEAD/timer.c -------------------------------------------------------------------------------- /debugLeds.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SrgShv/speex_stm32/HEAD/debugLeds.c -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | speex_stm32 2 | =========== 3 | 4 | realize speex codec in stm32f4 5 | -------------------------------------------------------------------------------- /Git speex_codec.lnk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SrgShv/speex_stm32/HEAD/Git speex_codec.lnk -------------------------------------------------------------------------------- /libPDMFilter_GCC.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SrgShv/speex_stm32/HEAD/libPDMFilter_GCC.a -------------------------------------------------------------------------------- /cmsis_boot/stm32f4xx.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SrgShv/speex_stm32/HEAD/cmsis_boot/stm32f4xx.h -------------------------------------------------------------------------------- /cmsis_lib/source/stm32f4xx_rcc.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SrgShv/speex_stm32/HEAD/cmsis_lib/source/stm32f4xx_rcc.c -------------------------------------------------------------------------------- /speex_codec/Debug/bin/speex_codec.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SrgShv/speex_stm32/HEAD/speex_codec/Debug/bin/speex_codec.bin -------------------------------------------------------------------------------- /speex_codec/Debug/bin/speex_codec.elf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SrgShv/speex_stm32/HEAD/speex_codec/Debug/bin/speex_codec.elf -------------------------------------------------------------------------------- /speex_codec.comemgui: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /debugLeds.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** 3 | ** debugLeds.h 4 | ** 5 | ** 6 | **********************************************************************/ 7 | 8 | #ifndef __DEBUGLEDS_H 9 | #define __DEBUGLEDS_H 10 | 11 | void debugBlinkBlueLed(const int divScaler); 12 | void debugBlinkRedLed(const int divScaler); 13 | void debugBlinkOrangeLed(const int divScaler); 14 | void debugBlinkGreenLed(const int divScaler); 15 | void initGPIO_LED(void); 16 | 17 | #endif /* __DEBUGLEDS_H */ 18 | 19 | -------------------------------------------------------------------------------- /SndMic.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** 3 | ** SndMic.h 4 | ** 5 | ** 6 | **********************************************************************/ 7 | 8 | #ifndef __SNDMIC_H 9 | #define __SNDMIC_H 10 | 11 | typedef unsigned int DWORD; 12 | typedef unsigned short WORD; 13 | typedef unsigned char BYTE; 14 | 15 | /* PDM buffer input size */ 16 | #define INTERNAL_BUFF_SIZE 64 17 | 18 | /* PCM buffer output size */ 19 | #define PCM_OUT_SIZE 16 20 | 21 | void initMic(void); 22 | 23 | extern void IRQ_mic(WORD *bff, WORD sz); 24 | 25 | #endif /* __SNDMIC_H */ -------------------------------------------------------------------------------- /timer.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** 3 | ** timer.h 4 | ** 5 | ** 6 | **********************************************************************/ 7 | 8 | #ifndef __TIMER_H 9 | #define __TIMER_H 10 | 11 | typedef unsigned int DWORD; 12 | typedef unsigned short WORD; 13 | typedef unsigned char BYTE; 14 | 15 | extern void IRQ_timer(void); 16 | 17 | void TIM2_Config(void); 18 | void TIM2_IRQHandler(void); 19 | void NVIC_Config(void); 20 | void TIM2_Start(void); 21 | void TIM2_Stop(void); 22 | 23 | extern void debugBlinkGreenLed(const int divScaler); 24 | 25 | 26 | #endif /* __TIMER_H */ 27 | -------------------------------------------------------------------------------- /codec.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** 3 | ** codec.h 4 | ** 5 | ** 6 | **********************************************************************/ 7 | 8 | #ifndef __CODEC_H 9 | #define __CODEC_H 10 | 11 | typedef unsigned int DWORD; 12 | typedef unsigned short WORD; 13 | typedef unsigned char BYTE; 14 | 15 | #define FRAME_SIZE 160 16 | #define SPEEX_SIZE 20 17 | 18 | //void initDecoder(void); 19 | 20 | void createEncoder(void); 21 | BYTE* encodeSPEEX(signed short *data); 22 | void createDecoder(void); 23 | void deleteEncoder(void); 24 | signed short* decodeSPEEX(BYTE *data); 25 | void deleteDecoder(void); 26 | 27 | #endif /* __CODEC_H */ 28 | -------------------------------------------------------------------------------- /SndPlay.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** 3 | ** SndPlay.h 4 | ** 5 | ** 6 | **********************************************************************/ 7 | 8 | #ifndef __SNDPLAY_H 9 | #define __SNDPLAY_H 10 | 11 | typedef unsigned int DWORD; 12 | typedef unsigned short WORD; 13 | typedef unsigned char BYTE; 14 | 15 | #define CODEC_FLAG_TIMEOUT ((uint32_t)0x1000) 16 | #define CODEC_LONG_TIMEOUT ((uint32_t)(300 * CODEC_FLAG_TIMEOUT)) 17 | #define CODEC_ADDRESS 0x94 /* b00100111 */ 18 | /* Mask for the bit EN of the I2S CFGR register */ 19 | #define I2S_ENABLE_MASK 0x0400 20 | 21 | void initPlayer(BYTE volume, WORD Fs); 22 | DWORD Codec_WriteRegister(BYTE RegisterAddr, BYTE RegisterValue); 23 | DWORD Codec_TIMEOUT_UserCallback(void); 24 | void initCS43L22(BYTE volume); 25 | DWORD Codec_ReadRegister(BYTE RegisterAddr); 26 | void sendSample(signed short smpl); 27 | char checkSPITXE(void); 28 | 29 | extern void IRQ_play(void); 30 | 31 | DWORD dbg_check1(void); 32 | DWORD dbg_check2(void); 33 | 34 | 35 | #endif /* __SNDPLAY_H */ 36 | -------------------------------------------------------------------------------- /codec.c: -------------------------------------------------------------------------------- 1 | 2 | #include "codec.h" 3 | #include "speex.h" 4 | 5 | 6 | short in_short[FRAME_SIZE]; 7 | signed short out_short[FRAME_SIZE]; 8 | BYTE in_byte[SPEEX_SIZE]; 9 | 10 | void *pDec = 0; 11 | SpeexBits inbits; 12 | SpeexBits obits; 13 | 14 | void *pEnc = 0; 15 | 16 | void createEncoder(void) 17 | { 18 | signed int tmp = 0; 19 | speex_bits_init(&inbits); 20 | pEnc = speex_encoder_init(&speex_nb_mode); 21 | //tmp=0; 22 | //speex_encoder_ctl(pEnc, SPEEX_SET_VBR, &tmp); 23 | tmp=4; 24 | speex_encoder_ctl(pEnc, SPEEX_SET_QUALITY, &tmp); 25 | tmp=2; 26 | speex_encoder_ctl(pEnc, SPEEX_SET_COMPLEXITY, &tmp); 27 | } 28 | 29 | BYTE* encodeSPEEX(signed short *data) 30 | { 31 | char *pCh = (char*)(&in_byte[0]); 32 | speex_bits_reset(&inbits); 33 | speex_encode_int(pEnc, data, &inbits); 34 | speex_bits_write(&inbits, pCh, SPEEX_SIZE); 35 | return (BYTE*)pCh; 36 | } 37 | 38 | void createDecoder(void) 39 | { 40 | pDec = speex_decoder_init(&speex_nb_mode); 41 | speex_bits_init(&obits); 42 | } 43 | 44 | signed short* decodeSPEEX(BYTE *data) 45 | { 46 | speex_bits_read_from(&obits, (char*)data, SPEEX_SIZE); 47 | speex_decode_int(pDec, &obits, out_short); 48 | speex_bits_reset(&obits); 49 | return (signed short*)(&out_short[0]); 50 | } 51 | 52 | void deleteEncoder(void) 53 | { 54 | 55 | } 56 | 57 | void deleteDecoder(void) 58 | { 59 | 60 | } 61 | 62 | 63 | -------------------------------------------------------------------------------- /syscalls/syscalls.c: -------------------------------------------------------------------------------- 1 | /**************************************************************************//***** 2 | * @file stdio.c 3 | * @brief Implementation of newlib syscall 4 | ********************************************************************************/ 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #undef errno 12 | extern int errno; 13 | extern int _end; 14 | 15 | __attribute__ ((used)) 16 | caddr_t _sbrk ( int incr ) 17 | { 18 | static unsigned char *heap = NULL; 19 | unsigned char *prev_heap; 20 | 21 | if (heap == NULL) { 22 | heap = (unsigned char *)&_end; 23 | } 24 | prev_heap = heap; 25 | 26 | heap += incr; 27 | 28 | return (caddr_t) prev_heap; 29 | } 30 | 31 | __attribute__ ((used)) 32 | int link(char *old, char *new) { 33 | return -1; 34 | } 35 | 36 | __attribute__ ((used)) 37 | int _close(int file) 38 | { 39 | return -1; 40 | } 41 | 42 | __attribute__ ((used)) 43 | int _fstat(int file, struct stat *st) 44 | { 45 | st->st_mode = S_IFCHR; 46 | return 0; 47 | } 48 | 49 | __attribute__ ((used)) 50 | int _isatty(int file) 51 | { 52 | return 1; 53 | } 54 | 55 | __attribute__ ((used)) 56 | int _lseek(int file, int ptr, int dir) 57 | { 58 | return 0; 59 | } 60 | __attribute__ ((used)) 61 | int _read(int file, char *ptr, int len) 62 | { 63 | return 0; 64 | } 65 | __attribute__ ((used)) 66 | int _write(int file, char *ptr, int len) 67 | { 68 | return len; 69 | } 70 | 71 | __attribute__ ((used)) 72 | void abort(void) 73 | { 74 | /* Abort called */ 75 | while(1); 76 | } 77 | 78 | /* --------------------------------- End Of File ------------------------------ */ 79 | -------------------------------------------------------------------------------- /speex/libspeex/lpc.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2002 Jean-Marc Valin */ 2 | /** 3 | @file lpc.h 4 | @brief Functions for LPC (Linear Prediction Coefficients) analysis 5 | */ 6 | /* 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions 9 | are met: 10 | 11 | - Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | 14 | - Redistributions in binary form must reproduce the above copyright 15 | notice, this list of conditions and the following disclaimer in the 16 | documentation and/or other materials provided with the distribution. 17 | 18 | - Neither the name of the Xiph.org Foundation nor the names of its 19 | contributors may be used to endorse or promote products derived from 20 | this software without specific prior written permission. 21 | 22 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 25 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR 26 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 27 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 28 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 29 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 30 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 31 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 32 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | */ 34 | 35 | #ifndef LPC_H 36 | #define LPC_H 37 | 38 | #include "arch.h" 39 | 40 | void _spx_autocorr( 41 | const spx_word16_t * x, /* in: [0...n-1] samples x */ 42 | spx_word16_t *ac, /* out: [0...lag-1] ac values */ 43 | int lag, int n); 44 | 45 | spx_word32_t /* returns minimum mean square error */ 46 | _spx_lpc( 47 | spx_coef_t * lpc, /* [0...p-1] LPC coefficients */ 48 | const spx_word16_t * ac, /* in: [0...p] autocorrelation values */ 49 | int p 50 | ); 51 | 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /speex/libspeex/exc_10_16_table.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2002 Jean-Marc Valin 2 | File: exc_10_16_table.c 3 | Codebook for excitation in narrowband CELP mode (3200 bps) 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 | 34 | const signed char exc_10_16_table[160] = { 35 | 22,39,14,44,11,35,-2,23,-4,6, 36 | 46,-28,13,-27,-23,12,4,20,-5,9, 37 | 37,-18,-23,23,0,9,-6,-20,4,-1, 38 | -17,-5,-4,17,0,1,9,-2,1,2, 39 | 2,-12,8,-25,39,15,9,16,-55,-11, 40 | 9,11,5,10,-2,-60,8,13,-6,11, 41 | -16,27,-47,-12,11,1,16,-7,9,-3, 42 | -29,9,-14,25,-19,34,36,12,40,-10, 43 | -3,-24,-14,-37,-21,-35,-2,-36,3,-6, 44 | 67,28,6,-17,-3,-12,-16,-15,-17,-7, 45 | -59,-36,-13,1,7,1,2,10,2,11, 46 | 13,10,8,-2,7,3,5,4,2,2, 47 | -3,-8,4,-5,6,7,-42,15,35,-2, 48 | -46,38,28,-20,-9,1,7,-3,0,-2, 49 | 0,0,0,0,0,0,0,0,0,0, 50 | -15,-28,52,32,5,-5,-17,-20,-10,-1}; 51 | -------------------------------------------------------------------------------- /speex/libspeex/gain_table_lbr.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2002 Jean-Marc Valin 2 | File: gain_table_lbr.c 3 | Codebook for 3-tap pitch prediction gain (32 entries) 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | 9 | 1. Redistributions of source code must retain the above copyright notice, 10 | this list of conditions and the following disclaimer. 11 | 12 | 2. 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 | 3. The name of the author may not be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 23 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 27 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 28 | ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 | POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | const signed char gain_cdbk_lbr[128] = { 33 | -32, -32, -32, 0, 34 | -31, -58, -16, 22, 35 | -41, -24, -43, 14, 36 | -56, -22, -55, 29, 37 | -13, 33, -41, 47, 38 | -4, -39, -9, 29, 39 | -41, 15, -12, 38, 40 | -8, -15, -12, 31, 41 | 1, 2, -44, 40, 42 | -22, -66, -42, 27, 43 | -38, 28, -23, 38, 44 | -21, 14, -37, 31, 45 | 0, 21, -50, 52, 46 | -53, -71, -27, 33, 47 | -37, -1, -19, 25, 48 | -19, -5, -28, 22, 49 | 6, 65, -44, 74, 50 | -33, -48, -33, 9, 51 | -40, 57, -14, 58, 52 | -17, 4, -45, 32, 53 | -31, 38, -33, 36, 54 | -23, 28, -40, 39, 55 | -43, 29, -12, 46, 56 | -34, 13, -23, 28, 57 | -16, 15, -27, 34, 58 | -14, -82, -15, 43, 59 | -31, 25, -32, 29, 60 | -21, 5, -5, 38, 61 | -47, -63, -51, 33, 62 | -46, 12, 3, 47, 63 | -28, -17, -29, 11, 64 | -10, 14, -40, 38}; 65 | -------------------------------------------------------------------------------- /cmsis_boot/system_stm32f4xx.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file system_stm32f4xx.h 4 | * @author MCD Application Team 5 | * @version V1.0.0 6 | * @date 30-September-2011 7 | * @brief CMSIS Cortex-M4 Device System Source File for STM32F4xx devices. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 17 | * 18 | *

© COPYRIGHT 2011 STMicroelectronics

19 | ****************************************************************************** 20 | */ 21 | 22 | /** @addtogroup CMSIS 23 | * @{ 24 | */ 25 | 26 | /** @addtogroup stm32f4xx_system 27 | * @{ 28 | */ 29 | 30 | /** 31 | * @brief Define to prevent recursive inclusion 32 | */ 33 | #ifndef __SYSTEM_STM32F4XX_H 34 | #define __SYSTEM_STM32F4XX_H 35 | 36 | #ifdef __cplusplus 37 | extern "C" { 38 | #endif 39 | 40 | /** @addtogroup STM32F4xx_System_Includes 41 | * @{ 42 | */ 43 | 44 | /** 45 | * @} 46 | */ 47 | 48 | 49 | /** @addtogroup STM32F4xx_System_Exported_types 50 | * @{ 51 | */ 52 | 53 | extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ 54 | 55 | 56 | /** 57 | * @} 58 | */ 59 | 60 | /** @addtogroup STM32F4xx_System_Exported_Constants 61 | * @{ 62 | */ 63 | 64 | /** 65 | * @} 66 | */ 67 | 68 | /** @addtogroup STM32F4xx_System_Exported_Macros 69 | * @{ 70 | */ 71 | 72 | /** 73 | * @} 74 | */ 75 | 76 | /** @addtogroup STM32F4xx_System_Exported_Functions 77 | * @{ 78 | */ 79 | 80 | extern void SystemInit(void); 81 | extern void SystemCoreClockUpdate(void); 82 | /** 83 | * @} 84 | */ 85 | 86 | #ifdef __cplusplus 87 | } 88 | #endif 89 | 90 | #endif /*__SYSTEM_STM32F4XX_H */ 91 | 92 | /** 93 | * @} 94 | */ 95 | 96 | /** 97 | * @} 98 | */ 99 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 100 | -------------------------------------------------------------------------------- /speex/libspeex/vbr.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2002 Jean-Marc Valin */ 2 | /** 3 | @file vbr.h 4 | @brief Variable Bit-Rate (VBR) related routines 5 | */ 6 | /* 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions 9 | are met: 10 | 11 | - Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | 14 | - Redistributions in binary form must reproduce the above copyright 15 | notice, this list of conditions and the following disclaimer in the 16 | documentation and/or other materials provided with the distribution. 17 | 18 | - Neither the name of the Xiph.org Foundation nor the names of its 19 | contributors may be used to endorse or promote products derived from 20 | this software without specific prior written permission. 21 | 22 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 25 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR 26 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 27 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 28 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 29 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 30 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 31 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 32 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | 34 | */ 35 | 36 | 37 | #ifndef VBR_H 38 | #define VBR_H 39 | 40 | #include "arch.h" 41 | 42 | #define VBR_MEMORY_SIZE 5 43 | 44 | extern const float vbr_nb_thresh[9][11]; 45 | extern const float vbr_hb_thresh[5][11]; 46 | extern const float vbr_uhb_thresh[2][11]; 47 | 48 | /** VBR state. */ 49 | typedef struct VBRState { 50 | float energy_alpha; 51 | float average_energy; 52 | float last_energy; 53 | float last_log_energy[VBR_MEMORY_SIZE]; 54 | float accum_sum; 55 | float last_pitch_coef; 56 | float soft_pitch; 57 | float last_quality; 58 | float noise_level; 59 | float noise_accum; 60 | float noise_accum_count; 61 | int consec_noise; 62 | } VBRState; 63 | 64 | void vbr_init(VBRState *vbr); 65 | 66 | float vbr_analysis(VBRState *vbr, spx_word16_t *sig, int len, int pitch, float pitch_coef); 67 | 68 | void vbr_destroy(VBRState *vbr); 69 | 70 | #endif 71 | -------------------------------------------------------------------------------- /speex_codec.comarker: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /speex/libspeex/vq.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2002 Jean-Marc Valin */ 2 | /** 3 | @file vq.h 4 | @brief Vector quantization 5 | */ 6 | /* 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions 9 | are met: 10 | 11 | - Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | 14 | - Redistributions in binary form must reproduce the above copyright 15 | notice, this list of conditions and the following disclaimer in the 16 | documentation and/or other materials provided with the distribution. 17 | 18 | - Neither the name of the Xiph.org Foundation nor the names of its 19 | contributors may be used to endorse or promote products derived from 20 | this software without specific prior written permission. 21 | 22 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 25 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR 26 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 27 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 28 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 29 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 30 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 31 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 32 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | */ 34 | 35 | #ifndef VQ_H 36 | #define VQ_H 37 | 38 | #include "arch.h" 39 | 40 | int scal_quant(spx_word16_t in, const spx_word16_t *boundary, int entries); 41 | int scal_quant32(spx_word32_t in, const spx_word32_t *boundary, int entries); 42 | 43 | #ifdef _USE_SSE 44 | #include 45 | void vq_nbest(spx_word16_t *in, const __m128 *codebook, int len, int entries, __m128 *E, int N, int *nbest, spx_word32_t *best_dist, char *stack); 46 | 47 | void vq_nbest_sign(spx_word16_t *in, const __m128 *codebook, int len, int entries, __m128 *E, int N, int *nbest, spx_word32_t *best_dist, char *stack); 48 | #else 49 | void vq_nbest(spx_word16_t *in, const spx_word16_t *codebook, int len, int entries, spx_word32_t *E, int N, int *nbest, spx_word32_t *best_dist, char *stack); 50 | 51 | void vq_nbest_sign(spx_word16_t *in, const spx_word16_t *codebook, int len, int entries, spx_word32_t *E, int N, int *nbest, spx_word32_t *best_dist, char *stack); 52 | #endif 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /speex/STM32/config.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2008 STMicroelectronics, MCD */ 2 | /* 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions 6 | are met: 7 | 8 | - Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | 11 | - Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | 15 | - Neither the name of the Xiph.org Foundation nor the names of its 16 | contributors may be used to endorse or promote products derived from 17 | this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR 23 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 24 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 25 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 26 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 27 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 28 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 29 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | #ifdef __IAR_SYSTEMS_ICC__ /* IAR Compiler */ 33 | #define inline inline 34 | #endif 35 | 36 | #ifdef __CC_ARM /* ARM Compiler */ 37 | #define inline __inline 38 | #endif 39 | 40 | 41 | 42 | //#define 43 | 44 | #define USE_KISS_FFT 45 | #define FIXED_POINT 46 | #define DISABLE_FLOAT_API 47 | #define DISABLE_VBR 48 | #define FRAME_SIZE 160 49 | #define DISABLE_WIDEBAND 50 | #define DISABLE_NOTIFICATIONS 51 | #define DISABLE_WARNINGS 52 | #define RELEASE 53 | #define OVERRIDE_SPEEX_PUTC 54 | //#define OVERRIDE_SPEEX_FATAL 55 | 56 | #define MAX_CHARS_PER_FRAME (20/BYTES_PER_CHAR) 57 | 58 | #define SPEEXENC_PERSIST_STACK_SIZE 5000 59 | #define SPEEXENC_SCRATCH_STACK_SIZE 3000 60 | #define SPEEXDEC_PERSIST_STACK_SIZE 2500 61 | #define SPEEXDEC_SCRATCH_STACK_SIZE 1000 62 | 63 | #define SPEEX_PERSIST_STACK_SIZE (SPEEXENC_PERSIST_STACK_SIZE + SPEEXDEC_PERSIST_STACK_SIZE) 64 | #define SPEEX_SCRATCH_STACK_SIZE SPEEXENC_SCRATCH_STACK_SIZE 65 | #define NB_ENC_STACK SPEEXENC_SCRATCH_STACK_SIZE 66 | #define NB_DEC_STACK SPEEXDEC_SCRATCH_STACK_SIZE 67 | 68 | extern void _speex_fatal(const char *str, const char *file, int line); 69 | extern void _speex_putc(int ch, void *file); 70 | 71 | 72 | -------------------------------------------------------------------------------- /main.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** 3 | ** main.h 4 | ** 5 | ** 6 | **********************************************************************/ 7 | 8 | #ifndef __MAIN_H 9 | #define __MAIN_H 10 | 11 | #include "stm32f4xx_conf.h" 12 | //#include "structs.h" 13 | //#include "tables.h" 14 | //#include "control.h" 15 | 16 | typedef unsigned int DWORD; 17 | typedef unsigned short WORD; 18 | typedef unsigned char BYTE; 19 | 20 | #define PCMSZ 480 21 | #define WPCMSZ (PCMSZ*2) 22 | #define SPBSZ 200 23 | #define SINSZ 32 24 | #define BFFSZ 1000 25 | #define SPXSZ 20 26 | #define SPEEX_BFF_SZ 200 27 | #define FRAME_SIZE 160 28 | #define PCM_BFF_SZ 480 29 | 30 | struct CRKLPCM 31 | { 32 | signed short buff[PCM_BFF_SZ]; 33 | BYTE overfl; 34 | WORD counter; 35 | WORD rxcnt; 36 | WORD wxcnt; 37 | } pcmbff; 38 | 39 | struct STREAMBUFF 40 | { 41 | BYTE buff[SPEEX_BFF_SZ]; 42 | BYTE overfl; 43 | WORD counter; 44 | WORD rxcnt; 45 | WORD wxcnt; 46 | } inSpxBff; 47 | 48 | #define OPUS_TEST 480 49 | short buffOUTPCM[OPUS_TEST*2+1]; 50 | 51 | /** start initialize PCM, SPX structures */ 52 | void IRQ_timer(void); 53 | void IRQ_mic(WORD *bff, WORD sz); 54 | void IRQ_play(void); 55 | 56 | void writeToBff(signed short data); 57 | signed short readFromBff(void); 58 | WORD checkBff(void); 59 | 60 | 61 | extern void TIM2_Start(void); 62 | extern void initGPIO_LED(void); 63 | extern void debugBlinkBlueLed(const int divScaler); 64 | extern void debugBlinkRedLed(const int divScaler); 65 | extern void debugBlinkOrangeLed(const int divScaler); 66 | extern void debugBlinkGreenLed(const int divScaler); 67 | extern void initPlayer(BYTE volume, WORD Fs); 68 | extern void sendSample(signed short smpl); 69 | extern char checkSPITXE(void); 70 | extern void initMic(void); 71 | 72 | /************************* speex codec interface ******************************/ 73 | extern void createEncoder(void); 74 | extern BYTE* encodeSPEEX(signed short *data); 75 | extern void createDecoder(void); 76 | extern void deleteEncoder(void); 77 | extern signed short* decodeSPEEX(BYTE *data); 78 | 79 | void initByte(void); 80 | void putByte(BYTE b); 81 | BYTE getByte(void); 82 | WORD checkByte(void); 83 | BYTE parseOpusInStream(BYTE b); 84 | void initWord(void); 85 | void putWord(signed short b); 86 | signed short getWord(void); 87 | WORD checkWord(void); 88 | 89 | void getFromFileSpx(BYTE *pack); 90 | 91 | #define LIM_N 5 92 | #define MULT_L0 10000 93 | #define MULT_L1 17783 94 | 95 | struct Limiter 96 | { 97 | int Ulim; 98 | int Utrs; 99 | int Ui[LIM_N]; 100 | int Uo[LIM_N]; 101 | int K[LIM_N]; 102 | } slim; 103 | 104 | void initLimiter(void); 105 | signed short limit(signed short dIn); 106 | 107 | #endif /* __MAIN_H */ 108 | -------------------------------------------------------------------------------- /speex/libspeex/lsp.h: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------*\ 2 | Original Copyright 3 | FILE........: AK2LSPD.H 4 | TYPE........: Turbo C header file 5 | COMPANY.....: Voicetronix 6 | AUTHOR......: James Whitehall 7 | DATE CREATED: 21/11/95 8 | 9 | Modified by Jean-Marc Valin 10 | 11 | This file contains functions for converting Linear Prediction 12 | Coefficients (LPC) to Line Spectral Pair (LSP) and back. Note that the 13 | LSP coefficients are not in radians format but in the x domain of the 14 | unit circle. 15 | 16 | \*---------------------------------------------------------------------------*/ 17 | /** 18 | @file lsp.h 19 | @brief Line Spectral Pair (LSP) functions. 20 | */ 21 | /* Speex License: 22 | 23 | Redistribution and use in source and binary forms, with or without 24 | modification, are permitted provided that the following conditions 25 | are met: 26 | 27 | - Redistributions of source code must retain the above copyright 28 | notice, this list of conditions and the following disclaimer. 29 | 30 | - Redistributions in binary form must reproduce the above copyright 31 | notice, this list of conditions and the following disclaimer in the 32 | documentation and/or other materials provided with the distribution. 33 | 34 | - Neither the name of the Xiph.org Foundation nor the names of its 35 | contributors may be used to endorse or promote products derived from 36 | this software without specific prior written permission. 37 | 38 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 39 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 40 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 41 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR 42 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 43 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 44 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 45 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 46 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 47 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 48 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 49 | */ 50 | 51 | #ifndef __AK2LSPD__ 52 | #define __AK2LSPD__ 53 | 54 | #include "arch.h" 55 | 56 | int lpc_to_lsp (spx_coef_t *a, int lpcrdr, spx_lsp_t *freq, int nb, spx_word16_t delta, char *stack); 57 | void lsp_to_lpc(spx_lsp_t *freq, spx_coef_t *ak, int lpcrdr, char *stack); 58 | 59 | /*Added by JMV*/ 60 | void lsp_enforce_margin(spx_lsp_t *lsp, int len, spx_word16_t margin); 61 | 62 | void lsp_interpolate(spx_lsp_t *old_lsp, spx_lsp_t *new_lsp, spx_lsp_t *interp_lsp, int len, int subframe, int nb_subframes); 63 | 64 | #endif /* __AK2LSPD__ */ 65 | -------------------------------------------------------------------------------- /speex/libspeex/exc_10_32_table.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2002 Jean-Marc Valin 2 | File: exc_10_32_table.c 3 | Codebook for excitation in narrowband CELP mode (4000 bps) 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 | 34 | const signed char exc_10_32_table[320] = { 35 | 7,17,17,27,25,22,12,4,-3,0, 36 | 28,-36,39,-24,-15,3,-9,15,-5,10, 37 | 31,-28,11,31,-21,9,-11,-11,-2,-7, 38 | -25,14,-22,31,4,-14,19,-12,14,-5, 39 | 4,-7,4,-5,9,0,-2,42,-47,-16, 40 | 1,8,0,9,23,-57,0,28,-11,6, 41 | -31,55,-45,3,-5,4,2,-2,4,-7, 42 | -3,6,-2,7,-3,12,5,8,54,-10, 43 | 8,-7,-8,-24,-25,-27,-14,-5,8,5, 44 | 44,23,5,-9,-11,-11,-13,-9,-12,-8, 45 | -29,-8,-22,6,-15,3,-12,-1,-5,-3, 46 | 34,-1,29,-16,17,-4,12,2,1,4, 47 | -2,-4,2,-1,11,-3,-52,28,30,-9, 48 | -32,25,44,-20,-24,4,6,-1,0,0, 49 | 0,0,0,0,0,0,0,0,0,0, 50 | -25,-10,22,29,13,-13,-22,-13,-4,0, 51 | -4,-16,10,15,-36,-24,28,25,-1,-3, 52 | 66,-33,-11,-15,6,0,3,4,-2,5, 53 | 24,-20,-47,29,19,-2,-4,-1,0,-1, 54 | -2,3,1,8,-11,5,5,-57,28,28, 55 | 0,-16,4,-4,12,-6,-1,2,-20,61, 56 | -9,24,-22,-42,29,6,17,8,4,2, 57 | -65,15,8,10,5,6,5,3,2,-2, 58 | -3,5,-9,4,-5,23,13,23,-3,-63, 59 | 3,-5,-4,-6,0,-3,23,-36,-46,9, 60 | 5,5,8,4,9,-5,1,-3,10,1, 61 | -6,10,-11,24,-47,31,22,-12,14,-10, 62 | 6,11,-7,-7,7,-31,51,-12,-6,7, 63 | 6,-17,9,-11,-20,52,-19,3,-6,-6, 64 | -8,-5,23,-41,37,1,-21,10,-14,8, 65 | 7,5,-15,-15,23,39,-26,-33,7,2, 66 | -32,-30,-21,-8,4,12,17,15,14,11}; 67 | -------------------------------------------------------------------------------- /pdm_filter.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file pdm_filter.h 4 | * @author MCD Application Team 5 | * @version V1.1.0 6 | * @date 28-October-2011 7 | * @brief Header file for PDM audio software decoding Library. 8 | * This Library is used to decode and reconstruct the audio signal 9 | * produced by MP45DT02 MEMS microphone from STMicroelectronics. 10 | * For more details about this Library, please refer to document 11 | * "PDM audio software decoding on STM32 microcontrollers (AN3998)". 12 | ****************************************************************************** 13 | * @attention 14 | * 15 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 16 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 17 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 18 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 19 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 20 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 21 | * 22 | *

© COPYRIGHT 2011 STMicroelectronics

23 | ****************************************************************************** 24 | */ 25 | 26 | /* Define to prevent recursive inclusion -------------------------------------*/ 27 | #ifndef __PDM_FILTER_H 28 | #define __PDM_FILTER_H 29 | 30 | #ifdef __cplusplus 31 | extern "C" { 32 | #endif 33 | 34 | /* Includes ------------------------------------------------------------------*/ 35 | #include 36 | 37 | /* Exported types ------------------------------------------------------------*/ 38 | typedef struct { 39 | uint16_t Fs; 40 | float LP_HZ; 41 | float HP_HZ; 42 | uint16_t In_MicChannels; 43 | uint16_t Out_MicChannels; 44 | char InternalFilter[34]; 45 | } PDMFilter_InitStruct; 46 | 47 | /* Exported constants --------------------------------------------------------*/ 48 | /* Exported macros -----------------------------------------------------------*/ 49 | #define HTONS(A) ((((u16)(A) & 0xff00) >> 8) | \ 50 | (((u16)(A) & 0x00ff) << 8)) 51 | 52 | /* Exported functions ------------------------------------------------------- */ 53 | void PDM_Filter_Init(PDMFilter_InitStruct * Filter); 54 | 55 | int32_t PDM_Filter_64_MSB(uint8_t* data, uint16_t* dataOut, uint16_t MicGain, PDMFilter_InitStruct * Filter); 56 | int32_t PDM_Filter_80_MSB(uint8_t* data, uint16_t* dataOut, uint16_t MicGain, PDMFilter_InitStruct * Filter); 57 | int32_t PDM_Filter_64_LSB(uint8_t* data, uint16_t* dataOut, uint16_t MicGain, PDMFilter_InitStruct * Filter); 58 | int32_t PDM_Filter_80_LSB(uint8_t* data, uint16_t* dataOut, uint16_t MicGain, PDMFilter_InitStruct * Filter); 59 | 60 | #ifdef __cplusplus 61 | } 62 | #endif 63 | 64 | #endif /* __PDM_FILTER_H */ 65 | 66 | /*******************(C)COPYRIGHT 2011 STMicroelectronics *****END OF FILE******/ 67 | -------------------------------------------------------------------------------- /speex/libspeex/quant_lsp.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2002 Jean-Marc Valin */ 2 | /** 3 | @file quant_lsp.h 4 | @brief LSP vector quantization 5 | */ 6 | /* 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions 9 | are met: 10 | 11 | - Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | 14 | - Redistributions in binary form must reproduce the above copyright 15 | notice, this list of conditions and the following disclaimer in the 16 | documentation and/or other materials provided with the distribution. 17 | 18 | - Neither the name of the Xiph.org Foundation nor the names of its 19 | contributors may be used to endorse or promote products derived from 20 | this software without specific prior written permission. 21 | 22 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 25 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR 26 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 27 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 28 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 29 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 30 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 31 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 32 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | */ 34 | 35 | #ifndef QUANT_LSP_H 36 | #define QUANT_LSP_H 37 | 38 | //#include 39 | #include "speex_bits.h" 40 | #include "arch.h" 41 | 42 | #define MAX_LSP_SIZE 20 43 | 44 | #define NB_CDBK_SIZE 64 45 | #define NB_CDBK_SIZE_LOW1 64 46 | #define NB_CDBK_SIZE_LOW2 64 47 | #define NB_CDBK_SIZE_HIGH1 64 48 | #define NB_CDBK_SIZE_HIGH2 64 49 | 50 | /*Narrowband codebooks*/ 51 | extern const signed char cdbk_nb[]; 52 | extern const signed char cdbk_nb_low1[]; 53 | extern const signed char cdbk_nb_low2[]; 54 | extern const signed char cdbk_nb_high1[]; 55 | extern const signed char cdbk_nb_high2[]; 56 | 57 | /* Quantizes narrowband LSPs with 30 bits */ 58 | void lsp_quant_nb(spx_lsp_t *lsp, spx_lsp_t *qlsp, int order, SpeexBits *bits); 59 | 60 | /* Decodes quantized narrowband LSPs */ 61 | void lsp_unquant_nb(spx_lsp_t *lsp, int order, SpeexBits *bits); 62 | 63 | /* Quantizes low bit-rate narrowband LSPs with 18 bits */ 64 | void lsp_quant_lbr(spx_lsp_t *lsp, spx_lsp_t *qlsp, int order, SpeexBits *bits); 65 | 66 | /* Decodes quantized low bit-rate narrowband LSPs */ 67 | void lsp_unquant_lbr(spx_lsp_t *lsp, int order, SpeexBits *bits); 68 | 69 | /* Quantizes high-band LSPs with 12 bits */ 70 | void lsp_quant_high(spx_lsp_t *lsp, spx_lsp_t *qlsp, int order, SpeexBits *bits); 71 | 72 | /* Decodes high-band LSPs */ 73 | void lsp_unquant_high(spx_lsp_t *lsp, int order, SpeexBits *bits); 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /speex/libspeex/exc_5_64_table.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2002 Jean-Marc Valin 2 | File: exc_5_64_table.c 3 | Codebook for excitation in narrowband CELP mode (9600 bps) 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 | 34 | const signed char exc_5_64_table[320]={ 35 | 1,5,-15,49,-66, 36 | -48,-4,50,-44,7, 37 | 37,16,-18,25,-26, 38 | -26,-15,19,19,-27, 39 | -47,28,57,5,-17, 40 | -32,-41,68,21,-2, 41 | 64,56,8,-16,-13, 42 | -26,-9,-16,11,6, 43 | -39,25,-19,22,-31, 44 | 20,-45,55,-43,10, 45 | -16,47,-40,40,-20, 46 | -51,3,-17,-14,-15, 47 | -24,53,-20,-46,46, 48 | 27,-68,32,3,-18, 49 | -5,9,-31,16,-9, 50 | -10,-1,-23,48,95, 51 | 47,25,-41,-32,-3, 52 | 15,-25,-55,36,41, 53 | -27,20,5,13,14, 54 | -22,5,2,-23,18, 55 | 46,-15,17,-18,-34, 56 | -5,-8,27,-55,73, 57 | 16,2,-1,-17,40, 58 | -78,33,0,2,19, 59 | 4,53,-16,-15,-16, 60 | -28,-3,-13,49,8, 61 | -7,-29,27,-13,32, 62 | 20,32,-61,16,14, 63 | 41,44,40,24,20, 64 | 7,4,48,-60,-77, 65 | 17,-6,-48,65,-15, 66 | 32,-30,-71,-10,-3, 67 | -6,10,-2,-7,-29, 68 | -56,67,-30,7,-5, 69 | 86,-6,-10,0,5, 70 | -31,60,34,-38,-3, 71 | 24,10,-2,30,23, 72 | 24,-41,12,70,-43, 73 | 15,-17,6,13,16, 74 | -13,8,30,-15,-8, 75 | 5,23,-34,-98,-4, 76 | -13,13,-48,-31,70, 77 | 12,31,25,24,-24, 78 | 26,-7,33,-16,8, 79 | 5,-11,-14,-8,-65, 80 | 13,10,-2,-9,0, 81 | -3,-68,5,35,7, 82 | 0,-31,-1,-17,-9, 83 | -9,16,-37,-18,-1, 84 | 69,-48,-28,22,-21, 85 | -11,5,49,55,23, 86 | -86,-36,16,2,13, 87 | 63,-51,30,-11,13, 88 | 24,-18,-6,14,-19, 89 | 1,41,9,-5,27, 90 | -36,-44,-34,-37,-21, 91 | -26,31,-39,15,43, 92 | 5,-8,29,20,-8, 93 | -20,-52,-28,-1,13, 94 | 26,-34,-10,-9,27, 95 | -8,8,27,-66,4, 96 | 12,-22,49,10,-77, 97 | 32,-18,3,-38,12, 98 | -3,-1,2,2,0}; 99 | -------------------------------------------------------------------------------- /speex/libspeex/hexc_10_32_table.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2002 Jean-Marc Valin 2 | File: hexc_10_32_table.c 3 | Codebook for high-band excitation in SB-CELP mode (4000 bps) 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 | const signed char hexc_10_32_table[320] = { 34 | -3, -2, -1, 0, -4, 5, 35, -40, -9, 13, 35 | -44, 5, -27, -1, -7, 6, -11, 7, -8, 7, 36 | 19, -14, 15, -4, 9, -10, 10, -8, 10, -9, 37 | -1, 1, 0, 0, 2, 5, -18, 22, -53, 50, 38 | 1, -23, 50, -36, 15, 3, -13, 14, -10, 6, 39 | 1, 5, -3, 4, -2, 5, -32, 25, 5, -2, 40 | -1, -4, 1, 11, -29, 26, -6, -15, 30, -18, 41 | 0, 15, -17, 40, -41, 3, 9, -2, -2, 3, 42 | -3, -1, -5, 2, 21, -6, -16, -21, 23, 2, 43 | 60, 15, 16, -16, -9, 14, 9, -1, 7, -9, 44 | 0, 1, 1, 0, -1, -6, 17, -28, 54, -45, 45 | -1, 1, -1, -6, -6, 2, 11, 26, -29, -2, 46 | 46, -21, 34, 12, -23, 32, -23, 16, -10, 3, 47 | 66, 19, -20, 24, 7, 11, -3, 0, -3, -1, 48 | -50, -46, 2, -18, -3, 4, -1, -2, 3, -3, 49 | -19, 41, -36, 9, 11, -24, 21, -16, 9, -3, 50 | -25, -3, 10, 18, -9, -2, -5, -1, -5, 6, 51 | -4, -3, 2, -26, 21, -19, 35, -15, 7, -13, 52 | 17, -19, 39, -43, 48, -31, 16, -9, 7, -2, 53 | -5, 3, -4, 9, -19, 27, -55, 63, -35, 10, 54 | 26, -44, -2, 9, 4, 1, -6, 8, -9, 5, 55 | -8, -1, -3, -16, 45, -42, 5, 15, -16, 10, 56 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 57 | -16, 24, -55, 47, -38, 27, -19, 7, -3, 1, 58 | 16, 27, 20, -19, 18, 5, -7, 1, -5, 2, 59 | -6, 8, -22, 0, -3, -3, 8, -1, 7, -8, 60 | 1, -3, 5, 0, 17, -48, 58, -52, 29, -7, 61 | -2, 3, -10, 6, -26, 58, -31, 1, -6, 3, 62 | 93, -29, 39, 3, 17, 5, 6, -1, -1, -1, 63 | 27, 13, 10, 19, -7, -34, 12, 10, -4, 9, 64 | -76, 9, 8, -28, -2, -11, 2, -1, 3, 1, 65 | -83, 38, -39, 4, -16, -6, -2, -5, 5, -2, 66 | }; 67 | -------------------------------------------------------------------------------- /speex/libspeex/exc_20_32_table.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2002 Jean-Marc Valin 2 | File: exc_20_32_table.c 3 | Codebook for excitation in narrowband CELP mode (2000 bps) 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 | 34 | const signed char exc_20_32_table[640] = { 35 | 12,32,25,46,36,33,9,14,-3,6,1,-8,0,-10,-5,-7,-7,-7,-5,-5, 36 | 31,-27,24,-32,-4,10,-11,21,-3,19,23,-9,22,24,-10,-1,-10,-13,-7,-11, 37 | 42,-33,31,19,-8,0,-10,-16,1,-21,-17,10,-8,14,8,4,11,-2,5,-2, 38 | -33,11,-16,33,11,-4,9,-4,11,2,6,-5,8,-5,11,-4,-6,26,-36,-16, 39 | 0,4,-2,-8,12,6,-1,34,-46,-22,9,9,21,9,5,-66,-5,26,2,10, 40 | 13,2,19,9,12,-81,3,13,13,0,-14,22,-35,6,-7,-4,6,-6,10,-6, 41 | -31,38,-33,0,-10,-11,5,-12,12,-17,5,0,-6,13,-9,10,8,25,33,2, 42 | -12,8,-6,10,-2,21,7,17,43,5,11,-7,-9,-20,-36,-20,-23,-4,-4,-3, 43 | 27,-9,-9,-49,-39,-38,-11,-9,6,5,23,25,5,3,3,4,1,2,-3,-1, 44 | 87,39,17,-21,-9,-19,-9,-15,-13,-14,-17,-11,-10,-11,-8,-6,-1,-3,-3,-1, 45 | -54,-34,-27,-8,-11,-4,-5,0,0,4,8,6,9,7,9,7,6,5,5,5, 46 | 48,10,19,-10,12,-1,9,-3,2,5,-3,2,-2,-2,0,-2,-26,6,9,-7, 47 | -16,-9,2,7,7,-5,-43,11,22,-11,-9,34,37,-15,-13,-6,1,-1,1,1, 48 | -64,56,52,-11,-27,5,4,3,1,2,1,3,-1,-4,-4,-10,-7,-4,-4,2, 49 | -1,-7,-7,-12,-10,-15,-9,-5,-5,-11,-16,-13,6,16,4,-13,-16,-10,-4,2, 50 | -47,-13,25,47,19,-14,-20,-8,-17,0,-3,-13,1,6,-17,-14,15,1,10,6, 51 | -24,0,-10,19,-69,-8,14,49,17,-5,33,-29,3,-4,0,2,-8,5,-6,2, 52 | 120,-56,-12,-47,23,-9,6,-5,1,2,-5,1,-10,4,-1,-1,4,-1,0,-3, 53 | 30,-52,-67,30,22,11,-1,-4,3,0,7,2,0,1,-10,-4,-8,-13,5,1, 54 | 1,-1,5,13,-9,-3,-10,-62,22,48,-4,-6,2,3,5,1,1,4,1,13, 55 | 3,-20,10,-9,13,-2,-4,9,-20,44,-1,20,-32,-67,19,0,28,11,8,2, 56 | -11,15,-19,-53,31,2,34,10,6,-4,-58,8,10,13,14,1,12,2,0,0, 57 | -128,37,-8,44,-9,26,-3,18,2,6,11,-1,9,1,5,3,0,1,1,2, 58 | 12,3,-2,-3,7,25,9,18,-6,-37,3,-8,-16,3,-10,-7,17,-34,-44,11, 59 | 17,-15,-3,-16,-1,-13,11,-46,-65,-2,8,13,2,4,4,5,15,5,9,6, 60 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 61 | -9,19,-12,12,-28,38,29,-1,12,2,5,23,-10,3,4,-15,21,-4,3,3, 62 | 6,17,-9,-4,-8,-20,26,5,-10,6,1,-19,18,-15,-12,47,-6,-2,-7,-9, 63 | -1,-17,-2,-2,-14,30,-14,2,-7,-4,-1,-12,11,-25,16,-3,-12,11,-7,7, 64 | -17,1,19,-28,31,-7,-10,7,-10,3,12,5,-16,6,24,41,-29,-54,0,1, 65 | 7,-1,5,-6,13,10,-4,-8,8,-9,-27,-53,-38,-1,10,19,17,16,12,12, 66 | 0,3,-7,-4,13,12,-31,-14,6,-5,3,5,17,43,50,25,10,1,-6,-2}; 67 | -------------------------------------------------------------------------------- /cmsis_boot/stm32f4xx_conf.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file Project/STM32F4xx_StdPeriph_Templates/stm32f4xx_conf.h 4 | * @author MCD Application Team 5 | * @version V1.0.0 6 | * @date 30-September-2011 7 | * @brief Library configuration file. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 17 | * 18 | *

© COPYRIGHT 2011 STMicroelectronics

19 | ****************************************************************************** 20 | */ 21 | 22 | /* Define to prevent recursive inclusion -------------------------------------*/ 23 | #ifndef __STM32F4xx_CONF_H 24 | #define __STM32F4xx_CONF_H 25 | 26 | /* Includes ------------------------------------------------------------------*/ 27 | /* Uncomment the line below to enable peripheral header file inclusion */ 28 | //#include "stm32f4xx_adc.h" 29 | //#include "stm32f4xx_can.h" 30 | //#include "stm32f4xx_crc.h" 31 | //#include "stm32f4xx_cryp.h" 32 | //#include "stm32f4xx_dac.h" 33 | //#include "stm32f4xx_dbgmcu.h" 34 | //#include "stm32f4xx_dcmi.h" 35 | //#include "stm32f4xx_dma.h" 36 | //#include "stm32f4xx_exti.h" 37 | //#include "stm32f4xx_flash.h" 38 | //#include "stm32f4xx_fsmc.h" 39 | //#include "stm32f4xx_hash.h" 40 | #include "stm32f4xx_gpio.h" 41 | #include "stm32f4xx_i2c.h" 42 | //#include "stm32f4xx_iwdg.h" 43 | //#include "stm32f4xx_pwr.h" 44 | #include "stm32f4xx_rcc.h" 45 | //#include "stm32f4xx_rng.h" 46 | //#include "stm32f4xx_rtc.h" 47 | //#include "stm32f4xx_sdio.h" 48 | #include "stm32f4xx_spi.h" 49 | #include "stm32f4xx_syscfg.h" 50 | #include "stm32f4xx_tim.h" 51 | //#include "stm32f4xx_usart.h" 52 | //#include "stm32f4xx_wwdg.h" 53 | #include "misc.h" 54 | /* High level functions for NVIC and SysTick (add-on to CMSIS functions) */ 55 | 56 | /* Exported types ------------------------------------------------------------*/ 57 | /* Exported constants --------------------------------------------------------*/ 58 | 59 | /* If an external clock source is used, then the value of the following define 60 | should be set to the value of the external clock source, else, if no external 61 | clock is used, keep this define commented */ 62 | /*#define I2S_EXTERNAL_CLOCK_VAL 12288000 */ /* Value of the external clock in Hz */ 63 | 64 | 65 | /* Uncomment the line below to expanse the "assert_param" macro in the 66 | Standard Peripheral Library drivers code */ 67 | /* #define USE_FULL_ASSERT 1 */ 68 | 69 | /* Exported macro ------------------------------------------------------------*/ 70 | #ifdef USE_FULL_ASSERT 71 | 72 | /** 73 | * @brief The assert_param macro is used for function's parameters check. 74 | * @param expr: If expr is false, it calls assert_failed function 75 | * which reports the name of the source file and the source 76 | * line number of the call that failed. 77 | * If expr is true, it returns no value. 78 | * @retval None 79 | */ 80 | #define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__)) 81 | /* Exported functions ------------------------------------------------------- */ 82 | void assert_failed(uint8_t* file, uint32_t line); 83 | #else 84 | #define assert_param(expr) ((void)0) 85 | #endif /* USE_FULL_ASSERT */ 86 | 87 | #endif /* __STM32F4xx_CONF_H */ 88 | 89 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 90 | -------------------------------------------------------------------------------- /speex/libspeex/stack_alloc.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2002 Jean-Marc Valin */ 2 | /** 3 | @file stack_alloc.h 4 | @brief Temporary memory allocation on stack 5 | */ 6 | /* 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions 9 | are met: 10 | 11 | - Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | 14 | - Redistributions in binary form must reproduce the above copyright 15 | notice, this list of conditions and the following disclaimer in the 16 | documentation and/or other materials provided with the distribution. 17 | 18 | - Neither the name of the Xiph.org Foundation nor the names of its 19 | contributors may be used to endorse or promote products derived from 20 | this software without specific prior written permission. 21 | 22 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 25 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR 26 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 27 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 28 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 29 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 30 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 31 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 32 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | */ 34 | 35 | #ifndef STACK_ALLOC_H 36 | #define STACK_ALLOC_H 37 | 38 | #ifdef USE_ALLOCA 39 | # ifdef WIN32 40 | # include 41 | # else 42 | # ifdef HAVE_ALLOCA_H 43 | # include 44 | # else 45 | # include 46 | # endif 47 | # endif 48 | #endif 49 | 50 | /** 51 | * @def ALIGN(stack, size) 52 | * 53 | * Aligns the stack to a 'size' boundary 54 | * 55 | * @param stack Stack 56 | * @param size New size boundary 57 | */ 58 | 59 | /** 60 | * @def PUSH(stack, size, type) 61 | * 62 | * Allocates 'size' elements of type 'type' on the stack 63 | * 64 | * @param stack Stack 65 | * @param size Number of elements 66 | * @param type Type of element 67 | */ 68 | 69 | /** 70 | * @def VARDECL(var) 71 | * 72 | * Declare variable on stack 73 | * 74 | * @param var Variable to declare 75 | */ 76 | 77 | /** 78 | * @def ALLOC(var, size, type) 79 | * 80 | * Allocate 'size' elements of 'type' on stack 81 | * 82 | * @param var Name of variable to allocate 83 | * @param size Number of elements 84 | * @param type Type of element 85 | */ 86 | 87 | #ifdef ENABLE_VALGRIND 88 | 89 | #include 90 | 91 | #define ALIGN(stack, size) ((stack) += ((size) - (long)(stack)) & ((size) - 1)) 92 | 93 | #define PUSH(stack, size, type) (VALGRIND_MAKE_NOACCESS(stack, 1000),ALIGN((stack),sizeof(type)),VALGRIND_MAKE_WRITABLE(stack, ((size)*sizeof(type))),(stack)+=((size)*sizeof(type)),(type*)((stack)-((size)*sizeof(type)))) 94 | 95 | #else 96 | 97 | #define ALIGN(stack, size) ((stack) += ((size) - (long)(stack)) & ((size) - 1)) 98 | 99 | #define PUSH(stack, size, type) (ALIGN((stack),sizeof(type)),(stack)+=((size)*sizeof(type)),(type*)((stack)-((size)*sizeof(type)))) 100 | 101 | #endif 102 | 103 | #if defined(VAR_ARRAYS) 104 | #define VARDECL(var) 105 | #define ALLOC(var, size, type) type var[size] 106 | #elif defined(USE_ALLOCA) 107 | #define VARDECL(var) var 108 | #define ALLOC(var, size, type) var = alloca(sizeof(type)*(size)) 109 | #else 110 | #define VARDECL(var) var 111 | #define ALLOC(var, size, type) var = PUSH(stack, size, type) 112 | #endif 113 | 114 | 115 | #endif 116 | -------------------------------------------------------------------------------- /speex/STM32/libspeex/gcc/ltp_cortexM3.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2008 STMicroelectronics, MCD */ 2 | /* 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions 6 | are met: 7 | 8 | - Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | 11 | - Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | 15 | - Neither the name of the Xiph.org Foundation nor the names of its 16 | contributors may be used to endorse or promote products derived from 17 | this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR 23 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 24 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 25 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 26 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 27 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 28 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 29 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | #ifndef __LTP_M3_H 33 | #define __LTP_M3_H 34 | 35 | 36 | #define OVERRIDE_COMPUTE_PITCH_ERROR 37 | #define OVERRIDE_PITCH_GAIN_SEARCH_3TAP_VQ 38 | int pitch_gain_search_3tap_vq( 39 | const signed char *gain_cdbk, 40 | int gain_cdbk_size, 41 | spx_word16_t *C16, 42 | spx_word16_t max_gain 43 | ) 44 | { 45 | int best_cdbk=0; 46 | spx_word32_t best_sum=-VERY_LARGE32; 47 | 48 | int i; 49 | 50 | 51 | spx_word16_t g_0[32]={ 52 | 0, 1, -9, -24, 53 | 19, 28, -9, 24, 54 | 33, 10, -6, 11, 55 | 32, -21, -5, 13, 56 | 38, -1, -8, 15, 57 | 1, 9, -11, -2, 58 | 16, 18, 1, 11, 59 | -15, -14, 4, 22}; 60 | 61 | spx_word16_t g_1[32]={ 62 | 0, -26, 8, 10, 63 | 65, -7, 47, 17, 64 | 34, -34, 60, 46, 65 | 53, -39, 31, 27, 66 | 97, -16, 89, 36, 67 | 70, 60, 61, 45, 68 | 47, -50, 57, 37, 69 | -31, 44, 15, 46}; 70 | 71 | spx_word16_t g_2[32]={ 72 | 0, 16, -11, -23, 73 | -9, 23, 20, 20, 74 | -12, -10, 9, -5, 75 | -18, 5, 13, 4, 76 | -12, -1, 18, -13, 77 | -1, -8, 20, 9, 78 | 5, 17, 0, 27, 79 | -19, 35, 3, -8}; 80 | 81 | spx_word16_t gain_sum[32]={ 82 | 0, 22, 14, 29, 83 | 47, 29, 38, 31, 84 | 40, 27, 38, 31, 85 | 52, 33, 25, 22, 86 | 74, 9, 58, 32, 87 | 36, 39, 46, 28, 88 | 34, 43, 29, 38, 89 | 33, 47, 11, 38}; 90 | 91 | for (i=0;i<32;i++) 92 | { 93 | 94 | spx_word32_t sum = 0; 95 | 96 | sum = ADD32(sum,MULT16_16(MULT16_16_16(g_0[i],64),C16[0])); 97 | sum = ADD32(sum,MULT16_16(MULT16_16_16(g_1[i],64),C16[1])); 98 | sum = ADD32(sum,MULT16_16(MULT16_16_16(g_2[i],64),C16[2])); 99 | sum = SUB32(sum,MULT16_16(MULT16_16_16(g_0[i],g_1[i]),C16[3])); 100 | sum = SUB32(sum,MULT16_16(MULT16_16_16(g_2[i],g_1[i]),C16[4])); 101 | sum = SUB32(sum,MULT16_16(MULT16_16_16(g_2[i],g_0[i]),C16[5])); 102 | sum = SUB32(sum,MULT16_16(MULT16_16_16(g_0[i],g_0[i]),C16[6])); 103 | sum = SUB32(sum,MULT16_16(MULT16_16_16(g_1[i],g_1[i]),C16[7])); 104 | sum = SUB32(sum,MULT16_16(MULT16_16_16(g_2[i],g_2[i]),C16[8])); 105 | 106 | if (sum>best_sum && gain_sum[i]<=max_gain) { 107 | best_sum=sum; 108 | best_cdbk=i; 109 | } 110 | } 111 | 112 | return best_cdbk; 113 | } 114 | 115 | 116 | #endif -------------------------------------------------------------------------------- /speex/STM32/libspeex/iar/ltp_cortexM3.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2008 STMicroelectronics, MCD */ 2 | /* 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions 6 | are met: 7 | 8 | - Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | 11 | - Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | 15 | - Neither the name of the Xiph.org Foundation nor the names of its 16 | contributors may be used to endorse or promote products derived from 17 | this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR 23 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 24 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 25 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 26 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 27 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 28 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 29 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | #ifndef __LTP_M3_H 33 | #define __LTP_M3_H 34 | 35 | 36 | #define OVERRIDE_COMPUTE_PITCH_ERROR 37 | #define OVERRIDE_PITCH_GAIN_SEARCH_3TAP_VQ 38 | int pitch_gain_search_3tap_vq( 39 | const signed char *gain_cdbk, 40 | int gain_cdbk_size, 41 | spx_word16_t *C16, 42 | spx_word16_t max_gain 43 | ) 44 | { 45 | int best_cdbk=0; 46 | spx_word32_t best_sum=-VERY_LARGE32; 47 | 48 | int i; 49 | 50 | 51 | spx_word16_t g_0[32]={ 52 | 0, 1, -9, -24, 53 | 19, 28, -9, 24, 54 | 33, 10, -6, 11, 55 | 32, -21, -5, 13, 56 | 38, -1, -8, 15, 57 | 1, 9, -11, -2, 58 | 16, 18, 1, 11, 59 | -15, -14, 4, 22}; 60 | 61 | spx_word16_t g_1[32]={ 62 | 0, -26, 8, 10, 63 | 65, -7, 47, 17, 64 | 34, -34, 60, 46, 65 | 53, -39, 31, 27, 66 | 97, -16, 89, 36, 67 | 70, 60, 61, 45, 68 | 47, -50, 57, 37, 69 | -31, 44, 15, 46}; 70 | 71 | spx_word16_t g_2[32]={ 72 | 0, 16, -11, -23, 73 | -9, 23, 20, 20, 74 | -12, -10, 9, -5, 75 | -18, 5, 13, 4, 76 | -12, -1, 18, -13, 77 | -1, -8, 20, 9, 78 | 5, 17, 0, 27, 79 | -19, 35, 3, -8}; 80 | 81 | spx_word16_t gain_sum[32]={ 82 | 0, 22, 14, 29, 83 | 47, 29, 38, 31, 84 | 40, 27, 38, 31, 85 | 52, 33, 25, 22, 86 | 74, 9, 58, 32, 87 | 36, 39, 46, 28, 88 | 34, 43, 29, 38, 89 | 33, 47, 11, 38}; 90 | 91 | for (i=0;i<32;i++) 92 | { 93 | 94 | spx_word32_t sum = 0; 95 | 96 | sum = ADD32(sum,MULT16_16(MULT16_16_16(g_0[i],64),C16[0])); 97 | sum = ADD32(sum,MULT16_16(MULT16_16_16(g_1[i],64),C16[1])); 98 | sum = ADD32(sum,MULT16_16(MULT16_16_16(g_2[i],64),C16[2])); 99 | sum = SUB32(sum,MULT16_16(MULT16_16_16(g_0[i],g_1[i]),C16[3])); 100 | sum = SUB32(sum,MULT16_16(MULT16_16_16(g_2[i],g_1[i]),C16[4])); 101 | sum = SUB32(sum,MULT16_16(MULT16_16_16(g_2[i],g_0[i]),C16[5])); 102 | sum = SUB32(sum,MULT16_16(MULT16_16_16(g_0[i],g_0[i]),C16[6])); 103 | sum = SUB32(sum,MULT16_16(MULT16_16_16(g_1[i],g_1[i]),C16[7])); 104 | sum = SUB32(sum,MULT16_16(MULT16_16_16(g_2[i],g_2[i]),C16[8])); 105 | 106 | if (sum>best_sum && gain_sum[i]<=max_gain) { 107 | best_sum=sum; 108 | best_cdbk=i; 109 | } 110 | } 111 | 112 | return best_cdbk; 113 | } 114 | 115 | 116 | #endif -------------------------------------------------------------------------------- /speex/libspeex/cb_search.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2002 Jean-Marc Valin & David Rowe */ 2 | /** 3 | @file cb_search.h 4 | @brief Overlapped codebook search 5 | */ 6 | /* 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions 9 | are met: 10 | 11 | - Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | 14 | - Redistributions in binary form must reproduce the above copyright 15 | notice, this list of conditions and the following disclaimer in the 16 | documentation and/or other materials provided with the distribution. 17 | 18 | - Neither the name of the Xiph.org Foundation nor the names of its 19 | contributors may be used to endorse or promote products derived from 20 | this software without specific prior written permission. 21 | 22 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 25 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR 26 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 27 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 28 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 29 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 30 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 31 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 32 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | */ 34 | 35 | #ifndef CB_SEARCH_H 36 | #define CB_SEARCH_H 37 | 38 | #include 39 | #include "arch.h" 40 | 41 | /** Split codebook parameters. */ 42 | typedef struct split_cb_params { 43 | int subvect_size; 44 | int nb_subvect; 45 | const signed char *shape_cb; 46 | int shape_bits; 47 | int have_sign; 48 | } split_cb_params; 49 | 50 | 51 | void split_cb_search_shape_sign( 52 | spx_word16_t target[], /* target vector */ 53 | spx_coef_t ak[], /* LPCs for this subframe */ 54 | spx_coef_t awk1[], /* Weighted LPCs for this subframe */ 55 | spx_coef_t awk2[], /* Weighted LPCs for this subframe */ 56 | const void *par, /* Codebook/search parameters */ 57 | int p, /* number of LPC coeffs */ 58 | int nsf, /* number of samples in subframe */ 59 | spx_sig_t *exc, 60 | spx_word16_t *r, 61 | SpeexBits *bits, 62 | char *stack, 63 | int complexity, 64 | int update_target 65 | ); 66 | 67 | void split_cb_shape_sign_unquant( 68 | spx_sig_t *exc, 69 | const void *par, /* non-overlapping codebook */ 70 | int nsf, /* number of samples in subframe */ 71 | SpeexBits *bits, 72 | char *stack, 73 | signed int *seed 74 | ); 75 | 76 | 77 | void noise_codebook_quant( 78 | spx_word16_t target[], /* target vector */ 79 | spx_coef_t ak[], /* LPCs for this subframe */ 80 | spx_coef_t awk1[], /* Weighted LPCs for this subframe */ 81 | spx_coef_t awk2[], /* Weighted LPCs for this subframe */ 82 | const void *par, /* Codebook/search parameters */ 83 | int p, /* number of LPC coeffs */ 84 | int nsf, /* number of samples in subframe */ 85 | spx_sig_t *exc, 86 | spx_word16_t *r, 87 | SpeexBits *bits, 88 | char *stack, 89 | int complexity, 90 | int update_target 91 | ); 92 | 93 | 94 | void noise_codebook_unquant( 95 | spx_sig_t *exc, 96 | const void *par, /* non-overlapping codebook */ 97 | int nsf, /* number of samples in subframe */ 98 | SpeexBits *bits, 99 | char *stack, 100 | signed int *seed 101 | ); 102 | 103 | #endif 104 | -------------------------------------------------------------------------------- /speex/STM32/libspeex/gcc/vq_cortexm3.s: -------------------------------------------------------------------------------- 1 | /*; Copyright (C) 2008 STMicroelectronics, MCD */ 2 | /*; 3 | ; 4 | ; Redistribution and use in source and binary forms, with or without 5 | ; modification, are permitted provided that the following conditions 6 | ; are met: 7 | ; 8 | ; - Redistributions of source code must retain the above copyright 9 | ; notice, this list of conditions and the following disclaimer. 10 | ; 11 | ; - Redistributions in binary form must reproduce the above copyright 12 | ; notice, this list of conditions and the following disclaimer in the 13 | ; documentation and/or other materials provided with the distribution. 14 | ; 15 | ; - Neither the name of the Xiph.org Foundation nor the names of its 16 | ; contributors may be used to endorse or promote products derived from 17 | ; this software without specific prior written permission. 18 | ; 19 | ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | ; ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | ; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | ; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR 23 | ; CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 24 | ; EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 25 | ; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 26 | ; PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 27 | ; LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 28 | ; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 29 | ; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.*/ 30 | 31 | .cpu cortex-m3 32 | .fpu softvfp 33 | .syntax unified 34 | .thumb 35 | .text 36 | 37 | .global vq_nbest 38 | 39 | t .req r0 40 | resp2 .req r1 41 | E .req r2 42 | dist .req r3 43 | E_k .req r4 44 | t_0 .req r4 45 | t_1 .req r5 46 | t_2 .req r4 47 | t_3 .req r5 48 | t_4 .req r4 49 | t_5 .req r5 50 | t_6 .req r4 51 | t_7 .req r5 52 | t_8 .req r4 53 | t_9 .req r5 54 | codebook_1 .req r7 55 | codebook_2 .req r8 56 | best_index .req r10 57 | best_dist .req lr 58 | k .req r6 59 | 60 | 61 | 62 | 63 | .thumb_func 64 | vq_nbest: 65 | 66 | PUSH {r4-r10,lr} 67 | MOV k, #0x00 68 | LDR E, [sp, #32] 69 | Loop: 70 | 71 | LDRSH codebook_1, [resp2], #2 72 | LDRSH codebook_2, [resp2], #2 73 | LDRSH t_0, [t, #0x0] 74 | LDRSH t_1, [t, #0x2] 75 | MUL dist, t_0, codebook_1 76 | MLA dist, t_1, codebook_2, dist 77 | 78 | LDRSH codebook_1, [resp2], #2 79 | LDRSH t_2, [t, #0x4] 80 | LDRSH codebook_2, [resp2], #2 81 | LDRSH t_3, [t, #0x6] 82 | MLA dist, t_2, codebook_1, dist 83 | MLA dist, t_3, codebook_2, dist 84 | 85 | LDRSH codebook_1, [resp2], #2 86 | LDRSH t_4, [t, #0x8] 87 | LDRSH codebook_2, [resp2], #2 88 | LDRSH t_5, [t, #0xA] 89 | MLA dist, t_4, codebook_1, dist 90 | MLA dist, t_5, codebook_2, dist 91 | 92 | LDRSH codebook_1, [resp2], #2 93 | LDRSH t_6, [t, #0xC] 94 | LDRSH codebook_2, [resp2], #2 95 | LDRSH t_7, [t, #0xE] 96 | MLA dist, t_6, codebook_1, dist 97 | MLA dist, t_7, codebook_2, dist 98 | 99 | LDRSH codebook_1, [resp2], #2 100 | LDRSH t_8, [t, #0x10] 101 | LDRSH codebook_2, [resp2], #2 102 | LDRSH t_9, [t, #0x12] 103 | MLA dist, t_8, codebook_1, dist 104 | MLA dist, t_9, codebook_2, dist 105 | 106 | LDR E_k, [E], #4 107 | RSB dist, dist, E_k, ASR #1 108 | 109 | CMP k,#0x01 110 | ITEE ge 111 | CMPGE dist, best_dist 112 | MOVLT best_dist, dist 113 | MOVLT best_index, k 114 | 115 | ADDS k, k, #1 116 | CMP k, #0x20 117 | BLT Loop 118 | 119 | LDR dist, [sp,#40] 120 | STR best_index, [dist] 121 | LDR dist, [sp,#44] 122 | STR best_dist, [dist] 123 | 124 | POP {r4-r10,pc} 125 | 126 | .end 127 | -------------------------------------------------------------------------------- /speex/STM32/libspeex/iar/vq_cortexm3.s: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2008 STMicroelectronics, MCD */ 2 | /* 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions 6 | are met: 7 | 8 | - Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | 11 | - Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | 15 | - Neither the name of the Xiph.org Foundation nor the names of its 16 | contributors may be used to endorse or promote products derived from 17 | this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR 23 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 24 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 25 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 26 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 27 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 28 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 29 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | SECTION .text:CODE(2) 33 | 34 | EXPORT vq_nbest 35 | 36 | #define t r0 37 | #define resp2 r1 38 | #define E r2 39 | 40 | #define dist r3 41 | 42 | #define E_k r4 43 | 44 | #define t_0 r4 45 | #define t_1 r5 46 | #define t_2 r4 47 | #define t_3 r5 48 | #define t_4 r4 49 | #define t_5 r5 50 | #define t_6 r4 51 | #define t_7 r5 52 | #define t_8 r4 53 | #define t_9 r5 54 | 55 | #define codebook_1 r7 56 | #define codebook_2 r8 57 | 58 | #define best_index r10 59 | #define best_dist lr 60 | 61 | #define k r6 62 | 63 | 64 | 65 | 66 | 67 | vq_nbest 68 | 69 | PUSH {r4-r10,lr} 70 | MOV k, #0x00 ; 32 71 | LDR E, [sp, #32] 72 | Loop 73 | 74 | LDRSH codebook_1, [resp2], #2 75 | LDRSH codebook_2, [resp2], #2 76 | LDRSH t_0, [t, #0x0] 77 | LDRSH t_1, [t, #0x2] 78 | MUL dist, t_0, codebook_1 79 | MLA dist, t_1, codebook_2, dist 80 | 81 | LDRSH codebook_1, [resp2], #2 82 | LDRSH t_2, [t, #0x4] 83 | LDRSH codebook_2, [resp2], #2 84 | LDRSH t_3, [t, #0x6] 85 | MLA dist, t_2, codebook_1, dist 86 | MLA dist, t_3, codebook_2, dist 87 | 88 | LDRSH codebook_1, [resp2], #2 89 | LDRSH t_4, [t, #0x8] 90 | LDRSH codebook_2, [resp2], #2 91 | LDRSH t_5, [t, #0xA] 92 | MLA dist, t_4, codebook_1, dist 93 | MLA dist, t_5, codebook_2, dist 94 | 95 | LDRSH codebook_1, [resp2], #2 96 | LDRSH t_6, [t, #0xC] 97 | LDRSH codebook_2, [resp2], #2 98 | LDRSH t_7, [t, #0xE] 99 | MLA dist, t_6, codebook_1, dist 100 | MLA dist, t_7, codebook_2, dist 101 | 102 | LDRSH codebook_1, [resp2], #2 103 | LDRSH t_8, [t, #0x10] 104 | LDRSH codebook_2, [resp2], #2 105 | LDRSH t_9, [t, #0x12] 106 | MLA dist, t_8, codebook_1, dist 107 | MLA dist, t_9, codebook_2, dist 108 | 109 | LDR E_k, [E], #4 110 | RSB dist, dist, E_k, ASR #1 111 | 112 | CMP k,#0x01 113 | ITEE GE 114 | CMPGE dist, best_dist 115 | MOVLT best_dist, dist 116 | MOVLT best_index, k 117 | 118 | ADDS k, k, #1 119 | CMP k, #0x20 120 | BLT Loop 121 | 122 | LDR dist, [sp,#40] 123 | STR best_index, [dist] 124 | LDR dist, [sp,#44] 125 | STR best_dist, [dist] 126 | 127 | POP {r4-r10,pc} 128 | 129 | END -------------------------------------------------------------------------------- /speex/include/speex/speex_types.h: -------------------------------------------------------------------------------- 1 | /* speex_types.h taken from libogg */ 2 | /******************************************************************** 3 | * * 4 | * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * 5 | * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * 6 | * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * 7 | * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * 8 | * * 9 | * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2002 * 10 | * by the Xiph.Org Foundation http://www.xiph.org/ * 11 | * * 12 | ******************************************************************** 13 | 14 | function: #ifdef jail to whip a few platforms into the UNIX ideal. 15 | last mod: $Id: os_types.h 7524 2004-08-11 04:20:36Z conrad $ 16 | 17 | ********************************************************************/ 18 | /** 19 | @file speex_types.h 20 | @brief Speex types 21 | */ 22 | #ifndef _SPEEX_TYPES_H 23 | #define _SPEEX_TYPES_H 24 | 25 | #if defined(_WIN32) 26 | 27 | # if defined(__CYGWIN__) 28 | # include <_G_config.h> 29 | typedef _G_int32_t signed int; 30 | typedef _G_uint32_t unsigned int; 31 | typedef _G_int16_t signed short; 32 | typedef _G_uint16_t unsigned short; 33 | # elif defined(__MINGW32__) 34 | typedef short signed short; 35 | typedef unsigned short unsigned short; 36 | typedef int signed int; 37 | typedef unsigned int unsigned int; 38 | # elif defined(__MWERKS__) 39 | typedef int signed int; 40 | typedef unsigned int unsigned int; 41 | typedef short signed short; 42 | typedef unsigned short unsigned short; 43 | # else 44 | /* MSVC/Borland */ 45 | typedef __int32 signed int; 46 | typedef unsigned __int32 unsigned int; 47 | typedef __int16 signed short; 48 | typedef unsigned __int16 unsigned short; 49 | # endif 50 | 51 | #elif defined(__MACOS__) 52 | 53 | # include 54 | typedef SInt16 signed short; 55 | typedef UInt16 unsigned short; 56 | typedef SInt32 signed int; 57 | typedef UInt32 unsigned int; 58 | 59 | #elif (defined(__APPLE__) && defined(__MACH__)) /* MacOS X Framework build */ 60 | 61 | # include 62 | typedef int16_t signed short; 63 | typedef u_int16_t unsigned short; 64 | typedef int32_t signed int; 65 | typedef u_int32_t unsigned int; 66 | 67 | #elif defined(__BEOS__) 68 | 69 | /* Be */ 70 | # include 71 | typedef int16_t signed short; 72 | typedef u_int16_t unsigned short; 73 | typedef int32_t signed int; 74 | typedef u_int32_t unsigned int; 75 | 76 | #elif defined (__EMX__) 77 | 78 | /* OS/2 GCC */ 79 | typedef short signed short; 80 | typedef unsigned short unsigned short; 81 | typedef int signed int; 82 | typedef unsigned int unsigned int; 83 | 84 | #elif defined (DJGPP) 85 | 86 | /* DJGPP */ 87 | typedef short signed short; 88 | typedef int signed int; 89 | typedef unsigned int unsigned int; 90 | 91 | #elif defined(R5900) 92 | 93 | /* PS2 EE */ 94 | typedef int signed int; 95 | typedef unsigned unsigned int; 96 | typedef short signed short; 97 | 98 | #elif defined(__SYMBIAN32__) 99 | 100 | /* Symbian GCC */ 101 | typedef signed short signed short; 102 | typedef unsigned short unsigned short; 103 | typedef signed int signed int; 104 | typedef unsigned int unsigned int; 105 | 106 | #elif defined(CONFIG_TI_C54X) || defined (CONFIG_TI_C55X) 107 | 108 | typedef short signed short; 109 | typedef unsigned short unsigned short; 110 | typedef long signed int; 111 | typedef unsigned long unsigned int; 112 | 113 | #elif defined(CONFIG_TI_C6X) 114 | 115 | typedef short signed short; 116 | typedef unsigned short unsigned short; 117 | typedef int signed int; 118 | typedef unsigned int unsigned int; 119 | 120 | #else 121 | 122 | //#include 123 | 124 | #endif 125 | 126 | #endif /* _SPEEX_TYPES_H */ 127 | -------------------------------------------------------------------------------- /speex/STM32/libspeex/arm/vq_cortexM3.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2008 STMicroelectronics, MCD */ 2 | /* 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions 6 | are met: 7 | 8 | - Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | 11 | - Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | 15 | - Neither the name of the Xiph.org Foundation nor the names of its 16 | contributors may be used to endorse or promote products derived from 17 | this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR 23 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 24 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 25 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 26 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 27 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 28 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 29 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | #ifndef __VQ_M3_H 33 | #define __VQ_M3_H 34 | 35 | #define t r0 36 | #define resp2 r1 37 | #define E r2 38 | 39 | #define dist r3 40 | 41 | #define E_k r4 42 | 43 | #define t_0 r4 44 | #define t_1 r5 45 | #define t_2 r4 46 | #define t_3 r5 47 | #define t_4 r4 48 | #define t_5 r5 49 | #define t_6 r4 50 | #define t_7 r5 51 | #define t_8 r4 52 | #define t_9 r5 53 | 54 | #define codebook_1 r7 55 | #define codebook_2 r8 56 | 57 | #define best_index r10 58 | #define best_dist lr 59 | 60 | #define k r6 61 | 62 | 63 | 64 | 65 | #define OVERRIDE_VQ_NBEST 66 | __asm void vq_nbest(spx_word16_t *in, const spx_word16_t *codebook, int len, int entries, spx_word32_t *E, int N, int *nbest, spx_word32_t *best_dist, char *stack) 67 | { 68 | PUSH {r4-r10,lr} 69 | MOV k, #0x00 ; 32 70 | LDR E, [sp, #32] 71 | Loop 72 | 73 | LDRSH codebook_1, [resp2], #2 74 | LDRSH codebook_2, [resp2], #2 75 | LDRSH t_0, [t, #0x0] 76 | LDRSH t_1, [t, #0x2] 77 | MUL dist, t_0, codebook_1 78 | MLA dist, t_1, codebook_2, dist 79 | 80 | LDRSH codebook_1, [resp2], #2 81 | LDRSH t_2, [t, #0x4] 82 | LDRSH codebook_2, [resp2], #2 83 | LDRSH t_3, [t, #0x6] 84 | MLA dist, t_2, codebook_1, dist 85 | MLA dist, t_3, codebook_2, dist 86 | 87 | LDRSH codebook_1, [resp2], #2 88 | LDRSH t_4, [t, #0x8] 89 | LDRSH codebook_2, [resp2], #2 90 | LDRSH t_5, [t, #0xA] 91 | MLA dist, t_4, codebook_1, dist 92 | MLA dist, t_5, codebook_2, dist 93 | 94 | LDRSH codebook_1, [resp2], #2 95 | LDRSH t_6, [t, #0xC] 96 | LDRSH codebook_2, [resp2], #2 97 | LDRSH t_7, [t, #0xE] 98 | MLA dist, t_6, codebook_1, dist 99 | MLA dist, t_7, codebook_2, dist 100 | 101 | LDRSH codebook_1, [resp2], #2 102 | LDRSH t_8, [t, #0x10] 103 | LDRSH codebook_2, [resp2], #2 104 | LDRSH t_9, [t, #0x12] 105 | MLA dist, t_8, codebook_1, dist 106 | MLA dist, t_9, codebook_2, dist 107 | 108 | LDR E_k, [E], #4 109 | RSB dist, dist, E_k, ASR #1 110 | 111 | CMP k,#0x01 112 | ITEE GE 113 | CMPGE dist, best_dist 114 | MOVLT best_dist, dist 115 | MOVLT best_index, k 116 | 117 | ADDS k, k, #1 118 | CMP k, #0x20 119 | BLT Loop 120 | 121 | LDR dist, [sp,#40] 122 | STR best_index, [dist] 123 | LDR dist, [sp,#44] 124 | STR best_dist, [dist] 125 | 126 | POP {r4-r10,pc} 127 | } 128 | 129 | 130 | 131 | #endif 132 | -------------------------------------------------------------------------------- /speex/libspeex/filters.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2002 Jean-Marc Valin */ 2 | /** 3 | @file filters.h 4 | @brief Various analysis/synthesis filters 5 | */ 6 | /* 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions 9 | are met: 10 | 11 | - Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | 14 | - Redistributions in binary form must reproduce the above copyright 15 | notice, this list of conditions and the following disclaimer in the 16 | documentation and/or other materials provided with the distribution. 17 | 18 | - Neither the name of the Xiph.org Foundation nor the names of its 19 | contributors may be used to endorse or promote products derived from 20 | this software without specific prior written permission. 21 | 22 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 25 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR 26 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 27 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 28 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 29 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 30 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 31 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 32 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | */ 34 | 35 | #ifndef FILTERS_H 36 | #define FILTERS_H 37 | 38 | #include "arch.h" 39 | 40 | spx_word16_t compute_rms(const spx_sig_t *x, int len); 41 | spx_word16_t compute_rms16(const spx_word16_t *x, int len); 42 | void signal_mul(const spx_sig_t *x, spx_sig_t *y, spx_word32_t scale, int len); 43 | void signal_div(const spx_word16_t *x, spx_word16_t *y, spx_word32_t scale, int len); 44 | 45 | #ifdef FIXED_POINT 46 | 47 | int normalize16(const spx_sig_t *x, spx_word16_t *y, spx_sig_t max_scale, int len); 48 | 49 | #endif 50 | 51 | 52 | #define HIGHPASS_NARROWBAND 0 53 | #define HIGHPASS_WIDEBAND 2 54 | #define HIGHPASS_INPUT 0 55 | #define HIGHPASS_OUTPUT 1 56 | #define HIGHPASS_IRS 4 57 | 58 | void highpass(const spx_word16_t *x, spx_word16_t *y, int len, int filtID, spx_mem_t *mem); 59 | 60 | 61 | void qmf_decomp(const spx_word16_t *xx, const spx_word16_t *aa, spx_word16_t *, spx_word16_t *y2, int N, int M, spx_word16_t *mem, char *stack); 62 | void qmf_synth(const spx_word16_t *x1, const spx_word16_t *x2, const spx_word16_t *a, spx_word16_t *y, int N, int M, spx_word16_t *mem1, spx_word16_t *mem2, char *stack); 63 | 64 | void filter_mem16(const spx_word16_t *x, const spx_coef_t *num, const spx_coef_t *den, spx_word16_t *y, int N, int ord, spx_mem_t *mem, char *stack); 65 | void iir_mem16(const spx_word16_t *x, const spx_coef_t *den, spx_word16_t *y, int N, int ord, spx_mem_t *mem, char *stack); 66 | void fir_mem16(const spx_word16_t *x, const spx_coef_t *num, spx_word16_t *y, int N, int ord, spx_mem_t *mem, char *stack); 67 | 68 | /* Apply bandwidth expansion on LPC coef */ 69 | void bw_lpc(spx_word16_t , const spx_coef_t *lpc_in, spx_coef_t *lpc_out, int order); 70 | void sanitize_values32(spx_word32_t *vec, spx_word32_t min_val, spx_word32_t max_val, int len); 71 | 72 | 73 | void syn_percep_zero16(const spx_word16_t *xx, const spx_coef_t *ak, const spx_coef_t *awk1, const spx_coef_t *awk2, spx_word16_t *y, int N, int ord, char *stack); 74 | void residue_percep_zero16(const spx_word16_t *xx, const spx_coef_t *ak, const spx_coef_t *awk1, const spx_coef_t *awk2, spx_word16_t *y, int N, int ord, char *stack); 75 | 76 | void compute_impulse_response(const spx_coef_t *ak, const spx_coef_t *awk1, const spx_coef_t *awk2, spx_word16_t *y, int N, int ord, char *stack); 77 | 78 | void multicomb( 79 | spx_word16_t *exc, /*decoded excitation*/ 80 | spx_word16_t *new_exc, /*enhanced excitation*/ 81 | spx_coef_t *ak, /*LPC filter coefs*/ 82 | int p, /*LPC order*/ 83 | int nsf, /*sub-frame size*/ 84 | int pitch, /*pitch period*/ 85 | int max_pitch, /*pitch gain (3-tap)*/ 86 | spx_word16_t comb_gain, /*gain of comb filter*/ 87 | char *stack 88 | ); 89 | 90 | #endif 91 | -------------------------------------------------------------------------------- /SndMic.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** 3 | ** SndMic.c 4 | ** 5 | ** 6 | **********************************************************************/ 7 | 8 | #include "SndMic.h" 9 | #include "pdm_filter.h" 10 | //#include "stm32f4xx_rcc.h" 11 | //#include "stm32f4xx_gpio.h" 12 | //#include "stm32f4xx_spi.h" 13 | //#include "misc.h" 14 | #include "main.h" 15 | 16 | PDMFilter_InitStruct Filter; 17 | WORD InternalBuffer[INTERNAL_BUFF_SIZE]; 18 | DWORD InternalBufferSize = 0; 19 | WORD RecBuf[PCM_OUT_SIZE]; 20 | WORD RecBuf1[PCM_OUT_SIZE]; 21 | 22 | void initMic(void) 23 | { 24 | /* Enable CRC module */ 25 | RCC->AHB1ENR |= RCC_AHB1ENR_CRCEN; 26 | 27 | /* Filter LP & HP Init */ 28 | //Filter.LP_HZ = 6000; 29 | //Filter.HP_HZ = 100; 30 | Filter.LP_HZ = 0; 31 | Filter.HP_HZ = 0; 32 | 33 | Filter.Fs = 16000; 34 | Filter.Out_MicChannels = 1; 35 | Filter.In_MicChannels = 1; 36 | 37 | PDM_Filter_Init((PDMFilter_InitStruct *)&Filter); 38 | 39 | /** --------------------------------------------------------------------- */ 40 | GPIO_InitTypeDef GPIO_InitStructure; 41 | 42 | /* Enable GPIO clocks */ 43 | RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB | RCC_AHB1Periph_GPIOC, ENABLE); 44 | 45 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; 46 | GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; 47 | GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; 48 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; 49 | 50 | /* SPI SCK pin configuration */ 51 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10; 52 | GPIO_Init(GPIOB, &GPIO_InitStructure); 53 | 54 | /* Connect SPI pins to AF5 */ 55 | GPIO_PinAFConfig(GPIOB, GPIO_PinSource10, GPIO_AF_SPI2); 56 | 57 | /* SPI MOSI pin configuration */ 58 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3; 59 | GPIO_Init(GPIOC, &GPIO_InitStructure); 60 | GPIO_PinAFConfig(GPIOC, GPIO_PinSource3, GPIO_AF_SPI2); 61 | 62 | /** --------------------------------------------------------------------- */ 63 | NVIC_InitTypeDef NVIC_InitStructure; 64 | 65 | NVIC_PriorityGroupConfig(NVIC_PriorityGroup_3); 66 | /* Configure the SPI interrupt priority */ 67 | NVIC_InitStructure.NVIC_IRQChannel = SPI2_IRQn; 68 | NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1; 69 | NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; 70 | NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; 71 | NVIC_Init(&NVIC_InitStructure); 72 | 73 | /** --------------------------------------------------------------------- */ 74 | I2S_InitTypeDef I2S_InitStructure; 75 | 76 | /* Enable the SPI clock */ 77 | RCC_APB1PeriphClockCmd(RCC_APB1Periph_SPI2,ENABLE); 78 | /* SPI configuration */ 79 | SPI_I2S_DeInit(SPI2); 80 | I2S_InitStructure.I2S_AudioFreq = 16000; 81 | I2S_InitStructure.I2S_Standard = I2S_Standard_MSB; 82 | I2S_InitStructure.I2S_DataFormat = I2S_DataFormat_16b; 83 | I2S_InitStructure.I2S_CPOL = I2S_CPOL_High; 84 | I2S_InitStructure.I2S_Mode = I2S_Mode_MasterRx; 85 | I2S_InitStructure.I2S_MCLKOutput = I2S_MCLKOutput_Disable; 86 | /* Initialize the I2S peripheral with the structure above */ 87 | I2S_Init(SPI2, &I2S_InitStructure); 88 | /* Enable the Rx buffer not empty interrupt */ 89 | SPI_I2S_ITConfig(SPI2, SPI_I2S_IT_RXNE, ENABLE); 90 | /** --------------------------------------------------------------------- */ 91 | /* Enable the SPI peripheral */ 92 | I2S_Cmd(SPI2, ENABLE); 93 | } 94 | 95 | /** Getting data from microphone and filterring PDM to PCM */ 96 | void SPI2_IRQHandler(void) 97 | { 98 | WORD volume;//, i; 99 | WORD app; 100 | //signed short tmp; 101 | 102 | /* Check if data are available in SPI Data register */ 103 | if (SPI_GetITStatus(SPI2, SPI_I2S_IT_RXNE) != RESET) 104 | { 105 | app = SPI_I2S_ReceiveData(SPI2); 106 | InternalBuffer[InternalBufferSize++] = ((((WORD)(app) & 0xFF00) >> 8) | (((WORD)(app) & 0x00FF) << 8)); 107 | /* Check to prevent overflow condition */ 108 | if (InternalBufferSize >= INTERNAL_BUFF_SIZE) // 64 109 | { 110 | InternalBufferSize = 0; 111 | volume = 100; 112 | PDM_Filter_64_LSB((BYTE *)InternalBuffer, (WORD *)RecBuf, volume , (PDMFilter_InitStruct *)&Filter); 113 | 114 | //for(i=0; i>2); 118 | //}; 119 | 120 | IRQ_mic((WORD *)RecBuf, PCM_OUT_SIZE); 121 | }; 122 | }; 123 | } 124 | 125 | 126 | 127 | 128 | -------------------------------------------------------------------------------- /speex/libspeex/gain_table.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2002 Jean-Marc Valin 2 | File: gain_table.c 3 | Codebook for 3-tap pitch prediction gain (128 entries) 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | 9 | 1. Redistributions of source code must retain the above copyright notice, 10 | this list of conditions and the following disclaimer. 11 | 12 | 2. 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 | 3. The name of the author may not be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 23 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 27 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 28 | ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 | POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | const signed char gain_cdbk_nb[512] = { 33 | -32, -32, -32, 0, 34 | -28, -67, -5, 33, 35 | -42, -6, -32, 18, 36 | -57, -10, -54, 35, 37 | -16, 27, -41, 42, 38 | 19, -19, -40, 36, 39 | -45, 24, -21, 40, 40 | -8, -14, -18, 28, 41 | 1, 14, -58, 53, 42 | -18, -88, -39, 39, 43 | -38, 21, -18, 37, 44 | -19, 20, -43, 38, 45 | 10, 17, -48, 54, 46 | -52, -58, -13, 33, 47 | -44, -1, -11, 32, 48 | -12, -11, -34, 22, 49 | 14, 0, -46, 46, 50 | -37, -35, -34, 5, 51 | -25, 44, -30, 43, 52 | 6, -4, -63, 49, 53 | -31, 43, -41, 43, 54 | -23, 30, -43, 41, 55 | -43, 26, -14, 44, 56 | -33, 1, -13, 27, 57 | -13, 18, -37, 37, 58 | -46, -73, -45, 34, 59 | -36, 24, -25, 34, 60 | -36, -11, -20, 19, 61 | -25, 12, -18, 33, 62 | -36, -69, -59, 34, 63 | -45, 6, 8, 46, 64 | -22, -14, -24, 18, 65 | -1, 13, -44, 44, 66 | -39, -48, -26, 15, 67 | -32, 31, -37, 34, 68 | -33, 15, -46, 31, 69 | -24, 30, -36, 37, 70 | -41, 31, -23, 41, 71 | -50, 22, -4, 50, 72 | -22, 2, -21, 28, 73 | -17, 30, -34, 40, 74 | -7, -60, -28, 29, 75 | -38, 42, -28, 42, 76 | -44, -11, 21, 43, 77 | -16, 8, -44, 34, 78 | -39, -55, -43, 21, 79 | -11, -35, 26, 41, 80 | -9, 0, -34, 29, 81 | -8, 121, -81, 113, 82 | 7, -16, -22, 33, 83 | -37, 33, -31, 36, 84 | -27, -7, -36, 17, 85 | -34, 70, -57, 65, 86 | -37, -11, -48, 21, 87 | -40, 17, -1, 44, 88 | -33, 6, -6, 33, 89 | -9, 0, -20, 34, 90 | -21, 69, -33, 57, 91 | -29, 33, -31, 35, 92 | -55, 12, -1, 49, 93 | -33, 27, -22, 35, 94 | -50, -33, -47, 17, 95 | -50, 54, 51, 94, 96 | -1, -5, -44, 35, 97 | -4, 22, -40, 45, 98 | -39, -66, -25, 24, 99 | -33, 1, -26, 20, 100 | -24, -23, -25, 12, 101 | -11, 21, -45, 44, 102 | -25, -45, -19, 17, 103 | -43, 105, -16, 82, 104 | 5, -21, 1, 41, 105 | -16, 11, -33, 30, 106 | -13, -99, -4, 57, 107 | -37, 33, -15, 44, 108 | -25, 37, -63, 54, 109 | -36, 24, -31, 31, 110 | -53, -56, -38, 26, 111 | -41, -4, 4, 37, 112 | -33, 13, -30, 24, 113 | 49, 52, -94, 114, 114 | -5, -30, -15, 23, 115 | 1, 38, -40, 56, 116 | -23, 12, -36, 29, 117 | -17, 40, -47, 51, 118 | -37, -41, -39, 11, 119 | -49, 34, 0, 58, 120 | -18, -7, -4, 34, 121 | -16, 17, -27, 35, 122 | 30, 5, -62, 65, 123 | 4, 48, -68, 76, 124 | -43, 11, -11, 38, 125 | -18, 19, -15, 41, 126 | -23, -62, -39, 23, 127 | -42, 10, -2, 41, 128 | -21, -13, -13, 25, 129 | -9, 13, -47, 42, 130 | -23, -62, -24, 24, 131 | -44, 60, -21, 58, 132 | -18, -3, -52, 32, 133 | -22, 22, -36, 34, 134 | -75, 57, 16, 90, 135 | -19, 3, 10, 45, 136 | -29, 23, -38, 32, 137 | -5, -62, -51, 38, 138 | -51, 40, -18, 53, 139 | -42, 13, -24, 32, 140 | -34, 14, -20, 30, 141 | -56, -75, -26, 37, 142 | -26, 32, 15, 59, 143 | -26, 17, -29, 29, 144 | -7, 28, -52, 53, 145 | -12, -30, 5, 30, 146 | -5, -48, -5, 35, 147 | 2, 2, -43, 40, 148 | 21, 16, 16, 75, 149 | -25, -45, -32, 10, 150 | -43, 18, -10, 42, 151 | 9, 0, -1, 52, 152 | -1, 7, -30, 36, 153 | 19, -48, -4, 48, 154 | -28, 25, -29, 32, 155 | -22, 0, -31, 22, 156 | -32, 17, -10, 36, 157 | -64, -41, -62, 36, 158 | -52, 15, 16, 58, 159 | -30, -22, -32, 6, 160 | -7, 9, -38, 36}; 161 | -------------------------------------------------------------------------------- /speex/libspeex/modes.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2002-2006 Jean-Marc Valin 2 | File: modes.c 3 | 4 | Describes the different 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 | 36 | /******************************************************************************/ 37 | /* Modified by STMicroelectronics, MCD Application Team, June 2008: */ 38 | /* support only submode 3 */ 39 | /******************************************************************************/ 40 | 41 | #ifdef HAVE_CONFIG_H 42 | #include "config.h" 43 | #endif 44 | 45 | #include "modes.h" 46 | #include "ltp.h" 47 | #include "quant_lsp.h" 48 | #include "cb_search.h" 49 | #include "sb_celp.h" 50 | #include "nb_celp.h" 51 | #include "vbr.h" 52 | #include "arch.h" 53 | #include 54 | 55 | #ifndef NULL 56 | #define NULL 0 57 | #endif 58 | 59 | 60 | /* Extern declarations for all codebooks we use here */ 61 | extern const signed char gain_cdbk_lbr[]; 62 | extern const signed char exc_10_32_table[]; 63 | 64 | 65 | /* Parameters for Long-Term Prediction (LTP)*/ 66 | static const ltp_params ltp_params_lbr = { 67 | gain_cdbk_lbr, 68 | 5, 69 | 7 70 | }; 71 | 72 | 73 | /* Split-VQ innovation parameters for low bit-rate narrowband */ 74 | static const split_cb_params split_cb_nb_lbr = { 75 | 10, /*subvect_size*/ 76 | 4, /*nb_subvect*/ 77 | exc_10_32_table, /*shape_cb*/ 78 | 5, /*shape_bits*/ 79 | 0, 80 | }; 81 | 82 | /* 8 kbps low bit-rate mode */ 83 | static const SpeexSubmode nb_submode3 = { 84 | -1, 85 | 0, 86 | 1, 87 | 0, 88 | /*LSP quantization*/ 89 | lsp_quant_lbr, 90 | lsp_unquant_lbr, 91 | /*Pitch quantization*/ 92 | pitch_search_3tap, 93 | pitch_unquant_3tap, 94 | <p_params_lbr, 95 | /*Innovation quantization*/ 96 | split_cb_search_shape_sign, 97 | split_cb_shape_sign_unquant, 98 | &split_cb_nb_lbr, 99 | QCONST16(.55,15), 100 | 160 101 | }; 102 | 103 | 104 | /* Default mode for narrowband */ 105 | static const SpeexNBMode nb_mode = { 106 | 160, /*frameSize*/ 107 | 40, /*subframeSize*/ 108 | 10, /*lpcSize*/ 109 | 17, /*pitchStart*/ 110 | 144, /*pitchEnd*/ 111 | #ifdef FIXED_POINT 112 | 29491, 19661, /* gamma1, gamma2 */ 113 | #else 114 | 0.9, 0.6, /* gamma1, gamma2 */ 115 | #endif 116 | QCONST16(.0002,15), /*lpc_floor*/ 117 | {NULL, NULL, NULL, &nb_submode3, NULL, NULL, NULL, NULL, 118 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, 119 | 5, 120 | {1, 8, 2, 3, 3, 4, 4, 5, 5, 6, 7} 121 | }; 122 | 123 | 124 | /* Default mode for narrowband */ 125 | const SpeexMode speex_nb_mode = { 126 | &nb_mode, 127 | nb_mode_query, 128 | "narrowband", 129 | 0, 130 | 4, 131 | &nb_encoder_init, 132 | &nb_encoder_destroy, 133 | &nb_encode, 134 | &nb_decoder_init, 135 | &nb_decoder_destroy, 136 | &nb_decode, 137 | &nb_encoder_ctl, 138 | &nb_decoder_ctl, 139 | }; 140 | 141 | 142 | 143 | int speex_mode_query(const SpeexMode *mode, int request, void *ptr) 144 | { 145 | return mode->query(mode->mode, request, ptr); 146 | } 147 | 148 | -------------------------------------------------------------------------------- /speex/STM32/libspeex/modes.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2002-2006 Jean-Marc Valin 2 | File: modes.c 3 | 4 | Describes the different 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 | 36 | /******************************************************************************/ 37 | /* Modified by STMicroelectronics, MCD Application Team, June 2008: */ 38 | /* support only submode 3 */ 39 | /******************************************************************************/ 40 | 41 | #ifdef HAVE_CONFIG_H 42 | #include "config.h" 43 | #endif 44 | 45 | #include "modes.h" 46 | #include "ltp.h" 47 | #include "quant_lsp.h" 48 | #include "cb_search.h" 49 | #include "sb_celp.h" 50 | #include "nb_celp.h" 51 | #include "vbr.h" 52 | #include "arch.h" 53 | #include 54 | 55 | #ifndef NULL 56 | #define NULL 0 57 | #endif 58 | 59 | 60 | /* Extern declarations for all codebooks we use here */ 61 | extern const signed char gain_cdbk_lbr[]; 62 | extern const signed char exc_10_32_table[]; 63 | 64 | 65 | /* Parameters for Long-Term Prediction (LTP)*/ 66 | static const ltp_params ltp_params_lbr = { 67 | gain_cdbk_lbr, 68 | 5, 69 | 7 70 | }; 71 | 72 | 73 | /* Split-VQ innovation parameters for low bit-rate narrowband */ 74 | static const split_cb_params split_cb_nb_lbr = { 75 | 10, /*subvect_size*/ 76 | 4, /*nb_subvect*/ 77 | exc_10_32_table, /*shape_cb*/ 78 | 5, /*shape_bits*/ 79 | 0, 80 | }; 81 | 82 | /* 8 kbps low bit-rate mode */ 83 | static const SpeexSubmode nb_submode3 = { 84 | -1, 85 | 0, 86 | 1, 87 | 0, 88 | /*LSP quantization*/ 89 | lsp_quant_lbr, 90 | lsp_unquant_lbr, 91 | /*Pitch quantization*/ 92 | pitch_search_3tap, 93 | pitch_unquant_3tap, 94 | <p_params_lbr, 95 | /*Innovation quantization*/ 96 | split_cb_search_shape_sign, 97 | split_cb_shape_sign_unquant, 98 | &split_cb_nb_lbr, 99 | QCONST16(.55,15), 100 | 160 101 | }; 102 | 103 | 104 | /* Default mode for narrowband */ 105 | static const SpeexNBMode nb_mode = { 106 | 160, /*frameSize*/ 107 | 40, /*subframeSize*/ 108 | 10, /*lpcSize*/ 109 | 17, /*pitchStart*/ 110 | 144, /*pitchEnd*/ 111 | #ifdef FIXED_POINT 112 | 29491, 19661, /* gamma1, gamma2 */ 113 | #else 114 | 0.9, 0.6, /* gamma1, gamma2 */ 115 | #endif 116 | QCONST16(.0002,15), /*lpc_floor*/ 117 | {NULL, NULL, NULL, &nb_submode3, NULL, NULL, NULL, NULL, 118 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, 119 | 5, 120 | {1, 8, 2, 3, 3, 4, 4, 5, 5, 6, 7} 121 | }; 122 | 123 | 124 | /* Default mode for narrowband */ 125 | const SpeexMode speex_nb_mode = { 126 | &nb_mode, 127 | nb_mode_query, 128 | "narrowband", 129 | 0, 130 | 4, 131 | &nb_encoder_init, 132 | &nb_encoder_destroy, 133 | &nb_encode, 134 | &nb_decoder_init, 135 | &nb_decoder_destroy, 136 | &nb_decode, 137 | &nb_encoder_ctl, 138 | &nb_decoder_ctl, 139 | }; 140 | 141 | 142 | 143 | int speex_mode_query(const SpeexMode *mode, int request, void *ptr) 144 | { 145 | return mode->query(mode->mode, request, ptr); 146 | } 147 | 148 | -------------------------------------------------------------------------------- /speex/libspeex/speex_callbacks.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2002 Jean-Marc Valin 2 | File speex_callbacks.c 3 | Callback handling and in-band signalling 4 | 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.h" 37 | #endif 38 | 39 | #include "speex_callbacks.h" 40 | #include "arch.h" 41 | #include "os_support.h" 42 | 43 | int speex_inband_handler(SpeexBits *bits, SpeexCallback *callback_list, void *state) 44 | { 45 | int id; 46 | SpeexCallback *callback; 47 | /*speex_bits_advance(bits, 5);*/ 48 | id=speex_bits_unpack_unsigned(bits, 4); 49 | callback = callback_list+id; 50 | 51 | if (callback->func) 52 | { 53 | return callback->func(bits, state, callback->data); 54 | } else 55 | /*If callback is not registered, skip the right number of bits*/ 56 | { 57 | int adv; 58 | if (id<2) 59 | adv = 1; 60 | else if (id<8) 61 | adv = 4; 62 | else if (id<10) 63 | adv = 8; 64 | else if (id<12) 65 | adv = 16; 66 | else if (id<14) 67 | adv = 32; 68 | else 69 | adv = 64; 70 | speex_bits_advance(bits, adv); 71 | } 72 | return 0; 73 | } 74 | 75 | int speex_std_mode_request_handler(SpeexBits *bits, void *state, void *data) 76 | { 77 | signed int m; 78 | m = speex_bits_unpack_unsigned(bits, 4); 79 | speex_encoder_ctl(data, SPEEX_SET_MODE, &m); 80 | return 0; 81 | } 82 | 83 | int speex_std_low_mode_request_handler(SpeexBits *bits, void *state, void *data) 84 | { 85 | signed int m; 86 | m = speex_bits_unpack_unsigned(bits, 4); 87 | speex_encoder_ctl(data, SPEEX_SET_LOW_MODE, &m); 88 | return 0; 89 | } 90 | 91 | int speex_std_high_mode_request_handler(SpeexBits *bits, void *state, void *data) 92 | { 93 | signed int m; 94 | m = speex_bits_unpack_unsigned(bits, 4); 95 | speex_encoder_ctl(data, SPEEX_SET_HIGH_MODE, &m); 96 | return 0; 97 | } 98 | 99 | #ifndef DISABLE_VBR 100 | int speex_std_vbr_request_handler(SpeexBits *bits, void *state, void *data) 101 | { 102 | signed int vbr; 103 | vbr = speex_bits_unpack_unsigned(bits, 1); 104 | speex_encoder_ctl(data, SPEEX_SET_VBR, &vbr); 105 | return 0; 106 | } 107 | #endif /* #ifndef DISABLE_VBR */ 108 | 109 | int speex_std_enh_request_handler(SpeexBits *bits, void *state, void *data) 110 | { 111 | signed int enh; 112 | enh = speex_bits_unpack_unsigned(bits, 1); 113 | speex_decoder_ctl(data, SPEEX_SET_ENH, &enh); 114 | return 0; 115 | } 116 | 117 | #ifndef DISABLE_VBR 118 | int speex_std_vbr_quality_request_handler(SpeexBits *bits, void *state, void *data) 119 | { 120 | float qual; 121 | qual = speex_bits_unpack_unsigned(bits, 4); 122 | speex_encoder_ctl(data, SPEEX_SET_VBR_QUALITY, &qual); 123 | return 0; 124 | } 125 | #endif /* #ifndef DISABLE_VBR */ 126 | 127 | int speex_std_char_handler(SpeexBits *bits, void *state, void *data) 128 | { 129 | unsigned char ch; 130 | ch = speex_bits_unpack_unsigned(bits, 8); 131 | _speex_putc(ch, data); 132 | /*printf("speex_std_char_handler ch=%x\n", ch);*/ 133 | return 0; 134 | } 135 | 136 | 137 | 138 | /* Default handler for user callbacks: skip it */ 139 | int speex_default_user_handler(SpeexBits *bits, void *state, void *data) 140 | { 141 | int req_size = speex_bits_unpack_unsigned(bits, 4); 142 | speex_bits_advance(bits, 5+8*req_size); 143 | return 0; 144 | } 145 | -------------------------------------------------------------------------------- /speex/libspeex/vq.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2002 Jean-Marc Valin 2 | File: vq.c 3 | Vector quantization 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.h" 35 | #endif 36 | 37 | #include "vq.h" 38 | #include "stack_alloc.h" 39 | #include "arch.h" 40 | 41 | #ifdef _USE_SSE 42 | #include 43 | #include "vq_sse.h" 44 | #elif defined(SHORTCUTS) && (defined(ARM4_ASM) || defined(ARM5E_ASM)) 45 | #include "vq_arm4.h" 46 | #elif defined(BFIN_ASM) 47 | #include "vq_bfin.h" 48 | #endif 49 | 50 | //added by MCD Application Team June 2008 51 | #ifdef __CC_ARM /* ARM Compiler */ 52 | #include "vq_cortexM3.h" 53 | #endif 54 | 55 | #ifdef __IAR_SYSTEMS_ICC__ /* IAR Compiler */ 56 | #define OVERRIDE_VQ_NBEST 57 | #endif 58 | 59 | #ifdef __GNUC__ /* GNU Compiler */ 60 | #define OVERRIDE_VQ_NBEST 61 | #endif 62 | 63 | int scal_quant(spx_word16_t in, const spx_word16_t *boundary, int entries) 64 | { 65 | int i=0; 66 | while (iboundary[0]) 67 | { 68 | boundary++; 69 | i++; 70 | } 71 | return i; 72 | } 73 | 74 | int scal_quant32(spx_word32_t in, const spx_word32_t *boundary, int entries) 75 | { 76 | int i=0; 77 | while (iboundary[0]) 78 | { 79 | boundary++; 80 | i++; 81 | } 82 | return i; 83 | } 84 | 85 | 86 | #ifndef OVERRIDE_VQ_NBEST 87 | /*Finds the indices of the n-best entries in a codebook*/ 88 | void vq_nbest(spx_word16_t *in, const spx_word16_t *codebook, int len, int entries, spx_word32_t *E, int N, int *nbest, spx_word32_t *best_dist, char *stack) 89 | { 90 | int i,j,k,used; 91 | used = 0; 92 | for (i=0;i= 1) && (k > used || dist < best_dist[k-1]); k--) 105 | { 106 | best_dist[k]=best_dist[k-1]; 107 | nbest[k] = nbest[k-1]; 108 | } 109 | best_dist[k]=dist; 110 | nbest[k]=i; 111 | used++; 112 | } 113 | } 114 | } 115 | #endif 116 | 117 | 118 | 119 | 120 | #ifndef OVERRIDE_VQ_NBEST_SIGN 121 | /*Finds the indices of the n-best entries in a codebook with sign*/ 122 | void vq_nbest_sign(spx_word16_t *in, const spx_word16_t *codebook, int len, int entries, spx_word32_t *E, int N, int *nbest, spx_word32_t *best_dist, char *stack) 123 | { 124 | int i,j,k, sign, used; 125 | used=0; 126 | for (i=0;i0) 132 | { 133 | sign=0; 134 | dist=-dist; 135 | } else 136 | { 137 | sign=1; 138 | } 139 | #ifdef FIXED_POINT 140 | dist = ADD32(dist,SHR32(E[i],1)); 141 | #else 142 | dist = ADD32(dist,.5f*E[i]); 143 | #endif 144 | if (i= 1) && (k > used || dist < best_dist[k-1]); k--) 147 | { 148 | best_dist[k]=best_dist[k-1]; 149 | nbest[k] = nbest[k-1]; 150 | } 151 | best_dist[k]=dist; 152 | nbest[k]=i; 153 | used++; 154 | if (sign) 155 | nbest[k]+=entries; 156 | } 157 | } 158 | } 159 | #endif 160 | -------------------------------------------------------------------------------- /speex/STM32/libspeex/vq.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2002 Jean-Marc Valin 2 | File: vq.c 3 | Vector quantization 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.h" 35 | #endif 36 | 37 | #include "vq.h" 38 | #include "stack_alloc.h" 39 | #include "arch.h" 40 | 41 | #ifdef _USE_SSE 42 | #include 43 | #include "vq_sse.h" 44 | #elif defined(SHORTCUTS) && (defined(ARM4_ASM) || defined(ARM5E_ASM)) 45 | #include "vq_arm4.h" 46 | #elif defined(BFIN_ASM) 47 | #include "vq_bfin.h" 48 | #endif 49 | 50 | //added by MCD Application Team June 2008 51 | #ifdef __CC_ARM /* ARM Compiler */ 52 | #include "vq_cortexM3.h" 53 | #endif 54 | 55 | #ifdef __IAR_SYSTEMS_ICC__ /* IAR Compiler */ 56 | #define OVERRIDE_VQ_NBEST 57 | #endif 58 | 59 | #ifdef __GNUC__ /* GNU Compiler */ 60 | #define OVERRIDE_VQ_NBEST 61 | #endif 62 | 63 | int scal_quant(spx_word16_t in, const spx_word16_t *boundary, int entries) 64 | { 65 | int i=0; 66 | while (iboundary[0]) 67 | { 68 | boundary++; 69 | i++; 70 | } 71 | return i; 72 | } 73 | 74 | int scal_quant32(spx_word32_t in, const spx_word32_t *boundary, int entries) 75 | { 76 | int i=0; 77 | while (iboundary[0]) 78 | { 79 | boundary++; 80 | i++; 81 | } 82 | return i; 83 | } 84 | 85 | 86 | #ifndef OVERRIDE_VQ_NBEST 87 | /*Finds the indices of the n-best entries in a codebook*/ 88 | void vq_nbest(spx_word16_t *in, const spx_word16_t *codebook, int len, int entries, spx_word32_t *E, int N, int *nbest, spx_word32_t *best_dist, char *stack) 89 | { 90 | int i,j,k,used; 91 | used = 0; 92 | for (i=0;i= 1) && (k > used || dist < best_dist[k-1]); k--) 105 | { 106 | best_dist[k]=best_dist[k-1]; 107 | nbest[k] = nbest[k-1]; 108 | } 109 | best_dist[k]=dist; 110 | nbest[k]=i; 111 | used++; 112 | } 113 | } 114 | } 115 | #endif 116 | 117 | 118 | 119 | 120 | #ifndef OVERRIDE_VQ_NBEST_SIGN 121 | /*Finds the indices of the n-best entries in a codebook with sign*/ 122 | void vq_nbest_sign(spx_word16_t *in, const spx_word16_t *codebook, int len, int entries, spx_word32_t *E, int N, int *nbest, spx_word32_t *best_dist, char *stack) 123 | { 124 | int i,j,k, sign, used; 125 | used=0; 126 | for (i=0;i0) 132 | { 133 | sign=0; 134 | dist=-dist; 135 | } else 136 | { 137 | sign=1; 138 | } 139 | #ifdef FIXED_POINT 140 | dist = ADD32(dist,SHR32(E[i],1)); 141 | #else 142 | dist = ADD32(dist,.5f*E[i]); 143 | #endif 144 | if (i= 1) && (k > used || dist < best_dist[k-1]); k--) 147 | { 148 | best_dist[k]=best_dist[k-1]; 149 | nbest[k] = nbest[k-1]; 150 | } 151 | best_dist[k]=dist; 152 | nbest[k]=i; 153 | used++; 154 | if (sign) 155 | nbest[k]+=entries; 156 | } 157 | } 158 | } 159 | #endif 160 | -------------------------------------------------------------------------------- /speex/libspeex/fixed_generic.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2003 Jean-Marc Valin */ 2 | /** 3 | @file fixed_generic.h 4 | @brief Generic fixed-point operations 5 | */ 6 | /* 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions 9 | are met: 10 | 11 | - Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | 14 | - Redistributions in binary form must reproduce the above copyright 15 | notice, this list of conditions and the following disclaimer in the 16 | documentation and/or other materials provided with the distribution. 17 | 18 | - Neither the name of the Xiph.org Foundation nor the names of its 19 | contributors may be used to endorse or promote products derived from 20 | this software without specific prior written permission. 21 | 22 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 25 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR 26 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 27 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 28 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 29 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 30 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 31 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 32 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | */ 34 | 35 | #ifndef FIXED_GENERIC_H 36 | #define FIXED_GENERIC_H 37 | 38 | #define QCONST16(x,bits) ((spx_word16_t)(.5+(x)*(((spx_word32_t)1)<<(bits)))) 39 | #define QCONST32(x,bits) ((spx_word32_t)(.5+(x)*(((spx_word32_t)1)<<(bits)))) 40 | 41 | #define NEG16(x) (-(x)) 42 | #define NEG32(x) (-(x)) 43 | #define EXTRACT16(x) ((spx_word16_t)(x)) 44 | #define EXTEND32(x) ((spx_word32_t)(x)) 45 | #define SHR16(a,shift) ((a) >> (shift)) 46 | #define SHL16(a,shift) ((a) << (shift)) 47 | #define SHR32(a,shift) ((a) >> (shift)) 48 | #define SHL32(a,shift) ((a) << (shift)) 49 | #define PSHR16(a,shift) (SHR16((a)+((1<<((shift))>>1)),shift)) 50 | #define PSHR32(a,shift) (SHR32((a)+((EXTEND32(1)<<((shift))>>1)),shift)) 51 | #define VSHR32(a, shift) (((shift)>0) ? SHR32(a, shift) : SHL32(a, -(shift))) 52 | #define SATURATE16(x,a) (((x)>(a) ? (a) : (x)<-(a) ? -(a) : (x))) 53 | #define SATURATE32(x,a) (((x)>(a) ? (a) : (x)<-(a) ? -(a) : (x))) 54 | 55 | #define SHR(a,shift) ((a) >> (shift)) 56 | #define SHL(a,shift) ((spx_word32_t)(a) << (shift)) 57 | #define PSHR(a,shift) (SHR((a)+((EXTEND32(1)<<((shift))>>1)),shift)) 58 | #define SATURATE(x,a) (((x)>(a) ? (a) : (x)<-(a) ? -(a) : (x))) 59 | 60 | 61 | #define ADD16(a,b) ((spx_word16_t)((spx_word16_t)(a)+(spx_word16_t)(b))) 62 | #define SUB16(a,b) ((spx_word16_t)(a)-(spx_word16_t)(b)) 63 | #define ADD32(a,b) ((spx_word32_t)(a)+(spx_word32_t)(b)) 64 | #define SUB32(a,b) ((spx_word32_t)(a)-(spx_word32_t)(b)) 65 | 66 | 67 | /* result fits in 16 bits */ 68 | #define MULT16_16_16(a,b) ((((spx_word16_t)(a))*((spx_word16_t)(b)))) 69 | 70 | /* (spx_word32_t)(spx_word16_t) gives TI compiler a hint that it's 16x16->32 multiply */ 71 | #define MULT16_16(a,b) (((spx_word32_t)(spx_word16_t)(a))*((spx_word32_t)(spx_word16_t)(b))) 72 | 73 | #define MAC16_16(c,a,b) (ADD32((c),MULT16_16((a),(b)))) 74 | #define MULT16_32_Q12(a,b) ADD32(MULT16_16((a),SHR((b),12)), SHR(MULT16_16((a),((b)&0x00000fff)),12)) 75 | #define MULT16_32_Q13(a,b) ADD32(MULT16_16((a),SHR((b),13)), SHR(MULT16_16((a),((b)&0x00001fff)),13)) 76 | #define MULT16_32_Q14(a,b) ADD32(MULT16_16((a),SHR((b),14)), SHR(MULT16_16((a),((b)&0x00003fff)),14)) 77 | 78 | #define MULT16_32_Q11(a,b) ADD32(MULT16_16((a),SHR((b),11)), SHR(MULT16_16((a),((b)&0x000007ff)),11)) 79 | #define MAC16_32_Q11(c,a,b) ADD32(c,ADD32(MULT16_16((a),SHR((b),11)), SHR(MULT16_16((a),((b)&0x000007ff)),11))) 80 | 81 | #define MULT16_32_P15(a,b) ADD32(MULT16_16((a),SHR((b),15)), PSHR(MULT16_16((a),((b)&0x00007fff)),15)) 82 | #define MULT16_32_Q15(a,b) ADD32(MULT16_16((a),SHR((b),15)), SHR(MULT16_16((a),((b)&0x00007fff)),15)) 83 | #define MAC16_32_Q15(c,a,b) ADD32(c,ADD32(MULT16_16((a),SHR((b),15)), SHR(MULT16_16((a),((b)&0x00007fff)),15))) 84 | 85 | 86 | #define MAC16_16_Q11(c,a,b) (ADD32((c),SHR(MULT16_16((a),(b)),11))) 87 | #define MAC16_16_Q13(c,a,b) (ADD32((c),SHR(MULT16_16((a),(b)),13))) 88 | #define MAC16_16_P13(c,a,b) (ADD32((c),SHR(ADD32(4096,MULT16_16((a),(b))),13))) 89 | 90 | #define MULT16_16_Q11_32(a,b) (SHR(MULT16_16((a),(b)),11)) 91 | #define MULT16_16_Q13(a,b) (SHR(MULT16_16((a),(b)),13)) 92 | #define MULT16_16_Q14(a,b) (SHR(MULT16_16((a),(b)),14)) 93 | #define MULT16_16_Q15(a,b) (SHR(MULT16_16((a),(b)),15)) 94 | 95 | #define MULT16_16_P13(a,b) (SHR(ADD32(4096,MULT16_16((a),(b))),13)) 96 | #define MULT16_16_P14(a,b) (SHR(ADD32(8192,MULT16_16((a),(b))),14)) 97 | #define MULT16_16_P15(a,b) (SHR(ADD32(16384,MULT16_16((a),(b))),15)) 98 | 99 | #define MUL_16_32_R15(a,bh,bl) ADD32(MULT16_16((a),(bh)), SHR(MULT16_16((a),(bl)),15)) 100 | 101 | #define DIV32_16(a,b) ((spx_word16_t)(((spx_word32_t)(a))/((spx_word16_t)(b)))) 102 | #define PDIV32_16(a,b) ((spx_word16_t)(((spx_word32_t)(a)+((spx_word16_t)(b)>>1))/((spx_word16_t)(b)))) 103 | #define DIV32(a,b) (((spx_word32_t)(a))/((spx_word32_t)(b))) 104 | #define PDIV32(a,b) (((spx_word32_t)(a)+((spx_word16_t)(b)>>1))/((spx_word32_t)(b))) 105 | 106 | #endif 107 | -------------------------------------------------------------------------------- /speex/include/speex/speex_callbacks.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2002 Jean-Marc Valin*/ 2 | /** 3 | @file speex_callbacks.h 4 | @brief Describes callback handling and in-band signalling 5 | */ 6 | /* 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions 9 | are met: 10 | 11 | - Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | 14 | - Redistributions in binary form must reproduce the above copyright 15 | notice, this list of conditions and the following disclaimer in the 16 | documentation and/or other materials provided with the distribution. 17 | 18 | - Neither the name of the Xiph.org Foundation nor the names of its 19 | contributors may be used to endorse or promote products derived from 20 | this software without specific prior written permission. 21 | 22 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 25 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR 26 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 27 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 28 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 29 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 30 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 31 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 32 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | 34 | */ 35 | 36 | #ifndef SPEEX_CALLBACKS_H 37 | #define SPEEX_CALLBACKS_H 38 | /** @defgroup SpeexCallbacks Various definitions for Speex callbacks supported by the decoder. 39 | * @{ 40 | */ 41 | 42 | #include "speex.h" 43 | 44 | #ifdef __cplusplus 45 | extern "C" { 46 | #endif 47 | 48 | /** Total number of callbacks */ 49 | #define SPEEX_MAX_CALLBACKS 16 50 | 51 | /* Describes all the in-band requests */ 52 | 53 | /*These are 1-bit requests*/ 54 | /** Request for perceptual enhancement (1 for on, 0 for off) */ 55 | #define SPEEX_INBAND_ENH_REQUEST 0 56 | /** Reserved */ 57 | #define SPEEX_INBAND_RESERVED1 1 58 | 59 | /*These are 4-bit requests*/ 60 | /** Request for a mode change */ 61 | #define SPEEX_INBAND_MODE_REQUEST 2 62 | /** Request for a low mode change */ 63 | #define SPEEX_INBAND_LOW_MODE_REQUEST 3 64 | /** Request for a high mode change */ 65 | #define SPEEX_INBAND_HIGH_MODE_REQUEST 4 66 | /** Request for VBR (1 on, 0 off) */ 67 | #define SPEEX_INBAND_VBR_QUALITY_REQUEST 5 68 | /** Request to be sent acknowledge */ 69 | #define SPEEX_INBAND_ACKNOWLEDGE_REQUEST 6 70 | /** Request for VBR (1 for on, 0 for off) */ 71 | #define SPEEX_INBAND_VBR_REQUEST 7 72 | 73 | /*These are 8-bit requests*/ 74 | /** Send a character in-band */ 75 | #define SPEEX_INBAND_CHAR 8 76 | /** Intensity stereo information */ 77 | #define SPEEX_INBAND_STEREO 9 78 | 79 | /*These are 16-bit requests*/ 80 | /** Transmit max bit-rate allowed */ 81 | #define SPEEX_INBAND_MAX_BITRATE 10 82 | 83 | /*These are 32-bit requests*/ 84 | /** Acknowledge packet reception */ 85 | #define SPEEX_INBAND_ACKNOWLEDGE 12 86 | 87 | /** Callback function type */ 88 | typedef int (*speex_callback_func)(SpeexBits *bits, void *state, void *data); 89 | 90 | /** Callback information */ 91 | typedef struct SpeexCallback { 92 | int callback_id; /**< ID associated to the callback */ 93 | speex_callback_func func; /**< Callback handler function */ 94 | void *data; /**< Data that will be sent to the handler */ 95 | void *reserved1; /**< Reserved for future use */ 96 | int reserved2; /**< Reserved for future use */ 97 | } SpeexCallback; 98 | 99 | /** Handle in-band request */ 100 | int speex_inband_handler(SpeexBits *bits, SpeexCallback *callback_list, void *state); 101 | 102 | /** Standard handler for mode request (change mode, no questions asked) */ 103 | int speex_std_mode_request_handler(SpeexBits *bits, void *state, void *data); 104 | 105 | /** Standard handler for high mode request (change high mode, no questions asked) */ 106 | int speex_std_high_mode_request_handler(SpeexBits *bits, void *state, void *data); 107 | 108 | /** Standard handler for in-band characters (write to stderr) */ 109 | int speex_std_char_handler(SpeexBits *bits, void *state, void *data); 110 | 111 | /** Default handler for user-defined requests: in this case, just ignore */ 112 | int speex_default_user_handler(SpeexBits *bits, void *state, void *data); 113 | 114 | 115 | 116 | /** Standard handler for low mode request (change low mode, no questions asked) */ 117 | int speex_std_low_mode_request_handler(SpeexBits *bits, void *state, void *data); 118 | 119 | /** Standard handler for VBR request (Set VBR, no questions asked) */ 120 | int speex_std_vbr_request_handler(SpeexBits *bits, void *state, void *data); 121 | 122 | /** Standard handler for enhancer request (Turn enhancer on/off, no questions asked) */ 123 | int speex_std_enh_request_handler(SpeexBits *bits, void *state, void *data); 124 | 125 | /** Standard handler for VBR quality request (Set VBR quality, no questions asked) */ 126 | int speex_std_vbr_quality_request_handler(SpeexBits *bits, void *state, void *data); 127 | 128 | 129 | #ifdef __cplusplus 130 | } 131 | #endif 132 | 133 | /** @} */ 134 | #endif 135 | -------------------------------------------------------------------------------- /speex/libspeex/exc_8_128_table.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2002 Jean-Marc Valin 2 | File: exc_8_128_table.c 3 | Codebook for excitation in narrowband CELP mode (7000 bps) 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 | 34 | const signed char exc_8_128_table[1024] = { 35 | -14,9,13,-32,2,-10,31,-10, 36 | -8,-8,6,-4,-1,10,-64,23, 37 | 6,20,13,6,8,-22,16,34, 38 | 7,42,-49,-28,5,26,4,-15, 39 | 41,34,41,32,33,24,23,14, 40 | 8,40,34,4,-24,-41,-19,-15, 41 | 13,-13,33,-54,24,27,-44,33, 42 | 27,-15,-15,24,-19,14,-36,14, 43 | -9,24,-12,-4,37,-5,16,-34, 44 | 5,10,33,-15,-54,-16,12,25, 45 | 12,1,2,0,3,-1,-4,-4, 46 | 11,2,-56,54,27,-20,13,-6, 47 | -46,-41,-33,-11,-5,7,12,14, 48 | -14,-5,8,20,6,3,4,-8, 49 | -5,-42,11,8,-14,25,-2,2, 50 | 13,11,-22,39,-9,9,5,-45, 51 | -9,7,-9,12,-7,34,-17,-102, 52 | 7,2,-42,18,35,-9,-34,11, 53 | -5,-2,3,22,46,-52,-25,-9, 54 | -94,8,11,-5,-5,-5,4,-7, 55 | -35,-7,54,5,-32,3,24,-9, 56 | -22,8,65,37,-1,-12,-23,-6, 57 | -9,-28,55,-33,14,-3,2,18, 58 | -60,41,-17,8,-16,17,-11,0, 59 | -11,29,-28,37,9,-53,33,-14, 60 | -9,7,-25,-7,-11,26,-32,-8, 61 | 24,-21,22,-19,19,-10,29,-14, 62 | 0,0,0,0,0,0,0,0, 63 | -5,-52,10,41,6,-30,-4,16, 64 | 32,22,-27,-22,32,-3,-28,-3, 65 | 3,-35,6,17,23,21,8,2, 66 | 4,-45,-17,14,23,-4,-31,-11, 67 | -3,14,1,19,-11,2,61,-8, 68 | 9,-12,7,-10,12,-3,-24,99, 69 | -48,23,50,-37,-5,-23,0,8, 70 | -14,35,-64,-5,46,-25,13,-1, 71 | -49,-19,-15,9,34,50,25,11, 72 | -6,-9,-16,-20,-32,-33,-32,-27, 73 | 10,-8,12,-15,56,-14,-32,33, 74 | 3,-9,1,65,-9,-9,-10,-2, 75 | -6,-23,9,17,3,-28,13,-32, 76 | 4,-2,-10,4,-16,76,12,-52, 77 | 6,13,33,-6,4,-14,-9,-3, 78 | 1,-15,-16,28,1,-15,11,16, 79 | 9,4,-21,-37,-40,-6,22,12, 80 | -15,-23,-14,-17,-16,-9,-10,-9, 81 | 13,-39,41,5,-9,16,-38,25, 82 | 46,-47,4,49,-14,17,-2,6, 83 | 18,5,-6,-33,-22,44,50,-2, 84 | 1,3,-6,7,7,-3,-21,38, 85 | -18,34,-14,-41,60,-13,6,16, 86 | -24,35,19,-13,-36,24,3,-17, 87 | -14,-10,36,44,-44,-29,-3,3, 88 | -54,-8,12,55,26,4,-2,-5, 89 | 2,-11,22,-23,2,22,1,-25, 90 | -39,66,-49,21,-8,-2,10,-14, 91 | -60,25,6,10,27,-25,16,5, 92 | -2,-9,26,-13,-20,58,-2,7, 93 | 52,-9,2,5,-4,-15,23,-1, 94 | -38,23,8,27,-6,0,-27,-7, 95 | 39,-10,-14,26,11,-45,-12,9, 96 | -5,34,4,-35,10,43,-22,-11, 97 | 56,-7,20,1,10,1,-26,9, 98 | 94,11,-27,-14,-13,1,-11,0, 99 | 14,-5,-6,-10,-4,-15,-8,-41, 100 | 21,-5,1,-28,-8,22,-9,33, 101 | -23,-4,-4,-12,39,4,-7,3, 102 | -60,80,8,-17,2,-6,12,-5, 103 | 1,9,15,27,31,30,27,23, 104 | 61,47,26,10,-5,-8,-12,-13, 105 | 5,-18,25,-15,-4,-15,-11,12, 106 | -2,-2,-16,-2,-6,24,12,11, 107 | -4,9,1,-9,14,-45,57,12, 108 | 20,-35,26,11,-64,32,-10,-10, 109 | 42,-4,-9,-16,32,24,7,10, 110 | 52,-11,-57,29,0,8,0,-6, 111 | 17,-17,-56,-40,7,20,18,12, 112 | -6,16,5,7,-1,9,1,10, 113 | 29,12,16,13,-2,23,7,9, 114 | -3,-4,-5,18,-64,13,55,-25, 115 | 9,-9,24,14,-25,15,-11,-40, 116 | -30,37,1,-19,22,-5,-31,13, 117 | -2,0,7,-4,16,-67,12,66, 118 | -36,24,-8,18,-15,-23,19,0, 119 | -45,-7,4,3,-13,13,35,5, 120 | 13,33,10,27,23,0,-7,-11, 121 | 43,-74,36,-12,2,5,-8,6, 122 | -33,11,-16,-14,-5,-7,-3,17, 123 | -34,27,-16,11,-9,15,33,-31, 124 | 8,-16,7,-6,-7,63,-55,-17, 125 | 11,-1,20,-46,34,-30,6,9, 126 | 19,28,-9,5,-24,-8,-23,-2, 127 | 31,-19,-16,-5,-15,-18,0,26, 128 | 18,37,-5,-15,-2,17,5,-27, 129 | 21,-33,44,12,-27,-9,17,11, 130 | 25,-21,-31,-7,13,33,-8,-25, 131 | -7,7,-10,4,-6,-9,48,-82, 132 | -23,-8,6,11,-23,3,-3,49, 133 | -29,25,31,4,14,16,9,-4, 134 | -18,10,-26,3,5,-44,-9,9, 135 | -47,-55,15,9,28,1,4,-3, 136 | 46,6,-6,-38,-29,-31,-15,-6, 137 | 3,0,14,-6,8,-54,-50,33, 138 | -5,1,-14,33,-48,26,-4,-5, 139 | -3,-5,-3,-5,-28,-22,77,55, 140 | -1,2,10,10,-9,-14,-66,-49, 141 | 11,-36,-6,-20,10,-10,16,12, 142 | 4,-1,-16,45,-44,-50,31,-2, 143 | 25,42,23,-32,-22,0,11,20, 144 | -40,-35,-40,-36,-32,-26,-21,-13, 145 | 52,-22,6,-24,-20,17,-5,-8, 146 | 36,-25,-11,21,-26,6,34,-8, 147 | 7,20,-3,5,-25,-8,18,-5, 148 | -9,-4,1,-9,20,20,39,48, 149 | -24,9,5,-65,22,29,4,3, 150 | -43,-11,32,-6,9,19,-27,-10, 151 | -47,-14,24,10,-7,-36,-7,-1, 152 | -4,-5,-5,16,53,25,-26,-29, 153 | -4,-12,45,-58,-34,33,-5,2, 154 | -1,27,-48,31,-15,22,-5,4, 155 | 7,7,-25,-3,11,-22,16,-12, 156 | 8,-3,7,-11,45,14,-73,-19, 157 | 56,-46,24,-20,28,-12,-2,-1, 158 | -36,-3,-33,19,-6,7,2,-15, 159 | 5,-31,-45,8,35,13,20,0, 160 | -9,48,-13,-43,-3,-13,2,-5, 161 | 72,-68,-27,2,1,-2,-7,5, 162 | 36,33,-40,-12,-4,-5,23,19}; 163 | -------------------------------------------------------------------------------- /speex/libspeex/high_lsp_tables.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2002 Jean-Marc Valin 2 | File: high_lsp_tables.c 3 | Codebooks for high-band LSPs in SB-CELP mode 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | 9 | 1. Redistributions of source code must retain the above copyright notice, 10 | this list of conditions and the following disclaimer. 11 | 12 | 2. 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 | 3. The name of the author may not be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 23 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 27 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 28 | ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 | POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | const signed char high_lsp_cdbk[512]={ 33 | 39,12,-14,-20,-29,-61,-67,-76, 34 | -32,-71,-67,68,77,46,34,5, 35 | -13,-48,-46,-72,-81,-84,-60,-58, 36 | -40,-28,82,93,68,45,29,3, 37 | -19,-47,-28,-43,-35,-30,-8,-13, 38 | -39,-91,-91,-123,-96,10,10,-6, 39 | -18,-55,-60,-91,-56,-36,-27,-16, 40 | -48,-75,40,28,-10,-28,35,9, 41 | 37,19,1,-20,-31,-41,-18,-25, 42 | -35,-68,-80,45,27,-1,47,13, 43 | 0,-29,-35,-57,-50,-79,-73,-38, 44 | -19,5,35,14,-10,-23,16,-8, 45 | 5,-24,-40,-62,-23,-27,-22,-16, 46 | -18,-46,-72,-77,43,21,33,1, 47 | -80,-70,-70,-64,-56,-52,-39,-33, 48 | -31,-38,-19,-19,-15,32,33,-2, 49 | 7,-15,-15,-24,-23,-33,-41,-56, 50 | -24,-57,5,89,64,41,27,5, 51 | -9,-47,-60,-97,-97,-124,-20,-9, 52 | -44,-73,31,29,-4,64,48,7, 53 | -35,-57,0,-3,-26,-47,-3,-6, 54 | -40,-76,-79,-48,12,81,55,10, 55 | 9,-24,-43,-73,-57,-69,16,5, 56 | -28,-53,18,29,20,0,-4,-11, 57 | 6,-13,23,7,-17,-35,-37,-37, 58 | -30,-68,-63,6,24,-9,-14,3, 59 | 21,-13,-27,-57,-49,-80,-24,-41, 60 | -5,-16,-5,1,45,25,12,-7, 61 | 3,-15,-6,-16,-15,-8,6,-13, 62 | -42,-81,-80,-87,14,1,-10,-3, 63 | -43,-69,-46,-24,-28,-29,36,6, 64 | -43,-56,-12,12,54,79,43,9, 65 | 54,22,2,8,-12,-43,-46,-52, 66 | -38,-69,-89,-5,75,38,33,5, 67 | -13,-53,-62,-87,-89,-113,-99,-55, 68 | -34,-37,62,55,33,16,21,-2, 69 | -17,-46,-29,-38,-38,-48,-39,-42, 70 | -36,-75,-72,-88,-48,-30,21,2, 71 | -15,-57,-64,-98,-84,-76,25,1, 72 | -46,-80,-12,18,-7,3,34,6, 73 | 38,31,23,4,-1,20,14,-15, 74 | -43,-78,-91,-24,14,-3,54,16, 75 | 0,-27,-28,-44,-56,-83,-92,-89, 76 | -3,34,56,41,36,22,20,-8, 77 | -7,-35,-42,-62,-49,3,12,-10, 78 | -50,-87,-96,-66,92,70,38,9, 79 | -70,-71,-62,-42,-39,-43,-11,-7, 80 | -50,-79,-58,-50,-31,32,31,-6, 81 | -4,-25,7,-17,-38,-70,-58,-27, 82 | -43,-83,-28,59,36,20,31,2, 83 | -27,-71,-80,-109,-98,-75,-33,-32, 84 | -31,-2,33,15,-6,43,33,-5, 85 | 0,-22,-10,-27,-34,-49,-11,-20, 86 | -41,-91,-100,-121,-39,57,41,10, 87 | -19,-50,-38,-59,-60,-70,-18,-20, 88 | -8,-31,-8,-15,1,-14,-26,-25, 89 | 33,21,32,17,1,-19,-19,-26, 90 | -58,-81,-35,-22,45,30,11,-11, 91 | 3,-26,-48,-87,-67,-83,-58,3, 92 | -1,-26,-20,44,10,25,39,5, 93 | -9,-35,-27,-38,7,10,4,-9, 94 | -42,-85,-102,-127,52,44,28,10, 95 | -47,-61,-40,-39,-17,-1,-10,-33, 96 | -42,-74,-48,21,-4,70,52,10}; 97 | 98 | 99 | const signed char high_lsp_cdbk2[512]={ 100 | -36,-62,6,-9,-10,-14,-56,23, 101 | 1,-26,23,-48,-17,12,8,-7, 102 | 23,29,-36,-28,-6,-29,-17,-5, 103 | 40,23,10,10,-46,-13,36,6, 104 | 4,-30,-29,62,32,-32,-1,22, 105 | -14,1,-4,-22,-45,2,54,4, 106 | -30,-57,-59,-12,27,-3,-31,8, 107 | -9,5,10,-14,32,66,19,9, 108 | 2,-25,-37,23,-15,18,-38,-31, 109 | 5,-9,-21,15,0,22,62,30, 110 | 15,-12,-14,-46,77,21,33,3, 111 | 34,29,-19,50,2,11,9,-38, 112 | -12,-37,62,1,-15,54,32,6, 113 | 2,-24,20,35,-21,2,19,24, 114 | -13,55,4,9,39,-19,30,-1, 115 | -21,73,54,33,8,18,3,15, 116 | 6,-19,-47,6,-3,-48,-50,1, 117 | 26,20,8,-23,-50,65,-14,-55, 118 | -17,-31,-37,-28,53,-1,-17,-53, 119 | 1,57,11,-8,-25,-30,-37,64, 120 | 5,-52,-45,15,23,31,15,14, 121 | -25,24,33,-2,-44,-56,-18,6, 122 | -21,-43,4,-12,17,-37,20,-10, 123 | 34,15,2,15,55,21,-11,-31, 124 | -6,46,25,16,-9,-25,-8,-62, 125 | 28,17,20,-32,-29,26,30,25, 126 | -19,2,-16,-17,26,-51,2,50, 127 | 42,19,-66,23,29,-2,3,19, 128 | -19,-37,32,15,6,30,-34,13, 129 | 11,-5,40,31,10,-42,4,-9, 130 | 26,-9,-70,17,-2,-23,20,-22, 131 | -55,51,-24,-31,22,-22,15,-13, 132 | 3,-10,-28,-16,56,4,-63,11, 133 | -18,-15,-18,-38,-35,16,-7,34, 134 | -1,-21,-49,-47,9,-37,7,8, 135 | 69,55,20,6,-33,-45,-10,-9, 136 | 6,-9,12,71,15,-3,-42,-7, 137 | -24,32,-35,-2,-42,-17,-5,0, 138 | -2,-33,-54,13,-12,-34,47,23, 139 | 19,55,7,-8,74,31,14,16, 140 | -23,-26,19,12,-18,-49,-28,-31, 141 | -20,2,-14,-20,-47,78,40,13, 142 | -23,-11,21,-6,18,1,47,5, 143 | 38,35,32,46,22,8,13,16, 144 | -14,18,51,19,40,39,11,-26, 145 | -1,-17,47,2,-53,-15,31,-22, 146 | 38,21,-15,-16,5,-33,53,15, 147 | -38,86,11,-3,-24,49,13,-4, 148 | -11,-18,28,20,-12,-27,-26,35, 149 | -25,-35,-3,-20,-61,30,10,-55, 150 | -12,-22,-52,-54,-14,19,-32,-12, 151 | 45,15,-8,-48,-9,11,-32,8, 152 | -16,-34,-13,51,18,38,-2,-32, 153 | -17,22,-2,-18,-28,-70,59,27, 154 | -28,-19,-10,-20,-9,-9,-8,-21, 155 | 21,-8,35,-2,45,-3,-9,12, 156 | 0,30,7,-39,43,27,-38,-91, 157 | 30,26,19,-55,-4,63,14,-17, 158 | 13,9,13,2,7,4,6,61, 159 | 72,-1,-17,29,-1,-22,-17,8, 160 | -28,-37,63,44,41,3,2,14, 161 | 9,-6,75,-8,-7,-12,-15,-12, 162 | 13,9,-4,30,-22,-65,15,0, 163 | -45,4,-4,1,5,22,11,23}; 164 | -------------------------------------------------------------------------------- /speex/libspeex/window.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2006 Jean-Marc Valin 2 | File: window.c 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions 6 | are met: 7 | 8 | - Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | 11 | - Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | 15 | - Neither the name of the Xiph.org Foundation nor the names of its 16 | contributors may be used to endorse or promote products derived from 17 | this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR 23 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 24 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 25 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 26 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 27 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 28 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 29 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | #ifdef HAVE_CONFIG_H 33 | #include "config.h" 34 | #endif 35 | 36 | #include "arch.h" 37 | 38 | #ifdef FIXED_POINT 39 | const spx_word16_t lag_window[11] = { 40 | 16384, 16337, 16199, 15970, 15656, 15260, 14790, 14254, 13659, 13015, 12330 41 | }; 42 | 43 | const spx_word16_t lpc_window[200] = { 44 | 1310, 1313, 1321, 1333, 1352, 1375, 1403, 1436, 45 | 1475, 1518, 1567, 1621, 1679, 1743, 1811, 1884, 46 | 1962, 2044, 2132, 2224, 2320, 2421, 2526, 2636, 47 | 2750, 2868, 2990, 3116, 3246, 3380, 3518, 3659, 48 | 3804, 3952, 4104, 4259, 4417, 4578, 4742, 4909, 49 | 5079, 5251, 5425, 5602, 5781, 5963, 6146, 6331, 50 | 6518, 6706, 6896, 7087, 7280, 7473, 7668, 7863, 51 | 8059, 8256, 8452, 8650, 8847, 9044, 9241, 9438, 52 | 9635, 9831, 10026, 10220, 10414, 10606, 10797, 10987, 53 | 11176, 11363, 11548, 11731, 11912, 12091, 12268, 12443, 54 | 12615, 12785, 12952, 13116, 13277, 13435, 13590, 13742, 55 | 13890, 14035, 14176, 14314, 14448, 14578, 14704, 14826, 56 | 14944, 15058, 15168, 15273, 15374, 15470, 15562, 15649, 57 | 15732, 15810, 15883, 15951, 16015, 16073, 16127, 16175, 58 | 16219, 16257, 16291, 16319, 16342, 16360, 16373, 16381, 59 | 16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384, 60 | 16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384, 61 | 16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384, 62 | 16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384, 63 | 16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384, 64 | 16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384, 65 | 16384, 16384, 16384, 16361, 16294, 16183, 16028, 15830, 66 | 15588, 15304, 14979, 14613, 14207, 13763, 13282, 12766, 67 | 12215, 11631, 11016, 10373, 9702, 9007, 8289, 7551, 68 | 6797, 6028, 5251, 4470, 3695, 2943, 2248, 1696 69 | }; 70 | #else 71 | const spx_word16_t lag_window[11] = { 72 | 1.00000, 0.99716, 0.98869, 0.97474, 0.95554, 0.93140, 0.90273, 0.86998, 0.83367, 0.79434, 0.75258 73 | }; 74 | 75 | const spx_word16_t lpc_window[200] = { 76 | 0.080000f, 0.080158f, 0.080630f, 0.081418f, 0.082520f, 0.083935f, 0.085663f, 0.087703f, 77 | 0.090052f, 0.092710f, 0.095674f, 0.098943f, 0.102514f, 0.106385f, 0.110553f, 0.115015f, 78 | 0.119769f, 0.124811f, 0.130137f, 0.135744f, 0.141628f, 0.147786f, 0.154212f, 0.160902f, 79 | 0.167852f, 0.175057f, 0.182513f, 0.190213f, 0.198153f, 0.206328f, 0.214731f, 0.223357f, 80 | 0.232200f, 0.241254f, 0.250513f, 0.259970f, 0.269619f, 0.279453f, 0.289466f, 0.299651f, 81 | 0.310000f, 0.320507f, 0.331164f, 0.341965f, 0.352901f, 0.363966f, 0.375151f, 0.386449f, 82 | 0.397852f, 0.409353f, 0.420943f, 0.432615f, 0.444361f, 0.456172f, 0.468040f, 0.479958f, 83 | 0.491917f, 0.503909f, 0.515925f, 0.527959f, 0.540000f, 0.552041f, 0.564075f, 0.576091f, 84 | 0.588083f, 0.600042f, 0.611960f, 0.623828f, 0.635639f, 0.647385f, 0.659057f, 0.670647f, 85 | 0.682148f, 0.693551f, 0.704849f, 0.716034f, 0.727099f, 0.738035f, 0.748836f, 0.759493f, 86 | 0.770000f, 0.780349f, 0.790534f, 0.800547f, 0.810381f, 0.820030f, 0.829487f, 0.838746f, 87 | 0.847800f, 0.856643f, 0.865269f, 0.873672f, 0.881847f, 0.889787f, 0.897487f, 0.904943f, 88 | 0.912148f, 0.919098f, 0.925788f, 0.932214f, 0.938372f, 0.944256f, 0.949863f, 0.955189f, 89 | 0.960231f, 0.964985f, 0.969447f, 0.973615f, 0.977486f, 0.981057f, 0.984326f, 0.987290f, 90 | 0.989948f, 0.992297f, 0.994337f, 0.996065f, 0.997480f, 0.998582f, 0.999370f, 0.999842f, 91 | 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 92 | 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 93 | 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 94 | 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 95 | 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 96 | 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 97 | 1.000000f, 1.000000f, 1.000000f, 0.998640f, 0.994566f, 0.987787f, 0.978324f, 0.966203f, 98 | 0.951458f, 0.934131f, 0.914270f, 0.891931f, 0.867179f, 0.840084f, 0.810723f, 0.779182f, 99 | 0.745551f, 0.709930f, 0.672424f, 0.633148f, 0.592223f, 0.549781f, 0.505964f, 0.460932f, 100 | 0.414863f, 0.367968f, 0.320511f, 0.272858f, 0.225569f, 0.179655f, 0.137254f, 0.103524f 101 | }; 102 | #endif 103 | -------------------------------------------------------------------------------- /speex/libspeex/os_support.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2007 Jean-Marc Valin 2 | 3 | File: os_support.h 4 | This is the (tiny) OS abstraction layer. Aside from math.h, this is the 5 | only place where system headers are allowed. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are 9 | met: 10 | 11 | 1. Redistributions of source code must retain the above copyright notice, 12 | this list of conditions and the following disclaimer. 13 | 14 | 2. Redistributions in binary form must reproduce the above copyright 15 | notice, this list of conditions and the following disclaimer in the 16 | documentation and/or other materials provided with the distribution. 17 | 18 | 3. The name of the author may not be used to endorse or promote products 19 | derived from this software without specific prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 22 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 23 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 25 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 29 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 30 | ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | POSSIBILITY OF SUCH DAMAGE. 32 | */ 33 | 34 | #ifndef OS_SUPPORT_H 35 | #define OS_SUPPORT_H 36 | 37 | #include 38 | #include 39 | #include 40 | 41 | #ifdef HAVE_CONFIG_H 42 | #include "config.h" 43 | #endif 44 | #ifdef OS_SUPPORT_CUSTOM 45 | #include "os_support_custom.h" 46 | #endif 47 | 48 | /** Speex wrapper for calloc. To do your own dynamic allocation, all you need to do is replace this function, speex_realloc and speex_free 49 | NOTE: speex_alloc needs to CLEAR THE MEMORY */ 50 | #ifndef OVERRIDE_SPEEX_ALLOC 51 | static inline void *speex_alloc (int size) 52 | { 53 | /* WARNING: this is not equivalent to malloc(). If you want to use malloc() 54 | or your own allocator, YOU NEED TO CLEAR THE MEMORY ALLOCATED. Otherwise 55 | you will experience strange bugs */ 56 | return calloc(size,1); 57 | } 58 | #endif 59 | 60 | /** Same as speex_alloc, except that the area is only needed inside a Speex call (might cause problem with wideband though) */ 61 | #ifndef OVERRIDE_SPEEX_ALLOC_SCRATCH 62 | static inline void *speex_alloc_scratch (int size) 63 | { 64 | /* Scratch space doesn't need to be cleared */ 65 | return calloc(size,1); 66 | } 67 | #endif 68 | 69 | /** Speex wrapper for realloc. To do your own dynamic allocation, all you need to do is replace this function, speex_alloc and speex_free */ 70 | #ifndef OVERRIDE_SPEEX_REALLOC 71 | static inline void *speex_realloc (void *ptr, int size) 72 | { 73 | return realloc(ptr, size); 74 | } 75 | #endif 76 | 77 | /** Speex wrapper for calloc. To do your own dynamic allocation, all you need to do is replace this function, speex_realloc and speex_alloc */ 78 | #ifndef OVERRIDE_SPEEX_FREE 79 | static inline void speex_free (void *ptr) 80 | { 81 | free(ptr); 82 | } 83 | #endif 84 | 85 | /** Same as speex_free, except that the area is only needed inside a Speex call (might cause problem with wideband though) */ 86 | #ifndef OVERRIDE_SPEEX_FREE_SCRATCH 87 | static inline void speex_free_scratch (void *ptr) 88 | { 89 | free(ptr); 90 | } 91 | #endif 92 | 93 | /** Copy n bytes of memory from src to dst. The 0* term provides compile-time type checking */ 94 | #ifndef OVERRIDE_SPEEX_COPY 95 | #define SPEEX_COPY(dst, src, n) (memcpy((dst), (src), (n)*sizeof(*(dst)) + 0*((dst)-(src)) )) 96 | #endif 97 | 98 | /** Copy n bytes of memory from src to dst, allowing overlapping regions. The 0* term 99 | provides compile-time type checking */ 100 | #ifndef OVERRIDE_SPEEX_MOVE 101 | #define SPEEX_MOVE(dst, src, n) (memmove((dst), (src), (n)*sizeof(*(dst)) + 0*((dst)-(src)) )) 102 | #endif 103 | 104 | /** Set n bytes of memory to value of c, starting at address s */ 105 | #ifndef OVERRIDE_SPEEX_MEMSET 106 | #define SPEEX_MEMSET(dst, c, n) (memset((dst), (c), (n)*sizeof(*(dst)))) 107 | #endif 108 | 109 | /* 110 | #ifndef OVERRIDE_SPEEX_FATAL 111 | static inline void _speex_fatal(const char *str, const char *file, int line) 112 | { 113 | fprintf (stderr, "Fatal (internal) error in %s, line %d: %s\n", file, line, str); 114 | exit(1); 115 | } 116 | #endif 117 | */ 118 | #ifndef OVERRIDE_SPEEX_WARNING 119 | static inline void speex_warning(const char *str) 120 | { 121 | #ifndef DISABLE_WARNINGS 122 | fprintf (stderr, "warning: %s\n", str); 123 | #endif 124 | } 125 | #endif 126 | 127 | #ifndef OVERRIDE_SPEEX_WARNING_INT 128 | static inline void speex_warning_int(const char *str, int val) 129 | { 130 | #ifndef DISABLE_WARNINGS 131 | fprintf (stderr, "warning: %s %d\n", str, val); 132 | #endif 133 | } 134 | #endif 135 | 136 | #ifndef OVERRIDE_SPEEX_NOTIFY 137 | static inline void speex_notify(const char *str) 138 | { 139 | #ifndef DISABLE_NOTIFICATIONS 140 | fprintf (stderr, "notification: %s\n", str); 141 | #endif 142 | } 143 | #endif 144 | 145 | #ifndef OVERRIDE_SPEEX_PUTC 146 | /** Speex wrapper for putc */ 147 | static inline void _speex_putc(int ch, void *file) 148 | { 149 | FILE *f = (FILE *)file; 150 | fprintf(f, "%c", ch); 151 | } 152 | #endif 153 | 154 | //#define speex_fatal(str) _speex_fatal(str, __FILE__, __LINE__); 155 | //#define speex_assert(cond) {if (!(cond)) {speex_fatal("assertion failed: " #cond);}} 156 | 157 | #ifndef RELEASE 158 | static inline void print_vec(float *vec, int len, char *name) 159 | { 160 | int i; 161 | printf ("%s ", name); 162 | for (i=0;i0 ? g[0] : -SHR16(g[0],1)) + (g[2]>0 ? g[2] : -SHR16(g[2],1))) 47 | #else 48 | #define gain_3tap_to_1tap(g) (ABS(g[1]) + (g[0]>0 ? g[0] : -.5*g[0]) + (g[2]>0 ? g[2] : -.5*g[2])) 49 | #endif 50 | 51 | spx_word32_t inner_prod(const spx_word16_t *x, const spx_word16_t *y, int len); 52 | void pitch_xcorr(const spx_word16_t *_x, const spx_word16_t *_y, spx_word32_t *corr, int len, int nb_pitch, char *stack); 53 | 54 | void open_loop_nbest_pitch(spx_word16_t *sw, int start, int end, int len, int *pitch, spx_word16_t *gain, int N, char *stack); 55 | 56 | 57 | /** Finds the best quantized 3-tap pitch predictor by analysis by synthesis */ 58 | int pitch_search_3tap( 59 | spx_word16_t target[], /* Target vector */ 60 | spx_word16_t *sw, 61 | spx_coef_t ak[], /* LPCs for this subframe */ 62 | spx_coef_t awk1[], /* Weighted LPCs #1 for this subframe */ 63 | spx_coef_t awk2[], /* Weighted LPCs #2 for this subframe */ 64 | spx_sig_t exc[], /* Overlapping codebook */ 65 | const void *par, 66 | int start, /* Smallest pitch value allowed */ 67 | int end, /* Largest pitch value allowed */ 68 | spx_word16_t pitch_coef, /* Voicing (pitch) coefficient */ 69 | int p, /* Number of LPC coeffs */ 70 | int nsf, /* Number of samples in subframe */ 71 | SpeexBits *bits, 72 | char *stack, 73 | spx_word16_t *exc2, 74 | spx_word16_t *r, 75 | int complexity, 76 | int cdbk_offset, 77 | int plc_tuning, 78 | spx_word32_t *cumul_gain 79 | ); 80 | 81 | /*Unquantize adaptive codebook and update pitch contribution*/ 82 | void pitch_unquant_3tap( 83 | spx_word16_t exc[], /* Input excitation */ 84 | spx_word32_t exc_out[], /* Output excitation */ 85 | int start, /* Smallest pitch value allowed */ 86 | int end, /* Largest pitch value allowed */ 87 | spx_word16_t pitch_coef, /* Voicing (pitch) coefficient */ 88 | const void *par, 89 | int nsf, /* Number of samples in subframe */ 90 | int *pitch_val, 91 | spx_word16_t *gain_val, 92 | SpeexBits *bits, 93 | char *stack, 94 | int lost, 95 | int subframe_offset, 96 | spx_word16_t last_pitch_gain, 97 | int cdbk_offset 98 | ); 99 | 100 | /** Forced pitch delay and gain */ 101 | int forced_pitch_quant( 102 | spx_word16_t target[], /* Target vector */ 103 | spx_word16_t *sw, 104 | spx_coef_t ak[], /* LPCs for this subframe */ 105 | spx_coef_t awk1[], /* Weighted LPCs #1 for this subframe */ 106 | spx_coef_t awk2[], /* Weighted LPCs #2 for this subframe */ 107 | spx_sig_t exc[], /* Excitation */ 108 | const void *par, 109 | int start, /* Smallest pitch value allowed */ 110 | int end, /* Largest pitch value allowed */ 111 | spx_word16_t pitch_coef, /* Voicing (pitch) coefficient */ 112 | int p, /* Number of LPC coeffs */ 113 | int nsf, /* Number of samples in subframe */ 114 | SpeexBits *bits, 115 | char *stack, 116 | spx_word16_t *exc2, 117 | spx_word16_t *r, 118 | int complexity, 119 | int cdbk_offset, 120 | int plc_tuning, 121 | spx_word32_t *cumul_gain 122 | ); 123 | 124 | /** Unquantize forced pitch delay and gain */ 125 | void forced_pitch_unquant( 126 | spx_word16_t exc[], /* Input excitation */ 127 | spx_word32_t exc_out[], /* Output excitation */ 128 | int start, /* Smallest pitch value allowed */ 129 | int end, /* Largest pitch value allowed */ 130 | spx_word16_t pitch_coef, /* Voicing (pitch) coefficient */ 131 | const void *par, 132 | int nsf, /* Number of samples in subframe */ 133 | int *pitch_val, 134 | spx_word16_t *gain_val, 135 | SpeexBits *bits, 136 | char *stack, 137 | int lost, 138 | int subframe_offset, 139 | spx_word16_t last_pitch_gain, 140 | int cdbk_offset 141 | ); 142 | -------------------------------------------------------------------------------- /speex/STM32/libspeex/gcc/filters_cortexM3.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2008 STMicroelectronics, MCD */ 2 | /* 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions 6 | are met: 7 | 8 | - Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | 11 | - Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | 15 | - Neither the name of the Xiph.org Foundation nor the names of its 16 | contributors may be used to endorse or promote products derived from 17 | this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR 23 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 24 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 25 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 26 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 27 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 28 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 29 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | #ifndef __FILTERS_M3_H 33 | #define __FILTERS_M3_H 34 | 35 | 36 | #define OVERRIDE_COMPUTE_IMPULSE_RESPONSE 37 | void compute_impulse_response(const spx_coef_t *ak, const spx_coef_t *awk1, const spx_coef_t *awk2, spx_word16_t *y, int N, int ord, char *stack) 38 | { 39 | int i; 40 | spx_word16_t y1, ny1i, ny2i; 41 | spx_mem_t mem1[10]; 42 | spx_mem_t mem2[10]; 43 | 44 | y1 = ADD16(LPC_SCALING, EXTRACT16(PSHR32(0,LPC_SHIFT))); 45 | ny1i = NEG16(y1); 46 | y[0] = PSHR32(SHL32(EXTEND32(y1),LPC_SHIFT+1),LPC_SHIFT); 47 | ny2i = NEG16(y[0]); 48 | 49 | mem1[0] = MULT16_16(awk2[0],ny1i); 50 | mem2[0] = MULT16_16(ak[0],ny2i); 51 | 52 | mem1[1] = MULT16_16(awk2[1],ny1i); 53 | mem2[1] = MULT16_16(ak[1],ny2i); 54 | 55 | mem1[2] = MULT16_16(awk2[2],ny1i); 56 | mem2[2] = MULT16_16(ak[2],ny2i); 57 | 58 | mem1[3] = MULT16_16(awk2[3],ny1i); 59 | mem2[3] = MULT16_16(ak[3],ny2i); 60 | 61 | mem1[4] = MULT16_16(awk2[4],ny1i); 62 | mem2[4] = MULT16_16(ak[4],ny2i); 63 | 64 | mem1[5] = MULT16_16(awk2[5],ny1i); 65 | mem2[5] = MULT16_16(ak[5],ny2i); 66 | 67 | mem1[6] = MULT16_16(awk2[6],ny1i); 68 | mem2[6] = MULT16_16(ak[6],ny2i); 69 | 70 | mem1[7] = MULT16_16(awk2[7],ny1i); 71 | mem2[7] = MULT16_16(ak[7],ny2i); 72 | 73 | mem1[8] = MULT16_16(awk2[8],ny1i); 74 | mem2[8] = MULT16_16(ak[8],ny2i); 75 | 76 | mem1[9] = MULT16_16(awk2[9],ny1i); 77 | mem2[9] = MULT16_16(ak[9],ny2i); 78 | 79 | for (i=1;i<11;i++) 80 | { 81 | y1 = ADD16(awk1[i-1], EXTRACT16(PSHR32(mem1[0],LPC_SHIFT))); 82 | ny1i = NEG16(y1); 83 | y[i] = PSHR32(ADD32(SHL32(EXTEND32(y1),LPC_SHIFT+1),mem2[0]),LPC_SHIFT); 84 | ny2i = NEG16(y[i]); 85 | 86 | mem1[0] = MAC16_16(mem1[1], awk2[0],ny1i); 87 | mem2[0] = MAC16_16(mem2[1], ak[0],ny2i); 88 | 89 | mem1[1] = MAC16_16(mem1[2], awk2[1],ny1i); 90 | mem2[1] = MAC16_16(mem2[2], ak[1],ny2i); 91 | 92 | mem1[2] = MAC16_16(mem1[3], awk2[2],ny1i); 93 | mem2[2] = MAC16_16(mem2[3], ak[2],ny2i); 94 | 95 | mem1[3] = MAC16_16(mem1[4], awk2[3],ny1i); 96 | mem2[3] = MAC16_16(mem2[4], ak[3],ny2i); 97 | 98 | mem1[4] = MAC16_16(mem1[5], awk2[4],ny1i); 99 | mem2[4] = MAC16_16(mem2[5], ak[4],ny2i); 100 | 101 | mem1[5] = MAC16_16(mem1[6], awk2[5],ny1i); 102 | mem2[5] = MAC16_16(mem2[6], ak[5],ny2i); 103 | 104 | mem1[6] = MAC16_16(mem1[7], awk2[6],ny1i); 105 | mem2[6] = MAC16_16(mem2[7], ak[6],ny2i); 106 | 107 | mem1[7] = MAC16_16(mem1[8], awk2[7],ny1i); 108 | mem2[7] = MAC16_16(mem2[8], ak[7],ny2i); 109 | 110 | mem1[8] = MAC16_16(mem1[9], awk2[8],ny1i); 111 | mem2[8] = MAC16_16(mem2[9], ak[8],ny2i); 112 | 113 | mem1[9] = MULT16_16(awk2[9],ny1i); 114 | mem2[9] = MULT16_16(ak[9],ny2i); 115 | } 116 | 117 | for (i=11;i<40;i++) 118 | { 119 | y1 = EXTRACT16(PSHR32(mem1[0],LPC_SHIFT)); 120 | ny1i = NEG16(y1); 121 | y[i] = PSHR32(ADD32(SHL32(EXTEND32(y1),LPC_SHIFT+1),mem2[0]),LPC_SHIFT); 122 | ny2i = NEG16(y[i]); 123 | 124 | 125 | mem1[0] = MAC16_16(mem1[1], awk2[0],ny1i); 126 | mem2[0] = MAC16_16(mem2[1], ak[0],ny2i); 127 | 128 | mem1[1] = MAC16_16(mem1[2], awk2[1],ny1i); 129 | mem2[1] = MAC16_16(mem2[2], ak[1],ny2i); 130 | 131 | mem1[2] = MAC16_16(mem1[3], awk2[2],ny1i); 132 | mem2[2] = MAC16_16(mem2[3], ak[2],ny2i); 133 | 134 | mem1[3] = MAC16_16(mem1[4], awk2[3],ny1i); 135 | mem2[3] = MAC16_16(mem2[4], ak[3],ny2i); 136 | 137 | mem1[4] = MAC16_16(mem1[5], awk2[4],ny1i); 138 | mem2[4] = MAC16_16(mem2[5], ak[4],ny2i); 139 | 140 | mem1[5] = MAC16_16(mem1[6], awk2[5],ny1i); 141 | mem2[5] = MAC16_16(mem2[6], ak[5],ny2i); 142 | 143 | mem1[6] = MAC16_16(mem1[7], awk2[6],ny1i); 144 | mem2[6] = MAC16_16(mem2[7], ak[6],ny2i); 145 | 146 | mem1[7] = MAC16_16(mem1[8], awk2[7],ny1i); 147 | mem2[7] = MAC16_16(mem2[8], ak[7],ny2i); 148 | 149 | mem1[8] = MAC16_16(mem1[9], awk2[8],ny1i); 150 | mem2[8] = MAC16_16(mem2[9], ak[8],ny2i); 151 | 152 | mem1[9] = MULT16_16(awk2[9],ny1i); 153 | mem2[9] = MULT16_16(ak[9],ny2i); 154 | } 155 | } 156 | 157 | #endif 158 | -------------------------------------------------------------------------------- /speex/STM32/libspeex/iar/filters_cortexM3.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2008 STMicroelectronics, MCD */ 2 | /* 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions 6 | are met: 7 | 8 | - Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | 11 | - Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | 15 | - Neither the name of the Xiph.org Foundation nor the names of its 16 | contributors may be used to endorse or promote products derived from 17 | this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR 23 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 24 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 25 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 26 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 27 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 28 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 29 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | #ifndef __FILTERS_M3_H 33 | #define __FILTERS_M3_H 34 | 35 | 36 | #define OVERRIDE_COMPUTE_IMPULSE_RESPONSE 37 | void compute_impulse_response(const spx_coef_t *ak, const spx_coef_t *awk1, const spx_coef_t *awk2, spx_word16_t *y, int N, int ord, char *stack) 38 | { 39 | int i; 40 | spx_word16_t y1, ny1i, ny2i; 41 | spx_mem_t mem1[10]; 42 | spx_mem_t mem2[10]; 43 | 44 | y1 = ADD16(LPC_SCALING, EXTRACT16(PSHR32(0,LPC_SHIFT))); 45 | ny1i = NEG16(y1); 46 | y[0] = PSHR32(SHL32(EXTEND32(y1),LPC_SHIFT+1),LPC_SHIFT); 47 | ny2i = NEG16(y[0]); 48 | 49 | mem1[0] = MULT16_16(awk2[0],ny1i); 50 | mem2[0] = MULT16_16(ak[0],ny2i); 51 | 52 | mem1[1] = MULT16_16(awk2[1],ny1i); 53 | mem2[1] = MULT16_16(ak[1],ny2i); 54 | 55 | mem1[2] = MULT16_16(awk2[2],ny1i); 56 | mem2[2] = MULT16_16(ak[2],ny2i); 57 | 58 | mem1[3] = MULT16_16(awk2[3],ny1i); 59 | mem2[3] = MULT16_16(ak[3],ny2i); 60 | 61 | mem1[4] = MULT16_16(awk2[4],ny1i); 62 | mem2[4] = MULT16_16(ak[4],ny2i); 63 | 64 | mem1[5] = MULT16_16(awk2[5],ny1i); 65 | mem2[5] = MULT16_16(ak[5],ny2i); 66 | 67 | mem1[6] = MULT16_16(awk2[6],ny1i); 68 | mem2[6] = MULT16_16(ak[6],ny2i); 69 | 70 | mem1[7] = MULT16_16(awk2[7],ny1i); 71 | mem2[7] = MULT16_16(ak[7],ny2i); 72 | 73 | mem1[8] = MULT16_16(awk2[8],ny1i); 74 | mem2[8] = MULT16_16(ak[8],ny2i); 75 | 76 | mem1[9] = MULT16_16(awk2[9],ny1i); 77 | mem2[9] = MULT16_16(ak[9],ny2i); 78 | 79 | for (i=1;i<11;i++) 80 | { 81 | y1 = ADD16(awk1[i-1], EXTRACT16(PSHR32(mem1[0],LPC_SHIFT))); 82 | ny1i = NEG16(y1); 83 | y[i] = PSHR32(ADD32(SHL32(EXTEND32(y1),LPC_SHIFT+1),mem2[0]),LPC_SHIFT); 84 | ny2i = NEG16(y[i]); 85 | 86 | mem1[0] = MAC16_16(mem1[1], awk2[0],ny1i); 87 | mem2[0] = MAC16_16(mem2[1], ak[0],ny2i); 88 | 89 | mem1[1] = MAC16_16(mem1[2], awk2[1],ny1i); 90 | mem2[1] = MAC16_16(mem2[2], ak[1],ny2i); 91 | 92 | mem1[2] = MAC16_16(mem1[3], awk2[2],ny1i); 93 | mem2[2] = MAC16_16(mem2[3], ak[2],ny2i); 94 | 95 | mem1[3] = MAC16_16(mem1[4], awk2[3],ny1i); 96 | mem2[3] = MAC16_16(mem2[4], ak[3],ny2i); 97 | 98 | mem1[4] = MAC16_16(mem1[5], awk2[4],ny1i); 99 | mem2[4] = MAC16_16(mem2[5], ak[4],ny2i); 100 | 101 | mem1[5] = MAC16_16(mem1[6], awk2[5],ny1i); 102 | mem2[5] = MAC16_16(mem2[6], ak[5],ny2i); 103 | 104 | mem1[6] = MAC16_16(mem1[7], awk2[6],ny1i); 105 | mem2[6] = MAC16_16(mem2[7], ak[6],ny2i); 106 | 107 | mem1[7] = MAC16_16(mem1[8], awk2[7],ny1i); 108 | mem2[7] = MAC16_16(mem2[8], ak[7],ny2i); 109 | 110 | mem1[8] = MAC16_16(mem1[9], awk2[8],ny1i); 111 | mem2[8] = MAC16_16(mem2[9], ak[8],ny2i); 112 | 113 | mem1[9] = MULT16_16(awk2[9],ny1i); 114 | mem2[9] = MULT16_16(ak[9],ny2i); 115 | } 116 | 117 | for (i=11;i<40;i++) 118 | { 119 | y1 = EXTRACT16(PSHR32(mem1[0],LPC_SHIFT)); 120 | ny1i = NEG16(y1); 121 | y[i] = PSHR32(ADD32(SHL32(EXTEND32(y1),LPC_SHIFT+1),mem2[0]),LPC_SHIFT); 122 | ny2i = NEG16(y[i]); 123 | 124 | 125 | mem1[0] = MAC16_16(mem1[1], awk2[0],ny1i); 126 | mem2[0] = MAC16_16(mem2[1], ak[0],ny2i); 127 | 128 | mem1[1] = MAC16_16(mem1[2], awk2[1],ny1i); 129 | mem2[1] = MAC16_16(mem2[2], ak[1],ny2i); 130 | 131 | mem1[2] = MAC16_16(mem1[3], awk2[2],ny1i); 132 | mem2[2] = MAC16_16(mem2[3], ak[2],ny2i); 133 | 134 | mem1[3] = MAC16_16(mem1[4], awk2[3],ny1i); 135 | mem2[3] = MAC16_16(mem2[4], ak[3],ny2i); 136 | 137 | mem1[4] = MAC16_16(mem1[5], awk2[4],ny1i); 138 | mem2[4] = MAC16_16(mem2[5], ak[4],ny2i); 139 | 140 | mem1[5] = MAC16_16(mem1[6], awk2[5],ny1i); 141 | mem2[5] = MAC16_16(mem2[6], ak[5],ny2i); 142 | 143 | mem1[6] = MAC16_16(mem1[7], awk2[6],ny1i); 144 | mem2[6] = MAC16_16(mem2[7], ak[6],ny2i); 145 | 146 | mem1[7] = MAC16_16(mem1[8], awk2[7],ny1i); 147 | mem2[7] = MAC16_16(mem2[8], ak[7],ny2i); 148 | 149 | mem1[8] = MAC16_16(mem1[9], awk2[8],ny1i); 150 | mem2[8] = MAC16_16(mem2[9], ak[8],ny2i); 151 | 152 | mem1[9] = MULT16_16(awk2[9],ny1i); 153 | mem2[9] = MULT16_16(ak[9],ny2i); 154 | } 155 | } 156 | 157 | #endif 158 | -------------------------------------------------------------------------------- /speex/libspeex/lpc.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 1992, 1993, 1994 by Jutta Degener and Carsten Bormann, 3 | Technische Universitaet Berlin 4 | 5 | Any use of this software is permitted provided that this notice is not 6 | removed and that neither the authors nor the Technische Universitaet Berlin 7 | are deemed to have made any representations as to the suitability of this 8 | software for any purpose nor are held responsible for any defects of 9 | this software. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE. 10 | 11 | As a matter of courtesy, the authors request to be informed about uses 12 | this software has found, about bugs in this software, and about any 13 | improvements that may be of general interest. 14 | 15 | Berlin, 28.11.1994 16 | Jutta Degener 17 | Carsten Bormann 18 | 19 | 20 | Code modified by Jean-Marc Valin 21 | 22 | Speex License: 23 | 24 | Redistribution and use in source and binary forms, with or without 25 | modification, are permitted provided that the following conditions 26 | are met: 27 | 28 | - Redistributions of source code must retain the above copyright 29 | notice, this list of conditions and the following disclaimer. 30 | 31 | - Redistributions in binary form must reproduce the above copyright 32 | notice, this list of conditions and the following disclaimer in the 33 | documentation and/or other materials provided with the distribution. 34 | 35 | - Neither the name of the Xiph.org Foundation nor the names of its 36 | contributors may be used to endorse or promote products derived from 37 | this software without specific prior written permission. 38 | 39 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 40 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 41 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 42 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR 43 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 44 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 45 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 46 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 47 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 48 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 49 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 50 | */ 51 | 52 | #ifdef HAVE_CONFIG_H 53 | #include "config.h" 54 | #endif 55 | 56 | #include "lpc.h" 57 | 58 | #ifdef BFIN_ASM 59 | #include "lpc_bfin.h" 60 | #endif 61 | 62 | /* LPC analysis 63 | * 64 | * The next two functions calculate linear prediction coefficients 65 | * and/or the related reflection coefficients from the first P_MAX+1 66 | * values of the autocorrelation function. 67 | */ 68 | 69 | /* Invented by N. Levinson in 1947, modified by J. Durbin in 1959. 70 | */ 71 | 72 | /* returns minimum mean square error */ 73 | spx_word32_t _spx_lpc( 74 | spx_coef_t *lpc, /* out: [0...p-1] LPC coefficients */ 75 | const spx_word16_t *ac, /* in: [0...p] autocorrelation values */ 76 | int p 77 | ) 78 | { 79 | int i, j; 80 | spx_word16_t r; 81 | spx_word16_t error = ac[0]; 82 | 83 | if (ac[0] == 0) 84 | { 85 | for (i = 0; i < p; i++) 86 | lpc[i] = 0; 87 | return 0; 88 | } 89 | 90 | for (i = 0; i < p; i++) { 91 | 92 | /* Sum up this iteration's reflection coefficient */ 93 | spx_word32_t rr = NEG32(SHL32(EXTEND32(ac[i + 1]),13)); 94 | for (j = 0; j < i; j++) 95 | rr = SUB32(rr,MULT16_16(lpc[j],ac[i - j])); 96 | #ifdef FIXED_POINT 97 | r = DIV32_16(rr+PSHR32(error,1),ADD16(error,8)); 98 | #else 99 | r = rr/(error+.003*ac[0]); 100 | #endif 101 | /* Update LPC coefficients and total error */ 102 | lpc[i] = r; 103 | for (j = 0; j < i>>1; j++) 104 | { 105 | spx_word16_t tmp = lpc[j]; 106 | lpc[j] = MAC16_16_P13(lpc[j],r,lpc[i-1-j]); 107 | lpc[i-1-j] = MAC16_16_P13(lpc[i-1-j],r,tmp); 108 | } 109 | if (i & 1) 110 | lpc[j] = MAC16_16_P13(lpc[j],lpc[j],r); 111 | 112 | error = SUB16(error,MULT16_16_Q13(r,MULT16_16_Q13(error,r))); 113 | } 114 | return error; 115 | } 116 | 117 | 118 | #ifdef FIXED_POINT 119 | 120 | /* Compute the autocorrelation 121 | * ,--, 122 | * ac(i) = > x(n) * x(n-i) for all n 123 | * `--' 124 | * for lags between 0 and lag-1, and x == 0 outside 0...n-1 125 | */ 126 | 127 | #ifndef OVERRIDE_SPEEX_AUTOCORR 128 | void _spx_autocorr( 129 | const spx_word16_t *x, /* in: [0...n-1] samples x */ 130 | spx_word16_t *ac, /* out: [0...lag-1] ac values */ 131 | int lag, 132 | int n 133 | ) 134 | { 135 | spx_word32_t d; 136 | int i, j; 137 | spx_word32_t ac0=1; 138 | int shift, ac_shift; 139 | 140 | for (j=0;j x(n) * x(n-i) for all n 178 | * `--' 179 | * for lags between 0 and lag-1, and x == 0 outside 0...n-1 180 | */ 181 | void _spx_autocorr( 182 | const spx_word16_t *x, /* in: [0...n-1] samples x */ 183 | float *ac, /* out: [0...lag-1] ac values */ 184 | int lag, 185 | int n 186 | ) 187 | { 188 | float d; 189 | int i; 190 | while (lag--) 191 | { 192 | for (i = lag, d = 0; i < n; i++) 193 | d += x[i] * x[i-lag]; 194 | ac[lag] = d; 195 | } 196 | ac[0] += 10; 197 | } 198 | 199 | #endif 200 | 201 | 202 | -------------------------------------------------------------------------------- /speex/libspeex/sb_celp.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2002-2006 Jean-Marc Valin */ 2 | /** 3 | @file sb_celp.h 4 | @brief Sub-band CELP mode used for wideband encoding 5 | */ 6 | /* 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions 9 | are met: 10 | 11 | - Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | 14 | - Redistributions in binary form must reproduce the above copyright 15 | notice, this list of conditions and the following disclaimer in the 16 | documentation and/or other materials provided with the distribution. 17 | 18 | - Neither the name of the Xiph.org Foundation nor the names of its 19 | contributors may be used to endorse or promote products derived from 20 | this software without specific prior written permission. 21 | 22 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 25 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR 26 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 27 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 28 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 29 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 30 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 31 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 32 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | 34 | */ 35 | 36 | #ifndef SB_CELP_H 37 | #define SB_CELP_H 38 | 39 | #include "modes.h" 40 | #include 41 | #include "nb_celp.h" 42 | 43 | /**Structure representing the full state of the sub-band encoder*/ 44 | typedef struct SBEncState { 45 | const SpeexMode *mode; /**< Pointer to the mode (containing for vtable info) */ 46 | void *st_low; /**< State of the low-band (narrowband) encoder */ 47 | int full_frame_size; /**< Length of full-band frames*/ 48 | int frame_size; /**< Length of high-band frames*/ 49 | int subframeSize; /**< Length of high-band sub-frames*/ 50 | int nbSubframes; /**< Number of high-band sub-frames*/ 51 | int windowSize; /**< Length of high-band LPC window*/ 52 | int lpcSize; /**< Order of high-band LPC analysis */ 53 | int first; /**< First frame? */ 54 | spx_word16_t lpc_floor; /**< Controls LPC analysis noise floor */ 55 | spx_word16_t gamma1; /**< Perceptual weighting coef 1 */ 56 | spx_word16_t gamma2; /**< Perceptual weighting coef 2 */ 57 | 58 | char *stack; /**< Temporary allocation stack */ 59 | spx_word16_t *high; /**< High-band signal (buffer) */ 60 | spx_word16_t *h0_mem, *h1_mem; 61 | 62 | const spx_word16_t *window; /**< LPC analysis window */ 63 | const spx_word16_t *lagWindow; /**< Auto-correlation window */ 64 | spx_lsp_t *old_lsp; /**< LSPs of previous frame */ 65 | spx_lsp_t *old_qlsp; /**< Quantized LSPs of previous frame */ 66 | spx_coef_t *interp_qlpc; /**< Interpolated quantized LPCs for current sub-frame */ 67 | 68 | spx_mem_t *mem_sp; /**< Synthesis signal memory */ 69 | spx_mem_t *mem_sp2; 70 | spx_mem_t *mem_sw; /**< Perceptual signal memory */ 71 | spx_word32_t *pi_gain; 72 | spx_word16_t *exc_rms; 73 | spx_word16_t *innov_rms_save; /**< If non-NULL, innovation is copied here */ 74 | 75 | #ifndef DISABLE_VBR 76 | float vbr_quality; /**< Quality setting for VBR encoding */ 77 | int vbr_enabled; /**< 1 for enabling VBR, 0 otherwise */ 78 | signed int vbr_max; /**< Max bit-rate allowed in VBR mode (total) */ 79 | signed int vbr_max_high; /**< Max bit-rate allowed in VBR mode for the high-band */ 80 | signed int abr_enabled; /**< ABR setting (in bps), 0 if off */ 81 | float abr_drift; 82 | float abr_drift2; 83 | float abr_count; 84 | int vad_enabled; /**< 1 for enabling VAD, 0 otherwise */ 85 | float relative_quality; 86 | #endif /* #ifndef DISABLE_VBR */ 87 | 88 | int encode_submode; 89 | const SpeexSubmode * const *submodes; 90 | int submodeID; 91 | int submodeSelect; 92 | int complexity; 93 | signed int sampling_rate; 94 | 95 | } SBEncState; 96 | 97 | 98 | /**Structure representing the full state of the sub-band decoder*/ 99 | typedef struct SBDecState { 100 | const SpeexMode *mode; /**< Pointer to the mode (containing for vtable info) */ 101 | void *st_low; /**< State of the low-band (narrowband) encoder */ 102 | int full_frame_size; 103 | int frame_size; 104 | int subframeSize; 105 | int nbSubframes; 106 | int lpcSize; 107 | int first; 108 | signed int sampling_rate; 109 | int lpc_enh_enabled; 110 | 111 | char *stack; 112 | spx_word16_t *g0_mem, *g1_mem; 113 | 114 | spx_word16_t *excBuf; 115 | spx_lsp_t *old_qlsp; 116 | spx_coef_t *interp_qlpc; 117 | 118 | spx_mem_t *mem_sp; 119 | spx_word32_t *pi_gain; 120 | spx_word16_t *exc_rms; 121 | spx_word16_t *innov_save; /** If non-NULL, innovation is copied here */ 122 | 123 | spx_word16_t last_ener; 124 | signed int seed; 125 | 126 | int encode_submode; 127 | const SpeexSubmode * const *submodes; 128 | int submodeID; 129 | } SBDecState; 130 | 131 | 132 | /**Initializes encoder state*/ 133 | void *sb_encoder_init(const SpeexMode *m); 134 | 135 | /**De-allocates encoder state resources*/ 136 | void sb_encoder_destroy(void *state); 137 | 138 | /**Encodes one frame*/ 139 | int sb_encode(void *state, void *in, SpeexBits *bits); 140 | 141 | 142 | /**Initializes decoder state*/ 143 | void *sb_decoder_init(const SpeexMode *m); 144 | 145 | /**De-allocates decoder state resources*/ 146 | void sb_decoder_destroy(void *state); 147 | 148 | /**Decodes one frame*/ 149 | int sb_decode(void *state, SpeexBits *bits, void *out); 150 | 151 | int sb_encoder_ctl(void *state, int request, void *ptr); 152 | 153 | int sb_decoder_ctl(void *state, int request, void *ptr); 154 | 155 | #endif 156 | -------------------------------------------------------------------------------- /speex/libspeex/hexc_table.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2002 Jean-Marc Valin 2 | File: hexc_table.c 3 | Codebook for high-band excitation in SB-CELP mode (8000 bps with sign) 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 | const signed char hexc_table[1024] = { 34 | -24, 21, -20, 5, -5, -7, 14, -10, 35 | 2, -27, 16, -20, 0, -32, 26, 19, 36 | 8, -11, -41, 31, 28, -27, -32, 34, 37 | 42, 34, -17, 22, -10, 13, -29, 18, 38 | -12, -26, -24, 11, 22, 5, -5, -5, 39 | 54, -68, -43, 57, -25, 24, 4, 4, 40 | 26, -8, -12, -17, 54, 30, -45, 1, 41 | 10, -15, 18, -41, 11, 68, -67, 37, 42 | -16, -24, -16, 38, -22, 6, -29, 30, 43 | 66, -27, 5, 7, -16, 13, 2, -12, 44 | -7, -3, -20, 36, 4, -28, 9, 3, 45 | 32, 48, 26, 39, 3, 0, 7, -21, 46 | -13, 5, -82, -7, 73, -20, 34, -9, 47 | -5, 1, -1, 10, -5, -10, -1, 9, 48 | 1, -9, 10, 0, -14, 11, -1, -2, 49 | -1, 11, 20, 96, -81, -22, -12, -9, 50 | -58, 9, 24, -30, 26, -35, 27, -12, 51 | 13, -18, 56, -59, 15, -7, 23, -15, 52 | -1, 6, -25, 14, -22, -20, 47, -11, 53 | 16, 2, 38, -23, -19, -30, -9, 40, 54 | -11, 5, 4, -6, 8, 26, -21, -11, 55 | 127, 4, 1, 6, -9, 2, -7, -2, 56 | -3, 7, -5, 10, -19, 7, -106, 91, 57 | -3, 9, -4, 21, -8, 26, -80, 8, 58 | 1, -2, -10, -17, -17, -27, 32, 71, 59 | 6, -29, 11, -23, 54, -38, 29, -22, 60 | 39, 87, -31, -12, -20, 3, -2, -2, 61 | 2, 20, 0, -1, -35, 27, 9, -6, 62 | -12, 3, -12, -6, 13, 1, 14, -22, 63 | -59, -15, -17, -25, 13, -7, 7, 3, 64 | 0, 1, -7, 6, -3, 61, -37, -23, 65 | -23, -29, 38, -31, 27, 1, -8, 2, 66 | -27, 23, -26, 36, -34, 5, 24, -24, 67 | -6, 7, 3, -59, 78, -62, 44, -16, 68 | 1, 6, 0, 17, 8, 45, 0, -110, 69 | 6, 14, -2, 32, -77, -56, 62, -3, 70 | 3, -13, 4, -16, 102, -15, -36, -1, 71 | 9, -113, 6, 23, 0, 9, 9, 5, 72 | -8, -1, -14, 5, -12, 121, -53, -27, 73 | -8, -9, 22, -13, 3, 2, -3, 1, 74 | -2, -71, 95, 38, -19, 15, -16, -5, 75 | 71, 10, 2, -32, -13, -5, 15, -1, 76 | -2, -14, -85, 30, 29, 6, 3, 2, 77 | 0, 0, 0, 0, 0, 0, 0, 0, 78 | 2, -65, -56, -9, 18, 18, 23, -14, 79 | -2, 0, 12, -29, 26, -12, 1, 2, 80 | -12, -64, 90, -6, 4, 1, 5, -5, 81 | -110, -3, -31, 22, -29, 9, 0, 8, 82 | -40, -5, 21, -5, -5, 13, 10, -18, 83 | 40, 1, 35, -20, 30, -28, 11, -6, 84 | 19, 7, 14, 18, -64, 9, -6, 16, 85 | 51, 68, 8, 16, 12, -8, 0, -9, 86 | 20, -22, 25, 7, -4, -13, 41, -35, 87 | 93, -18, -54, 11, -1, 1, -9, 4, 88 | -66, 66, -31, 20, -22, 25, -23, 11, 89 | 10, 9, 19, 15, 11, -5, -31, -10, 90 | -23, -28, -6, -6, -3, -4, 5, 3, 91 | -28, 22, -11, -42, 25, -25, -16, 41, 92 | 34, 47, -6, 2, 42, -19, -22, 5, 93 | -39, 32, 6, -35, 22, 17, -30, 8, 94 | -26, -11, -11, 3, -12, 33, 33, -37, 95 | 21, -1, 6, -4, 3, 0, -5, 5, 96 | 12, -12, 57, 27, -61, -3, 20, -17, 97 | 2, 0, 4, 0, -2, -33, -58, 81, 98 | -23, 39, -10, -5, 2, 6, -7, 5, 99 | 4, -3, -2, -13, -23, -72, 107, 15, 100 | -5, 0, -7, -3, -6, 5, -4, 15, 101 | 47, 12, -31, 25, -16, 8, 22, -25, 102 | -62, -56, -18, 14, 28, 12, 2, -11, 103 | 74, -66, 41, -20, -7, 16, -20, 16, 104 | -8, 0, -16, 4, -19, 92, 12, -59, 105 | -14, -39, 49, -25, -16, 23, -27, 19, 106 | -3, -33, 19, 85, -29, 6, -7, -10, 107 | 16, -7, -12, 1, -6, 2, 4, -2, 108 | 64, 10, -25, 41, -2, -31, 15, 0, 109 | 110, 50, 69, 35, 28, 19, -10, 2, 110 | -43, -49, -56, -15, -16, 10, 3, 12, 111 | -1, -8, 1, 26, -12, -1, 7, -11, 112 | -27, 41, 25, 1, -11, -18, 22, -7, 113 | -1, -47, -8, 23, -3, -17, -7, 18, 114 | -125, 59, -5, 3, 18, 1, 2, 3, 115 | 27, -35, 65, -53, 50, -46, 37, -21, 116 | -28, 7, 14, -37, -5, -5, 12, 5, 117 | -8, 78, -19, 21, -6, -16, 8, -7, 118 | 5, 2, 7, 2, 10, -6, 12, -60, 119 | 44, 11, -36, -32, 31, 0, 2, -2, 120 | 2, 1, -3, 7, -10, 17, -21, 10, 121 | 6, -2, 19, -2, 59, -38, -86, 38, 122 | 8, -41, -30, -45, -33, 7, 15, 28, 123 | 29, -7, 24, -40, 7, 7, 5, -2, 124 | 9, 24, -23, -18, 6, -29, 30, 2, 125 | 28, 49, -11, -46, 10, 43, -13, -9, 126 | -1, -3, -7, -7, -17, -6, 97, -33, 127 | -21, 3, 5, 1, 12, -43, -8, 28, 128 | 7, -43, -7, 17, -20, 19, -1, 2, 129 | -13, 9, 54, 34, 9, -28, -11, -9, 130 | -17, 110, -59, 44, -26, 0, 3, -12, 131 | -47, 73, -34, -43, 38, -33, 16, -5, 132 | -46, -4, -6, -2, -25, 19, -29, 28, 133 | -13, 5, 14, 27, -40, -43, 4, 32, 134 | -13, -2, -35, -4, 112, -42, 9, -12, 135 | 37, -28, 17, 14, -19, 35, -39, 23, 136 | 3, -14, -1, -57, -5, 94, -9, 3, 137 | -39, 5, 30, -10, -32, 42, -13, -14, 138 | -97, -63, 30, -9, 1, -7, 12, 5, 139 | 20, 17, -9, -36, -30, 25, 47, -9, 140 | -15, 12, -22, 98, -8, -50, 15, -27, 141 | 21, -16, -11, 2, 12, -10, 10, -3, 142 | 33, 36, -96, 0, -17, 31, -9, 9, 143 | 3, -20, 13, -11, 8, -4, 10, -10, 144 | 9, 1, 112, -70, -27, 5, -21, 2, 145 | -57, -3, -29, 10, 19, -21, 21, -10, 146 | -66, -3, 91, -35, 30, -12, 0, -7, 147 | 59, -28, 26, 2, 14, -18, 1, 1, 148 | 11, 17, 20, -54, -59, 27, 4, 29, 149 | 32, 5, 19, 12, -4, 1, 7, -10, 150 | 5, -2, 10, 0, 23, -5, 28, -104, 151 | 46, 11, 16, 3, 29, 1, -8, -14, 152 | 1, 7, -50, 88, -62, 26, 8, -17, 153 | -14, 50, 0, 32, -12, -3, -27, 18, 154 | -8, -5, 8, 3, -20, -11, 37, -12, 155 | 9, 33, 46, -101, -1, -4, 1, 6, 156 | -1, 28, -42, -15, 16, 5, -1, -2, 157 | -55, 85, 38, -9, -4, 11, -2, -9, 158 | -6, 3, -20, -10, -77, 89, 24, -3, 159 | -104, -57, -26, -31, -20, -6, -9, 14, 160 | 20, -23, 46, -15, -31, 28, 1, -15, 161 | -2, 6, -2, 31, 45, -76, 23, -25, 162 | }; 163 | -------------------------------------------------------------------------------- /speex/STM32/libspeex/iar/ltp_cortexM3.s: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2008 STMicroelectronics, MCD */ 2 | /* 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions 6 | are met: 7 | 8 | - Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | 11 | - Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | 15 | - Neither the name of the Xiph.org Foundation nor the names of its 16 | contributors may be used to endorse or promote products derived from 17 | this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR 23 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 24 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 25 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 26 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 27 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 28 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 29 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | SECTION .text:CODE(2) 33 | EXPORT inner_prod 34 | 35 | 36 | 37 | #define x R0 // input array x[] 38 | #define c R1 // input array c[] 39 | #define N R2 // number of samples (a multiple of 4) // 40 samples: the lpcsize == 40 for narrowband mode, submode3 40 | #define acc R3 // accumulator 41 | #define sum R6 // sum 42 | #define x_0 R4 // elements from array x[] 43 | #define x_1 R5 44 | #define c_0 R7 // elements from array c[] 45 | #define c_1 R8 46 | 47 | 48 | 49 | 50 | 51 | inner_prod 52 | 53 | PUSH {r4-r8, lr} 54 | MOV sum, #0 55 | 56 | Loop 57 | 58 | MOV acc, #0 59 | LDRSH x_0, [x], #2 60 | LDRSH c_0, [c], #2 61 | MLA acc, x_0, c_0, acc 62 | LDRSH x_1, [x], #2 63 | LDRSH c_1, [c], #2 64 | MLA acc, x_1, c_1, acc 65 | LDRSH x_0, [x], #2 66 | LDRSH c_0, [c], #2 67 | MLA acc, x_0, c_0, acc 68 | LDRSH x_1, [x], #2 69 | LDRSH c_1, [c], #2 70 | MLA acc, x_1, c_1, acc 71 | ADD sum,sum,acc,ASR #6 72 | 73 | MOV acc, #0 74 | LDRSH x_0, [x], #2 75 | LDRSH c_0, [c], #2 76 | MLA acc, x_0, c_0, acc 77 | LDRSH x_1, [x], #2 78 | LDRSH c_1, [c], #2 79 | MLA acc, x_1, c_1, acc 80 | LDRSH x_0, [x], #2 81 | LDRSH c_0, [c], #2 82 | MLA acc, x_0, c_0, acc 83 | LDRSH x_1, [x], #2 84 | LDRSH c_1, [c], #2 85 | MLA acc, x_1, c_1, acc 86 | ADD sum,sum,acc,ASR #6 87 | 88 | MOV acc, #0 89 | LDRSH x_0, [x], #2 90 | LDRSH c_0, [c], #2 91 | MLA acc, x_0, c_0, acc 92 | LDRSH x_1, [x], #2 93 | LDRSH c_1, [c], #2 94 | MLA acc, x_1, c_1, acc 95 | LDRSH x_0, [x], #2 96 | LDRSH c_0, [c], #2 97 | MLA acc, x_0, c_0, acc 98 | LDRSH x_1, [x], #2 99 | LDRSH c_1, [c], #2 100 | MLA acc, x_1, c_1, acc 101 | ADD sum,sum,acc,ASR #6 102 | 103 | MOV acc, #0 104 | LDRSH x_0, [x], #2 105 | LDRSH c_0, [c], #2 106 | MLA acc, x_0, c_0, acc 107 | LDRSH x_1, [x], #2 108 | LDRSH c_1, [c], #2 109 | MLA acc, x_1, c_1, acc 110 | LDRSH x_0, [x], #2 111 | LDRSH c_0, [c], #2 112 | MLA acc, x_0, c_0, acc 113 | LDRSH x_1, [x], #2 114 | LDRSH c_1, [c], #2 115 | MLA acc, x_1, c_1, acc 116 | ADD sum,sum,acc,ASR #6 117 | 118 | MOV acc, #0 119 | LDRSH x_0, [x], #2 120 | LDRSH c_0, [c], #2 121 | MLA acc, x_0, c_0, acc 122 | LDRSH x_1, [x], #2 123 | LDRSH c_1, [c], #2 124 | MLA acc, x_1, c_1, acc 125 | LDRSH x_0, [x], #2 126 | LDRSH c_0, [c], #2 127 | MLA acc, x_0, c_0, acc 128 | LDRSH x_1, [x], #2 129 | LDRSH c_1, [c], #2 130 | MLA acc, x_1, c_1, acc 131 | ADD sum,sum,acc,ASR #6 132 | 133 | MOV acc, #0 134 | LDRSH x_0, [x], #2 135 | LDRSH c_0, [c], #2 136 | MLA acc, x_0, c_0, acc 137 | LDRSH x_1, [x], #2 138 | LDRSH c_1, [c], #2 139 | MLA acc, x_1, c_1, acc 140 | LDRSH x_0, [x], #2 141 | LDRSH c_0, [c], #2 142 | MLA acc, x_0, c_0, acc 143 | LDRSH x_1, [x], #2 144 | LDRSH c_1, [c], #2 145 | MLA acc, x_1, c_1, acc 146 | ADD sum,sum,acc,ASR #6 147 | 148 | MOV acc, #0 149 | LDRSH x_0, [x], #2 150 | LDRSH c_0, [c], #2 151 | MLA acc, x_0, c_0, acc 152 | LDRSH x_1, [x], #2 153 | LDRSH c_1, [c], #2 154 | MLA acc, x_1, c_1, acc 155 | LDRSH x_0, [x], #2 156 | LDRSH c_0, [c], #2 157 | MLA acc, x_0, c_0, acc 158 | LDRSH x_1, [x], #2 159 | LDRSH c_1, [c], #2 160 | MLA acc, x_1, c_1, acc 161 | ADD sum,sum,acc,ASR #6 162 | 163 | MOV acc, #0 164 | LDRSH x_0, [x], #2 165 | LDRSH c_0, [c], #2 166 | MLA acc, x_0, c_0, acc 167 | LDRSH x_1, [x], #2 168 | LDRSH c_1, [c], #2 169 | MLA acc, x_1, c_1, acc 170 | LDRSH x_0, [x], #2 171 | LDRSH c_0, [c], #2 172 | MLA acc, x_0, c_0, acc 173 | LDRSH x_1, [x], #2 174 | LDRSH c_1, [c], #2 175 | MLA acc, x_1, c_1, acc 176 | ADD sum,sum,acc,ASR #6 177 | 178 | MOV acc, #0 179 | LDRSH x_0, [x], #2 180 | LDRSH c_0, [c], #2 181 | MLA acc, x_0, c_0, acc 182 | LDRSH x_1, [x], #2 183 | LDRSH c_1, [c], #2 184 | MLA acc, x_1, c_1, acc 185 | LDRSH x_0, [x], #2 186 | LDRSH c_0, [c], #2 187 | MLA acc, x_0, c_0, acc 188 | LDRSH x_1, [x], #2 189 | LDRSH c_1, [c], #2 190 | MLA acc, x_1, c_1, acc 191 | ADD sum,sum,acc,ASR #6 192 | 193 | MOV acc, #0 194 | LDRSH x_0, [x], #2 195 | LDRSH c_0, [c], #2 196 | MLA acc, x_0, c_0, acc 197 | LDRSH x_1, [x], #2 198 | LDRSH c_1, [c], #2 199 | MLA acc, x_1, c_1, acc 200 | LDRSH x_0, [x], #2 201 | LDRSH c_0, [c], #2 202 | MLA acc, x_0, c_0, acc 203 | LDRSH x_1, [x], #2 204 | LDRSH c_1, [c], #2 205 | MLA acc, x_1, c_1, acc 206 | ADD sum,sum,acc,ASR #6 207 | MOV r0, sum 208 | 209 | POP {r4-r8, pc} 210 | END -------------------------------------------------------------------------------- /cmsis_lib/include/misc.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file misc.h 4 | * @author MCD Application Team 5 | * @version V1.0.0 6 | * @date 30-September-2011 7 | * @brief This file contains all the functions prototypes for the miscellaneous 8 | * firmware library functions (add-on to CMSIS functions). 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 13 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 14 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 15 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 16 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 17 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 18 | * 19 | *

© COPYRIGHT 2011 STMicroelectronics

20 | ****************************************************************************** 21 | */ 22 | 23 | /* Define to prevent recursive inclusion -------------------------------------*/ 24 | #ifndef __MISC_H 25 | #define __MISC_H 26 | 27 | #ifdef __cplusplus 28 | extern "C" { 29 | #endif 30 | 31 | /* Includes ------------------------------------------------------------------*/ 32 | #include "stm32f4xx.h" 33 | 34 | /** @addtogroup STM32F4xx_StdPeriph_Driver 35 | * @{ 36 | */ 37 | 38 | /** @addtogroup MISC 39 | * @{ 40 | */ 41 | 42 | /* Exported types ------------------------------------------------------------*/ 43 | 44 | /** 45 | * @brief NVIC Init Structure definition 46 | */ 47 | 48 | typedef struct 49 | { 50 | uint8_t NVIC_IRQChannel; /*!< Specifies the IRQ channel to be enabled or disabled. 51 | This parameter can be an enumerator of @ref IRQn_Type 52 | enumeration (For the complete STM32 Devices IRQ Channels 53 | list, please refer to stm32f4xx.h file) */ 54 | 55 | uint8_t NVIC_IRQChannelPreemptionPriority; /*!< Specifies the pre-emption priority for the IRQ channel 56 | specified in NVIC_IRQChannel. This parameter can be a value 57 | between 0 and 15 as described in the table @ref MISC_NVIC_Priority_Table 58 | A lower priority value indicates a higher priority */ 59 | 60 | uint8_t NVIC_IRQChannelSubPriority; /*!< Specifies the subpriority level for the IRQ channel specified 61 | in NVIC_IRQChannel. This parameter can be a value 62 | between 0 and 15 as described in the table @ref MISC_NVIC_Priority_Table 63 | A lower priority value indicates a higher priority */ 64 | 65 | FunctionalState NVIC_IRQChannelCmd; /*!< Specifies whether the IRQ channel defined in NVIC_IRQChannel 66 | will be enabled or disabled. 67 | This parameter can be set either to ENABLE or DISABLE */ 68 | } NVIC_InitTypeDef; 69 | 70 | /* Exported constants --------------------------------------------------------*/ 71 | 72 | /** @defgroup MISC_Exported_Constants 73 | * @{ 74 | */ 75 | 76 | /** @defgroup MISC_Vector_Table_Base 77 | * @{ 78 | */ 79 | 80 | #define NVIC_VectTab_RAM ((uint32_t)0x20000000) 81 | #define NVIC_VectTab_FLASH ((uint32_t)0x08000000) 82 | #define IS_NVIC_VECTTAB(VECTTAB) (((VECTTAB) == NVIC_VectTab_RAM) || \ 83 | ((VECTTAB) == NVIC_VectTab_FLASH)) 84 | /** 85 | * @} 86 | */ 87 | 88 | /** @defgroup MISC_System_Low_Power 89 | * @{ 90 | */ 91 | 92 | #define NVIC_LP_SEVONPEND ((uint8_t)0x10) 93 | #define NVIC_LP_SLEEPDEEP ((uint8_t)0x04) 94 | #define NVIC_LP_SLEEPONEXIT ((uint8_t)0x02) 95 | #define IS_NVIC_LP(LP) (((LP) == NVIC_LP_SEVONPEND) || \ 96 | ((LP) == NVIC_LP_SLEEPDEEP) || \ 97 | ((LP) == NVIC_LP_SLEEPONEXIT)) 98 | /** 99 | * @} 100 | */ 101 | 102 | /** @defgroup MISC_Preemption_Priority_Group 103 | * @{ 104 | */ 105 | 106 | #define NVIC_PriorityGroup_0 ((uint32_t)0x700) /*!< 0 bits for pre-emption priority 107 | 4 bits for subpriority */ 108 | #define NVIC_PriorityGroup_1 ((uint32_t)0x600) /*!< 1 bits for pre-emption priority 109 | 3 bits for subpriority */ 110 | #define NVIC_PriorityGroup_2 ((uint32_t)0x500) /*!< 2 bits for pre-emption priority 111 | 2 bits for subpriority */ 112 | #define NVIC_PriorityGroup_3 ((uint32_t)0x400) /*!< 3 bits for pre-emption priority 113 | 1 bits for subpriority */ 114 | #define NVIC_PriorityGroup_4 ((uint32_t)0x300) /*!< 4 bits for pre-emption priority 115 | 0 bits for subpriority */ 116 | 117 | #define IS_NVIC_PRIORITY_GROUP(GROUP) (((GROUP) == NVIC_PriorityGroup_0) || \ 118 | ((GROUP) == NVIC_PriorityGroup_1) || \ 119 | ((GROUP) == NVIC_PriorityGroup_2) || \ 120 | ((GROUP) == NVIC_PriorityGroup_3) || \ 121 | ((GROUP) == NVIC_PriorityGroup_4)) 122 | 123 | #define IS_NVIC_PREEMPTION_PRIORITY(PRIORITY) ((PRIORITY) < 0x10) 124 | 125 | #define IS_NVIC_SUB_PRIORITY(PRIORITY) ((PRIORITY) < 0x10) 126 | 127 | #define IS_NVIC_OFFSET(OFFSET) ((OFFSET) < 0x000FFFFF) 128 | 129 | /** 130 | * @} 131 | */ 132 | 133 | /** @defgroup MISC_SysTick_clock_source 134 | * @{ 135 | */ 136 | 137 | #define SysTick_CLKSource_HCLK_Div8 ((uint32_t)0xFFFFFFFB) 138 | #define SysTick_CLKSource_HCLK ((uint32_t)0x00000004) 139 | #define IS_SYSTICK_CLK_SOURCE(SOURCE) (((SOURCE) == SysTick_CLKSource_HCLK) || \ 140 | ((SOURCE) == SysTick_CLKSource_HCLK_Div8)) 141 | /** 142 | * @} 143 | */ 144 | 145 | /** 146 | * @} 147 | */ 148 | 149 | /* Exported macro ------------------------------------------------------------*/ 150 | /* Exported functions --------------------------------------------------------*/ 151 | 152 | void NVIC_PriorityGroupConfig(uint32_t NVIC_PriorityGroup); 153 | void NVIC_Init(NVIC_InitTypeDef* NVIC_InitStruct); 154 | void NVIC_SetVectorTable(uint32_t NVIC_VectTab, uint32_t Offset); 155 | void NVIC_SystemLPConfig(uint8_t LowPowerMode, FunctionalState NewState); 156 | void SysTick_CLKSourceConfig(uint32_t SysTick_CLKSource); 157 | 158 | #ifdef __cplusplus 159 | } 160 | #endif 161 | 162 | #endif /* __MISC_H */ 163 | 164 | /** 165 | * @} 166 | */ 167 | 168 | /** 169 | * @} 170 | */ 171 | 172 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 173 | -------------------------------------------------------------------------------- /speex/STM32/libspeex/gcc/ltp_cortexM3.s: -------------------------------------------------------------------------------- 1 | /*; Copyright (C) 2008 STMicroelectronics, MCD 2 | ; 3 | ; 4 | ; Redistribution and use in source and binary forms, with or without 5 | ; modification, are permitted provided that the following conditions 6 | ; are met: 7 | ; 8 | ; - Redistributions of source code must retain the above copyright 9 | ; notice, this list of conditions and the following disclaimer. 10 | ; 11 | ; - Redistributions in binary form must reproduce the above copyright 12 | ; notice, this list of conditions and the following disclaimer in the 13 | ; documentation and/or other materials provided with the distribution. 14 | ; 15 | ; - Neither the name of the Xiph.org Foundation nor the names of its 16 | ; contributors may be used to endorse or promote products derived from 17 | ; this software without specific prior written permission. 18 | ; 19 | ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | ; ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | ; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | ; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR 23 | ; CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 24 | ; EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 25 | ; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 26 | ; PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 27 | ; LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 28 | ; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 29 | ; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.*/ 30 | 31 | .cpu cortex-m3 32 | .fpu softvfp 33 | .syntax unified 34 | .thumb 35 | .text 36 | 37 | .global inner_prod 38 | 39 | 40 | 41 | x .req R0 /*; input array x[] */ 42 | c .req R1 /*; input array c[] */ 43 | N .req R2 /*; number of samples (a multiple of 4) // 40 samples: the lpcsize == 40 for narrowband mode, submode3 */ 44 | acc .req R3 /*; accumulator */ 45 | sum .req R6 /*; sum */ 46 | x_0 .req R4 /*; elements from array x[]*/ 47 | x_1 .req R5 48 | c_0 .req R7 /*; elements from array c[] */ 49 | c_1 .req R8 50 | 51 | 52 | 53 | 54 | .thumb_func 55 | inner_prod: 56 | 57 | PUSH {r4-r8, lr} 58 | MOV sum, #0 59 | 60 | Loop: 61 | 62 | MOV acc, #0 63 | LDRSH x_0, [x], #2 64 | LDRSH c_0, [c], #2 65 | MLA acc, x_0, c_0, acc 66 | LDRSH x_1, [x], #2 67 | LDRSH c_1, [c], #2 68 | MLA acc, x_1, c_1, acc 69 | LDRSH x_0, [x], #2 70 | LDRSH c_0, [c], #2 71 | MLA acc, x_0, c_0, acc 72 | LDRSH x_1, [x], #2 73 | LDRSH c_1, [c], #2 74 | MLA acc, x_1, c_1, acc 75 | ADD sum,sum,acc,ASR #6 76 | 77 | MOV acc, #0 78 | LDRSH x_0, [x], #2 79 | LDRSH c_0, [c], #2 80 | MLA acc, x_0, c_0, acc 81 | LDRSH x_1, [x], #2 82 | LDRSH c_1, [c], #2 83 | MLA acc, x_1, c_1, acc 84 | LDRSH x_0, [x], #2 85 | LDRSH c_0, [c], #2 86 | MLA acc, x_0, c_0, acc 87 | LDRSH x_1, [x], #2 88 | LDRSH c_1, [c], #2 89 | MLA acc, x_1, c_1, acc 90 | ADD sum,sum,acc,ASR #6 91 | 92 | MOV acc, #0 93 | LDRSH x_0, [x], #2 94 | LDRSH c_0, [c], #2 95 | MLA acc, x_0, c_0, acc 96 | LDRSH x_1, [x], #2 97 | LDRSH c_1, [c], #2 98 | MLA acc, x_1, c_1, acc 99 | LDRSH x_0, [x], #2 100 | LDRSH c_0, [c], #2 101 | MLA acc, x_0, c_0, acc 102 | LDRSH x_1, [x], #2 103 | LDRSH c_1, [c], #2 104 | MLA acc, x_1, c_1, acc 105 | ADD sum,sum,acc,ASR #6 106 | 107 | MOV acc, #0 108 | LDRSH x_0, [x], #2 109 | LDRSH c_0, [c], #2 110 | MLA acc, x_0, c_0, acc 111 | LDRSH x_1, [x], #2 112 | LDRSH c_1, [c], #2 113 | MLA acc, x_1, c_1, acc 114 | LDRSH x_0, [x], #2 115 | LDRSH c_0, [c], #2 116 | MLA acc, x_0, c_0, acc 117 | LDRSH x_1, [x], #2 118 | LDRSH c_1, [c], #2 119 | MLA acc, x_1, c_1, acc 120 | ADD sum,sum,acc,ASR #6 121 | 122 | MOV acc, #0 123 | LDRSH x_0, [x], #2 124 | LDRSH c_0, [c], #2 125 | MLA acc, x_0, c_0, acc 126 | LDRSH x_1, [x], #2 127 | LDRSH c_1, [c], #2 128 | MLA acc, x_1, c_1, acc 129 | LDRSH x_0, [x], #2 130 | LDRSH c_0, [c], #2 131 | MLA acc, x_0, c_0, acc 132 | LDRSH x_1, [x], #2 133 | LDRSH c_1, [c], #2 134 | MLA acc, x_1, c_1, acc 135 | ADD sum,sum,acc,ASR #6 136 | 137 | MOV acc, #0 138 | LDRSH x_0, [x], #2 139 | LDRSH c_0, [c], #2 140 | MLA acc, x_0, c_0, acc 141 | LDRSH x_1, [x], #2 142 | LDRSH c_1, [c], #2 143 | MLA acc, x_1, c_1, acc 144 | LDRSH x_0, [x], #2 145 | LDRSH c_0, [c], #2 146 | MLA acc, x_0, c_0, acc 147 | LDRSH x_1, [x], #2 148 | LDRSH c_1, [c], #2 149 | MLA acc, x_1, c_1, acc 150 | ADD sum,sum,acc,ASR #6 151 | 152 | MOV acc, #0 153 | LDRSH x_0, [x], #2 154 | LDRSH c_0, [c], #2 155 | MLA acc, x_0, c_0, acc 156 | LDRSH x_1, [x], #2 157 | LDRSH c_1, [c], #2 158 | MLA acc, x_1, c_1, acc 159 | LDRSH x_0, [x], #2 160 | LDRSH c_0, [c], #2 161 | MLA acc, x_0, c_0, acc 162 | LDRSH x_1, [x], #2 163 | LDRSH c_1, [c], #2 164 | MLA acc, x_1, c_1, acc 165 | ADD sum,sum,acc,ASR #6 166 | 167 | MOV acc, #0 168 | LDRSH x_0, [x], #2 169 | LDRSH c_0, [c], #2 170 | MLA acc, x_0, c_0, acc 171 | LDRSH x_1, [x], #2 172 | LDRSH c_1, [c], #2 173 | MLA acc, x_1, c_1, acc 174 | LDRSH x_0, [x], #2 175 | LDRSH c_0, [c], #2 176 | MLA acc, x_0, c_0, acc 177 | LDRSH x_1, [x], #2 178 | LDRSH c_1, [c], #2 179 | MLA acc, x_1, c_1, acc 180 | ADD sum,sum,acc,ASR #6 181 | 182 | MOV acc, #0 183 | LDRSH x_0, [x], #2 184 | LDRSH c_0, [c], #2 185 | MLA acc, x_0, c_0, acc 186 | LDRSH x_1, [x], #2 187 | LDRSH c_1, [c], #2 188 | MLA acc, x_1, c_1, acc 189 | LDRSH x_0, [x], #2 190 | LDRSH c_0, [c], #2 191 | MLA acc, x_0, c_0, acc 192 | LDRSH x_1, [x], #2 193 | LDRSH c_1, [c], #2 194 | MLA acc, x_1, c_1, acc 195 | ADD sum,sum,acc,ASR #6 196 | 197 | MOV acc, #0 198 | LDRSH x_0, [x], #2 199 | LDRSH c_0, [c], #2 200 | MLA acc, x_0, c_0, acc 201 | LDRSH x_1, [x], #2 202 | LDRSH c_1, [c], #2 203 | MLA acc, x_1, c_1, acc 204 | LDRSH x_0, [x], #2 205 | LDRSH c_0, [c], #2 206 | MLA acc, x_0, c_0, acc 207 | LDRSH x_1, [x], #2 208 | LDRSH c_1, [c], #2 209 | MLA acc, x_1, c_1, acc 210 | ADD sum,sum,acc,ASR #6 211 | MOV r0, sum 212 | 213 | POP {r4-r8, pc} 214 | .end 215 | --------------------------------------------------------------------------------