├── doc ├── .cvsignore ├── Makefile.am ├── manual.pdf ├── components.odg ├── echo_path.odg ├── speex_abs.odg ├── celp_decoder.odg ├── speex_analysis.odg ├── draft-herlein-avt-rtp-speex-00.txt ├── sampleenc.c ├── sampledec.c └── rtp.txt ├── include ├── Makefile.am └── speex │ ├── speex_config_types.h.in │ ├── Makefile.am │ ├── speex_stereo.h │ ├── speex_types.h │ └── speex_header.h ├── NEWS ├── src ├── .cvsignore ├── Makefile.am ├── speexdec.1 ├── speexenc.1 ├── wav_io.h ├── wave_out.h └── skeleton.h ├── html ├── speex.png ├── speex.xcf ├── speex.webprj └── patents.html ├── macosx ├── English.lproj │ └── InfoPlist.strings ├── Speex_Prefix.pch └── Info.plist ├── libspeex ├── .cvsignore ├── bfin.h ├── kiss_fftr.h ├── smallft.h ├── Makefile.am ├── lpc.h ├── exc_10_16_table.c ├── gain_table_lbr.c ├── misc_bfin.h ├── fftwrap.h ├── vbr.h ├── vq.h ├── lsp.h ├── exc_10_32_table.c ├── quant_lsp.h ├── exc_5_64_table.c ├── hexc_10_32_table.c ├── kiss_fft.h ├── cb_search_sse.h ├── lsp_bfin.h ├── ltp_sse.h ├── filters_arm4.h ├── vorbis_psy.h ├── exc_20_32_table.c ├── stack_alloc.h ├── cb_search.h ├── testenc_uwb.c ├── testenc_wb.c ├── vq_sse.h ├── vq_arm4.h └── testenc.c ├── IDEAS ├── speexclient ├── compile.sh ├── README ├── speex_jitter_buffer.h ├── alsa_device.h └── speex_jitter_buffer.c ├── INSTALL ├── symbian ├── Makefile.am ├── bld.inf ├── speex.mmp └── config.h ├── .cvsignore ├── autogen.sh ├── win32 ├── speexdec │ ├── Makefile.am │ └── speexdec.dsw ├── speexenc │ ├── Makefile.am │ └── speexenc.dsw ├── VS2003 │ ├── libspeex │ │ └── Makefile.am │ ├── speexdec │ │ └── Makefile.am │ ├── speexenc │ │ └── Makefile.am │ ├── Makefile.am │ └── tests │ │ └── Makefile.am ├── VS2005 │ ├── libspeex │ │ └── Makefile.am │ ├── speexdec │ │ └── Makefile.am │ ├── speexenc │ │ └── Makefile.am │ ├── Makefile.am │ └── tests │ │ └── Makefile.am ├── VS2008 │ ├── libspeex │ │ └── Makefile.am │ ├── speexdec │ │ └── Makefile.am │ ├── speexenc │ │ └── Makefile.am │ ├── Makefile.am │ └── tests │ │ └── Makefile.am ├── libspeex │ ├── Makefile.am │ └── libspeex.dsw ├── Makefile.am ├── config.h ├── libspeex.def └── speex.iss ├── ti ├── speex_C55_test │ ├── Makefile.am │ ├── speex_C55_test.pjt │ └── speex_C55_test.cmd ├── speex_C64_test │ ├── Makefile.am │ ├── speex_C64_test.pjt │ └── speex_C64_test.cmd ├── speex_C54_test │ ├── Makefile.am │ ├── speex_C54_test.pjt │ └── speex_C54_test.cmd ├── Makefile.am └── config.h ├── OPTIMIZE ├── speex.pc.in ├── m4 └── add_cflags.m4 ├── AUTHORS ├── .gitignore ├── README.win32 ├── README ├── tmv ├── speex_config_types.h ├── misc_tm.h ├── fixed_tm.h └── config.h ├── README.blackfin ├── Makefile.am ├── ChangeLog ├── TODO ├── README.symbian ├── COPYING ├── Speex.spec.in ├── README.TI-DSP └── speex.m4 /doc/.cvsignore: -------------------------------------------------------------------------------- 1 | Makefile 2 | Makefile.in 3 | -------------------------------------------------------------------------------- /include/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | SUBDIRS = speex 3 | -------------------------------------------------------------------------------- /NEWS: -------------------------------------------------------------------------------- 1 | 2002/02/13: Creation of the "Speex" project 2 | -------------------------------------------------------------------------------- /src/.cvsignore: -------------------------------------------------------------------------------- 1 | .deps 2 | Makefile 3 | Makefile.in 4 | -------------------------------------------------------------------------------- /doc/Makefile.am: -------------------------------------------------------------------------------- 1 | doc_DATA = manual.pdf 2 | 3 | EXTRA_DIST = $(doc_DATA) 4 | -------------------------------------------------------------------------------- /doc/manual.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumble-voip/speex/master/doc/manual.pdf -------------------------------------------------------------------------------- /html/speex.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumble-voip/speex/master/html/speex.png -------------------------------------------------------------------------------- /html/speex.xcf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumble-voip/speex/master/html/speex.xcf -------------------------------------------------------------------------------- /doc/components.odg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumble-voip/speex/master/doc/components.odg -------------------------------------------------------------------------------- /doc/echo_path.odg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumble-voip/speex/master/doc/echo_path.odg -------------------------------------------------------------------------------- /doc/speex_abs.odg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumble-voip/speex/master/doc/speex_abs.odg -------------------------------------------------------------------------------- /doc/celp_decoder.odg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumble-voip/speex/master/doc/celp_decoder.odg -------------------------------------------------------------------------------- /doc/speex_analysis.odg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumble-voip/speex/master/doc/speex_analysis.odg -------------------------------------------------------------------------------- /doc/draft-herlein-avt-rtp-speex-00.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumble-voip/speex/master/doc/draft-herlein-avt-rtp-speex-00.txt -------------------------------------------------------------------------------- /macosx/English.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumble-voip/speex/master/macosx/English.lproj/InfoPlist.strings -------------------------------------------------------------------------------- /macosx/Speex_Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'Speex' target in the 'Speex' project. 3 | // 4 | 5 | #include 6 | -------------------------------------------------------------------------------- /libspeex/.cvsignore: -------------------------------------------------------------------------------- 1 | .deps 2 | .libs 3 | *.la 4 | *.lo 5 | *.o 6 | Makefile 7 | Makefile.in 8 | testdenoise 9 | testenc 10 | testenc_uwb 11 | testenc_wb 12 | -------------------------------------------------------------------------------- /IDEAS: -------------------------------------------------------------------------------- 1 | - Non-linear adaptive codebook (use exc[n]*|exc[n]| to reduce noise 2 | component in adaptive codebook excitation) 3 | 4 | - Include time-domain masking for VBR 5 | -------------------------------------------------------------------------------- /speexclient/compile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | gcc -Wall -I../include speex_jitter_buffer.c speexclient.c alsa_device.c `pkg-config --cflags speexdsp` -o speexclient -lspeex -lspeexdsp -lasound -lm `pkg-config --libs speexdsp` 3 | 4 | -------------------------------------------------------------------------------- /html/speex.webprj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /INSTALL: -------------------------------------------------------------------------------- 1 | Installing Speex is as easy as: 2 | 3 | % ./configure [--prefix=] 4 | % make 5 | % make install 6 | 7 | Note that if you are using the code from Git, you will need to run "autogen.sh" 8 | and then "configure". 9 | -------------------------------------------------------------------------------- /symbian/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in. -*-Makefile-*- 2 | 3 | # Disable automatic dependency tracking if using other tools than gcc and gmake 4 | #AUTOMAKE_OPTIONS = no-dependencies 5 | 6 | EXTRA_DIST = bld.inf config.h speex.mmp 7 | -------------------------------------------------------------------------------- /.cvsignore: -------------------------------------------------------------------------------- 1 | Makefile 2 | Makefile.in 3 | Speex.spec 4 | aclocal.m4 5 | autom4te.cache 6 | config.guess 7 | config.log 8 | config.status 9 | config.sub 10 | configure 11 | depcomp 12 | install-sh 13 | libtool 14 | ltconfig 15 | ltmain.sh 16 | missing 17 | mkinstalldirs 18 | -------------------------------------------------------------------------------- /autogen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Run this to set up the build system: configure, makefiles, etc. 3 | set -e 4 | 5 | srcdir=`dirname $0` 6 | test -n "$srcdir" && cd "$srcdir" 7 | 8 | echo "Updating build configuration files, please wait...." 9 | 10 | autoreconf -if 11 | 12 | -------------------------------------------------------------------------------- /win32/speexdec/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in. -*-Makefile-*- 2 | 3 | # Disable automatic dependency tracking if using other tools than gcc and gmake 4 | #AUTOMAKE_OPTIONS = no-dependencies 5 | 6 | EXTRA_DIST = speexdec.dsp speexdec.dsw 7 | -------------------------------------------------------------------------------- /win32/speexenc/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in. -*-Makefile-*- 2 | 3 | # Disable automatic dependency tracking if using other tools than gcc and gmake 4 | #AUTOMAKE_OPTIONS = no-dependencies 5 | 6 | EXTRA_DIST = speexenc.dsp speexenc.dsw 7 | -------------------------------------------------------------------------------- /ti/speex_C55_test/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in. -*-Makefile-*- 2 | 3 | # Disable automatic dependency tracking if using other tools than gcc and gmake 4 | #AUTOMAKE_OPTIONS = no-dependencies 5 | 6 | EXTRA_DIST = speex_C55_test.cmd speex_C55_test.pjt 7 | -------------------------------------------------------------------------------- /ti/speex_C64_test/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in. -*-Makefile-*- 2 | 3 | # Disable automatic dependency tracking if using other tools than gcc and gmake 4 | #AUTOMAKE_OPTIONS = no-dependencies 5 | 6 | EXTRA_DIST = speex_C64_test.cmd speex_C64_test.pjt 7 | -------------------------------------------------------------------------------- /win32/VS2003/libspeex/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in. -*-Makefile-*- 2 | 3 | # Disable automatic dependency tracking if using other tools than gcc and gmake 4 | #AUTOMAKE_OPTIONS = no-dependencies 5 | 6 | EXTRA_DIST = libspeex.vcproj 7 | 8 | 9 | -------------------------------------------------------------------------------- /win32/VS2003/speexdec/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in. -*-Makefile-*- 2 | 3 | # Disable automatic dependency tracking if using other tools than gcc and gmake 4 | #AUTOMAKE_OPTIONS = no-dependencies 5 | 6 | EXTRA_DIST = speexdec.vcproj 7 | 8 | 9 | -------------------------------------------------------------------------------- /win32/VS2003/speexenc/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in. -*-Makefile-*- 2 | 3 | # Disable automatic dependency tracking if using other tools than gcc and gmake 4 | #AUTOMAKE_OPTIONS = no-dependencies 5 | 6 | EXTRA_DIST = speexenc.vcproj 7 | 8 | 9 | -------------------------------------------------------------------------------- /win32/VS2005/libspeex/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in. -*-Makefile-*- 2 | 3 | # Disable automatic dependency tracking if using other tools than gcc and gmake 4 | #AUTOMAKE_OPTIONS = no-dependencies 5 | 6 | EXTRA_DIST = libspeex.vcproj 7 | 8 | 9 | -------------------------------------------------------------------------------- /win32/VS2005/speexdec/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in. -*-Makefile-*- 2 | 3 | # Disable automatic dependency tracking if using other tools than gcc and gmake 4 | #AUTOMAKE_OPTIONS = no-dependencies 5 | 6 | EXTRA_DIST = speexdec.vcproj 7 | 8 | 9 | -------------------------------------------------------------------------------- /win32/VS2005/speexenc/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in. -*-Makefile-*- 2 | 3 | # Disable automatic dependency tracking if using other tools than gcc and gmake 4 | #AUTOMAKE_OPTIONS = no-dependencies 5 | 6 | EXTRA_DIST = speexenc.vcproj 7 | 8 | 9 | -------------------------------------------------------------------------------- /win32/VS2008/libspeex/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in. -*-Makefile-*- 2 | 3 | # Disable automatic dependency tracking if using other tools than gcc and gmake 4 | #AUTOMAKE_OPTIONS = no-dependencies 5 | 6 | EXTRA_DIST = libspeex.vcproj 7 | 8 | 9 | -------------------------------------------------------------------------------- /win32/VS2008/speexdec/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in. -*-Makefile-*- 2 | 3 | # Disable automatic dependency tracking if using other tools than gcc and gmake 4 | #AUTOMAKE_OPTIONS = no-dependencies 5 | 6 | EXTRA_DIST = speexdec.vcproj 7 | 8 | 9 | -------------------------------------------------------------------------------- /win32/VS2008/speexenc/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in. -*-Makefile-*- 2 | 3 | # Disable automatic dependency tracking if using other tools than gcc and gmake 4 | #AUTOMAKE_OPTIONS = no-dependencies 5 | 6 | EXTRA_DIST = speexenc.vcproj 7 | 8 | 9 | -------------------------------------------------------------------------------- /include/speex/speex_config_types.h.in: -------------------------------------------------------------------------------- 1 | #ifndef __SPEEX_TYPES_H__ 2 | #define __SPEEX_TYPES_H__ 3 | 4 | @INCLUDE_STDINT@ 5 | 6 | typedef @SIZE16@ spx_int16_t; 7 | typedef @USIZE16@ spx_uint16_t; 8 | typedef @SIZE32@ spx_int32_t; 9 | typedef @USIZE32@ spx_uint32_t; 10 | 11 | #endif 12 | 13 | -------------------------------------------------------------------------------- /win32/libspeex/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in. -*-Makefile-*- 2 | 3 | # Disable automatic dependency tracking if using other tools than gcc and gmake 4 | #AUTOMAKE_OPTIONS = no-dependencies 5 | 6 | EXTRA_DIST = libspeex.dsw libspeex.dsp libspeex_dynamic.dsp 7 | -------------------------------------------------------------------------------- /ti/speex_C54_test/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in. -*-Makefile-*- 2 | 3 | # Disable automatic dependency tracking if using other tools than gcc and gmake 4 | #AUTOMAKE_OPTIONS = no-dependencies 5 | 6 | EXTRA_DIST = speex_C54_test.cmd speex_C54_test.pjt 7 | 8 | 9 | -------------------------------------------------------------------------------- /win32/VS2003/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in. -*-Makefile-*- 2 | 3 | # Disable automatic dependency tracking if using other tools than gcc and gmake 4 | #AUTOMAKE_OPTIONS = no-dependencies 5 | 6 | SUBDIRS = libspeex speexenc speexdec tests 7 | 8 | EXTRA_DIST = libspeex.sln 9 | -------------------------------------------------------------------------------- /win32/VS2005/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in. -*-Makefile-*- 2 | 3 | # Disable automatic dependency tracking if using other tools than gcc and gmake 4 | #AUTOMAKE_OPTIONS = no-dependencies 5 | 6 | SUBDIRS = libspeex speexenc speexdec tests 7 | 8 | EXTRA_DIST = libspeex.sln 9 | -------------------------------------------------------------------------------- /win32/VS2008/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in. -*-Makefile-*- 2 | 3 | # Disable automatic dependency tracking if using other tools than gcc and gmake 4 | #AUTOMAKE_OPTIONS = no-dependencies 5 | 6 | SUBDIRS = libspeex speexenc speexdec tests 7 | 8 | EXTRA_DIST = libspeex.sln 9 | -------------------------------------------------------------------------------- /OPTIMIZE: -------------------------------------------------------------------------------- 1 | Narrowband: 2 | 3 | - pitch_gain_search_3tap calls syn_filt_zero more times than it should (we're 4 | computing some things twice) 5 | 6 | Wideband 7 | 8 | - All narrowband optimizations apply 9 | - Lots of time spent in the codebook search. We could speed that up by using 10 | a hierarchical codebook 11 | -------------------------------------------------------------------------------- /win32/VS2003/tests/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in. -*-Makefile-*- 2 | 3 | # Disable automatic dependency tracking if using other tools than gcc and gmake 4 | #AUTOMAKE_OPTIONS = no-dependencies 5 | 6 | EXTRA_DIST = testenc.vcproj testenc_uwb.vcproj testenc_wb.vcproj 7 | 8 | 9 | -------------------------------------------------------------------------------- /win32/VS2005/tests/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in. -*-Makefile-*- 2 | 3 | # Disable automatic dependency tracking if using other tools than gcc and gmake 4 | #AUTOMAKE_OPTIONS = no-dependencies 5 | 6 | EXTRA_DIST = testenc.vcproj testenc_uwb.vcproj testenc_wb.vcproj 7 | 8 | 9 | -------------------------------------------------------------------------------- /win32/VS2008/tests/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in. -*-Makefile-*- 2 | 3 | # Disable automatic dependency tracking if using other tools than gcc and gmake 4 | #AUTOMAKE_OPTIONS = no-dependencies 5 | 6 | EXTRA_DIST = testenc.vcproj testenc_uwb.vcproj testenc_wb.vcproj 7 | 8 | 9 | -------------------------------------------------------------------------------- /include/speex/Makefile.am: -------------------------------------------------------------------------------- 1 | # Disable automatic dependency tracking if using other tools than gcc and gmake 2 | #AUTOMAKE_OPTIONS = no-dependencies 3 | 4 | nodist_pkginclude_HEADERS = speex_config_types.h 5 | 6 | pkginclude_HEADERS = speex.h speex_bits.h speex_callbacks.h \ 7 | speex_header.h \ 8 | speex_stereo.h speex_types.h 9 | 10 | -------------------------------------------------------------------------------- /win32/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in. -*-Makefile-*- 2 | 3 | # Disable automatic dependency tracking if using other tools than gcc and gmake 4 | #AUTOMAKE_OPTIONS = no-dependencies 5 | 6 | SUBDIRS = libspeex speexenc speexdec VS2003 VS2005 VS2008 7 | 8 | EXTRA_DIST = speex.iss config.h libspeex.def 9 | -------------------------------------------------------------------------------- /speex.pc.in: -------------------------------------------------------------------------------- 1 | # libspeex pkg-config source file 2 | 3 | prefix=@prefix@ 4 | exec_prefix=@exec_prefix@ 5 | libdir=@libdir@ 6 | includedir=@includedir@ 7 | 8 | Name: speex 9 | Description: Speex is an audio codec tuned for speech 10 | Version: @SPEEX_VERSION@ 11 | Requires: 12 | Conflicts: 13 | Libs: -L${libdir} -lspeex 14 | Libs.private: @LIBM@ 15 | Cflags: -I${includedir} 16 | -------------------------------------------------------------------------------- /ti/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in. -*-Makefile-*- 2 | 3 | # Disable automatic dependency tracking if using other tools than gcc and gmake 4 | #AUTOMAKE_OPTIONS = no-dependencies 5 | 6 | SUBDIRS = speex_C54_test speex_C55_test speex_C64_test 7 | 8 | EXTRA_DIST = config.h testenc-TI-C5x.c os_support_custom.h testenc-TI-C64x.c 9 | 10 | -------------------------------------------------------------------------------- /libspeex/bfin.h: -------------------------------------------------------------------------------- 1 | /* Common Blackfin assembly defines 2 | * 3 | * Copyright (C) 2005-2009 Analog Devices 4 | */ 5 | 6 | #if __GNUC__ <= 3 7 | /* GCC-3.4 and older did not use hardware loops and thus did not have 8 | * register constraints for declaring clobbers. 9 | */ 10 | # define BFIN_HWLOOP0_REGS 11 | # define BFIN_HWLOOP1_REGS 12 | #else 13 | # define BFIN_HWLOOP0_REGS , "LB0", "LT0", "LC0" 14 | # define BFIN_HWLOOP1_REGS , "LB1", "LT1", "LC1" 15 | #endif 16 | -------------------------------------------------------------------------------- /m4/add_cflags.m4: -------------------------------------------------------------------------------- 1 | dnl @synopsis XIPH_ADD_CFLAGS 2 | dnl 3 | dnl Add the given option to CFLAGS, if it doesn't break the compiler 4 | 5 | AC_DEFUN([XIPH_ADD_CFLAGS], 6 | [AC_MSG_CHECKING([if $CC accepts $1]) 7 | ac_add_cflags__old_cflags="$CFLAGS" 8 | CFLAGS="$1" 9 | AC_TRY_LINK([ 10 | #include 11 | ], 12 | [puts("Hello, World!"); return 0;], 13 | AC_MSG_RESULT([yes]) 14 | CFLAGS="$ac_add_cflags__old_cflags $1", 15 | AC_MSG_RESULT([no]) 16 | CFLAGS="$ac_add_cflags__old_cflags" 17 | ) 18 | ])# XIPH_ADD_CFLAGS 19 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | Jean-Marc Valin 2 | All the code except the following 3 | 4 | David Rowe 5 | lsp.c lsp.h 6 | Also ideas and feedback 7 | 8 | John Francis Edwards 9 | wave_out.[ch], some #ifdefs for windows port and MSVC project files 10 | 11 | Segher Boessenkool 12 | Misc. optimizations (for QMF in particular) 13 | 14 | Atsuhiko Yamanaka : 15 | Patch to speexenc.c to add Vorbis comment format 16 | 17 | Radim Kolar : 18 | Patch to speexenc.c for supporting more input formats 19 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | *.lo 3 | Makefile.in 4 | *~ 5 | *.orig 6 | fixed 7 | float 8 | Speex.kdevelop.pcs 9 | Speex.kdevses 10 | aclocal.m4 11 | autom4te.cache 12 | compile 13 | config.guess 14 | config.h.in 15 | config.sub 16 | configure 17 | depcomp 18 | install-sh 19 | ltmain.sh 20 | missing 21 | Makefile 22 | .deps 23 | .libs 24 | *.la 25 | work 26 | Speex.spec 27 | config.h 28 | config.log 29 | config.status 30 | include/speex/speex_config_types.h 31 | *.sw[lmnop] 32 | testenc 33 | testenc_uwb 34 | testenc_wb 35 | libtool 36 | speex.pc 37 | src/speexdec 38 | src/speexenc 39 | stamp-* 40 | patches 41 | -------------------------------------------------------------------------------- /README.win32: -------------------------------------------------------------------------------- 1 | Win32 Specific options 2 | 3 | In order to enable the following options within Speex, you will need to manually edit the project options for the appropriate VC configuration. These macros can be specified by adding them as "Preprocessor Definitions" under the appropriate Configuration's project options. If you don't know how to do this, please check your Visual C documentation. 4 | 5 | Feature: 6 | 7 | Intel Streaming SIMD Extensions - SSE - macro: USE_SSE 8 | Fixed point - macro: FIXED_POINT 9 | Epic 48 - macro: EPIC_48K 10 | 11 | Note: USE_SSE and FIXED_POINT are mutually exclusive. 12 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | See INSTALL file for instruction on how to install Speex. 2 | 3 | The Speex is a patent-free, Open Source/Free Software voice codec. Unlike other codecs like MP3 and Ogg Vorbis, Speex is designed to compress voice at bitrates in the 2-45 kbps range. Possible applications include VoIP, internet audio streaming, archiving of speech data (e.g. voice mail), and audio books. In some sense, it is meant to be complementary to the Ogg Vorbis codec. 4 | 5 | To use the Speex command line tools: 6 | 7 | % speexenc [options] input_file.wav compressed_file.spx 8 | 9 | % speexdec [options] compressed_file.spx output_file.wav 10 | -------------------------------------------------------------------------------- /tmv/speex_config_types.h: -------------------------------------------------------------------------------- 1 | #ifndef __SPEEX_TYPES_H__ 2 | #define __SPEEX_TYPES_H__ 3 | 4 | #ifdef __TCS__ 5 | 6 | #include 7 | 8 | 9 | 10 | typedef Int16 spx_int16_t; 11 | typedef UInt16 spx_uint16_t; 12 | typedef Int32 spx_int32_t; 13 | typedef UInt32 spx_uint32_t; 14 | 15 | #ifdef FIXED_POINT 16 | #define VMUX(a,b,c) mux((a),(b),(c)) 17 | #define VABS(a) iabs((a)) 18 | #define VMAX(a,b) imax((a),(b)) 19 | #define VMIN(a,b) imin((a),(b)) 20 | #else 21 | #define VMUX(a,b,c) fmux((a),(b),(c)) 22 | #define VABS(a) fabs((a)) 23 | #define VMAX(a,b) fmax((a),(b)) 24 | #define VMIN(a,b) fmin((a),(b)) 25 | #endif 26 | 27 | #endif 28 | 29 | 30 | #endif 31 | 32 | -------------------------------------------------------------------------------- /README.blackfin: -------------------------------------------------------------------------------- 1 | Speex has been ported to the Blackfin DSP, for the STAMP development board. 2 | 3 | This port has been tested on the STAMP development board and requires the 4 | toolchain available at http://blackfin.uclinux.org/ 5 | 6 | 1/ In order to cross-compile for uClinux from the Speex tarball: 7 | 8 | ./configure --enable-blackfin-asm --enable-fixed-point --host=bfin-uclinux 9 | cd libspeex 10 | make 11 | 12 | The --enable-blackfin-asm option is not required, but it speeds up Speex by 13 | approximately a factor of two. 14 | 15 | 2/ In order to cross-compile for uClinux from the Speex Git: 16 | 17 | git clone git://git.xiph.org/speex.git 18 | cd speex 19 | ./autogen.sh --enable-blackfin-asm --enable-fixed-point --host=bfin-uclinux 20 | cd libspeex 21 | make 22 | -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in. -*-Makefile-*- 2 | 3 | # To disable automatic dependency tracking if using other tools than 4 | # gcc and gmake, add the option 'no-dependencies' 5 | AUTOMAKE_OPTIONS = 1.8 6 | ACLOCAL_AMFLAGS = -I m4 7 | 8 | m4datadir = $(datadir)/aclocal 9 | m4data_DATA = speex.m4 10 | 11 | pkgconfigdir = $(libdir)/pkgconfig 12 | pkgconfig_DATA = speex.pc 13 | 14 | EXTRA_DIST = Speex.spec Speex.spec.in Speex.kdevelop speex.m4 speex.pc.in README.blackfin README.symbian README.TI-DSP 15 | 16 | #Fools KDevelop into including all files 17 | SUBDIRS = libspeex include doc win32 symbian ti 18 | 19 | if BUILD_BINARIES 20 | SUBDIRS += src 21 | endif 22 | 23 | DIST_SUBDIRS = libspeex include src doc win32 symbian ti 24 | 25 | rpm: dist 26 | rpmbuild -ta ${PACKAGE}-${VERSION}.tar.gz 27 | -------------------------------------------------------------------------------- /speexclient/README: -------------------------------------------------------------------------------- 1 | This is a VERY SIMPLE Speex VoIP client. It is not a complete VoIP application, 2 | isn't compatible with anything else (including probably future versions of 3 | itself) and does not support any form of standard protocols. It is intended 4 | only as a way to show how to use Speex in a VoIP application. 5 | 6 | To use it: 7 | 8 | On Alices machine: 9 | % speexclient plughw:0,0 bob.somewhere.net alice_port bob_port 10 | 11 | On Bob's machine: 12 | % speexclient plughw:0,0 alice.somewhere.net bob_port alice_port 13 | 14 | where bob_port is the UDP port on which bob receives and alice_port is the 15 | UDP port on which alice receives. In most cases, the two ports can be the same. 16 | 17 | Note that the clients do not even know whether they are connected or not. All 18 | they do is send/receive the audio to/from a specific port. 19 | -------------------------------------------------------------------------------- /ChangeLog: -------------------------------------------------------------------------------- 1 | 2005-09-07 Thomas Vander Stichele 2 | 3 | * libspeex/cb_search.c: (split_cb_search_shape_sign_N1): 4 | add declaration for n, seems like an obvious build fix, slap 5 | me down if it's not 6 | 7 | 2004-02-18 Jean-Marc Valin 8 | Patch for compiling with mingw32 sent by j@thing.net 9 | 10 | 2004-02-18 Jean-Marc Valin 11 | Integrated IRIX patch (getopt stuff) from Michael Pruett 12 | 13 | 2004-02-18 Jean-Marc Valin 14 | Changed the Makefile.am so that KDevelop can parse SUBDIRS correctly 15 | 16 | 2002/03/27 Jean-Marc Valin: 17 | Working encoder and decoder for both narrowband and wideband. 18 | 19 | 2002/02/27 Jean-Marc Valin: 20 | Got the basic encoder working as a demo with quantization only on some 21 | parameters. 22 | -------------------------------------------------------------------------------- /TODO: -------------------------------------------------------------------------------- 1 | For 1.2: 2 | Major points: 3 | - Make documentation match the actual code 4 | - Stabilise all APIs (need feedback) 5 | - NaN checks? 6 | - Better error reporting 7 | - Make kiss-fft 32-bit safe 8 | 9 | Minor issues: 10 | - Fix last frame of speexenc 11 | 12 | 13 | Post 1.2: 14 | improve float<->int conversion 15 | split encoder and decoder? 16 | Merge TriMedia stuff 17 | packet dump 18 | Do VAD properly 19 | 20 | Optimisations 21 | - Add restrict in a few places? 22 | - enable 4x4 version of pitch_xcorr() at least on some archs? 23 | - use __builtin_expect() (likely()/unlikely()) 24 | 25 | Would be nice: 26 | Implement wideband split as IIR instead of QMF? 27 | 28 | Allocator override (speex_lib_ctl?) 29 | Fixed-point: 30 | - VBR 31 | 32 | Standards 33 | -Complete Speex RTP profile 34 | -MIME type registration 35 | 36 | ideas: 37 | Peelable stream (double codebook, higher bands, stereo) 38 | LPC from spectral domain 39 | -------------------------------------------------------------------------------- /win32/config.h: -------------------------------------------------------------------------------- 1 | // Microsoft version of 'inline' 2 | #define inline __inline 3 | 4 | // In Visual Studio, _M_IX86_FP=1 means /arch:SSE was used, likewise 5 | // _M_IX86_FP=2 means /arch:SSE2 was used. 6 | // Also, enable both _USE_SSE and _USE_SSE2 if we're compiling for x86-64 7 | #if _M_IX86_FP >= 1 || defined(_M_X64) 8 | #define _USE_SSE 9 | #endif 10 | 11 | #if _M_IX86_FP >= 2 || defined(_M_X64) 12 | #define _USE_SSE2 13 | #endif 14 | 15 | // Visual Studio support alloca(), but it always align variables to 16-bit 16 | // boundary, while SSE need 128-bit alignment. So we disable alloca() when 17 | // SSE is enabled. 18 | #ifndef _USE_SSE 19 | # define USE_ALLOCA 20 | #endif 21 | 22 | /* Default to floating point */ 23 | #ifndef FIXED_POINT 24 | # define FLOATING_POINT 25 | # define USE_SMALLFT 26 | #else 27 | # define USE_KISS_FFT 28 | #endif 29 | 30 | /* We don't support visibility on Win32 */ 31 | #define EXPORT 32 | -------------------------------------------------------------------------------- /src/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in. -*-Makefile-*- 2 | 3 | # $Id: Makefile.am,v 1.11 2004/02/18 06:59:40 jm Exp $ 4 | 5 | # Disable automatic dependency tracking if using other tools than gcc and gmake 6 | #AUTOMAKE_OPTIONS = no-dependencies 7 | 8 | AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_builddir)/include/speex -I$(top_builddir) @OGG_CFLAGS@ @SPEEXDSP_CFLAGS@ 9 | 10 | man_MANS = speexenc.1 speexdec.1 11 | 12 | EXTRA_DIST = $(man_MANS) getopt_win.h getopt.c getopt1.c wave_out.c wave_out.h skeleton.h 13 | 14 | include_HEADERS = 15 | noinst_HEADERS = wav_io.h 16 | 17 | bin_PROGRAMS = speexenc speexdec 18 | 19 | CFLAGS += $(OGG_CFLAGS) 20 | 21 | speexenc_SOURCES = speexenc.c wav_io.c skeleton.c 22 | speexenc_LDADD = $(top_builddir)/libspeex/libspeex.la \ 23 | $(OGG_LIBS) @FFT_LIBS@ @SPEEXDSP_LIBS@ 24 | 25 | speexdec_SOURCES = speexdec.c wav_io.c 26 | speexdec_LDADD = $(top_builddir)/libspeex/libspeex.la \ 27 | $(OGG_LIBS) @WINMM_LIBS@ @FFT_LIBS@ 28 | 29 | -------------------------------------------------------------------------------- /macosx/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | Speex 9 | CFBundleGetInfoString 10 | Speex framework 1.1.12svn, Copyright © 2002-2006 Xiph.Org Foundation 11 | CFBundleIconFile 12 | 13 | CFBundleIdentifier 14 | org.xiph.speex 15 | CFBundleInfoDictionaryVersion 16 | 6.0 17 | CFBundlePackageType 18 | FMWK 19 | CFBundleShortVersionString 20 | 1.1.12svn 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1.1.12d1 25 | NSHumanReadableCopyright 26 | Speex framework 1.1.12svn, Copyright © 2002-2006 Xiph.Org Foundation 27 | CSResourcesFileMapped 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /libspeex/kiss_fftr.h: -------------------------------------------------------------------------------- 1 | #ifndef KISS_FTR_H 2 | #define KISS_FTR_H 3 | 4 | #include "kiss_fft.h" 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | 10 | /* 11 | 12 | Real optimized version can save about 45% cpu time vs. complex fft of a real seq. 13 | 14 | 15 | 16 | */ 17 | 18 | typedef struct kiss_fftr_state *kiss_fftr_cfg; 19 | 20 | 21 | kiss_fftr_cfg kiss_fftr_alloc(int nfft,int inverse_fft,void * mem, size_t * lenmem); 22 | /* 23 | nfft must be even 24 | 25 | If you don't care to allocate space, use mem = lenmem = NULL 26 | */ 27 | 28 | 29 | void kiss_fftr(kiss_fftr_cfg cfg,const kiss_fft_scalar *timedata,kiss_fft_cpx *freqdata); 30 | /* 31 | input timedata has nfft scalar points 32 | output freqdata has nfft/2+1 complex points 33 | */ 34 | 35 | void kiss_fftr2(kiss_fftr_cfg st,const kiss_fft_scalar *timedata,kiss_fft_scalar *freqdata); 36 | 37 | void kiss_fftri(kiss_fftr_cfg cfg,const kiss_fft_cpx *freqdata,kiss_fft_scalar *timedata); 38 | 39 | void kiss_fftri2(kiss_fftr_cfg st,const kiss_fft_scalar *freqdata, kiss_fft_scalar *timedata); 40 | 41 | /* 42 | input freqdata has nfft/2+1 complex points 43 | output timedata has nfft scalar points 44 | */ 45 | 46 | #define kiss_fftr_free speex_free 47 | 48 | #ifdef __cplusplus 49 | } 50 | #endif 51 | #endif 52 | -------------------------------------------------------------------------------- /win32/speexdec/speexdec.dsw: -------------------------------------------------------------------------------- 1 | Microsoft Developer Studio Workspace File, Format Version 6.00 2 | # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! 3 | 4 | ############################################################################### 5 | 6 | Project: "libspeex"=..\libspeex\libspeex.dsp - Package Owner=<4> 7 | 8 | Package=<5> 9 | {{{ 10 | }}} 11 | 12 | Package=<4> 13 | {{{ 14 | }}} 15 | 16 | ############################################################################### 17 | 18 | Project: "ogg_static"="..\..\..\libogg\win32\ogg_static.dsp" - Package Owner=<4> 19 | 20 | Package=<5> 21 | {{{ 22 | }}} 23 | 24 | Package=<4> 25 | {{{ 26 | }}} 27 | 28 | ############################################################################### 29 | 30 | Project: "speexdec"=.\speexdec.dsp - Package Owner=<4> 31 | 32 | Package=<5> 33 | {{{ 34 | }}} 35 | 36 | Package=<4> 37 | {{{ 38 | Begin Project Dependency 39 | Project_Dep_Name libspeex 40 | End Project Dependency 41 | Begin Project Dependency 42 | Project_Dep_Name ogg_static 43 | End Project Dependency 44 | }}} 45 | 46 | ############################################################################### 47 | 48 | Global: 49 | 50 | Package=<5> 51 | {{{ 52 | }}} 53 | 54 | Package=<3> 55 | {{{ 56 | }}} 57 | 58 | ############################################################################### 59 | 60 | -------------------------------------------------------------------------------- /win32/libspeex/libspeex.dsw: -------------------------------------------------------------------------------- 1 | Microsoft Developer Studio Workspace File, Format Version 6.00 2 | # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! 3 | 4 | ############################################################################### 5 | 6 | Project: "libspeex"=.\libspeex.dsp - Package Owner=<4> 7 | 8 | Package=<5> 9 | {{{ 10 | }}} 11 | 12 | Package=<4> 13 | {{{ 14 | }}} 15 | 16 | ############################################################################### 17 | 18 | Project: "libspeex_dynamic"=.\libspeex_dynamic.dsp - Package Owner=<4> 19 | 20 | Package=<5> 21 | {{{ 22 | }}} 23 | 24 | Package=<4> 25 | {{{ 26 | }}} 27 | 28 | ############################################################################### 29 | 30 | Project: "libspeexdsp"=.\libspeexdsp.dsp - Package Owner=<4> 31 | 32 | Package=<5> 33 | {{{ 34 | }}} 35 | 36 | Package=<4> 37 | {{{ 38 | }}} 39 | 40 | ############################################################################### 41 | 42 | Project: "libspeexdsp_dynamic"=.\libspeexdsp_dynamic.dsp - Package Owner=<4> 43 | 44 | Package=<5> 45 | {{{ 46 | }}} 47 | 48 | Package=<4> 49 | {{{ 50 | }}} 51 | 52 | ############################################################################### 53 | 54 | Global: 55 | 56 | Package=<5> 57 | {{{ 58 | }}} 59 | 60 | Package=<3> 61 | {{{ 62 | }}} 63 | 64 | ############################################################################### 65 | 66 | -------------------------------------------------------------------------------- /README.symbian: -------------------------------------------------------------------------------- 1 | Using Speex on Symbian OS 2 | Conrad Parker and Colin Ward, CSIRO Australia, July 2004 3 | 4 | 5 | Introduction 6 | ------------ 7 | 8 | The symbian/ directory contains the following files for Symbian's abuild tool: 9 | 10 | bld.inf Component definition file 11 | speex.mmp Project specification file 12 | config.h Configuration options for both emulator and device builds 13 | 14 | 15 | Developing applications for libspeex for Symbian OS 16 | --------------------------------------------------- 17 | 18 | Any references to the statically defined SpeexMode structures must be 19 | replaced by a call to a speex_lib_get_mode () for that mode. 20 | 21 | * References to the statically defined array speex_mode_list[modeID] 22 | must be replaced by a call to speex_lib_get_mode (modeID): 23 | 24 | - mode = speex_mode_list[modeID]; 25 | + mode = speex_lib_get_mode (modeID); 26 | 27 | * References to the statically defined mode structures must be replaced: 28 | 29 | SpeexMode * mode1, * mode2, * mode3; 30 | 31 | - mode1 = &speex_nb_mode; 32 | + mode1 = speex_lib_get_mode (SPEEX_MODEID_NB); 33 | 34 | - mode2 = &speex_wb_mode; 35 | + mode2 = speex_lib_get_mode (SPEEX_MODEID_WB); 36 | 37 | - mode3 = &speex_uwb_mode; 38 | + mode3 = speex_lib_get_mode (SPEEX_MODEID_UWB); 39 | 40 | Note that the constants SPEEX_MODEID_NB, SPEEX_MODEID_WB and 41 | SPEEX_MODEID_UWB were introduced in libspeex 1.1.6, and are 42 | defined in . speex_lib_get_mode() was introduced 43 | in libspeex 1.1.7 and is declared in . 44 | -------------------------------------------------------------------------------- /win32/libspeex.def: -------------------------------------------------------------------------------- 1 | LIBRARY libspeex 2 | EXPORTS 3 | 4 | 5 | ; 6 | ; speex.h 7 | ; 8 | speex_encoder_init 9 | speex_encoder_destroy 10 | speex_encode 11 | speex_encode_int 12 | speex_encoder_ctl 13 | speex_decoder_init 14 | speex_decoder_destroy 15 | speex_decode 16 | speex_decode_int 17 | speex_decoder_ctl 18 | speex_mode_query 19 | speex_lib_ctl 20 | speex_lib_get_mode 21 | 22 | ; 23 | ; speex_bits.h 24 | ; 25 | speex_bits_init 26 | speex_bits_init_buffer 27 | speex_bits_set_bit_buffer 28 | speex_bits_destroy 29 | speex_bits_reset 30 | speex_bits_rewind 31 | speex_bits_read_from 32 | speex_bits_read_whole_bytes 33 | speex_bits_write 34 | speex_bits_write_whole_bytes 35 | speex_bits_pack 36 | speex_bits_unpack_signed 37 | speex_bits_unpack_unsigned 38 | speex_bits_nbytes 39 | speex_bits_peek_unsigned 40 | speex_bits_peek 41 | speex_bits_advance 42 | speex_bits_remaining 43 | speex_bits_insert_terminator 44 | 45 | ; 46 | ; speex_callbacks.h 47 | ; 48 | speex_inband_handler 49 | speex_std_mode_request_handler 50 | speex_std_high_mode_request_handler 51 | speex_std_char_handler 52 | speex_default_user_handler 53 | speex_std_low_mode_request_handler 54 | speex_std_vbr_request_handler 55 | speex_std_enh_request_handler 56 | speex_std_vbr_quality_request_handler 57 | 58 | ; 59 | ; speex_header.h 60 | ; 61 | speex_init_header 62 | speex_header_to_packet 63 | speex_packet_to_header 64 | 65 | ; 66 | ; speex_stereo.h 67 | ; 68 | speex_stereo_state_init 69 | speex_stereo_state_reset 70 | speex_stereo_state_destroy 71 | speex_encode_stereo 72 | speex_encode_stereo_int 73 | speex_decode_stereo 74 | speex_decode_stereo_int 75 | speex_std_stereo_request_handler 76 | -------------------------------------------------------------------------------- /libspeex/smallft.h: -------------------------------------------------------------------------------- 1 | /******************************************************************** 2 | * * 3 | * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * 4 | * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * 5 | * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * 6 | * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * 7 | * * 8 | * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2001 * 9 | * by the XIPHOPHORUS Company http://www.xiph.org/ * 10 | * * 11 | ******************************************************************** 12 | 13 | function: fft transform 14 | last mod: $Id: smallft.h,v 1.3 2003/09/16 18:35:45 jm Exp $ 15 | 16 | ********************************************************************/ 17 | /** 18 | @file smallft.h 19 | @brief Discrete Rotational Fourier Transform (DRFT) 20 | */ 21 | 22 | #ifndef _V_SMFT_H_ 23 | #define _V_SMFT_H_ 24 | 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | /** Discrete Rotational Fourier Transform lookup */ 31 | struct drft_lookup{ 32 | int n; 33 | float *trigcache; 34 | int *splitcache; 35 | }; 36 | 37 | extern void spx_drft_forward(struct drft_lookup *l,float *data); 38 | extern void spx_drft_backward(struct drft_lookup *l,float *data); 39 | extern void spx_drft_init(struct drft_lookup *l,int n); 40 | extern void spx_drft_clear(struct drft_lookup *l); 41 | 42 | #ifdef __cplusplus 43 | } 44 | #endif 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /win32/speexenc/speexenc.dsw: -------------------------------------------------------------------------------- 1 | Microsoft Developer Studio Workspace File, Format Version 6.00 2 | # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! 3 | 4 | ############################################################################### 5 | 6 | Project: "libspeex"=..\libspeex\libspeex.dsp - Package Owner=<4> 7 | 8 | Package=<5> 9 | {{{ 10 | }}} 11 | 12 | Package=<4> 13 | {{{ 14 | }}} 15 | 16 | ############################################################################### 17 | 18 | Project: "libspeexdsp"=..\libspeex\libspeexdsp.dsp - Package Owner=<4> 19 | 20 | Package=<5> 21 | {{{ 22 | }}} 23 | 24 | Package=<4> 25 | {{{ 26 | }}} 27 | 28 | ############################################################################### 29 | 30 | Project: "ogg_static"=..\..\..\libogg\win32\ogg_static.dsp - Package Owner=<4> 31 | 32 | Package=<5> 33 | {{{ 34 | }}} 35 | 36 | Package=<4> 37 | {{{ 38 | }}} 39 | 40 | ############################################################################### 41 | 42 | Project: "speexenc"=.\speexenc.dsp - Package Owner=<4> 43 | 44 | Package=<5> 45 | {{{ 46 | }}} 47 | 48 | Package=<4> 49 | {{{ 50 | Begin Project Dependency 51 | Project_Dep_Name libspeex 52 | End Project Dependency 53 | Begin Project Dependency 54 | Project_Dep_Name ogg_static 55 | End Project Dependency 56 | Begin Project Dependency 57 | Project_Dep_Name libspeexdsp 58 | End Project Dependency 59 | }}} 60 | 61 | ############################################################################### 62 | 63 | Global: 64 | 65 | Package=<5> 66 | {{{ 67 | }}} 68 | 69 | Package=<3> 70 | {{{ 71 | }}} 72 | 73 | ############################################################################### 74 | 75 | -------------------------------------------------------------------------------- /src/speexdec.1: -------------------------------------------------------------------------------- 1 | .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.29. 2 | .TH SPEEXDEC "1" "September 2003" "speexdec version 1.1" "User Commands" 3 | .SH NAME 4 | speexdec \- The reference implementation speex decoder. 5 | .SH SYNOPSIS 6 | .B speexdec 7 | [\fIoptions\fR] \fIinput_file.spx \fR[\fIoutput_file\fR] 8 | .SH DESCRIPTION 9 | Decodes a Speex file and produce a WAV file or raw file 10 | .SS "input_file can be:" 11 | .TP 12 | filename.spx 13 | regular Speex file 14 | .TP 15 | - 16 | stdin 17 | .SS "output_file can be:" 18 | .TP 19 | filename.wav 20 | Wav file 21 | .TP 22 | filename.* 23 | Raw PCM file (any extension other that .wav) 24 | .TP 25 | - 26 | stdout 27 | .TP 28 | (nothing) 29 | Will be played to soundcard 30 | .SH OPTIONS 31 | .TP 32 | \fB\-\-enh\fR 33 | Enable perceptual enhancement (default) 34 | .TP 35 | \fB\-\-no\-enh\fR 36 | Disable perceptual enhancement 37 | .TP 38 | \fB\-\-force\-nb\fR 39 | Force decoding in narrowband 40 | .TP 41 | \fB\-\-force\-wb\fR 42 | Force decoding in wideband 43 | .TP 44 | \fB\-\-force\-uwb\fR 45 | Force decoding in ultra-wideband 46 | .TP 47 | \fB\-\-mono\fR 48 | Force decoding in mono 49 | .TP 50 | \fB\-\-stereo\fR 51 | Force decoding in stereo 52 | .TP 53 | \fB\-\-rate\fR n 54 | Force decoding at sampling rate n Hz 55 | .TP 56 | \fB\-\-packet\-loss\fR n 57 | Simulate n % random packet loss 58 | .TP 59 | \fB\-V\fR 60 | Verbose mode (show bit-rate) 61 | .TP 62 | \fB\-h\fR, \fB\-\-help\fR 63 | This help 64 | .TP 65 | \fB\-v\fR, \fB\-\-version\fR 66 | Version information 67 | .TP 68 | \fB\-\-pf\fR 69 | Deprecated, use \fB\-\-enh\fR instead 70 | .TP 71 | \fB\-\-no\-pf\fR 72 | Deprecated, use \fB\-\-no\-enh\fR instead 73 | .PP 74 | More information is available from the Speex site: http://www.speex.org 75 | .PP 76 | Please report bugs to the mailing list `speex-dev@xiph.org'. 77 | .SH COPYRIGHT 78 | Copyright \(co 2002 Jean-Marc Valin 79 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | Copyright 2002-2008 Xiph.org Foundation 2 | Copyright 2002-2008 Jean-Marc Valin 3 | Copyright 2005-2007 Analog Devices Inc. 4 | Copyright 2005-2008 Commonwealth Scientific and Industrial Research 5 | Organisation (CSIRO) 6 | Copyright 1993, 2002, 2006 David Rowe 7 | Copyright 2003 EpicGames 8 | Copyright 1992-1994 Jutta Degener, Carsten Bormann 9 | 10 | Redistribution and use in source and binary forms, with or without 11 | modification, are permitted provided that the following conditions 12 | are met: 13 | 14 | - Redistributions of source code must retain the above copyright 15 | notice, this list of conditions and the following disclaimer. 16 | 17 | - Redistributions in binary form must reproduce the above copyright 18 | notice, this list of conditions and the following disclaimer in the 19 | documentation and/or other materials provided with the distribution. 20 | 21 | - Neither the name of the Xiph.org Foundation nor the names of its 22 | contributors may be used to endorse or promote products derived from 23 | this software without specific prior written permission. 24 | 25 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 26 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 27 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 28 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR 29 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 30 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 31 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 32 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 33 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 34 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 35 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 36 | -------------------------------------------------------------------------------- /speexclient/speex_jitter_buffer.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2002 Jean-Marc Valin */ 2 | /** 3 | @file speex_jitter_buffer.h 4 | @brief Adaptive jitter buffer for Speex packets only 5 | */ 6 | 7 | #include 8 | #include 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | /** @defgroup SpeexJitter SpeexJitter: Adaptive jitter buffer specifically for Speex 15 | * This is the jitter buffer that reorders UDP/RTP packets and adjusts the buffer size 16 | * to maintain good quality and low latency. This is a simplified version that works only 17 | * with Speex, but is much easier to use. 18 | * @{ 19 | */ 20 | 21 | /** Speex jitter-buffer state. Never use it directly! */ 22 | typedef struct SpeexJitter { 23 | SpeexBits current_packet; /**< Current Speex packet */ 24 | int valid_bits; /**< True if Speex bits are valid */ 25 | JitterBuffer *packets; /**< Generic jitter buffer state */ 26 | void *dec; /**< Pointer to Speex decoder */ 27 | spx_int32_t frame_size; /**< Frame size of Speex decoder */ 28 | } SpeexJitter; 29 | 30 | /** Initialise jitter buffer 31 | * 32 | * @param jitter State of the Speex jitter buffer 33 | * @param decoder Speex decoder to call 34 | * @param sampling_rate Sampling rate used by the decoder 35 | */ 36 | void speex_jitter_init(SpeexJitter *jitter, void *decoder, int sampling_rate); 37 | 38 | /** Destroy jitter buffer */ 39 | void speex_jitter_destroy(SpeexJitter *jitter); 40 | 41 | /** Put one packet into the jitter buffer */ 42 | void speex_jitter_put(SpeexJitter *jitter, char *packet, int len, int timestamp); 43 | 44 | /** Get one packet from the jitter buffer */ 45 | void speex_jitter_get(SpeexJitter *jitter, spx_int16_t *out, int *start_offset); 46 | 47 | /** Get pointer timestamp of jitter buffer */ 48 | int speex_jitter_get_pointer_timestamp(SpeexJitter *jitter); 49 | 50 | #ifdef __cplusplus 51 | } 52 | #endif 53 | 54 | /* @} */ 55 | -------------------------------------------------------------------------------- /win32/speex.iss: -------------------------------------------------------------------------------- 1 | ; Script generated by the Inno Setup Script Wizard. 2 | ; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! 3 | 4 | [Setup] 5 | AppName=Speex 6 | AppVerName=Speex V1.1.6 7 | AppPublisherURL=http://www.speex.org 8 | AppSupportURL=http://www.speex.org 9 | AppUpdatesURL=http://www.speex.org 10 | DefaultDirName={pf}\Speex 11 | DefaultGroupName=Speex 12 | AllowNoIcons=yes 13 | LicenseFile=..\COPYING 14 | InfoAfterFile=..\README 15 | OutputDir=. 16 | OutputBaseFilename=speex_win32_1.1.6_setup 17 | ; uncomment the following line if you want your installation to run on NT 3.51 too. 18 | ; MinVersion=4,3.51 19 | 20 | [Tasks] 21 | ;Name: "desktopicon"; Description: "Create a &desktop icon"; GroupDescription: "Additional icons:"; MinVersion: 4,4 22 | 23 | [Dirs] 24 | Name: "{app}" 25 | Name: "{app}\doc" 26 | Name: "{app}\html" 27 | Name: "{app}\libspeex" 28 | Name: "{app}\libspeex\include" 29 | 30 | [Files] 31 | Source: "speexdec\Release\speexdec.exe"; DestDir: "{app}"; Flags: ignoreversion 32 | Source: "speexenc\Release\speexenc.exe"; DestDir: "{app}"; Flags: ignoreversion 33 | Source: "libspeex\Release\libspeex.lib"; DestDir: "{app}\libspeex"; Flags: ignoreversion 34 | Source: "libspeex\Release\libspeex.exp"; DestDir: "{app}\libspeex"; Flags: ignoreversion 35 | Source: "libspeex\Release\libspeex.dll"; DestDir: "{app}\libspeex"; Flags: ignoreversion 36 | Source: "..\include\speex\speex.h"; DestDir: "{app}\libspeex\include"; Flags: ignoreversion 37 | Source: "..\include\speex\speex_bits.h"; DestDir: "{app}\libspeex\include"; Flags: ignoreversion 38 | Source: "..\include\speex\speex_callbacks.h"; DestDir: "{app}\libspeex\include"; Flags: ignoreversion 39 | Source: "..\include\speex\speex_header.h"; DestDir: "{app}\libspeex\include"; Flags: ignoreversion 40 | Source: "..\include\speex\speex_stereo.h"; DestDir: "{app}\libspeex\include"; Flags: ignoreversion 41 | Source: "..\doc\manual.pdf"; DestDir: "{app}\doc"; Flags: ignoreversion 42 | 43 | [Run] 44 | 45 | -------------------------------------------------------------------------------- /doc/sampleenc.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | /*The frame size in hardcoded for this sample code but it doesn't have to be*/ 5 | #define FRAME_SIZE 160 6 | int main(int argc, char **argv) 7 | { 8 | char *inFile; 9 | FILE *fin; 10 | short in[FRAME_SIZE]; 11 | float input[FRAME_SIZE]; 12 | char cbits[200]; 13 | int nbBytes; 14 | /*Holds the state of the encoder*/ 15 | void *state; 16 | /*Holds bits so they can be read and written to by the Speex routines*/ 17 | SpeexBits bits; 18 | int i, tmp; 19 | 20 | /*Create a new encoder state in narrowband mode*/ 21 | state = speex_encoder_init(&speex_nb_mode); 22 | 23 | /*Set the quality to 8 (15 kbps)*/ 24 | tmp=8; 25 | speex_encoder_ctl(state, SPEEX_SET_QUALITY, &tmp); 26 | 27 | inFile = argv[1]; 28 | fin = fopen(inFile, "r"); 29 | 30 | /*Initialization of the structure that holds the bits*/ 31 | speex_bits_init(&bits); 32 | while (1) 33 | { 34 | /*Read a 16 bits/sample audio frame*/ 35 | fread(in, sizeof(short), FRAME_SIZE, fin); 36 | if (feof(fin)) 37 | break; 38 | /*Copy the 16 bits values to float so Speex can work on them*/ 39 | for (i=0;i 2 | 3 | 4 | Speex and patents 5 | 6 | 7 | 8 | 9 | 10 |
11 |

Position regarding patents

12 | 13 |
The goal of Speex is to provide a codec that is open-source 14 | (released under the LGPL) 15 | and that can be used in open-source software. This implies that it also has 16 | to be free from patent restrictions. Unfortunately, the field of speech coding 17 | known to be a real patent minefield and to make the matter worse, each country 18 | has its own patent laws and list of granted patents so tracking them all 19 | would be next to impossible. This is why we cannot provide an absolute warranty 20 | that Speex is indeed completely patent-free.
21 |
22 | That being said, we are doing our best to keep away from known patents and 23 | we do not patent the algorithms we use. That's about all we can do about it. 24 | If you are aware of a patent issue with Speex, please let us know.
26 |
27 | Normally there shouldn't be any problem when you use Speex. However for the 28 | reasons explained above, if you are thinking about using Speex commercially, 29 | we strongly suggest that you have a closer look at patent issues with respect 30 | to your country. Note that this is not specific to Speex, since many "standardized" 31 | codecs have an unclear patent status (like MP3, GSM and probably 34 | others), not to mention the risks of a previously unknown patent holder claiming 35 | rights on a standardized codec long after standardization (GIF, JPEG).
36 |
37 |
38 | 39 | 40 | -------------------------------------------------------------------------------- /doc/sampledec.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | /*The frame size in hardcoded for this sample code but it doesn't have to be*/ 5 | #define FRAME_SIZE 160 6 | int main(int argc, char **argv) 7 | { 8 | char *outFile; 9 | FILE *fout; 10 | /*Holds the audio that will be written to file (16 bits per sample)*/ 11 | short out[FRAME_SIZE]; 12 | /*Speex handle samples as float, so we need an array of floats*/ 13 | float output[FRAME_SIZE]; 14 | char cbits[200]; 15 | int nbBytes; 16 | /*Holds the state of the decoder*/ 17 | void *state; 18 | /*Holds bits so they can be read and written to by the Speex routines*/ 19 | SpeexBits bits; 20 | int i, tmp; 21 | 22 | /*Create a new decoder state in narrowband mode*/ 23 | state = speex_decoder_init(&speex_nb_mode); 24 | 25 | /*Set the perceptual enhancement on*/ 26 | tmp=1; 27 | speex_decoder_ctl(state, SPEEX_SET_ENH, &tmp); 28 | 29 | outFile = argv[1]; 30 | fout = fopen(outFile, "w"); 31 | 32 | /*Initialization of the structure that holds the bits*/ 33 | speex_bits_init(&bits); 34 | while (1) 35 | { 36 | /*Read the size encoded by sampleenc, this part will likely be 37 | different in your application*/ 38 | fread(&nbBytes, sizeof(int), 1, stdin); 39 | fprintf (stderr, "nbBytes: %d\n", nbBytes); 40 | if (feof(stdin)) 41 | break; 42 | 43 | /*Read the "packet" encoded by sampleenc*/ 44 | fread(cbits, 1, nbBytes, stdin); 45 | /*Copy the data into the bit-stream struct*/ 46 | speex_bits_read_from(&bits, cbits, nbBytes); 47 | 48 | /*Decode the data*/ 49 | speex_decode(state, &bits, output); 50 | 51 | /*Copy from float to short (16 bits) for output*/ 52 | for (i=0;i 0.5.2 37 | - Added buildroot and docdir and ldconfig. Makes it builadble by non-roots 38 | and also doesn't write to actual library paths when building. 39 | 40 | %prep 41 | %setup 42 | 43 | %build 44 | export CFLAGS='-O3' 45 | ./configure --prefix=/usr --enable-shared --enable-static 46 | make 47 | 48 | %install 49 | rm -rf $RPM_BUILD_ROOT 50 | make DESTDIR=$RPM_BUILD_ROOT install 51 | 52 | %post -p /sbin/ldconfig 53 | %postun -p /sbin/ldconfig 54 | 55 | %files 56 | %defattr(644,root,root,755) 57 | %doc COPYING AUTHORS ChangeLog NEWS README 58 | %doc doc/manual.pdf 59 | /usr/share/man/man1/speexenc.1* 60 | /usr/share/man/man1/speexdec.1* 61 | %attr(755,root,root) %{_bindir}/speex* 62 | %attr(755,root,root) %{_libdir}/libspeex*.so* 63 | 64 | %files devel 65 | %defattr(644,root,root,755) 66 | %attr(755,root,root) %{_libdir}/libspeex*.la 67 | %{_includedir}/speex/speex*.h 68 | /usr/share/aclocal/speex.m4 69 | %{_libdir}/pkgconfig/speex.pc 70 | %{_libdir}/pkgconfig/speexdsp.pc 71 | %{_libdir}/libspeex*.a 72 | -------------------------------------------------------------------------------- /libspeex/Makefile.am: -------------------------------------------------------------------------------- 1 | # Disable automatic dependency tracking if using other tools than gcc and gmake 2 | #AUTOMAKE_OPTIONS = no-dependencies 3 | 4 | if BUILD_VORBIS_PSY 5 | VPSY_SOURCE=vorbis_psy.c 6 | if BUILD_KISS_FFT 7 | FFTSRC=kiss_fft.c _kiss_fft_guts.h kiss_fft.h kiss_fftr.c kiss_fftr.h 8 | else 9 | if BUILD_SMALLFT 10 | FFTSRC=smallft.c 11 | else 12 | FFTSRC= 13 | endif 14 | endif 15 | else 16 | VPSY_SOURCE= 17 | FFTSRC= 18 | endif 19 | 20 | AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_builddir)/include/speex -I$(top_builddir) @OGG_CFLAGS@ @FFT_CFLAGS@ 21 | 22 | lib_LTLIBRARIES = libspeex.la 23 | 24 | # Sources for compilation in the library 25 | libspeex_la_SOURCES = $(VPSY_SOURCE) $(FFTSRC) cb_search.c exc_10_32_table.c exc_8_128_table.c \ 26 | filters.c gain_table.c hexc_table.c high_lsp_tables.c lsp.c \ 27 | ltp.c speex.c stereo.c vbr.c vq.c bits.c exc_10_16_table.c \ 28 | exc_20_32_table.c exc_5_256_table.c exc_5_64_table.c gain_table_lbr.c hexc_10_32_table.c \ 29 | lpc.c lsp_tables_nb.c modes.c modes_wb.c nb_celp.c quant_lsp.c sb_celp.c \ 30 | speex_callbacks.c speex_header.c window.c 31 | 32 | 33 | noinst_HEADERS = arch.h bfin.h cb_search_arm4.h cb_search_bfin.h cb_search_sse.h \ 34 | filters.h filters_arm4.h filters_bfin.h filters_sse.h fixed_arm4.h \ 35 | fixed_arm5e.h fixed_bfin.h fixed_debug.h lpc.h lpc_bfin.h ltp.h ltp_arm4.h \ 36 | ltp_sse.h math_approx.h misc_bfin.h nb_celp.h quant_lsp.h sb_celp.h \ 37 | stack_alloc.h vbr.h vq.h vq_arm4.h vq_bfin.h vq_sse.h cb_search.h fftwrap.h \ 38 | fixed_generic.h lsp.h lsp_bfin.h ltp_bfin.h modes.h os_support.h \ 39 | quant_lsp_bfin.h smallft.h vorbis_psy.h 40 | 41 | 42 | libspeex_la_LDFLAGS = -no-undefined -version-info @SPEEX_LT_CURRENT@:@SPEEX_LT_REVISION@:@SPEEX_LT_AGE@ 43 | libspeex_la_LIBADD = $(LIBM) 44 | 45 | if BUILD_BINARIES 46 | noinst_PROGRAMS = testenc testenc_wb testenc_uwb 47 | testenc_SOURCES = testenc.c 48 | testenc_LDADD = libspeex.la $(LIBM) 49 | testenc_wb_SOURCES = testenc_wb.c 50 | testenc_wb_LDADD = libspeex.la $(LIBM) 51 | testenc_uwb_SOURCES = testenc_uwb.c 52 | testenc_uwb_LDADD = libspeex.la $(LIBM) 53 | endif 54 | -------------------------------------------------------------------------------- /ti/speex_C55_test/speex_C55_test.pjt: -------------------------------------------------------------------------------- 1 | ; Code Composer Project File, Version 2.0 (do not modify or remove this line) 2 | 3 | [Project Settings] 4 | ProjectDir="C:\Speex\speex_14274\ti\speex_C55_test\" 5 | ProjectType=Executable 6 | CPUFamily=TMS320C55XX 7 | Tool="Compiler" 8 | Tool="CustomBuilder" 9 | Tool="DspBiosBuilder" 10 | Tool="Linker" 11 | Config="Debug" 12 | Config="Release" 13 | 14 | [Source Files] 15 | Source="..\..\libspeex\bits.c" 16 | Source="..\..\libspeex\cb_search.c" 17 | Source="..\..\libspeex\exc_10_16_table.c" 18 | Source="..\..\libspeex\exc_10_32_table.c" 19 | Source="..\..\libspeex\exc_20_32_table.c" 20 | Source="..\..\libspeex\exc_5_256_table.c" 21 | Source="..\..\libspeex\exc_5_64_table.c" 22 | Source="..\..\libspeex\exc_8_128_table.c" 23 | Source="..\..\libspeex\filters.c" 24 | Source="..\..\libspeex\gain_table.c" 25 | Source="..\..\libspeex\gain_table_lbr.c" 26 | Source="..\..\libspeex\lpc.c" 27 | Source="..\..\libspeex\lsp.c" 28 | Source="..\..\libspeex\lsp_tables_nb.c" 29 | Source="..\..\libspeex\ltp.c" 30 | Source="..\..\libspeex\modes.c" 31 | Source="..\..\libspeex\nb_celp.c" 32 | Source="..\..\libspeex\quant_lsp.c" 33 | Source="..\..\libspeex\sb_celp.c" 34 | Source="..\..\libspeex\speex.c" 35 | Source="..\..\libspeex\speex_callbacks.c" 36 | Source="..\..\libspeex\vbr.c" 37 | Source="..\..\libspeex\vq.c" 38 | Source="..\..\libspeex\window.c" 39 | Source="..\..\ti\testenc-TI-C5x.c" 40 | Source="speex_C55_test.cmd" 41 | 42 | ["Compiler" Settings: "Debug"] 43 | Options=-g -q -o3 -fr"..\ti\speex_C55_test\Debug" -i"..\ti" -i"..\include" -d"_DEBUG" -d"CONFIG_TI_C55X" -d"HAVE_CONFIG_H" -mn 44 | 45 | ["Compiler" Settings: "Release"] 46 | Options=-q -o2 -fr"..\ti\speex_C55_test\Release" -i"..\ti" -i"..\include" -d"CONFIG_TI_C55X" -d"HAVE_CONFIG_H" -mn 47 | 48 | ["DspBiosBuilder" Settings: "Debug"] 49 | Options=-v55 50 | 51 | ["DspBiosBuilder" Settings: "Release"] 52 | Options=-v55 53 | 54 | ["Linker" Settings: "Debug"] 55 | Options=-q -c -m".\Debug\speex_C55_test.map" -o".\Debug\speex_C55_test.out" -w -x 56 | 57 | ["Linker" Settings: "Release"] 58 | Options=-q -c -m".\Release\speex_C55_test.map" -o".\Release\speex_C55_test.out" -w -x 59 | 60 | -------------------------------------------------------------------------------- /ti/speex_C64_test/speex_C64_test.pjt: -------------------------------------------------------------------------------- 1 | ; Code Composer Project File, Version 2.0 (do not modify or remove this line) 2 | 3 | [Project Settings] 4 | ProjectDir="C:\Speex\speex_14274\ti\speex_C64_test\" 5 | ProjectType=Executable 6 | CPUFamily=TMS320C64XX 7 | Tool="Compiler" 8 | Tool="CustomBuilder" 9 | Tool="DspBiosBuilder" 10 | Tool="Linker" 11 | Config="Debug" 12 | Config="Release" 13 | 14 | [Source Files] 15 | Source="..\..\..\..\CCStudio_v3.1\C6000\cgtools\lib\rts6400.lib" 16 | Source="..\..\libspeex\bits.c" 17 | Source="..\..\libspeex\cb_search.c" 18 | Source="..\..\libspeex\exc_10_16_table.c" 19 | Source="..\..\libspeex\exc_10_32_table.c" 20 | Source="..\..\libspeex\exc_20_32_table.c" 21 | Source="..\..\libspeex\exc_5_256_table.c" 22 | Source="..\..\libspeex\exc_5_64_table.c" 23 | Source="..\..\libspeex\exc_8_128_table.c" 24 | Source="..\..\libspeex\filters.c" 25 | Source="..\..\libspeex\gain_table.c" 26 | Source="..\..\libspeex\gain_table_lbr.c" 27 | Source="..\..\libspeex\lpc.c" 28 | Source="..\..\libspeex\lsp.c" 29 | Source="..\..\libspeex\lsp_tables_nb.c" 30 | Source="..\..\libspeex\ltp.c" 31 | Source="..\..\libspeex\modes.c" 32 | Source="..\..\libspeex\nb_celp.c" 33 | Source="..\..\libspeex\quant_lsp.c" 34 | Source="..\..\libspeex\sb_celp.c" 35 | Source="..\..\libspeex\speex.c" 36 | Source="..\..\libspeex\speex_callbacks.c" 37 | Source="..\..\libspeex\vbr.c" 38 | Source="..\..\libspeex\vq.c" 39 | Source="..\..\libspeex\window.c" 40 | Source="..\testenc-TI-C64x.c" 41 | Source="speex_C64_test.cmd" 42 | 43 | ["Compiler" Settings: "Debug"] 44 | Options=-g -o3 -fr"$(Proj_dir)\Debug" -i"..\ti" -i"..\include" -d"_DEBUG" -d"CONFIG_TI_C6X" -d"HAVE_CONFIG_H" -mv6400 45 | 46 | ["Compiler" Settings: "Release"] 47 | Options=-o3 -fr"$(Proj_dir)\Release" -i"..\ti" -i"..\include" -d"HAVE_CONFIG_H" -mv6400 48 | 49 | ["DspBiosBuilder" Settings: "Debug"] 50 | Options=-v6x 51 | 52 | ["DspBiosBuilder" Settings: "Release"] 53 | Options=-v6x 54 | 55 | ["Linker" Settings: "Debug"] 56 | Options=-c -m".\Debug\speex_C64_test.map" -o".\Debug\speex_C64_test.out" -w -x 57 | 58 | ["Linker" Settings: "Release"] 59 | Options=-c -m".\Release\speex_C64_test.map" -o".\Release\speex_C64_test.out" -w -x 60 | 61 | -------------------------------------------------------------------------------- /ti/speex_C54_test/speex_C54_test.pjt: -------------------------------------------------------------------------------- 1 | ; Code Composer Project File, Version 2.0 (do not modify or remove this line) 2 | 3 | [Project Settings] 4 | ProjectDir="C:\Speex\speex_14274\ti\speex_C54_test\" 5 | ProjectType=Executable 6 | CPUFamily=TMS320C54XX 7 | Tool="Compiler" 8 | Tool="CustomBuilder" 9 | Tool="DspBiosBuilder" 10 | Tool="Linker" 11 | Config="Debug" 12 | Config="Release" 13 | 14 | [Source Files] 15 | Source="..\..\libspeex\bits.c" 16 | Source="..\..\libspeex\cb_search.c" 17 | Source="..\..\libspeex\exc_10_16_table.c" 18 | Source="..\..\libspeex\exc_10_32_table.c" 19 | Source="..\..\libspeex\exc_20_32_table.c" 20 | Source="..\..\libspeex\exc_5_256_table.c" 21 | Source="..\..\libspeex\exc_5_64_table.c" 22 | Source="..\..\libspeex\exc_8_128_table.c" 23 | Source="..\..\libspeex\filters.c" 24 | Source="..\..\libspeex\gain_table.c" 25 | Source="..\..\libspeex\gain_table_lbr.c" 26 | Source="..\..\libspeex\lpc.c" 27 | Source="..\..\libspeex\lsp.c" 28 | Source="..\..\libspeex\lsp_tables_nb.c" 29 | Source="..\..\libspeex\ltp.c" 30 | Source="..\..\libspeex\modes.c" 31 | Source="..\..\libspeex\nb_celp.c" 32 | Source="..\..\libspeex\quant_lsp.c" 33 | Source="..\..\libspeex\sb_celp.c" 34 | Source="..\..\libspeex\speex.c" 35 | Source="..\..\libspeex\speex_callbacks.c" 36 | Source="..\..\libspeex\vbr.c" 37 | Source="..\..\libspeex\vq.c" 38 | Source="..\..\libspeex\window.c" 39 | Source="..\..\ti\testenc-TI-C5x.c" 40 | Source="speex_C54_test.cmd" 41 | 42 | ["Compiler" Settings: "Debug"] 43 | Options=-g -q -o3 -fr"..\ti\speex_C54_test\Debug" -i"..\ti" -i"..\include" -d"_DEBUG" -d"CONFIG_TI_C54X" -d"HAVE_CONFIG_H" -d"NO_LONGLONG" -mf -ms 44 | 45 | ["Compiler" Settings: "Release"] 46 | Options=-q -o2 -fr"..\ti\speex_C54_test\Release" -i"..\ti" -i"..\include" -d"CONFIG_TI_C54X" -d"HAVE_CONFIG_H" -d"NO_LONGLONG" -mf -ms 47 | 48 | ["DspBiosBuilder" Settings: "Debug"] 49 | Options=-v54 50 | 51 | ["DspBiosBuilder" Settings: "Release"] 52 | Options=-v54 53 | 54 | ["Linker" Settings: "Debug"] 55 | Options=-q -c -heap4096 -m".\Debug\speex_C54_test.map" -o".\Debug\speex_C54_test.out" -stack4096 -w -x 56 | 57 | ["Linker" Settings: "Release"] 58 | Options=-q -c -m".\Release\speex_C54_test.map" -o".\Release\speex_C54_test.out" -w -x 59 | 60 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /symbian/bld.inf: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2003 Commonwealth Scientific and Industrial Research 3 | Organisation (CSIRO) Australia 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 CSIRO Australia 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 A 23 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION 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 | PRJ_EXPORTS 34 | 35 | ..\include\speex\speex_bits.h \epoc32\include\speex\speex_bits.h 36 | ..\include\speex\speex_callbacks.h \epoc32\include\speex\speex_callbacks.h 37 | ..\include\speex\speex_config_types.h \epoc32\include\speex\speex_config_types.h 38 | ..\include\speex\speex.h \epoc32\include\speex\speex.h 39 | ..\include\speex\speex_header.h \epoc32\include\speex\speex_header.h 40 | ..\include\speex\speex_stereo.h \epoc32\include\speex\speex_stereo.h 41 | ..\include\speex\speex_types.h \epoc32\include\speex\speex_types.h 42 | 43 | 44 | PRJ_MMPFILES 45 | 46 | speex.mmp 47 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /libspeex/misc_bfin.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2005 Analog Devices */ 2 | /** 3 | @file misc_bfin.h 4 | @author Jean-Marc Valin 5 | @brief Various compatibility routines for Speex (Blackfin version) 6 | */ 7 | /* 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions 10 | are met: 11 | 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | 15 | - Redistributions in binary form must reproduce the above copyright 16 | notice, this list of conditions and the following disclaimer in the 17 | documentation and/or other materials provided with the distribution. 18 | 19 | - Neither the name of the Xiph.org Foundation nor the names of its 20 | contributors may be used to endorse or promote products derived from 21 | this software without specific prior written permission. 22 | 23 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 26 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR 27 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 28 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 29 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 30 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 31 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 32 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 33 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 | */ 35 | 36 | #include "bfin.h" 37 | 38 | #define OVERRIDE_SPEEX_MOVE 39 | void *speex_move (void *dest, void *src, int n) 40 | { 41 | __asm__ __volatile__ 42 | ( 43 | "L0 = 0;\n\t" 44 | "I0 = %0;\n\t" 45 | "R0 = [I0++];\n\t" 46 | "LOOP move%= LC0 = %2;\n\t" 47 | "LOOP_BEGIN move%=;\n\t" 48 | "[%1++] = R0 || R0 = [I0++];\n\t" 49 | "LOOP_END move%=;\n\t" 50 | "[%1++] = R0;\n\t" 51 | : "=a" (src), "=a" (dest) 52 | : "a" ((n>>2)-1), "0" (src), "1" (dest) 53 | : "R0", "I0", "L0", "memory" BFIN_HWLOOP0_REGS 54 | ); 55 | return dest; 56 | } 57 | -------------------------------------------------------------------------------- /ti/speex_C64_test/speex_C64_test.cmd: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2005 Psi Systems, Inc. 2 | File: speex_C64_test.cmd 3 | Linker command file with memory allocation for TI TMS320C6415 processor 4 | for use with TI Code Composer (TM) DSP development tools. 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 | -stack 0x10000 35 | -heap 0x10000 36 | 37 | 38 | MEMORY 39 | { 40 | VECRAM : origin = 0x0, len = 0x200 41 | IPRAM : origin = 0x200, len = 0x40000 42 | IDRAM : origin = 0x80000, len = 0x70000 43 | } 44 | 45 | SECTIONS 46 | { 47 | .vectors > VECRAM 48 | .text > IPRAM 49 | 50 | .bss > IDRAM 51 | .cinit > IDRAM 52 | .const > IDRAM 53 | .far > IDRAM 54 | .stack > IDRAM 55 | .cio > IDRAM 56 | .sysmem > IDRAM 57 | .switch > IDRAM 58 | .myheap > IDRAM 59 | } 60 | -------------------------------------------------------------------------------- /libspeex/fftwrap.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2005 Jean-Marc Valin 2 | File: fftwrap.h 3 | 4 | Wrapper for various FFTs 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 | #ifndef FFTWRAP_H 36 | #define FFTWRAP_H 37 | 38 | #include "arch.h" 39 | 40 | /** Compute tables for an FFT */ 41 | void *spx_fft_init(int size); 42 | 43 | /** Destroy tables for an FFT */ 44 | void spx_fft_destroy(void *table); 45 | 46 | /** Forward (real to half-complex) transform */ 47 | void spx_fft(void *table, spx_word16_t *in, spx_word16_t *out); 48 | 49 | /** Backward (half-complex to real) transform */ 50 | void spx_ifft(void *table, spx_word16_t *in, spx_word16_t *out); 51 | 52 | /** Forward (real to half-complex) transform of float data */ 53 | void spx_fft_float(void *table, float *in, float *out); 54 | 55 | /** Backward (half-complex to real) transform of float data */ 56 | void spx_ifft_float(void *table, float *in, float *out); 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /symbian/speex.mmp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2003 Commonwealth Scientific and Industrial Research 3 | Organisation (CSIRO) Australia 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 CSIRO Australia 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 A 23 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION 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 | TARGET speex.lib 34 | TARGETTYPE lib 35 | UID 0 36 | MACRO HAVE_CONFIG_H 37 | SOURCEPATH ..\libspeex 38 | SOURCE bits.c cb_search.c exc_5_64_table.c exc_5_256_table.c exc_8_128_table.c 39 | SOURCE exc_10_16_table.c exc_10_32_table.c exc_20_32_table.c fftwrap.c kiss_fft.c kiss_fftr.c filters.c gain_table.c 40 | SOURCE gain_table_lbr.c hexc_10_32_table.c hexc_table.c high_lsp_tables.c 41 | SOURCE lbr_48k_tables.c lpc.c lsp.c lsp_tables_nb.c ltp.c math_approx.c misc.c 42 | SOURCE modes.c nb_celp.c quant_lsp.c sb_celp.c smallft.c 43 | SOURCE speex.c speex_callbacks.c speex_header.c stereo.c vbr.c vq.c window.c 44 | USERINCLUDE . ..\include\speex 45 | SYSTEMINCLUDE \epoc32\include \epoc32\include\libc ..\include 46 | -------------------------------------------------------------------------------- /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 average_energy; 51 | float last_energy; 52 | float last_log_energy[VBR_MEMORY_SIZE]; 53 | float accum_sum; 54 | float last_pitch_coef; 55 | float soft_pitch; 56 | float last_quality; 57 | float noise_level; 58 | float noise_accum; 59 | float noise_accum_count; 60 | int consec_noise; 61 | } VBRState; 62 | 63 | void vbr_init(VBRState *vbr); 64 | 65 | float vbr_analysis(VBRState *vbr, spx_word16_t *sig, int len, int pitch, float pitch_coef); 66 | 67 | void vbr_destroy(VBRState *vbr); 68 | 69 | #endif 70 | -------------------------------------------------------------------------------- /symbian/config.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2003 Commonwealth Scientific and Industrial Research 3 | Organisation (CSIRO) Australia 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 CSIRO Australia 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 A 23 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION 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 | #ifndef CONFIG_H 34 | #define CONFIG_H 35 | 36 | /* An inline macro is required for use of the inline keyword as not all C compilers support */ 37 | /* inline. It is officially C99 and C++ only */ 38 | 39 | #ifdef __WINS__ 40 | 41 | #define inline __inline 42 | 43 | /* Disable some pointless/stupid warnings */ 44 | 45 | #pragma warning(disable: 4100) /* unreferenced formal parameter */ 46 | #pragma warning(disable: 4127) /* conditional expression is constant */ 47 | #pragma warning(disable: 4305) /* truncation from '...' to '...' */ 48 | #pragma warning(disable: 4244) /* conversion from '...' to '...', possible loss of data */ 49 | #pragma warning(disable: 4701) /* local variable may be be used without having been initialized */ 50 | 51 | #endif /* ! __WINS__ */ 52 | 53 | /* Use only fixed point arithmetic */ 54 | 55 | #define FIXED_POINT 1 56 | 57 | #endif /* ! CONFIG_H */ 58 | -------------------------------------------------------------------------------- /speexclient/alsa_device.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2004-2006 Jean-Marc Valin 3 | Copyright (C) 2006 Commonwealth Scientific and Industrial Research 4 | Organisation (CSIRO) Australia 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are 8 | met: 9 | 10 | 1. Redistributions of source code must retain the above copyright notice, 11 | this list of conditions and the following disclaimer. 12 | 13 | 2. 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 | 3. The name of the author may not be used to endorse or promote products 18 | derived from this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 21 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 24 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 25 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 28 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 29 | ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | POSSIBILITY OF SUCH DAMAGE. 31 | 32 | */ 33 | 34 | #ifndef ALSA_DEVICE_H 35 | #define ALSA_DEVICE_H 36 | 37 | #include 38 | 39 | #ifdef __cplusplus 40 | extern "C" { 41 | #endif 42 | 43 | struct AlsaDevice_; 44 | 45 | typedef struct AlsaDevice_ AlsaDevice; 46 | 47 | AlsaDevice *alsa_device_open(char *device_name, unsigned int rate, int channels, int period); 48 | 49 | void alsa_device_close(AlsaDevice *dev); 50 | 51 | int alsa_device_read(AlsaDevice *dev, short *pcm, int len); 52 | 53 | int alsa_device_write(AlsaDevice *dev, const short *pcm, int len); 54 | 55 | int alsa_device_capture_ready(AlsaDevice *dev, struct pollfd *pfds, unsigned int nfds); 56 | 57 | int alsa_device_playback_ready(AlsaDevice *dev, struct pollfd *pfds, unsigned int nfds); 58 | 59 | void alsa_device_start(AlsaDevice *dev); 60 | 61 | int alsa_device_nfds(AlsaDevice *dev); 62 | 63 | void alsa_device_getfds(AlsaDevice *dev, struct pollfd *pfds, unsigned int nfds); 64 | 65 | #ifdef __cplusplus 66 | } 67 | #endif 68 | 69 | #endif 70 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /src/speexenc.1: -------------------------------------------------------------------------------- 1 | .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.29. 2 | .TH SPEEXENC "1" "September 2003" "speexenc version 1.1" "User Commands" 3 | .SH NAME 4 | speexenc \- The reference implementation speex encoder. 5 | .SH SYNOPSIS 6 | .B speexenc 7 | [\fIoptions\fR] \fIinput_file output_file\fR 8 | .SH DESCRIPTION 9 | Encodes input_file using Speex. It can read the WAV or raw files. 10 | .SS "input_file can be:" 11 | .TP 12 | filename.wav 13 | wav file 14 | .TP 15 | filename.* 16 | Raw PCM file (any extension other than .wav) 17 | .TP 18 | - 19 | stdin 20 | .SS "output_file can be:" 21 | .TP 22 | filename.spx 23 | Speex file 24 | .TP 25 | - 26 | stdout 27 | .SH OPTIONS 28 | .TP 29 | \fB\-n\fR, \fB\-\-narrowband\fR 30 | Narrowband (8 kHz) input file 31 | .TP 32 | \fB\-w\fR, \fB\-\-wideband\fR 33 | Wideband (16 kHz) input file 34 | .HP 35 | \fB\-u\fR, \fB\-\-ultra\-wideband\fR "Ultra-wideband" (32 kHz) input file 36 | .TP 37 | \fB\-\-quality\fR n 38 | Encoding quality (0-10), default 8 39 | .TP 40 | \fB\-\-bitrate\fR n 41 | Encoding bit-rate (use bit-rate n or lower) 42 | .TP 43 | \fB\-\-vbr\fR 44 | Enable variable bit-rate (VBR) 45 | .TP 46 | \fB\-\-abr\fR rate 47 | Enable average bit-rate (ABR) at rate bps 48 | .TP 49 | \fB\-\-vad\fR 50 | Enable voice activity detection (VAD) 51 | .TP 52 | \fB\-\-dtx\fR 53 | Enable file-based discontinuous transmission (DTX) 54 | .TP 55 | \fB\-\-comp\fR n 56 | Set encoding complexity (0-10), default 3 57 | .TP 58 | \fB\-\-nframes\fR n 59 | Number of frames per Ogg packet (1-10), default 1 60 | .TP 61 | \fB\-\-comment\fR 62 | Add the given string as an extra comment. This may be 63 | used multiple times 64 | .TP 65 | \fB\-\-author\fR 66 | Author of this track 67 | .TP 68 | \fB\-\-title\fR 69 | Title for this track 70 | .TP 71 | \fB\-h\fR, \fB\-\-help\fR 72 | This help 73 | .TP 74 | \fB\-v\fR, \fB\-\-version\fR 75 | Version information 76 | .TP 77 | \fB\-V\fR 78 | Verbose mode (show bit-rate) 79 | .SS "Raw input options:" 80 | .TP 81 | \fB\-\-rate\fR n 82 | Sampling rate for raw input 83 | .TP 84 | \fB\-\-stereo\fR 85 | Consider raw input as stereo 86 | .TP 87 | \fB\-\-le\fR 88 | Raw input is little-endian 89 | .TP 90 | \fB\-\-be\fR 91 | Raw input is big-endian 92 | .TP 93 | \fB\-\-8bit\fR 94 | Raw input is 8-bit unsigned 95 | .TP 96 | \fB\-\-16bit\fR 97 | Raw input is 16-bit signed 98 | .PP 99 | Default raw PCM input is 16-bit, little-endian, mono 100 | .PP 101 | More information is available from the Speex site: http://www.speex.org 102 | .PP 103 | Please report bugs to the mailing list `speex-dev@xiph.org'. 104 | .SH COPYRIGHT 105 | Copyright \(co 2002 Jean-Marc Valin 106 | -------------------------------------------------------------------------------- /speexclient/speex_jitter_buffer.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "speex_jitter_buffer.h" 3 | 4 | #ifndef NULL 5 | #define NULL 0 6 | #endif 7 | 8 | 9 | void speex_jitter_init(SpeexJitter *jitter, void *decoder, int sampling_rate) 10 | { 11 | jitter->dec = decoder; 12 | speex_decoder_ctl(decoder, SPEEX_GET_FRAME_SIZE, &jitter->frame_size); 13 | 14 | jitter->packets = jitter_buffer_init(jitter->frame_size); 15 | 16 | speex_bits_init(&jitter->current_packet); 17 | jitter->valid_bits = 0; 18 | 19 | } 20 | 21 | void speex_jitter_destroy(SpeexJitter *jitter) 22 | { 23 | jitter_buffer_destroy(jitter->packets); 24 | speex_bits_destroy(&jitter->current_packet); 25 | } 26 | 27 | void speex_jitter_put(SpeexJitter *jitter, char *packet, int len, int timestamp) 28 | { 29 | JitterBufferPacket p; 30 | p.data = packet; 31 | p.len = len; 32 | p.timestamp = timestamp; 33 | p.span = jitter->frame_size; 34 | jitter_buffer_put(jitter->packets, &p); 35 | } 36 | 37 | void speex_jitter_get(SpeexJitter *jitter, spx_int16_t *out, int *current_timestamp) 38 | { 39 | int i; 40 | int ret; 41 | spx_int32_t activity; 42 | char data[2048]; 43 | JitterBufferPacket packet; 44 | packet.data = data; 45 | packet.len = 2048; 46 | 47 | if (jitter->valid_bits) 48 | { 49 | /* Try decoding last received packet */ 50 | ret = speex_decode_int(jitter->dec, &jitter->current_packet, out); 51 | if (ret == 0) 52 | { 53 | jitter_buffer_tick(jitter->packets); 54 | return; 55 | } else { 56 | jitter->valid_bits = 0; 57 | } 58 | } 59 | 60 | ret = jitter_buffer_get(jitter->packets, &packet, jitter->frame_size, NULL); 61 | 62 | if (ret != JITTER_BUFFER_OK) 63 | { 64 | /* No packet found */ 65 | 66 | /*fprintf (stderr, "lost/late frame\n");*/ 67 | /*Packet is late or lost*/ 68 | speex_decode_int(jitter->dec, NULL, out); 69 | } else { 70 | speex_bits_read_from(&jitter->current_packet, packet.data, packet.len); 71 | /* Decode packet */ 72 | ret = speex_decode_int(jitter->dec, &jitter->current_packet, out); 73 | if (ret == 0) 74 | { 75 | jitter->valid_bits = 1; 76 | } else { 77 | /* Error while decoding */ 78 | for (i=0;iframe_size;i++) 79 | out[i]=0; 80 | } 81 | } 82 | speex_decoder_ctl(jitter->dec, SPEEX_GET_ACTIVITY, &activity); 83 | if (activity < 30) 84 | jitter_buffer_update_delay(jitter->packets, &packet, NULL); 85 | jitter_buffer_tick(jitter->packets); 86 | } 87 | 88 | int speex_jitter_get_pointer_timestamp(SpeexJitter *jitter) 89 | { 90 | return jitter_buffer_get_pointer_timestamp(jitter->packets); 91 | } 92 | -------------------------------------------------------------------------------- /src/wav_io.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2002 Jean-Marc Valin 2 | File: wav_io.h 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 WAV_IO_H 33 | #define WAV_IO_H 34 | 35 | #include 36 | #include "speex/speex_types.h" 37 | 38 | #if !defined(__LITTLE_ENDIAN__) && ( defined(WORDS_BIGENDIAN) || defined(__BIG_ENDIAN__) ) 39 | #define le_short(s) ((short) ((unsigned short) (s) << 8) | ((unsigned short) (s) >> 8)) 40 | #define be_short(s) ((short) (s)) 41 | #else 42 | #define le_short(s) ((short) (s)) 43 | #define be_short(s) ((short) ((unsigned short) (s) << 8) | ((unsigned short) (s) >> 8)) 44 | #endif 45 | 46 | /** Convert little endian */ 47 | static inline spx_int32_t le_int(spx_int32_t i) 48 | { 49 | #if !defined(__LITTLE_ENDIAN__) && ( defined(WORDS_BIGENDIAN) || defined(__BIG_ENDIAN__) ) 50 | spx_uint32_t ui, ret; 51 | ui = i; 52 | ret = ui>>24; 53 | ret |= (ui>>8)&0x0000ff00; 54 | ret |= (ui<<8)&0x00ff0000; 55 | ret |= (ui<<24); 56 | return ret; 57 | #else 58 | return i; 59 | #endif 60 | } 61 | 62 | int read_wav_header(FILE *file, int *rate, int *channels, int *format, spx_int32_t *size); 63 | 64 | void write_wav_header(FILE *file, int rate, int channels, int format, int size); 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /ti/speex_C55_test/speex_C55_test.cmd: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2005 Psi Systems, Inc. 2 | File: speex_C55_test.cmd 3 | Linker command file with memory allocation for TI TMS320VC5509A processor 4 | for use with TI Code Composer (TM) DSP development tools. 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 | -c 35 | -stack 0x1c00 36 | -heap 0x1000 /* If private memory allocation is used for Speex */ 37 | /*-heap 0x6000 / * If calloc is used for Speex */ 38 | -sysstack 0x200 39 | -lrts55.lib 40 | 41 | MEMORY 42 | { 43 | DARAM: origin = 0x200, len = 0x7e00 44 | DARAM_B: origin = 0x8000, len = 0x8000 45 | VECT: origin = 0x100, len = 0x100 46 | SARAM_A: origin = 0x10000, len = 0x10000 47 | SARAM_B: origin = 0x20000, len = 0x20000 48 | } 49 | 50 | SECTIONS 51 | { 52 | .vectors: {} > VECT 53 | .bootmem: {} > DARAM 54 | .text: {} > SARAM_B 55 | .cinit: {} > SARAM_B 56 | .switch: {} > SARAM_B 57 | .bss: {} > DARAM 58 | /* .far: {} > DARAM*/ 59 | .const: {} > DARAM 60 | .sysmem: {} > DARAM_B 61 | .cio: {} > DARAM 62 | .stack: {} > DARAM 63 | .sysstack: {} > DARAM 64 | .myheap: {} > SARAM_A 65 | } 66 | -------------------------------------------------------------------------------- /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(const spx_lsp_t *freq, spx_coef_t *ak, int lpcrdr, char *stack); 58 | 59 | /*Added by JMV*/ 60 | 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, spx_word16_t margin); 61 | 62 | #endif /* __AK2LSPD__ */ 63 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /tmv/misc_tm.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2007 Hong Zhiqian */ 2 | /** 3 | @file misc_tm.h 4 | @author Hong Zhiqian 5 | @brief Various compatibility routines for Speex (TriMedia version) 6 | */ 7 | /* 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions 10 | are met: 11 | 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | 15 | - Redistributions in binary form must reproduce the above copyright 16 | notice, this list of conditions and the following disclaimer in the 17 | documentation and/or other materials provided with the distribution. 18 | 19 | - Neither the name of the Xiph.org Foundation nor the names of its 20 | contributors may be used to endorse or promote products derived from 21 | this software without specific prior written permission. 22 | 23 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 26 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR 27 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 28 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 29 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 30 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 31 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 32 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 33 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 | */ 35 | #include 36 | 37 | 38 | #if TM_PROFILE 39 | int __profile_begin; 40 | int __profile_end; 41 | #endif 42 | 43 | #define OVERRIDE_SPEEX_ALLOC 44 | void *speex_alloc (int size) 45 | { 46 | void *ptr; 47 | 48 | if ( tmmlMalloc(0, size, (pVoid*)&ptr, tmmlMallocCacheAligned | tmmlMallocCleared) != TM_OK ) 49 | { return NULL; 50 | } 51 | 52 | return ptr; 53 | } 54 | 55 | 56 | #define OVERRIDE_SPEEX_ALLOC_SCRATCH 57 | void *speex_alloc_scratch (int size) 58 | { 59 | void *ptr; 60 | 61 | if ( tmmlMalloc(0, size, (pVoid*)&ptr, tmmlMallocCacheAligned | tmmlMallocCleared) != TM_OK ) 62 | { return NULL; 63 | } 64 | 65 | return ptr; 66 | } 67 | 68 | 69 | #define OVERRIDE_SPEEX_REALLOC 70 | void *speex_realloc (void *ptr, int size) 71 | { 72 | if ( tmmlRealloc(0, size, (pVoid)ptr, (pVoid*)&ptr, tmmlMallocCacheAligned | tmmlMallocCleared) != TM_OK ) 73 | { return NULL; 74 | } 75 | 76 | return ptr; 77 | } 78 | 79 | 80 | #define OVERRIDE_SPEEX_FREE 81 | void speex_free (void *ptr) 82 | { 83 | tmmlFree(ptr); 84 | } 85 | 86 | 87 | #define OVERRIDE_SPEEX_FREE_SCRATCH 88 | void speex_free_scratch (void *ptr) 89 | { 90 | tmmlFree(ptr); 91 | } 92 | 93 | -------------------------------------------------------------------------------- /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 "speex/speex_bits.h" 39 | #include "arch.h" 40 | 41 | #define MAX_LSP_SIZE 20 42 | 43 | #define NB_CDBK_SIZE 64 44 | #define NB_CDBK_SIZE_LOW1 64 45 | #define NB_CDBK_SIZE_LOW2 64 46 | #define NB_CDBK_SIZE_HIGH1 64 47 | #define NB_CDBK_SIZE_HIGH2 64 48 | 49 | /*Narrowband codebooks*/ 50 | extern const signed char cdbk_nb[]; 51 | extern const signed char cdbk_nb_low1[]; 52 | extern const signed char cdbk_nb_low2[]; 53 | extern const signed char cdbk_nb_high1[]; 54 | extern const signed char cdbk_nb_high2[]; 55 | 56 | /* Quantizes narrowband LSPs with 30 bits */ 57 | void lsp_quant_nb(spx_lsp_t *lsp, spx_lsp_t *qlsp, int order, SpeexBits *bits); 58 | 59 | /* Decodes quantized narrowband LSPs */ 60 | void lsp_unquant_nb(spx_lsp_t *lsp, int order, SpeexBits *bits); 61 | 62 | /* Quantizes low bit-rate narrowband LSPs with 18 bits */ 63 | void lsp_quant_lbr(spx_lsp_t *lsp, spx_lsp_t *qlsp, int order, SpeexBits *bits); 64 | 65 | /* Decodes quantized low bit-rate narrowband LSPs */ 66 | void lsp_unquant_lbr(spx_lsp_t *lsp, int order, SpeexBits *bits); 67 | 68 | /* Quantizes high-band LSPs with 12 bits */ 69 | void lsp_quant_high(spx_lsp_t *lsp, spx_lsp_t *qlsp, int order, SpeexBits *bits); 70 | 71 | /* Decodes high-band LSPs */ 72 | void lsp_unquant_high(spx_lsp_t *lsp, int order, SpeexBits *bits); 73 | 74 | #endif 75 | -------------------------------------------------------------------------------- /src/wave_out.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2002, John Edwards 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions 5 | are met: 6 | 7 | - Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | 10 | - Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | 14 | - Neither the name of the Xiph.org Foundation nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR 22 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 23 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 25 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | // WAVE_OUT.H - Necessary stuff for WIN_AUDIO 32 | 33 | #ifndef WAVE_OUT_H 34 | #define WAVE_OUT_H 35 | 36 | #include 37 | #include 38 | #ifdef __MINGW32__ 39 | #include 40 | #endif 41 | 42 | #define VERSION_STRING "\n 0.7.0\n" 43 | 44 | #define Cdecl __cdecl 45 | #define __attribute__(x) 46 | #define sleep(__sec) Sleep ((__sec) * 1000) 47 | #define inline __inline 48 | #define restrict 49 | 50 | //// constants ///////////////////////////////////////////////////// 51 | 52 | #define CD_SAMPLE_FREQ 44.1e3 53 | #define SAMPLE_SIZE 16 54 | #define SAMPLE_SIZE_STRING "" 55 | #define WINAUDIO_FD ((FILE_T)-128) 56 | #define FILE_T FILE* 57 | #define INVALID_FILEDESC NULL 58 | 59 | //// Simple types ////////////////////////////////////////////////// 60 | 61 | typedef signed int Int; // at least -32767...+32767, fast type 62 | typedef unsigned int Uint; // at least 0...65535, fast type 63 | typedef long double Ldouble; // most exact floating point format 64 | 65 | //// procedures/functions ////////////////////////////////////////// 66 | // wave_out.c 67 | Int Set_WIN_Params ( FILE_T dummyFile , Ldouble SampleFreq, Uint BitsPerSample, Uint Channels); 68 | int WIN_Play_Samples ( const void* buff, size_t len ); 69 | int WIN_Audio_close ( void ); 70 | 71 | #endif /* WAVE_OUT_H */ 72 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /src/skeleton.h: -------------------------------------------------------------------------------- 1 | /* 2 | * skeleton.h 3 | * author: Tahseen Mohammad 4 | */ 5 | 6 | #ifndef _SKELETON_H 7 | #define _SKELETON_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | #ifdef WIN32 14 | #define snprintf _snprintf 15 | #endif 16 | 17 | #include 18 | 19 | #define SKELETON_VERSION_MAJOR 3 20 | #define SKELETON_VERSION_MINOR 0 21 | #define FISHEAD_IDENTIFIER "fishead\0" 22 | #define FISBONE_IDENTIFIER "fisbone\0" 23 | #define FISHEAD_SIZE 64 24 | #define FISBONE_SIZE 52 25 | #define FISBONE_MESSAGE_HEADER_OFFSET 44 26 | 27 | /* fishead_packet holds a fishead header packet. */ 28 | typedef struct { 29 | ogg_uint16_t version_major; /* skeleton version major */ 30 | ogg_uint16_t version_minor; /* skeleton version minor */ 31 | /* Start time of the presentation 32 | * For a new stream presentationtime & basetime is same. */ 33 | ogg_int64_t ptime_n; /* presentation time numerator */ 34 | ogg_int64_t ptime_d; /* presentation time denominator */ 35 | ogg_int64_t btime_n; /* basetime numerator */ 36 | ogg_int64_t btime_d; /* basetime denominator */ 37 | /* will holds the time of origin of the stream, a 20 bit field. */ 38 | unsigned char UTC[20]; 39 | } fishead_packet; 40 | 41 | /* fisbone_packet holds a fisbone header packet. */ 42 | typedef struct { 43 | ogg_uint32_t serial_no; /* serial no of the corresponding stream */ 44 | ogg_uint32_t nr_header_packet; /* number of header packets */ 45 | /* granule rate is the temporal resolution of the logical bitstream */ 46 | ogg_int64_t granule_rate_n; /* granule rate numerator */ 47 | ogg_int64_t granule_rate_d; /* granule rate denominator */ 48 | ogg_int64_t start_granule; /* start granule value */ 49 | ogg_uint32_t preroll; /* preroll */ 50 | unsigned char granule_shift; /* 1 byte value holding the granule shift */ 51 | char *message_header_fields; /* holds all the message header fields */ 52 | /* current total size of the message header fields, for realloc purpose, initially zero */ 53 | ogg_uint32_t current_header_size; 54 | } fisbone_packet; 55 | 56 | extern int write_ogg_page_to_file(ogg_page *og, FILE *out); 57 | extern int add_message_header_field(fisbone_packet *fp, char *header_key, char *header_value); 58 | /* remember to deallocate the returned ogg_packet properly */ 59 | extern ogg_packet ogg_from_fishead(fishead_packet *fp); 60 | extern ogg_packet ogg_from_fisbone(fisbone_packet *fp); 61 | extern fishead_packet fishead_from_ogg(ogg_packet *op); 62 | extern fisbone_packet fisbone_from_ogg(ogg_packet *op); 63 | extern int add_fishead_to_stream(ogg_stream_state *os, fishead_packet *fp); 64 | extern int add_fisbone_to_stream(ogg_stream_state *os, fisbone_packet *fp); 65 | extern int add_eos_packet_to_stream(ogg_stream_state *os); 66 | extern int flush_ogg_stream_to_file(ogg_stream_state *os, FILE *out); 67 | 68 | #ifdef __cplusplus 69 | } 70 | #endif 71 | 72 | #endif /* _SKELETON_H */ 73 | 74 | 75 | 76 | 77 | 78 | 79 | -------------------------------------------------------------------------------- /README.TI-DSP: -------------------------------------------------------------------------------- 1 | These are all of the changes and additions necessary to build a loopback application for the 2 | TI C6415, C5509A, or C5416 simulators using the TI Code Composer Studio (CCS) development system. 3 | A trial version of the tools can be downloaded from the TI website. 4 | 5 | This build runs 8kbps narrowband, with minimum complexity. 6 | 7 | Several changes are introduced in Speex 1.1.11 which are used in these applications: 8 | 9 | arch.h: Added switch for compilers not supporting "long long" (C55x does, C54x, CCS 2.x C64x does not) 10 | bits.c: Allow external definition for max buffer size, changed MAX_BYTES_PER_FRAME 11 | to MAX_CHARS_PER_FRAME for consistency 12 | misc.c: Added override switches to alloc routines, conditional include of user file "user_misc.h". 13 | These changes allow manual memory allocation rather than using heap 14 | 15 | The arch.h change allows operation with 2.x versions of Code Composer Studio. 16 | The bits.c change reduces the data memory usage. 17 | The misc.c change allows private memory allocation, for cases where it is not 18 | desirable to use the normal heap. 19 | 20 | Added files: 21 | 22 | testenc-TI-C5x.c (For C54x and C55x builds, derived from testenc.c, 23 | manual alloc, byte packing/unpacking added) 24 | testenc-TI-C64x.c (For C64x builds, derived from testenc.c, manual alloc, byte packing/unpacking added) 25 | 26 | config.h (not automatically generated, sets memory sizes, enables/disables manual alloc) 27 | user_misc.h (contains the manual memory alloc routines, with debug code to display mem usage) 28 | speex\speex_config_types.h (match Speex types to compiler types, not generated from types.in) 29 | 30 | speex_c54_test\speex_c54_test.cmd (C5416 linker command file) 31 | speex_c54_test\speex_c54_test.pjt (Code Composer Studio Project File ) 32 | speex_c55_test\speex_c55_test.cmd (C5509A linker command file) 33 | speex_c55_test\speex_c55_test.pjt (Code Composer Studio Project File ) 34 | speex_c64_test\speex_c64_test.cmd (C6415 linker command file) 35 | speex_c64_test\speex_c64_test.pjt (Code Composer Studio Project File ) 36 | 37 | samples\male.snd 38 | 39 | Usage: 40 | 1. Create a Speex 1.1.11 (or later) source tree. 41 | 2. Edit the files testenc-TI-C5x.c and/or testenc-TI-C64x.c to change the hard-coded path 42 | for the test audio and data files. 43 | This build uses the file e:\speextrunktest\samples\male.snd. 44 | Note: This is a headerless 16-bit stereo audio file derived from the male.wav test file 45 | http://www.speex.org/samples/male.wav 46 | 3. Edit the .pjt file with a text editor and change projdir or projectdir to the correct path 47 | (one place near the top of the file). 48 | 4. Edit config.h if desired, to change the memory allocation method (calloc or manual), 49 | and to enable/disable debug prints for the memory allocation 50 | (this makes it easier to determine the required size). 51 | 5. Run Code Composer Studio, and open the project for the desired target (e.g. speex_c55_test). 52 | Note that the correct simulator must be selected (in CCS Setup) before starting CCS. 53 | 6. Build and run the simulation. 54 | 55 | Note that assembly optimizations will be required to run C54x in real time. 56 | There are no assembly optimizations in any of these builds. 57 | -------------------------------------------------------------------------------- /ti/speex_C54_test/speex_C54_test.cmd: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2005 Psi Systems, Inc. 2 | File: speex_C54_test.cmd 3 | Linker command file with memory allocation for TI TMS320VC5416 processor 4 | for use with TI Code Composer (TM) DSP development tools. 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 | -c 35 | -stack 0x2000 36 | -heap 0x1000 /* If private memory allocation is used for Speex */ 37 | /*-heap 0x6000 /* If calloc is used for Speex */ 38 | -lrts_ext.lib 39 | 40 | MEMORY 41 | { 42 | /* PAGE 0: P_DARAM03: origin = 0x80, len = 0x7f00*/ 43 | PAGE 0: P_DARAM03: origin = 0x5000, len = 0x2f80 44 | PAGE 0: VECT: origin = 0x7f80, len = 0x80 45 | PAGE 0: P_DARAM47: origin = 0x18000, len = 0x8000 46 | PAGE 0: SARAM03: origin = 0x28000, len = 0x8000 47 | PAGE 0: SARAM47: origin = 0x38000, len = 0x8000 48 | 49 | PAGE 1: USERREGS: origin = 0x60, len = 0x1a 50 | PAGE 1: BIOSREGS: origin = 0x7c, len = 0x4 51 | PAGE 1: CSLREGS: origin = 0x7a, len = 0x2 52 | D_DARAM03: origin = 0x80, len = 0x4f80 53 | D_DARAM47: origin = 0x8000, len = 0x8000 54 | } 55 | 56 | SECTIONS 57 | { 58 | .vectors: {} > VECT PAGE 0 59 | .bootmem: {rts_ext.lib (.text)} > P_DARAM03 PAGE 0 60 | /* .bootmem: {} > P_DARAM03 PAGE 0 */ 61 | .text: {} > SARAM03 PAGE 0 62 | .cinit: {} > SARAM03 PAGE 0 63 | .switch: {} > SARAM03 PAGE 0 64 | .bss: {} > D_DARAM03 | D_DARAM47 PAGE 1 65 | .far: {} > D_DARAM03 | D_DARAM47 PAGE 1 66 | .const: {} > D_DARAM03 | D_DARAM47 PAGE 1 67 | .sysmem: {} > D_DARAM47 PAGE 1 68 | .cio: {} > D_DARAM03 | D_DARAM47 PAGE 1 69 | .stack: {} > D_DARAM03 | D_DARAM47 PAGE 1 70 | .myheap: {} > D_DARAM47 PAGE 1 71 | } 72 | -------------------------------------------------------------------------------- /libspeex/kiss_fft.h: -------------------------------------------------------------------------------- 1 | #ifndef KISS_FFT_H 2 | #define KISS_FFT_H 3 | 4 | #include 5 | #include 6 | #include "arch.h" 7 | 8 | #ifdef __cplusplus 9 | extern "C" { 10 | #endif 11 | 12 | /* 13 | ATTENTION! 14 | If you would like a : 15 | -- a utility that will handle the caching of fft objects 16 | -- real-only (no imaginary time component ) FFT 17 | -- a multi-dimensional FFT 18 | -- a command-line utility to perform ffts 19 | -- a command-line utility to perform fast-convolution filtering 20 | 21 | Then see kfc.h kiss_fftr.h kiss_fftnd.h fftutil.c kiss_fastfir.c 22 | in the tools/ directory. 23 | */ 24 | 25 | #ifdef USE_SIMD 26 | # include 27 | # define kiss_fft_scalar __m128 28 | #define KISS_FFT_MALLOC(nbytes) memalign(16,nbytes) 29 | #else 30 | #define KISS_FFT_MALLOC speex_alloc 31 | #endif 32 | 33 | 34 | #ifdef FIXED_POINT 35 | #include "arch.h" 36 | # define kiss_fft_scalar spx_int16_t 37 | #else 38 | # ifndef kiss_fft_scalar 39 | /* default is float */ 40 | # define kiss_fft_scalar float 41 | # endif 42 | #endif 43 | 44 | typedef struct { 45 | kiss_fft_scalar r; 46 | kiss_fft_scalar i; 47 | }kiss_fft_cpx; 48 | 49 | typedef struct kiss_fft_state* kiss_fft_cfg; 50 | 51 | /* 52 | * kiss_fft_alloc 53 | * 54 | * Initialize a FFT (or IFFT) algorithm's cfg/state buffer. 55 | * 56 | * typical usage: kiss_fft_cfg mycfg=kiss_fft_alloc(1024,0,NULL,NULL); 57 | * 58 | * The return value from fft_alloc is a cfg buffer used internally 59 | * by the fft routine or NULL. 60 | * 61 | * If lenmem is NULL, then kiss_fft_alloc will allocate a cfg buffer using malloc. 62 | * The returned value should be free()d when done to avoid memory leaks. 63 | * 64 | * The state can be placed in a user supplied buffer 'mem': 65 | * If lenmem is not NULL and mem is not NULL and *lenmem is large enough, 66 | * then the function places the cfg in mem and the size used in *lenmem 67 | * and returns mem. 68 | * 69 | * If lenmem is not NULL and ( mem is NULL or *lenmem is not large enough), 70 | * then the function returns NULL and places the minimum cfg 71 | * buffer size in *lenmem. 72 | * */ 73 | 74 | kiss_fft_cfg kiss_fft_alloc(int nfft,int inverse_fft,void * mem,size_t * lenmem); 75 | 76 | /* 77 | * kiss_fft(cfg,in_out_buf) 78 | * 79 | * Perform an FFT on a complex input buffer. 80 | * for a forward FFT, 81 | * fin should be f[0] , f[1] , ... ,f[nfft-1] 82 | * fout will be F[0] , F[1] , ... ,F[nfft-1] 83 | * Note that each element is complex and can be accessed like 84 | f[k].r and f[k].i 85 | * */ 86 | void kiss_fft(kiss_fft_cfg cfg,const kiss_fft_cpx *fin,kiss_fft_cpx *fout); 87 | 88 | /* 89 | A more generic version of the above function. It reads its input from every Nth sample. 90 | * */ 91 | void kiss_fft_stride(kiss_fft_cfg cfg,const kiss_fft_cpx *fin,kiss_fft_cpx *fout,int fin_stride); 92 | 93 | /* If kiss_fft_alloc allocated a buffer, it is one contiguous 94 | buffer and can be simply free()d when no longer needed*/ 95 | #define kiss_fft_free speex_free 96 | 97 | /* 98 | Cleans up some memory that gets managed internally. Not necessary to call, but it might clean up 99 | your compiler output to call this before you exit. 100 | */ 101 | void kiss_fft_cleanup(void); 102 | 103 | 104 | #ifdef __cplusplus 105 | } 106 | #endif 107 | 108 | #endif 109 | -------------------------------------------------------------------------------- /libspeex/cb_search_sse.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2004 Jean-Marc Valin */ 2 | /** 3 | @file cb_search_sse.h 4 | @brief Fixed codebook functions (SSE version) 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 | #include 36 | 37 | static inline void _spx_mm_getr_ps (__m128 U, float *__Z, float *__Y, float *__X, float *__W) 38 | { 39 | union { 40 | float __a[4]; 41 | __m128 __v; 42 | } __u; 43 | 44 | __u.__v = U; 45 | 46 | *__Z = __u.__a[0]; 47 | *__Y = __u.__a[1]; 48 | *__X = __u.__a[2]; 49 | *__W = __u.__a[3]; 50 | 51 | } 52 | 53 | #define OVERRIDE_COMPUTE_WEIGHTED_CODEBOOK 54 | static void compute_weighted_codebook(const signed char *shape_cb, const spx_sig_t *_r, float *resp, __m128 *resp2, __m128 *E, int shape_cb_size, int subvect_size, char *stack) 55 | { 56 | int i, j, k; 57 | __m128 resj, EE; 58 | VARDECL(__m128 *r); 59 | VARDECL(__m128 *shape); 60 | ALLOC(r, subvect_size, __m128); 61 | ALLOC(shape, subvect_size, __m128); 62 | for(j=0;j>2] = EE; 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /ti/config.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2005 Psi Systems, Inc. 2 | File: config.h 3 | Main Speex option include file for TI C64xx, C54xx and C55xx processors 4 | for use with TI Code Composer (TM) DSP development tools. 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 | #define FIXED_POINT 35 | #define FRAME_SIZE 160 36 | #define DISABLE_WIDEBAND 37 | #define EXPORT 38 | 39 | /* Disable DC block if doing SNR testing */ 40 | #define DISABLE_HIGHPASS 41 | 42 | /* Allow for 2 20ms narrowband blocks per frame, plus a couple of bytes */ 43 | #define MAX_CHARS_PER_FRAME (42/BYTES_PER_CHAR) 44 | 45 | /* for debug */ 46 | #undef DECODE_ONLY 47 | #define VERBOSE_ALLOC 48 | 49 | /* EITHER Allocate from fixed array (C heap not used) */ 50 | /* Enable VERBOSE_ALLOC to see how much is used */ 51 | #define MANUAL_ALLOC 52 | #define OS_SUPPORT_CUSTOM 53 | 54 | /* OR Use CALLOC (heap size must be increased in linker command file) */ 55 | //#undef MANUAL_ALLOC 56 | //#undef OS_SUPPORT_CUSTOM 57 | 58 | #if defined (CONFIG_TI_C54X) || defined (CONFIG_TI_C55X) 59 | //#define PRECISION16 60 | 61 | // These values determined by analysis for 8kbps narrowband 62 | #define SPEEXENC_PERSIST_STACK_SIZE 1000 63 | #define SPEEXENC_SCRATCH_STACK_SIZE 3000 64 | #define SPEEXDEC_PERSIST_STACK_SIZE 1000 65 | #define SPEEXDEC_SCRATCH_STACK_SIZE 1000 66 | #else /* C6X */ 67 | #define NO_LONGLONG 68 | 69 | #define SPEEXENC_PERSIST_STACK_SIZE 2000 70 | #define SPEEXENC_SCRATCH_STACK_SIZE 6000 71 | #define SPEEXDEC_PERSIST_STACK_SIZE 2000 72 | #define SPEEXDEC_SCRATCH_STACK_SIZE 2000 73 | #endif 74 | #define SPEEX_PERSIST_STACK_SIZE (SPEEXENC_PERSIST_STACK_SIZE + SPEEXDEC_PERSIST_STACK_SIZE) 75 | #define SPEEX_SCRATCH_STACK_SIZE SPEEXENC_SCRATCH_STACK_SIZE 76 | #define NB_ENC_STACK SPEEXENC_SCRATCH_STACK_SIZE 77 | #define NB_DEC_STACK SPEEXDEC_SCRATCH_STACK_SIZE 78 | 79 | -------------------------------------------------------------------------------- /libspeex/lsp_bfin.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2006 David Rowe */ 2 | /** 3 | @file lsp_bfin.h 4 | @author David Rowe 5 | @brief LSP routines optimised for the Blackfin 6 | */ 7 | /* 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions 10 | are met: 11 | 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | 15 | - Redistributions in binary form must reproduce the above copyright 16 | notice, this list of conditions and the following disclaimer in the 17 | documentation and/or other materials provided with the distribution. 18 | 19 | - Neither the name of the Xiph.org Foundation nor the names of its 20 | contributors may be used to endorse or promote products derived from 21 | this software without specific prior written permission. 22 | 23 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 26 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR 27 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 28 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 29 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 30 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 31 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 32 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 33 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 | */ 35 | 36 | #define OVERRIDE_CHEB_POLY_EVA 37 | #ifdef OVERRIDE_CHEB_POLY_EVA 38 | static inline spx_word32_t cheb_poly_eva( 39 | spx_word16_t *coef, /* P or Q coefs in Q13 format */ 40 | spx_word16_t x, /* cos of freq (-1.0 to 1.0) in Q14 format */ 41 | int m, /* LPC order/2 */ 42 | char *stack 43 | ) 44 | { 45 | spx_word32_t sum; 46 | 47 | __asm__ __volatile__ 48 | ( 49 | "P0 = %2;\n\t" /* P0: coef[m], coef[m-1],..., coef[0] */ 50 | "R4 = 8192;\n\t" /* R4: rounding constant */ 51 | "R2 = %1;\n\t" /* R2: x */ 52 | 53 | "R5 = -16383;\n\t" 54 | "R2 = MAX(R2,R5);\n\t" 55 | "R5 = 16383;\n\t" 56 | "R2 = MIN(R2,R5);\n\t" 57 | 58 | "R3 = W[P0--] (X);\n\t" /* R3: sum */ 59 | "R5 = W[P0--] (X);\n\t" 60 | "R5 = R5.L * R2.L (IS);\n\t" 61 | "R5 = R5 + R4;\n\t" 62 | "R5 >>>= 14;\n\t" 63 | "R3 = R3 + R5;\n\t" 64 | 65 | "R0 = R2;\n\t" /* R0: b0 */ 66 | "R1 = 16384;\n\t" /* R1: b1 */ 67 | "LOOP cpe%= LC0 = %3;\n\t" 68 | "LOOP_BEGIN cpe%=;\n\t" 69 | "P1 = R0;\n\t" 70 | "R0 = R2.L * R0.L (IS) || R5 = W[P0--] (X);\n\t" 71 | "R0 >>>= 13;\n\t" 72 | "R0 = R0 - R1;\n\t" 73 | "R1 = P1;\n\t" 74 | "R5 = R5.L * R0.L (IS);\n\t" 75 | "R5 = R5 + R4;\n\t" 76 | "R5 >>>= 14;\n\t" 77 | "R3 = R3 + R5;\n\t" 78 | "LOOP_END cpe%=;\n\t" 79 | "%0 = R3;\n\t" 80 | : "=&d" (sum) 81 | : "a" (x), "a" (&coef[m]), "a" (m-1) 82 | : "R0", "R1", "R3", "R2", "R4", "R5", "P0", "P1", "ASTAT" BFIN_HWLOOP0_REGS 83 | ); 84 | return sum; 85 | } 86 | #endif 87 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /libspeex/ltp_sse.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2002 Jean-Marc Valin */ 2 | /** 3 | @file ltp_sse.h 4 | @brief Long-Term Prediction functions (SSE version) 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 | #include 36 | 37 | #define OVERRIDE_INNER_PROD 38 | float inner_prod(const float *a, const float *b, int len) 39 | { 40 | int i; 41 | float ret; 42 | __m128 sum = _mm_setzero_ps(); 43 | for (i=0;i<(len>>2);i+=2) 44 | { 45 | sum = _mm_add_ps(sum, _mm_mul_ps(_mm_loadu_ps(a+0), _mm_loadu_ps(b+0))); 46 | sum = _mm_add_ps(sum, _mm_mul_ps(_mm_loadu_ps(a+4), _mm_loadu_ps(b+4))); 47 | a += 8; 48 | b += 8; 49 | } 50 | sum = _mm_add_ps(sum, _mm_movehl_ps(sum, sum)); 51 | sum = _mm_add_ss(sum, _mm_shuffle_ps(sum, sum, 0x55)); 52 | _mm_store_ss(&ret, sum); 53 | return ret; 54 | } 55 | 56 | #define OVERRIDE_PITCH_XCORR 57 | void pitch_xcorr(const float *_x, const float *_y, float *corr, int len, int nb_pitch, char *stack) 58 | { 59 | int i, offset; 60 | VARDECL(__m128 *x); 61 | VARDECL(__m128 *y); 62 | int N, L; 63 | N = len>>2; 64 | L = nb_pitch>>2; 65 | ALLOC(x, N, __m128); 66 | ALLOC(y, N+L, __m128); 67 | for (i=0;imax_scale) 67 | { 68 | sig_shift++; 69 | max_val >>= 1; 70 | } 71 | 72 | __asm__ __volatile__ ( 73 | ".normalize16loop%=: \n" 74 | 75 | "\tldr %4, [%0], #4 \n" 76 | "\tldr %5, [%0], #4 \n" 77 | "\tmov %4, %4, asr %3 \n" 78 | "\tstrh %4, [%1], #2 \n" 79 | "\tldr %4, [%0], #4 \n" 80 | "\tmov %5, %5, asr %3 \n" 81 | "\tstrh %5, [%1], #2 \n" 82 | "\tldr %5, [%0], #4 \n" 83 | "\tmov %4, %4, asr %3 \n" 84 | "\tstrh %4, [%1], #2 \n" 85 | "\tsubs %2, %2, #1 \n" 86 | "\tmov %5, %5, asr %3 \n" 87 | "\tstrh %5, [%1], #2 \n" 88 | 89 | "\tbgt .normalize16loop%=\n" 90 | : "=r" (dead1), "=r" (dead2), "=r" (dead3), "=r" (dead4), 91 | "=r" (dead5), "=r" (dead6) 92 | : "0" (x), "1" (y), "2" (len>>2), "3" (sig_shift) 93 | : "cc", "memory"); 94 | return sig_shift; 95 | } 96 | 97 | -------------------------------------------------------------------------------- /tmv/fixed_tm.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2007 Hong Zhiqian */ 2 | /** 3 | @file fixed_tm.h 4 | @author Hong Zhiqian 5 | @brief Various compatibility routines for Speex (TriMedia version) 6 | */ 7 | /* 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions 10 | are met: 11 | 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | 15 | - Redistributions in binary form must reproduce the above copyright 16 | notice, this list of conditions and the following disclaimer in the 17 | documentation and/or other materials provided with the distribution. 18 | 19 | - Neither the name of the Xiph.org Foundation nor the names of its 20 | contributors may be used to endorse or promote products derived from 21 | this software without specific prior written permission. 22 | 23 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 26 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR 27 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 28 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 29 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 30 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 31 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 32 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 33 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 | */ 35 | #ifndef FIXED_TM_H 36 | #define FIXED_TM_H 37 | 38 | #include 39 | 40 | 41 | #undef SATURATE 42 | #undef SATURATE16 43 | #undef SATURATE32 44 | #define SATURATE(x,a) iclipi(x,a) 45 | #define SATURATE16(x,a) iclipi(x,a) 46 | #define SATURATE32(x,a) iclipi(x,a) 47 | 48 | #undef EXTEND32 49 | #define EXTEND32(x) sex16(x) 50 | 51 | #undef NEG16 52 | #undef NEG32 53 | #define NEG16(x) ineg((int)(x)) 54 | #define NEG32(x) ineg(x) 55 | 56 | #undef ABS 57 | #undef ABS16 58 | #undef ABS32 59 | #define ABS(x) iabs(x) 60 | #define ABS32(x) iabs(x) 61 | #define ABS16(x) iabs((int)(x)) 62 | 63 | #undef MIN16 64 | #undef MIN32 65 | #define MIN16(a,b) imin((int)(a),(int)(b)) 66 | #define MIN32(a,b) imin(a,b) 67 | 68 | #undef MAX16 69 | #undef MAX32 70 | #define MAX16(a,b) imax((int)(a),(int)(b)) 71 | #define MAX32(a,b) imax(a,b) 72 | 73 | #undef ADD16 74 | #undef SUB16 75 | #undef ADD32 76 | #undef SUB32 77 | #undef MULT16_16 78 | #undef MULT16_16_16 79 | 80 | #define ADD16(a,b) ((int)(a) + (int)(b)) 81 | #define SUB16(a,b) ((int)(a) - (int)(b)) 82 | #define ADD32(a,b) ((int)(a) + (int)(b)) 83 | #define SUB32(a,b) ((int)(a) - (int)(b)) 84 | #define MULT16_16_16(a,b) ((int)(a) * (int)(b)) 85 | #define MULT16_16(a,b) ((int)(a) * (int)(b)) 86 | 87 | #if TM_DEBUGMEM_ALIGNNMENT 88 | #include 89 | #define TMDEBUG_ALIGNMEM(x) \ 90 | { if( ((int)(x) & (int)(0x00000003)) != 0 ) \ 91 | { printf("memory not align. file: %s, line: %d\n", __FILE__, __LINE__); \ 92 | } \ 93 | } 94 | 95 | #else 96 | #define TMDEBUG_ALIGNMEM(x) 97 | #endif 98 | 99 | #endif 100 | 101 | -------------------------------------------------------------------------------- /tmv/config.h: -------------------------------------------------------------------------------- 1 | #ifndef _CONFIG_H_ 2 | #define _CONFIG_H_ 3 | 4 | #define USE_COMPACT_KISS_FFT 5 | //#define USE_KISS_FFT 6 | 7 | #ifdef WIN32 8 | 9 | //#define FIXED_POINT 10 | 11 | #define inline __inline 12 | #define restrict 13 | 14 | #elif defined (__TCS__) 15 | 16 | #define FIXED_POINT 17 | #define PREPROCESS_MDF_FLOAT 18 | #define TM_ASM 19 | 20 | #define TM_DEBUGMEM_ALIGNNMENT 1 21 | 22 | #define TM_PROFILE 1 23 | #define TM_PROFILE_FIRMEM16 0 24 | #define TM_PROFILE_IIRMEM16 0 25 | #define TM_PROFILE_FILTERMEM16 0 26 | #define TM_PROFILE_VQNBEST 0 27 | #define TM_PROFILE_VQNBESTSIGN 0 28 | #define TM_PROFILE_COMPUTEQUANTWEIGHTS 0 29 | #define TM_PROFILE_LSPQUANT 0 30 | #define TM_PROFILE_LSPWEIGHTQUANT 0 31 | #define TM_PROFILE_LSPENFORCEMARGIN 0 32 | #define TM_PROFILE_LSPTOLPC 0 33 | #define TM_PROFILE_INNERPROD 0 34 | #define TM_PROFILE_PITCHXCORR 0 35 | #define TM_PROFILE_LSP_INTERPOLATE 0 36 | #define TM_PROFILE_CHEBPOLYEVA 0 37 | #define TM_PROFILE_COMPUTEWEIGHTEDCODEBOOK 0 38 | #define TM_PROFILE_TARGETUPDATE 0 39 | #define TM_PROFILE_SPXAUTOCORR 0 40 | #define TM_PROFILE_COMPUTEPITCHERROR 0 41 | #define TM_PROFILE_COMPUTERMS16 0 42 | #define TM_PROFILE_NORMALIZE16 0 43 | #define TM_PROFILE_BWLPC 0 44 | #define TM_PROFILE_HIGHPASS 0 45 | #define TM_PROFILE_SIGNALMUL 0 46 | #define TM_PROFILE_SIGNALDIV 0 47 | #define TM_PROFILE_COMPUTEIMPULSERESPONSE 0 48 | #define TM_PROFILE_PITCHGAINSEARCH3TAPVQ 0 49 | #define TM_PROFILE_OPENLOOPNBESTPITCH 0 50 | #define TM_PROFILE_PREPROCESSANALYSIS 0 51 | #define TM_PROFILE_UPDATENOISEPROB 0 52 | #define TM_PROFILE_COMPUTEGAINFLOOR 0 53 | #define TM_PROFILE_FILTERDCNOTCH16 0 54 | #define TM_PROFILE_MDFINNERPROD 0 55 | #define TM_PROFILE_SPECTRALMULACCUM 0 56 | #define TM_PROFILE_WEIGHTEDSPECTRALMULCONJ 0 57 | #define TM_PROFILE_MDFADJUSTPROP 0 58 | #define TM_PROFILE_SPEEXECHOGETRESIDUAL 0 59 | #define TM_PROFILE_MAXIMIZERANGE 0 60 | #define TM_PROFILE_RENORMRANGE 0 61 | #define TM_PROFILE_POWERSPECTRUM 0 62 | #define TM_PROFILE_QMFSYNTH 0 63 | #define TM_PROFILE_QMFDECOMP 0 64 | #define TM_PROFILE_FILTERBANKCOMPUTEBANK32 0 65 | #define TM_PROFILE_FILTERBANKCOMPUTEPSD16 0 66 | 67 | #define TM_UNROLL 1 68 | #define TM_UNROLL_FILTER 1 69 | #define TM_UNROLL_IIR 1 70 | #define TM_UNROLL_FIR 1 71 | #define TM_UNROLL_HIGHPASS 1 72 | #define TM_UNROLL_SIGNALMUL 1 73 | #define TM_UNROLL_SIGNALDIV 1 74 | #define TM_UNROLL_VQNBEST 1 75 | #define TM_UNROLL_VQSIGNNBEST 1 76 | #define TM_UNROLL__SPXAUTOCORR 1 77 | #define TM_UNROLL_COMPUTERMS16 1 78 | #define TM_UNROLL_COMPUTEIMPULSERESPONSE 1 79 | #define TM_UNROLL_QMFSYNTH 1 80 | #define TM_UNROLL_PITCHGAINSEARCH3TAPVQ 1 81 | #define TM_UNROLL_OPENLOOPNBESTPITCH 1 82 | #define TM_UNROLL_FILTERBANKCOMPUTEBANK32 1 83 | #define TM_UNROLL_FILTERBANKCOMPUTEPSD16 1 84 | #define TM_UNROLL_SPEEXPREPROCESSRUN 1 85 | #define TM_UNROLL_PREPROCESSANALYSIS 1 86 | #define TM_UNROLL_UPDATENOISEPROB 1 87 | #define TM_UNROLL_COMPUTEGAINFLOOR 1 88 | #define TM_UNROLL_SPEEXECHOGETRESIDUAL 1 89 | #define TM_UNROLL_SPEEXECHOCANCELLATION 1 90 | #define TM_UNROLL_FILTERDCNOTCH16 1 91 | #define TM_UNROLL_MDFINNERPRODUCT 1 92 | #define TM_UNROLL_SPECTRALMULACCUM 1 93 | #define TM_UNROLL_MDFADJUSTPROP 1 94 | 95 | #endif 96 | 97 | #endif 98 | 99 | -------------------------------------------------------------------------------- /libspeex/vorbis_psy.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2005 Jean-Marc Valin, CSIRO, Christopher Montgomery 2 | File: vorbis_psy.h 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 VORBIS_PSY_H 33 | #define VORBIS_PSY_H 34 | 35 | #ifdef VORBIS_PSYCHO 36 | 37 | #include "smallft.h" 38 | #define P_BANDS 17 /* 62Hz to 16kHz */ 39 | #define NOISE_COMPAND_LEVELS 40 40 | 41 | 42 | #define todB(x) ((x)>1e-13?log((x)*(x))*4.34294480f:-30) 43 | #define fromdB(x) (exp((x)*.11512925f)) 44 | 45 | /* The bark scale equations are approximations, since the original 46 | table was somewhat hand rolled. The below are chosen to have the 47 | best possible fit to the rolled tables, thus their somewhat odd 48 | appearance (these are more accurate and over a longer range than 49 | the oft-quoted bark equations found in the texts I have). The 50 | approximations are valid from 0 - 30kHz (nyquist) or so. 51 | 52 | all f in Hz, z in Bark */ 53 | 54 | #define toBARK(n) (13.1f*atan(.00074f*(n))+2.24f*atan((n)*(n)*1.85e-8f)+1e-4f*(n)) 55 | #define fromBARK(z) (102.f*(z)-2.f*pow(z,2.f)+.4f*pow(z,3.f)+pow(1.46f,z)-1.f) 56 | 57 | /* Frequency to octave. We arbitrarily declare 63.5 Hz to be octave 58 | 0.0 */ 59 | 60 | #define toOC(n) (log(n)*1.442695f-5.965784f) 61 | #define fromOC(o) (exp(((o)+5.965784f)*.693147f)) 62 | 63 | 64 | typedef struct { 65 | 66 | float noisewindowlo; 67 | float noisewindowhi; 68 | int noisewindowlomin; 69 | int noisewindowhimin; 70 | int noisewindowfixed; 71 | float noiseoff[P_BANDS]; 72 | float noisecompand[NOISE_COMPAND_LEVELS]; 73 | 74 | } VorbisPsyInfo; 75 | 76 | 77 | 78 | typedef struct { 79 | int n; 80 | int rate; 81 | struct drft_lookup lookup; 82 | VorbisPsyInfo *vi; 83 | 84 | float *window; 85 | float *noiseoffset; 86 | long *bark; 87 | 88 | } VorbisPsy; 89 | 90 | 91 | VorbisPsy *vorbis_psy_init(int rate, int size); 92 | void vorbis_psy_destroy(VorbisPsy *psy); 93 | void compute_curve(VorbisPsy *psy, float *audio, float *curve); 94 | void curve_to_lpc(VorbisPsy *psy, float *curve, float *awk1, float *awk2, int ord); 95 | 96 | #endif 97 | #endif 98 | -------------------------------------------------------------------------------- /doc/rtp.txt: -------------------------------------------------------------------------------- 1 | The Speex RTP payload is defined as a header, followed by any number of 2 | requests to the remote encoder and all encoded speech frames. 3 | 4 | +--------+----------+----------------+ 5 | | Header | Requests | Speech data... | 6 | +--------+----------+----------------+ 7 | 8 | The header contains only the number of frames sent 9 | encoded in 6 bits 10 | 11 | 0 1 2 3 4 5 12 | +-+-+-+-+-+-+ 13 | | NB frames | 14 | +-+-+-+-+-+-+ 15 | 16 | There can be any number of requests of the form 17 | 18 | 0 1 2 3 4 5 6 7 0 1 19 | +-+-+-+-+-+-+-+-+-+-+ 20 | |R| ReqID | ReqVal | 21 | +-+-+-+-+-+-+-+-+-+-+ 22 | 23 | where R is 1 when a request is following and 0 when there is no more 24 | request. Each request (if R=1) is composed of a 4-bit request ID (ReqID) and 25 | a 5-bit value (ReqVal) 26 | 27 | Possible values for ReqID are: 28 | 0: REQ_PERSIST ReqVal=1 for persistent requests/mode selection, 29 | 0 otherwise 30 | 1: PERSIST_ACK Acknowledge a REQ_PERSIST from the other end, 31 | ReqVal equals the value received 32 | 2: MODE Choose the encoder mode directly 33 | 3: QUALITY Choose the encoder quality 34 | 4: VBR Set VBR on (ReqVal=1) or off (ReqVal=2) 35 | 5: VBR_QUALITY Set the encoder quality for VBR mode 36 | 6: LOW_MODE Set the encoder mode for low-band (wideband only) 37 | 7: HIGH_MODE Set the encoder mode for high-band (wideband only) 38 | 39 | All requests should be considered at the receiver as a suggestion and 40 | compliance is not mandatory. The PERSIST_ACK should be sent upon receiving a 41 | REQ_PERSIST request to indicate that the request has been received. 42 | 43 | The speech data part contains speech frames one after the other. The size of 44 | the encoded frames can be found since the mode is directly encoded into each 45 | frame. 46 | 47 | For example, a frame where we request VBR to be on with quality 8 and we 48 | transmit two frames encoded at 8.35 kbps (167 bits/frame) will be: 49 | 50 | 0 1 2 3 51 | 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 52 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 53 | | NB=2 |1|ReqID=2| ReqVal=0|1|ReqID=3|ReqVal=8 |0| frame 1 | 54 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 55 | | frame 1 | 56 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 57 | | frame 1 | 58 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 59 | | frame 1 | 60 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 61 | | frame 1 | 62 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 63 | | frame 1 | 64 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 65 | |end| frame 2 | 66 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 67 | | frame 2 | 68 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 69 | | frame 2 | 70 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 71 | | frame 2 | 72 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 73 | | frame 2 | 74 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 75 | | end frame 2 |P|P|P|P|P|P| 76 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 77 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /include/speex/speex_stereo.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2002 Jean-Marc Valin*/ 2 | /** 3 | @file speex_stereo.h 4 | @brief Describes the handling for intensity stereo 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 STEREO_H 36 | #define STEREO_H 37 | /** @defgroup SpeexStereoState SpeexStereoState: Handling Speex stereo files 38 | * This describes the Speex intensity stereo encoding/decoding 39 | * @{ 40 | */ 41 | 42 | #include "speex_types.h" 43 | #include "speex_bits.h" 44 | 45 | 46 | #ifdef __cplusplus 47 | extern "C" { 48 | #endif 49 | 50 | /** If you access any of these fields directly, I'll personally come and bite you */ 51 | typedef struct SpeexStereoState { 52 | float balance; /**< Left/right balance info */ 53 | float e_ratio; /**< Ratio of energies: E(left+right)/[E(left)+E(right)] */ 54 | float smooth_left; /**< Smoothed left channel gain */ 55 | float smooth_right; /**< Smoothed right channel gain */ 56 | float reserved1; /**< Reserved for future use */ 57 | float reserved2; /**< Reserved for future use */ 58 | } SpeexStereoState; 59 | 60 | /** Deprecated. Use speex_stereo_state_init() instead. */ 61 | #define SPEEX_STEREO_STATE_INIT {1,.5,1,1,0,0} 62 | 63 | /** Initialise/create a stereo stereo state */ 64 | SpeexStereoState *speex_stereo_state_init(); 65 | 66 | /** Reset/re-initialise an already allocated stereo state */ 67 | void speex_stereo_state_reset(SpeexStereoState *stereo); 68 | 69 | /** Destroy a stereo stereo state */ 70 | void speex_stereo_state_destroy(SpeexStereoState *stereo); 71 | 72 | /** Transforms a stereo frame into a mono frame and stores intensity stereo info in 'bits' */ 73 | void speex_encode_stereo(float *data, int frame_size, SpeexBits *bits); 74 | 75 | /** Transforms a stereo frame into a mono frame and stores intensity stereo info in 'bits' */ 76 | void speex_encode_stereo_int(spx_int16_t *data, int frame_size, SpeexBits *bits); 77 | 78 | /** Transforms a mono frame into a stereo frame using intensity stereo info */ 79 | void speex_decode_stereo(float *data, int frame_size, SpeexStereoState *stereo); 80 | 81 | /** Transforms a mono frame into a stereo frame using intensity stereo info */ 82 | void speex_decode_stereo_int(spx_int16_t *data, int frame_size, SpeexStereoState *stereo); 83 | 84 | /** Callback handler for intensity stereo info */ 85 | int speex_std_stereo_request_handler(SpeexBits *bits, void *state, void *data); 86 | 87 | #ifdef __cplusplus 88 | } 89 | #endif 90 | 91 | /** @} */ 92 | #endif 93 | -------------------------------------------------------------------------------- /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 "speex/speex_bits.h" 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 | spx_int32_t *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 | spx_int32_t *seed 101 | ); 102 | 103 | #endif 104 | -------------------------------------------------------------------------------- /libspeex/testenc_uwb.c: -------------------------------------------------------------------------------- 1 | #ifdef HAVE_CONFIG_H 2 | #include "config.h" 3 | #endif 4 | 5 | #include "speex/speex_callbacks.h" 6 | #include 7 | #include 8 | 9 | #ifdef FIXED_DEBUG 10 | extern long long spx_mips; 11 | #endif 12 | 13 | #define FRAME_SIZE 640 14 | #include 15 | int main(int argc, char **argv) 16 | { 17 | char *inFile, *outFile, *bitsFile; 18 | FILE *fin, *fout, *fbits=NULL; 19 | short in_short[FRAME_SIZE]; 20 | short out_short[FRAME_SIZE]; 21 | float sigpow,errpow,snr, seg_snr=0; 22 | int snr_frames = 0; 23 | char cbits[200]; 24 | int nbBits; 25 | int i; 26 | void *st; 27 | void *dec; 28 | SpeexBits bits; 29 | spx_int32_t tmp; 30 | int bitCount=0; 31 | spx_int32_t skip_group_delay; 32 | SpeexCallback callback; 33 | 34 | sigpow = 0; 35 | errpow = 0; 36 | 37 | st = speex_encoder_init(speex_lib_get_mode(SPEEX_MODEID_UWB)); 38 | dec = speex_decoder_init(speex_lib_get_mode(SPEEX_MODEID_UWB)); 39 | 40 | callback.callback_id = SPEEX_INBAND_CHAR; 41 | callback.func = speex_std_char_handler; 42 | callback.data = stderr; 43 | speex_decoder_ctl(dec, SPEEX_SET_HANDLER, &callback); 44 | 45 | callback.callback_id = SPEEX_INBAND_MODE_REQUEST; 46 | callback.func = speex_std_mode_request_handler; 47 | callback.data = st; 48 | speex_decoder_ctl(dec, SPEEX_SET_HANDLER, &callback); 49 | 50 | tmp=0; 51 | speex_decoder_ctl(dec, SPEEX_SET_ENH, &tmp); 52 | tmp=0; 53 | speex_encoder_ctl(st, SPEEX_SET_VBR, &tmp); 54 | tmp=7; 55 | speex_encoder_ctl(st, SPEEX_SET_QUALITY, &tmp); 56 | tmp=1; 57 | speex_encoder_ctl(st, SPEEX_SET_COMPLEXITY, &tmp); 58 | 59 | speex_encoder_ctl(st, SPEEX_GET_LOOKAHEAD, &skip_group_delay); 60 | speex_decoder_ctl(dec, SPEEX_GET_LOOKAHEAD, &tmp); 61 | skip_group_delay += tmp; 62 | 63 | 64 | if (argc != 4 && argc != 3) 65 | { 66 | fprintf (stderr, "Usage: encode [in file] [out file] [bits file]\nargc = %d", argc); 67 | exit(1); 68 | } 69 | inFile = argv[1]; 70 | fin = fopen(inFile, "rb"); 71 | outFile = argv[2]; 72 | fout = fopen(outFile, "wb+"); 73 | if (argc==4) 74 | { 75 | bitsFile = argv[3]; 76 | fbits = fopen(bitsFile, "wb"); 77 | } 78 | speex_bits_init(&bits); 79 | while (!feof(fin)) 80 | { 81 | fread(in_short, sizeof(short), FRAME_SIZE, fin); 82 | if (feof(fin)) 83 | break; 84 | speex_bits_reset(&bits); 85 | 86 | speex_encode_int(st, in_short, &bits); 87 | nbBits = speex_bits_write(&bits, cbits, 200); 88 | bitCount+=bits.nbBits; 89 | 90 | if (argc==4) 91 | fwrite(cbits, 1, nbBits, fbits); 92 | speex_bits_rewind(&bits); 93 | 94 | speex_decode_int(dec, &bits, out_short); 95 | speex_bits_reset(&bits); 96 | 97 | fwrite(&out_short[skip_group_delay], sizeof(short), FRAME_SIZE-skip_group_delay, fout); 98 | skip_group_delay = 0; 99 | } 100 | fprintf (stderr, "Total encoded size: %d bits\n", bitCount); 101 | speex_encoder_destroy(st); 102 | speex_decoder_destroy(dec); 103 | 104 | rewind(fin); 105 | rewind(fout); 106 | 107 | while ( FRAME_SIZE == fread(in_short, sizeof(short), FRAME_SIZE, fin) 108 | && 109 | FRAME_SIZE == fread(out_short, sizeof(short), FRAME_SIZE,fout) ) 110 | { 111 | float s=0, e=0; 112 | for (i=0;i 3 | # Shamelessly stolen from: 4 | # Jack Moffitt 10-21-2000 5 | # Shamelessly stolen from Owen Taylor and Manish Singh 6 | 7 | dnl XIPH_PATH_SPEEX([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]) 8 | dnl Test for libspeex, and define SPEEX_CFLAGS and SPEEX_LIBS 9 | dnl 10 | AC_DEFUN([XIPH_PATH_SPEEX], 11 | [dnl 12 | dnl Get the cflags and libraries 13 | dnl 14 | AC_ARG_WITH(speex,[ --with-speex=PFX Prefix where libspeex is installed (optional)], speex_prefix="$withval", speex_prefix="") 15 | AC_ARG_WITH(speex-libraries,[ --with-speex-libraries=DIR Directory where libspeex library is installed (optional)], speex_libraries="$withval", speex_libraries="") 16 | AC_ARG_WITH(speex-includes,[ --with-speex-includes=DIR Directory where libspeex header files are installed (optional)], speex_includes="$withval", speex_includes="") 17 | AC_ARG_ENABLE(speextest, [ --disable-speextest Do not try to compile and run a test Speex program],, enable_speextest=yes) 18 | 19 | if test "x$speex_libraries" != "x" ; then 20 | SPEEX_LIBS="-L$speex_libraries" 21 | elif test "x$speex_prefix" != "x" ; then 22 | SPEEX_LIBS="-L$speex_prefix/lib" 23 | elif test "x$prefix" != "xNONE" ; then 24 | SPEEX_LIBS="-L$prefix/lib" 25 | fi 26 | 27 | SPEEX_LIBS="$SPEEX_LIBS -lspeex" 28 | 29 | if test "x$speex_includes" != "x" ; then 30 | SPEEX_CFLAGS="-I$speex_includes" 31 | elif test "x$speex_prefix" != "x" ; then 32 | SPEEX_CFLAGS="-I$speex_prefix/include" 33 | elif test "x$prefix" != "xNONE"; then 34 | SPEEX_CFLAGS="-I$prefix/include" 35 | fi 36 | 37 | AC_MSG_CHECKING(for Speex) 38 | no_speex="" 39 | 40 | 41 | if test "x$enable_speextest" = "xyes" ; then 42 | ac_save_CFLAGS="$CFLAGS" 43 | ac_save_LIBS="$LIBS" 44 | CFLAGS="$CFLAGS $SPEEX_CFLAGS" 45 | LIBS="$LIBS $SPEEX_LIBS" 46 | dnl 47 | dnl Now check if the installed Speex is sufficiently new. 48 | dnl 49 | rm -f conf.speextest 50 | AC_TRY_RUN([ 51 | #include 52 | #include 53 | #include 54 | #include 55 | 56 | int main () 57 | { 58 | system("touch conf.speextest"); 59 | return 0; 60 | } 61 | 62 | ],, no_speex=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) 63 | CFLAGS="$ac_save_CFLAGS" 64 | LIBS="$ac_save_LIBS" 65 | fi 66 | 67 | if test "x$no_speex" = "x" ; then 68 | AC_MSG_RESULT(yes) 69 | ifelse([$1], , :, [$1]) 70 | else 71 | AC_MSG_RESULT(no) 72 | if test -f conf.speextest ; then 73 | : 74 | else 75 | echo "*** Could not run Speex test program, checking why..." 76 | CFLAGS="$CFLAGS $SPEEX_CFLAGS" 77 | LIBS="$LIBS $SPEEX_LIBS" 78 | AC_TRY_LINK([ 79 | #include 80 | #include 81 | ], [ return 0; ], 82 | [ echo "*** The test program compiled, but did not run. This usually means" 83 | echo "*** that the run-time linker is not finding Speex or finding the wrong" 84 | echo "*** version of Speex. If it is not finding Speex, you'll need to set your" 85 | echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" 86 | echo "*** to the installed location Also, make sure you have run ldconfig if that" 87 | echo "*** is required on your system" 88 | echo "***" 89 | echo "*** If you have an old version installed, it is best to remove it, although" 90 | echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"], 91 | [ echo "*** The test program failed to compile or link. See the file config.log for the" 92 | echo "*** exact error that occured. This usually means Speex was incorrectly installed" 93 | echo "*** or that you have moved Speex since it was installed." ]) 94 | CFLAGS="$ac_save_CFLAGS" 95 | LIBS="$ac_save_LIBS" 96 | fi 97 | SPEEX_CFLAGS="" 98 | SPEEX_LIBS="" 99 | ifelse([$2], , :, [$2]) 100 | fi 101 | AC_SUBST(SPEEX_CFLAGS) 102 | AC_SUBST(SPEEX_LIBS) 103 | rm -f conf.speextest 104 | ]) 105 | -------------------------------------------------------------------------------- /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 spx_int32_t; 30 | typedef _G_uint32_t spx_uint32_t; 31 | typedef _G_int16_t spx_int16_t; 32 | typedef _G_uint16_t spx_uint16_t; 33 | # elif defined(__MINGW32__) 34 | typedef short spx_int16_t; 35 | typedef unsigned short spx_uint16_t; 36 | typedef int spx_int32_t; 37 | typedef unsigned int spx_uint32_t; 38 | # elif defined(__MWERKS__) 39 | typedef int spx_int32_t; 40 | typedef unsigned int spx_uint32_t; 41 | typedef short spx_int16_t; 42 | typedef unsigned short spx_uint16_t; 43 | # else 44 | /* MSVC/Borland */ 45 | typedef __int32 spx_int32_t; 46 | typedef unsigned __int32 spx_uint32_t; 47 | typedef __int16 spx_int16_t; 48 | typedef unsigned __int16 spx_uint16_t; 49 | # endif 50 | 51 | #elif defined(__MACOS__) 52 | 53 | # include 54 | typedef SInt16 spx_int16_t; 55 | typedef UInt16 spx_uint16_t; 56 | typedef SInt32 spx_int32_t; 57 | typedef UInt32 spx_uint32_t; 58 | 59 | #elif (defined(__APPLE__) && defined(__MACH__)) /* MacOS X Framework build */ 60 | 61 | # include 62 | typedef int16_t spx_int16_t; 63 | typedef u_int16_t spx_uint16_t; 64 | typedef int32_t spx_int32_t; 65 | typedef u_int32_t spx_uint32_t; 66 | 67 | #elif defined(__BEOS__) 68 | 69 | /* Be */ 70 | # include 71 | typedef int16_t spx_int16_t; 72 | typedef u_int16_t spx_uint16_t; 73 | typedef int32_t spx_int32_t; 74 | typedef u_int32_t spx_uint32_t; 75 | 76 | #elif defined (__EMX__) 77 | 78 | /* OS/2 GCC */ 79 | typedef short spx_int16_t; 80 | typedef unsigned short spx_uint16_t; 81 | typedef int spx_int32_t; 82 | typedef unsigned int spx_uint32_t; 83 | 84 | #elif defined (DJGPP) 85 | 86 | /* DJGPP */ 87 | typedef short spx_int16_t; 88 | typedef int spx_int32_t; 89 | typedef unsigned int spx_uint32_t; 90 | 91 | #elif defined(R5900) 92 | 93 | /* PS2 EE */ 94 | typedef int spx_int32_t; 95 | typedef unsigned spx_uint32_t; 96 | typedef short spx_int16_t; 97 | 98 | #elif defined(__SYMBIAN32__) 99 | 100 | /* Symbian GCC */ 101 | typedef signed short spx_int16_t; 102 | typedef unsigned short spx_uint16_t; 103 | typedef signed int spx_int32_t; 104 | typedef unsigned int spx_uint32_t; 105 | 106 | #elif defined(CONFIG_TI_C54X) || defined (CONFIG_TI_C55X) 107 | 108 | typedef short spx_int16_t; 109 | typedef unsigned short spx_uint16_t; 110 | typedef long spx_int32_t; 111 | typedef unsigned long spx_uint32_t; 112 | 113 | #elif defined(CONFIG_TI_C6X) 114 | 115 | typedef short spx_int16_t; 116 | typedef unsigned short spx_uint16_t; 117 | typedef int spx_int32_t; 118 | typedef unsigned int spx_uint32_t; 119 | 120 | #else 121 | 122 | #include "speex_config_types.h" 123 | 124 | #endif 125 | 126 | #endif /* _SPEEX_TYPES_H */ 127 | -------------------------------------------------------------------------------- /libspeex/testenc_wb.c: -------------------------------------------------------------------------------- 1 | #ifdef HAVE_CONFIG_H 2 | #include "config.h" 3 | #endif 4 | 5 | #include "speex/speex_callbacks.h" 6 | #include 7 | #include 8 | 9 | #ifdef FIXED_DEBUG 10 | extern long long spx_mips; 11 | #endif 12 | 13 | #define FRAME_SIZE 320 14 | #include 15 | int main(int argc, char **argv) 16 | { 17 | char *inFile, *outFile, *bitsFile; 18 | FILE *fin, *fout, *fbits=NULL; 19 | short in_short[FRAME_SIZE]; 20 | short out_short[FRAME_SIZE]; 21 | float sigpow,errpow,snr, seg_snr=0; 22 | int snr_frames = 0; 23 | char cbits[200]; 24 | int nbBits; 25 | int i; 26 | void *st; 27 | void *dec; 28 | SpeexBits bits; 29 | spx_int32_t tmp; 30 | int bitCount=0; 31 | spx_int32_t skip_group_delay; 32 | SpeexCallback callback; 33 | 34 | sigpow = 0; 35 | errpow = 0; 36 | 37 | st = speex_encoder_init(speex_lib_get_mode(SPEEX_MODEID_WB)); 38 | dec = speex_decoder_init(speex_lib_get_mode(SPEEX_MODEID_WB)); 39 | 40 | callback.callback_id = SPEEX_INBAND_CHAR; 41 | callback.func = speex_std_char_handler; 42 | callback.data = stderr; 43 | speex_decoder_ctl(dec, SPEEX_SET_HANDLER, &callback); 44 | 45 | callback.callback_id = SPEEX_INBAND_MODE_REQUEST; 46 | callback.func = speex_std_mode_request_handler; 47 | callback.data = st; 48 | speex_decoder_ctl(dec, SPEEX_SET_HANDLER, &callback); 49 | 50 | tmp=1; 51 | speex_decoder_ctl(dec, SPEEX_SET_ENH, &tmp); 52 | tmp=0; 53 | speex_encoder_ctl(st, SPEEX_SET_VBR, &tmp); 54 | tmp=8; 55 | speex_encoder_ctl(st, SPEEX_SET_QUALITY, &tmp); 56 | tmp=3; 57 | speex_encoder_ctl(st, SPEEX_SET_COMPLEXITY, &tmp); 58 | /*tmp=3; 59 | speex_encoder_ctl(st, SPEEX_SET_HIGH_MODE, &tmp); 60 | tmp=6; 61 | speex_encoder_ctl(st, SPEEX_SET_LOW_MODE, &tmp); 62 | */ 63 | 64 | speex_encoder_ctl(st, SPEEX_GET_LOOKAHEAD, &skip_group_delay); 65 | speex_decoder_ctl(dec, SPEEX_GET_LOOKAHEAD, &tmp); 66 | skip_group_delay += tmp; 67 | 68 | 69 | if (argc != 4 && argc != 3) 70 | { 71 | fprintf (stderr, "Usage: encode [in file] [out file] [bits file]\nargc = %d", argc); 72 | exit(1); 73 | } 74 | inFile = argv[1]; 75 | fin = fopen(inFile, "rb"); 76 | outFile = argv[2]; 77 | fout = fopen(outFile, "wb+"); 78 | if (argc==4) 79 | { 80 | bitsFile = argv[3]; 81 | fbits = fopen(bitsFile, "wb"); 82 | } 83 | speex_bits_init(&bits); 84 | while (!feof(fin)) 85 | { 86 | fread(in_short, sizeof(short), FRAME_SIZE, fin); 87 | if (feof(fin)) 88 | break; 89 | speex_bits_reset(&bits); 90 | 91 | speex_encode_int(st, in_short, &bits); 92 | nbBits = speex_bits_write(&bits, cbits, 200); 93 | bitCount+=bits.nbBits; 94 | 95 | if (argc==4) 96 | fwrite(cbits, 1, nbBits, fbits); 97 | speex_bits_rewind(&bits); 98 | 99 | speex_decode_int(dec, &bits, out_short); 100 | speex_bits_reset(&bits); 101 | 102 | fwrite(&out_short[skip_group_delay], sizeof(short), FRAME_SIZE-skip_group_delay, fout); 103 | skip_group_delay = 0; 104 | } 105 | fprintf (stderr, "Total encoded size: %d bits\n", bitCount); 106 | speex_encoder_destroy(st); 107 | speex_decoder_destroy(dec); 108 | speex_bits_destroy(&bits); 109 | 110 | rewind(fin); 111 | rewind(fout); 112 | 113 | while ( FRAME_SIZE == fread(in_short, sizeof(short), FRAME_SIZE, fin) 114 | && 115 | FRAME_SIZE == fread(out_short, sizeof(short), FRAME_SIZE,fout) ) 116 | { 117 | float s=0, e=0; 118 | for (i=0;i>2;i++) 49 | { 50 | __m128 d = _mm_mul_ps(E[i], half); 51 | for (j=0;j= 1) && (k > used || dist[i] < best_dist[k-1]); k--) 60 | { 61 | best_dist[k]=best_dist[k-1]; 62 | nbest[k] = nbest[k-1]; 63 | } 64 | best_dist[k]=dist[i]; 65 | nbest[k]=i; 66 | used++; 67 | } 68 | } 69 | } 70 | 71 | 72 | 73 | 74 | #define OVERRIDE_VQ_NBEST_SIGN 75 | 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) 76 | { 77 | int i,j,k,used; 78 | VARDECL(float *dist); 79 | VARDECL(__m128 *in); 80 | 81 | used = 0; 82 | ALLOC(dist, entries, float); 83 | 84 | ALLOC(in, len, __m128); 85 | for (i=0;i>2;i++) 88 | { 89 | __m128 d = _mm_setzero_ps(); 90 | for (j=0;j0) 98 | { 99 | sign=0; 100 | dist[i]=-dist[i]; 101 | } else 102 | { 103 | sign=1; 104 | } 105 | dist[i] += .5f*((float*)E)[i]; 106 | if (i= 1) && (k > used || dist[i] < best_dist[k-1]); k--) 109 | { 110 | best_dist[k]=best_dist[k-1]; 111 | nbest[k] = nbest[k-1]; 112 | } 113 | best_dist[k]=dist[i]; 114 | nbest[k]=i; 115 | used++; 116 | if (sign) 117 | nbest[k]+=entries; 118 | } 119 | } 120 | } 121 | -------------------------------------------------------------------------------- /include/speex/speex_header.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2002 Jean-Marc Valin */ 2 | /** 3 | @file speex_header.h 4 | @brief Describes the Speex header 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 SPEEX_HEADER_H 38 | #define SPEEX_HEADER_H 39 | /** @defgroup SpeexHeader SpeexHeader: Makes it easy to write/parse an Ogg/Speex header 40 | * This is the Speex header for the Ogg encapsulation. You don't need that if you just use RTP. 41 | * @{ 42 | */ 43 | 44 | #include "speex_types.h" 45 | 46 | #ifdef __cplusplus 47 | extern "C" { 48 | #endif 49 | 50 | struct SpeexMode; 51 | 52 | /** Length of the Speex header identifier */ 53 | #define SPEEX_HEADER_STRING_LENGTH 8 54 | 55 | /** Maximum number of characters for encoding the Speex version number in the header */ 56 | #define SPEEX_HEADER_VERSION_LENGTH 20 57 | 58 | /** Speex header info for file-based formats */ 59 | typedef struct SpeexHeader { 60 | char speex_string[SPEEX_HEADER_STRING_LENGTH]; /**< Identifies a Speex bit-stream, always set to "Speex " */ 61 | char speex_version[SPEEX_HEADER_VERSION_LENGTH]; /**< Speex version */ 62 | spx_int32_t speex_version_id; /**< Version for Speex (for checking compatibility) */ 63 | spx_int32_t header_size; /**< Total size of the header ( sizeof(SpeexHeader) ) */ 64 | spx_int32_t rate; /**< Sampling rate used */ 65 | spx_int32_t mode; /**< Mode used (0 for narrowband, 1 for wideband) */ 66 | spx_int32_t mode_bitstream_version; /**< Version ID of the bit-stream */ 67 | spx_int32_t nb_channels; /**< Number of channels encoded */ 68 | spx_int32_t bitrate; /**< Bit-rate used */ 69 | spx_int32_t frame_size; /**< Size of frames */ 70 | spx_int32_t vbr; /**< 1 for a VBR encoding, 0 otherwise */ 71 | spx_int32_t frames_per_packet; /**< Number of frames stored per Ogg packet */ 72 | spx_int32_t extra_headers; /**< Number of additional headers after the comments */ 73 | spx_int32_t reserved1; /**< Reserved for future use, must be zero */ 74 | spx_int32_t reserved2; /**< Reserved for future use, must be zero */ 75 | } SpeexHeader; 76 | 77 | /** Initializes a SpeexHeader using basic information */ 78 | void speex_init_header(SpeexHeader *header, int rate, int nb_channels, const struct SpeexMode *m); 79 | 80 | /** Creates the header packet from the header itself (mostly involves endianness conversion) */ 81 | char *speex_header_to_packet(SpeexHeader *header, int *size); 82 | 83 | /** Creates a SpeexHeader from a packet */ 84 | SpeexHeader *speex_packet_to_header(char *packet, int size); 85 | 86 | /** Frees the memory allocated by either speex_header_to_packet() or speex_packet_to_header() */ 87 | void speex_header_free(void *ptr); 88 | 89 | #ifdef __cplusplus 90 | } 91 | #endif 92 | 93 | /** @} */ 94 | #endif 95 | -------------------------------------------------------------------------------- /libspeex/vq_arm4.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2004 Jean-Marc Valin */ 2 | /** 3 | @file vq_arm4.h 4 | @brief ARM4-optimized vq routine 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 | #define OVERRIDE_VQ_NBEST 36 | 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) 37 | { 38 | int i,j; 39 | for (i=0;i 7 | #include 8 | 9 | #ifdef FIXED_DEBUG 10 | extern long long spx_mips; 11 | #endif 12 | 13 | #define FRAME_SIZE 160 14 | #include 15 | int main(int argc, char **argv) 16 | { 17 | char *inFile, *outFile, *bitsFile; 18 | FILE *fin, *fout, *fbits=NULL; 19 | short in_short[FRAME_SIZE]; 20 | short out_short[FRAME_SIZE]; 21 | int snr_frames = 0; 22 | char cbits[200]; 23 | int nbBits; 24 | int i; 25 | void *st; 26 | void *dec; 27 | SpeexBits bits; 28 | spx_int32_t tmp; 29 | int bitCount=0; 30 | spx_int32_t skip_group_delay; 31 | SpeexCallback callback; 32 | 33 | st = speex_encoder_init(speex_lib_get_mode(SPEEX_MODEID_NB)); 34 | dec = speex_decoder_init(speex_lib_get_mode(SPEEX_MODEID_NB)); 35 | 36 | /* BEGIN: You probably don't need the following in a real application */ 37 | callback.callback_id = SPEEX_INBAND_CHAR; 38 | callback.func = speex_std_char_handler; 39 | callback.data = stderr; 40 | speex_decoder_ctl(dec, SPEEX_SET_HANDLER, &callback); 41 | 42 | callback.callback_id = SPEEX_INBAND_MODE_REQUEST; 43 | callback.func = speex_std_mode_request_handler; 44 | callback.data = st; 45 | speex_decoder_ctl(dec, SPEEX_SET_HANDLER, &callback); 46 | /* END of unnecessary stuff */ 47 | 48 | tmp=1; 49 | speex_decoder_ctl(dec, SPEEX_SET_ENH, &tmp); 50 | tmp=0; 51 | speex_encoder_ctl(st, SPEEX_SET_VBR, &tmp); 52 | tmp=8; 53 | speex_encoder_ctl(st, SPEEX_SET_QUALITY, &tmp); 54 | tmp=1; 55 | speex_encoder_ctl(st, SPEEX_SET_COMPLEXITY, &tmp); 56 | 57 | /* Turn this off if you want to measure SNR (on by default) */ 58 | tmp=1; 59 | speex_encoder_ctl(st, SPEEX_SET_HIGHPASS, &tmp); 60 | speex_decoder_ctl(dec, SPEEX_SET_HIGHPASS, &tmp); 61 | 62 | speex_encoder_ctl(st, SPEEX_GET_LOOKAHEAD, &skip_group_delay); 63 | speex_decoder_ctl(dec, SPEEX_GET_LOOKAHEAD, &tmp); 64 | skip_group_delay += tmp; 65 | 66 | if (argc != 4 && argc != 3) 67 | { 68 | fprintf (stderr, "Usage: encode [in file] [out file] [bits file]\nargc = %d", argc); 69 | exit(1); 70 | } 71 | inFile = argv[1]; 72 | fin = fopen(inFile, "rb"); 73 | outFile = argv[2]; 74 | fout = fopen(outFile, "wb+"); 75 | if (argc==4) 76 | { 77 | bitsFile = argv[3]; 78 | fbits = fopen(bitsFile, "wb"); 79 | } 80 | speex_bits_init(&bits); 81 | while (!feof(fin)) 82 | { 83 | fread(in_short, sizeof(short), FRAME_SIZE, fin); 84 | if (feof(fin)) 85 | break; 86 | speex_bits_reset(&bits); 87 | 88 | speex_encode_int(st, in_short, &bits); 89 | nbBits = speex_bits_write(&bits, cbits, 200); 90 | bitCount+=bits.nbBits; 91 | 92 | if (argc==4) 93 | fwrite(cbits, 1, nbBits, fbits); 94 | speex_bits_rewind(&bits); 95 | 96 | speex_decode_int(dec, &bits, out_short); 97 | speex_bits_reset(&bits); 98 | 99 | fwrite(&out_short[skip_group_delay], sizeof(short), FRAME_SIZE-skip_group_delay, fout); 100 | skip_group_delay = 0; 101 | } 102 | fprintf (stderr, "Total encoded size: %d bits\n", bitCount); 103 | speex_encoder_destroy(st); 104 | speex_decoder_destroy(dec); 105 | speex_bits_destroy(&bits); 106 | 107 | #ifndef DISABLE_FLOAT_API 108 | { 109 | float sigpow,errpow,snr, seg_snr=0; 110 | sigpow = 0; 111 | errpow = 0; 112 | 113 | /* This code just computes SNR, so you don't need it either */ 114 | rewind(fin); 115 | rewind(fout); 116 | 117 | while ( FRAME_SIZE == fread(in_short, sizeof(short), FRAME_SIZE, fin) 118 | && 119 | FRAME_SIZE == fread(out_short, sizeof(short), FRAME_SIZE,fout) ) 120 | { 121 | float s=0, e=0; 122 | for (i=0;i