2
3
mirror of https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git synced 2025-07-14 02:27:40 -04:00

Remove old SDK code from CWE source base. Now entirely in SDK submodule.

This commit is contained in:
rarified
2021-10-17 16:50:42 -06:00
parent 3489b924ce
commit 8434eb25ce
368 changed files with 0 additions and 163385 deletions

View File

@ -1,15 +0,0 @@
Jean-Marc Valin <jean-marc.valin@hermes.usherb.ca>
All the code except the following
David Rowe <david@voicetronix.com.au> via VoiceTronix
lsp.c lsp.h
Also ideas and feedback
John Francis Edwards:
wave_out.[ch], some #ifdefs for windows port and MSVC project files
Atsuhiko Yamanaka <ymnk@jcraft.com>:
Patch to speexenc.c to add Vorbis comment format
Radim Kolar <hsn@cybermail.net>:
Patch to speexenc.c for supporting more input formats

View File

@ -1,26 +0,0 @@
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of the Xiph.org Foundation nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@ -1,6 +0,0 @@
2002/03/27 Jean-Marc Valin:
Working encoder and decoder for both narrowband and wideband.
2002/02/27 Jean-Marc Valin:
Got the basic encoder working as a demo with quantization only on some
parameters.

View File

@ -1,8 +0,0 @@
Installing Speex is as easy as:
% ./configure [--prefix=<install-path>]
% make
% make install
Note that if you are using the code from CVS, you will need to run "autogen.sh"
instead of "configure".

View File

@ -1,11 +0,0 @@
## Process this file with automake to produce Makefile.in. -*-Makefile-*-
# Disable automatic dependency tracking if using other tools than gcc and gmake
#AUTOMAKE_OPTIONS = no-dependencies
EXTRA_DIST = Speex.spec Speex.spec.in
SUBDIRS = libspeex @src@ doc win32
rpm: dist
rpmbuild -ta ${PACKAGE}-${VERSION}.tar.gz

View File

@ -1,347 +0,0 @@
# Makefile.in generated automatically by automake 1.4-p6 from Makefile.am
# Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
# Disable automatic dependency tracking if using other tools than gcc and gmake
#AUTOMAKE_OPTIONS = no-dependencies
SHELL = @SHELL@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
sbindir = @sbindir@
libexecdir = @libexecdir@
datadir = @datadir@
sysconfdir = @sysconfdir@
sharedstatedir = @sharedstatedir@
localstatedir = @localstatedir@
libdir = @libdir@
infodir = @infodir@
mandir = @mandir@
includedir = @includedir@
oldincludedir = /usr/include
DESTDIR =
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
top_builddir = .
ACLOCAL = @ACLOCAL@
AUTOCONF = @AUTOCONF@
AUTOMAKE = @AUTOMAKE@
AUTOHEADER = @AUTOHEADER@
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
INSTALL_DATA = @INSTALL_DATA@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
transform = @program_transform_name@
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
host_alias = @host_alias@
host_triplet = @host@
AS = @AS@
CC = @CC@
DLLTOOL = @DLLTOOL@
ECHO = @ECHO@
EXEEXT = @EXEEXT@
LIBTOOL = @LIBTOOL@
LN_S = @LN_S@
MAINT = @MAINT@
MAKEINFO = @MAKEINFO@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
OGG_INCLUDES = @OGG_INCLUDES@
OGG_LDFLAGS = @OGG_LDFLAGS@
OGG_LIBS = @OGG_LIBS@
PACKAGE = @PACKAGE@
RANLIB = @RANLIB@
SPEEX_LT_AGE = @SPEEX_LT_AGE@
SPEEX_LT_CURRENT = @SPEEX_LT_CURRENT@
SPEEX_LT_REVISION = @SPEEX_LT_REVISION@
STRIP = @STRIP@
VERSION = @VERSION@
src = @src@
EXTRA_DIST = Speex.spec Speex.spec.in
SUBDIRS = libspeex @src@ doc win32
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_CLEAN_FILES = Speex.spec
DIST_COMMON = README AUTHORS COPYING ChangeLog INSTALL Makefile.am \
Makefile.in NEWS Speex.spec.in TODO acinclude.m4 aclocal.m4 \
config.guess config.sub configure configure.in install-sh ltmain.sh \
missing mkinstalldirs
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
TAR = gtar
GZIP_ENV = --best
all: all-redirect
.SUFFIXES:
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
cd $(top_builddir) \
&& CONFIG_FILES=$@ CONFIG_HEADERS= $(SHELL) ./config.status
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ configure.in acinclude.m4
cd $(srcdir) && $(ACLOCAL)
config.status: $(srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
$(SHELL) ./config.status --recheck
$(srcdir)/configure: @MAINTAINER_MODE_TRUE@$(srcdir)/configure.in $(ACLOCAL_M4) $(CONFIGURE_DEPENDENCIES)
cd $(srcdir) && $(AUTOCONF)
Speex.spec: $(top_builddir)/config.status Speex.spec.in
cd $(top_builddir) && CONFIG_FILES=$@ CONFIG_HEADERS= $(SHELL) ./config.status
# This directory's subdirectories are mostly independent; you can cd
# into them and run `make' without going through this Makefile.
# To change the values of `make' variables: instead of editing Makefiles,
# (1) if the variable is set in `config.status', edit `config.status'
# (which will cause the Makefiles to be regenerated when you run `make');
# (2) otherwise, pass the desired values on the `make' command line.
@SET_MAKE@
all-recursive install-data-recursive install-exec-recursive \
installdirs-recursive install-recursive uninstall-recursive \
check-recursive installcheck-recursive info-recursive dvi-recursive:
@set fnord $(MAKEFLAGS); amf=$$2; \
dot_seen=no; \
target=`echo $@ | sed s/-recursive//`; \
list='$(SUBDIRS)'; for subdir in $$list; do \
echo "Making $$target in $$subdir"; \
if test "$$subdir" = "."; then \
dot_seen=yes; \
local_target="$$target-am"; \
else \
local_target="$$target"; \
fi; \
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|| case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
done; \
if test "$$dot_seen" = "no"; then \
$(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
fi; test -z "$$fail"
mostlyclean-recursive clean-recursive distclean-recursive \
maintainer-clean-recursive:
@set fnord $(MAKEFLAGS); amf=$$2; \
dot_seen=no; \
rev=''; list='$(SUBDIRS)'; for subdir in $$list; do \
rev="$$subdir $$rev"; \
test "$$subdir" != "." || dot_seen=yes; \
done; \
test "$$dot_seen" = "no" && rev=". $$rev"; \
target=`echo $@ | sed s/-recursive//`; \
for subdir in $$rev; do \
echo "Making $$target in $$subdir"; \
if test "$$subdir" = "."; then \
local_target="$$target-am"; \
else \
local_target="$$target"; \
fi; \
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|| case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
done && test -z "$$fail"
tags-recursive:
list='$(SUBDIRS)'; for subdir in $$list; do \
test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
done
tags: TAGS
ID: $(HEADERS) $(SOURCES) $(LISP)
list='$(SOURCES) $(HEADERS)'; \
unique=`for i in $$list; do echo $$i; done | \
awk ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
here=`pwd` && cd $(srcdir) \
&& mkid -f$$here/ID $$unique $(LISP)
TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SUBDIRS)'; for subdir in $$list; do \
if test "$$subdir" = .; then :; else \
test -f $$subdir/TAGS && tags="$$tags -i $$here/$$subdir/TAGS"; \
fi; \
done; \
list='$(SOURCES) $(HEADERS)'; \
unique=`for i in $$list; do echo $$i; done | \
awk ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \
|| (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS)
mostlyclean-tags:
clean-tags:
distclean-tags:
-rm -f TAGS ID
maintainer-clean-tags:
distdir = $(PACKAGE)-$(VERSION)
top_distdir = $(distdir)
# This target untars the dist file and tries a VPATH configuration. Then
# it guarantees that the distribution is self-contained by making another
# tarfile.
distcheck: dist
-rm -rf $(distdir)
GZIP=$(GZIP_ENV) $(TAR) zxf $(distdir).tar.gz
mkdir $(distdir)/=build
mkdir $(distdir)/=inst
dc_install_base=`cd $(distdir)/=inst && pwd`; \
cd $(distdir)/=build \
&& ../configure --srcdir=.. --prefix=$$dc_install_base \
&& $(MAKE) $(AM_MAKEFLAGS) \
&& $(MAKE) $(AM_MAKEFLAGS) dvi \
&& $(MAKE) $(AM_MAKEFLAGS) check \
&& $(MAKE) $(AM_MAKEFLAGS) install \
&& $(MAKE) $(AM_MAKEFLAGS) installcheck \
&& $(MAKE) $(AM_MAKEFLAGS) dist
-rm -rf $(distdir)
@banner="$(distdir).tar.gz is ready for distribution"; \
dashes=`echo "$$banner" | sed s/./=/g`; \
echo "$$dashes"; \
echo "$$banner"; \
echo "$$dashes"
dist: distdir
-chmod -R a+r $(distdir)
GZIP=$(GZIP_ENV) $(TAR) chozf $(distdir).tar.gz $(distdir)
-rm -rf $(distdir)
dist-all: distdir
-chmod -R a+r $(distdir)
GZIP=$(GZIP_ENV) $(TAR) chozf $(distdir).tar.gz $(distdir)
-rm -rf $(distdir)
distdir: $(DISTFILES)
-rm -rf $(distdir)
mkdir $(distdir)
-chmod 777 $(distdir)
@for file in $(DISTFILES); do \
d=$(srcdir); \
if test -d $$d/$$file; then \
cp -pr $$d/$$file $(distdir)/$$file; \
else \
test -f $(distdir)/$$file \
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
|| cp -p $$d/$$file $(distdir)/$$file || :; \
fi; \
done
for subdir in $(SUBDIRS); do \
if test "$$subdir" = .; then :; else \
test -d $(distdir)/$$subdir \
|| mkdir $(distdir)/$$subdir \
|| exit 1; \
chmod 777 $(distdir)/$$subdir; \
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir=../$(distdir) distdir=../$(distdir)/$$subdir distdir) \
|| exit 1; \
fi; \
done
info-am:
info: info-recursive
dvi-am:
dvi: dvi-recursive
check-am: all-am
check: check-recursive
installcheck-am:
installcheck: installcheck-recursive
install-exec-am:
install-exec: install-exec-recursive
install-data-am:
install-data: install-data-recursive
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
install: install-recursive
uninstall-am:
uninstall: uninstall-recursive
all-am: Makefile
all-redirect: all-recursive
install-strip:
$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
installdirs: installdirs-recursive
installdirs-am:
mostlyclean-generic:
clean-generic:
distclean-generic:
-rm -f Makefile $(CONFIG_CLEAN_FILES)
-rm -f config.cache config.log stamp-h stamp-h[0-9]*
maintainer-clean-generic:
mostlyclean-am: mostlyclean-tags mostlyclean-generic
mostlyclean: mostlyclean-recursive
clean-am: clean-tags clean-generic mostlyclean-am
clean: clean-recursive
distclean-am: distclean-tags distclean-generic clean-am
-rm -f libtool
distclean: distclean-recursive
-rm -f config.status
maintainer-clean-am: maintainer-clean-tags maintainer-clean-generic \
distclean-am
@echo "This command is intended for maintainers to use;"
@echo "it deletes files that may require special tools to rebuild."
maintainer-clean: maintainer-clean-recursive
-rm -f config.status
.PHONY: install-data-recursive uninstall-data-recursive \
install-exec-recursive uninstall-exec-recursive installdirs-recursive \
uninstalldirs-recursive all-recursive check-recursive \
installcheck-recursive info-recursive dvi-recursive \
mostlyclean-recursive distclean-recursive clean-recursive \
maintainer-clean-recursive tags tags-recursive mostlyclean-tags \
distclean-tags clean-tags maintainer-clean-tags distdir info-am info \
dvi-am dvi check check-am installcheck-am installcheck install-exec-am \
install-exec install-data-am install-data install-am install \
uninstall-am uninstall all-redirect all-am all installdirs-am \
installdirs mostlyclean-generic distclean-generic clean-generic \
maintainer-clean-generic clean mostlyclean distclean maintainer-clean
rpm: dist
rpmbuild -ta ${PACKAGE}-${VERSION}.tar.gz
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

View File

@ -1 +0,0 @@
2002/02/13: Creation of the "Speex" project

View File

@ -1,9 +0,0 @@
See INSTALL file for instruction on how to install Speex.
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.
To use the Speex command line tools:
% speexenc [options] input_file.wav compressed_file.spx
% speexdec [options] compressed_file.spx output_file.wav

View File

@ -1,68 +0,0 @@
%define name speex
%define ver 1.0.1
%define rel 1
Summary: An open-source, patent-free speech codec
Name: %name
Version: %ver
Release: %rel
Copyright: BSD
Group: Application/Devel
Source: http://www.speex.org/download/%{name}-%{ver}.tar.gz
URL: http://www.speex.org/
Vendor: Speex
Packager: Jean-Marc Valin (jean-marc.valin@hermes.usherb.ca)
BuildRoot: /var/tmp/%{name}-build-root
Docdir: /usr/share/doc
%description
Speex is a patent-free audio codec designed especially for voice (unlike
Vorbis which targets general audio) signals and providing good narrowband
and wideband quality. This project aims to be complementary to the Vorbis
codec.
%package devel
Summary: Speex development files
Group: Development/Libraries
Requires: %{name} = %{version}
%description devel
Speex development files.
%changelog
* Thu Oct 03 2002 Jean-Marc Valin
- Added devel package inspired from PLD spec file
* Tue Jul 30 2002 Fredrik Rambris <boost@users.sourceforge.net> 0.5.2
- Added buildroot and docdir and ldconfig. Makes it builadble by non-roots
and also doesn't write to actual library paths when building.
%prep
%setup
%build
export CFLAGS='-O3 -DRELEASE'
./configure --prefix=/usr --enable-shared --enable-static
make
%install
rm -rf $RPM_BUILD_ROOT
make DESTDIR=$RPM_BUILD_ROOT install
%post -p /sbin/ldconfig
%postun -p /sbin/ldconfig
%files
%defattr(644,root,root,755)
%doc COPYING AUTHORS ChangeLog NEWS README
%doc doc/manual.pdf
/usr/share/man/man1/speexenc.1*
/usr/share/man/man1/speexdec.1*
%attr(755,root,root) %{_bindir}/speex*
%attr(755,root,root) %{_libdir}/libspeex*.so*
%files devel
%defattr(644,root,root,755)
%attr(755,root,root) %{_libdir}/libspeex*.la
%{_includedir}/speex*.h
%{_libdir}/libspeex*.a

View File

@ -1,68 +0,0 @@
%define name @PACKAGE@
%define ver @VERSION@
%define rel 1
Summary: An open-source, patent-free speech codec
Name: %name
Version: %ver
Release: %rel
Copyright: BSD
Group: Application/Devel
Source: http://www.speex.org/download/%{name}-%{ver}.tar.gz
URL: http://www.speex.org/
Vendor: Speex
Packager: Jean-Marc Valin (jean-marc.valin@hermes.usherb.ca)
BuildRoot: /var/tmp/%{name}-build-root
Docdir: /usr/share/doc
%description
Speex is a patent-free audio codec designed especially for voice (unlike
Vorbis which targets general audio) signals and providing good narrowband
and wideband quality. This project aims to be complementary to the Vorbis
codec.
%package devel
Summary: Speex development files
Group: Development/Libraries
Requires: %{name} = %{version}
%description devel
Speex development files.
%changelog
* Thu Oct 03 2002 Jean-Marc Valin
- Added devel package inspired from PLD spec file
* Tue Jul 30 2002 Fredrik Rambris <boost@users.sourceforge.net> 0.5.2
- Added buildroot and docdir and ldconfig. Makes it builadble by non-roots
and also doesn't write to actual library paths when building.
%prep
%setup
%build
export CFLAGS='-O3 -DRELEASE'
./configure --prefix=/usr --enable-shared --enable-static
make
%install
rm -rf $RPM_BUILD_ROOT
make DESTDIR=$RPM_BUILD_ROOT install
%post -p /sbin/ldconfig
%postun -p /sbin/ldconfig
%files
%defattr(644,root,root,755)
%doc COPYING AUTHORS ChangeLog NEWS README
%doc doc/manual.pdf
/usr/share/man/man1/speexenc.1*
/usr/share/man/man1/speexdec.1*
%attr(755,root,root) %{_bindir}/speex*
%attr(755,root,root) %{_libdir}/libspeex*.so*
%files devel
%defattr(644,root,root,755)
%attr(755,root,root) %{_libdir}/libspeex*.la
%{_includedir}/speex*.h
%{_libdir}/libspeex*.a

View File

@ -1,18 +0,0 @@
Features
-Add maximum/minimum bit-rate control for VBR
-Get the encoder to use the rate of packet loss (more conservative pitch gains)
Long-term quality improvements
-Improve perceptual enhancement (including wideband)
Standards
*Complete Speex RTP profile
-MIME type registration
-MS ACM wrapper
*required for 1.0
ideas:
Peelable stream (double codebook, higher bands, stereo)
LPC from spectral domain
Better psycho-acoustics? Masking curve from Vorbis

View File

@ -1,84 +0,0 @@
AC_DEFUN(AC_FIND_FILE,
[
$3=NONE
for i in $2;
do
for j in $1;
do
if test -r "$i/$j"; then
$3=$i
break 2
fi
done
done
])
AC_DEFUN(AC_PATH_LIBOGG,
[
OGG_LIBS="-logg"
AC_MSG_CHECKING([for libogg])
ac_ogg_includes=NONE ac_ogg_libraries=NONE ac_ogg_bindir=NONE
ogg_libraries=""
ogg_includes=""
AC_ARG_WITH(ogg-dir,
[ --with-ogg-dir=DIR where the root of OGG is installed ],
[ ac_ogg_includes="$withval"/include
ac_ogg_libraries="$withval"/lib
])
AC_ARG_WITH(ogg-includes,
[ --with-ogg-includes=DIR where the OGG includes are. ],
[
ac_ogg_includes="$withval"
])
ogg_libs_given=no
AC_ARG_WITH(ogg-libraries,
[ --with-ogg-libraries=DIR where the OGG library is installed.],
[ ac_ogg_libraries="$withval"
ogg_libs_given=yes
])
ogg_incdirs="/usr/include /usr/lib/ogg/include /opt/include /usr/local/ogg/include /usr/include/ogg /usr/include /usr/local/include"
if test ! "$ac_ogg_includes" = "NONE"; then
ogg_incdirs="$ac_ogg_includes $ac_ogg_includes/.. $ogg_incdirs"
fi
AC_FIND_FILE(ogg/ogg.h, $ogg_incdirs, ogg_incdir)
echo "Ogg includes in $ogg_incdir"
ogg_libdirs="$ac_ogg_libraries /usr/lib/ogg/lib /usr/lib /opt/lib /usr/local/ogg/lib /usr/local/lib /usr/lib/ogg /usr/local/lib"
test -n "$OGGDIR" && ogg_libdirs="$OGGDIR/lib $OGGDIR $ogg_libdirs"
if test ! "$ac_ogg_libraries" = "NONE"; then
ogg_libdirs="$ac_ogg_libraries $ogg_libdirs"
fi
test=NONE
ogg_libdir=NONE
for dir in $ogg_libdirs; do
try="ls -1 $dir/libogg*"
if test=`eval $try 2> /dev/null`; then ogg_libdir=$dir; break; else echo "tried $dir" >&AC_FD_CC ; fi
done
echo "Ogg libraries in $ogg_libdir"
if test "$ogg_libdir" = "NONE" || test "$ogg_incdir" = "NONE"; then
have_libogg=no
else
have_libogg=yes
AC_DEFINE(HAVE_LIBOGG)
fi
OGG_INCLUDES="-I$ogg_incdir"
OGG_LDFLAGS="-L$ogg_libdir"
AC_SUBST(OGG_LIBS)
AC_SUBST(OGG_INCLUDES)
AC_SUBST(OGG_LDFLAGS)
])

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,69 +0,0 @@
dnl Process this file with autoconf to produce a configure script. -*-m4-*-
AC_INIT(libspeex/speex.h)
SPEEX_MAJOR_VERSION=1
SPEEX_MINOR_VERSION=0
SPEEX_MICRO_VERSION=1
SPEEX_VERSION=1.0.1
SPEEX_LT_CURRENT=2
SPEEX_LT_REVISION=0
SPEEX_LT_AGE=1
AC_SUBST(SPEEX_LT_CURRENT)
AC_SUBST(SPEEX_LT_REVISION)
AC_SUBST(SPEEX_LT_AGE)
# For automake.
VERSION=$SPEEX_VERSION
PACKAGE=speex
AM_INIT_AUTOMAKE($PACKAGE, $VERSION, no-define)
AM_MAINTAINER_MODE
AC_CANONICAL_HOST
AM_PROG_LIBTOOL
AC_C_BIGENDIAN
AC_CHECK_HEADERS(sys/soundcard.h)
AC_ARG_ENABLE(ogg,
[ --enable-ogg=[yes/no] Turn on or off the use of ogg
libraries [default=yes]],
[case "${enableval}" in
yes) useogg=true ;;
no) useogg=false ;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-ogg) ;;
esac],[useogg=true])
if test x$useogg = xtrue; then
AC_PATH_LIBOGG
fi
if test "$have_libogg" = yes; then
src=src
else
src=
fi
AC_SUBST(src)
AC_CHECK_LIB(m, sin)
AC_CHECK_LIB(gnugetopt, getopt_long)
AC_DEFINE_UNQUOTED(VERSION, "${VERSION}")
AC_ARG_ENABLE(sse, [ --enable-sse enable SSE support], [if test "$enableval" = yes; then AC_DEFINE(_USE_SSE) fi])
dnl Output the makefiles and version.h.
AC_OUTPUT([Makefile libspeex/Makefile src/Makefile doc/Makefile Speex.spec
win32/Makefile win32/libspeex/Makefile win32/speexenc/Makefile
win32/speexdec/Makefile ])
if test "x$src" = "x"; then
echo "You don't seem to have libogg installed. Only the Speex library (libspeex) will be built (no encoder/decoder executable)"
echo "You can download libogg from http://www.ogg.org/ogg/index.html"
fi
echo "Type \"make; make install\" to compile and install Speex";

View File

@ -1,5 +0,0 @@
docdir=$(prefix)/share/doc/@PACKAGE@-@VERSION@
doc_DATA = manual.pdf
EXTRA_DIST = $(doc_DATA)

View File

@ -1,213 +0,0 @@
# Makefile.in generated automatically by automake 1.4-p6 from Makefile.am
# Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
SHELL = @SHELL@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
sbindir = @sbindir@
libexecdir = @libexecdir@
datadir = @datadir@
sysconfdir = @sysconfdir@
sharedstatedir = @sharedstatedir@
localstatedir = @localstatedir@
libdir = @libdir@
infodir = @infodir@
mandir = @mandir@
includedir = @includedir@
oldincludedir = /usr/include
DESTDIR =
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
top_builddir = ..
ACLOCAL = @ACLOCAL@
AUTOCONF = @AUTOCONF@
AUTOMAKE = @AUTOMAKE@
AUTOHEADER = @AUTOHEADER@
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
INSTALL_DATA = @INSTALL_DATA@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
transform = @program_transform_name@
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
host_alias = @host_alias@
host_triplet = @host@
AS = @AS@
CC = @CC@
DLLTOOL = @DLLTOOL@
ECHO = @ECHO@
EXEEXT = @EXEEXT@
LIBTOOL = @LIBTOOL@
LN_S = @LN_S@
MAINT = @MAINT@
MAKEINFO = @MAKEINFO@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
OGG_INCLUDES = @OGG_INCLUDES@
OGG_LDFLAGS = @OGG_LDFLAGS@
OGG_LIBS = @OGG_LIBS@
PACKAGE = @PACKAGE@
RANLIB = @RANLIB@
SPEEX_LT_AGE = @SPEEX_LT_AGE@
SPEEX_LT_CURRENT = @SPEEX_LT_CURRENT@
SPEEX_LT_REVISION = @SPEEX_LT_REVISION@
STRIP = @STRIP@
VERSION = @VERSION@
src = @src@
docdir = $(prefix)/share/doc/@PACKAGE@-@VERSION@
doc_DATA = manual.pdf
EXTRA_DIST = $(doc_DATA)
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_CLEAN_FILES =
DATA = $(doc_DATA)
DIST_COMMON = Makefile.am Makefile.in
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
TAR = gtar
GZIP_ENV = --best
all: all-redirect
.SUFFIXES:
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps doc/Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
cd $(top_builddir) \
&& CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
install-docDATA: $(doc_DATA)
@$(NORMAL_INSTALL)
$(mkinstalldirs) $(DESTDIR)$(docdir)
@list='$(doc_DATA)'; for p in $$list; do \
if test -f $(srcdir)/$$p; then \
echo " $(INSTALL_DATA) $(srcdir)/$$p $(DESTDIR)$(docdir)/$$p"; \
$(INSTALL_DATA) $(srcdir)/$$p $(DESTDIR)$(docdir)/$$p; \
else if test -f $$p; then \
echo " $(INSTALL_DATA) $$p $(DESTDIR)$(docdir)/$$p"; \
$(INSTALL_DATA) $$p $(DESTDIR)$(docdir)/$$p; \
fi; fi; \
done
uninstall-docDATA:
@$(NORMAL_UNINSTALL)
list='$(doc_DATA)'; for p in $$list; do \
rm -f $(DESTDIR)$(docdir)/$$p; \
done
tags: TAGS
TAGS:
distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
subdir = doc
distdir: $(DISTFILES)
@for file in $(DISTFILES); do \
d=$(srcdir); \
if test -d $$d/$$file; then \
cp -pr $$d/$$file $(distdir)/$$file; \
else \
test -f $(distdir)/$$file \
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
|| cp -p $$d/$$file $(distdir)/$$file || :; \
fi; \
done
info-am:
info: info-am
dvi-am:
dvi: dvi-am
check-am: all-am
check: check-am
installcheck-am:
installcheck: installcheck-am
install-exec-am:
install-exec: install-exec-am
install-data-am: install-docDATA
install-data: install-data-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
install: install-am
uninstall-am: uninstall-docDATA
uninstall: uninstall-am
all-am: Makefile $(DATA)
all-redirect: all-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
installdirs:
$(mkinstalldirs) $(DESTDIR)$(docdir)
mostlyclean-generic:
clean-generic:
distclean-generic:
-rm -f Makefile $(CONFIG_CLEAN_FILES)
-rm -f config.cache config.log stamp-h stamp-h[0-9]*
maintainer-clean-generic:
mostlyclean-am: mostlyclean-generic
mostlyclean: mostlyclean-am
clean-am: clean-generic mostlyclean-am
clean: clean-am
distclean-am: distclean-generic clean-am
-rm -f libtool
distclean: distclean-am
maintainer-clean-am: maintainer-clean-generic distclean-am
@echo "This command is intended for maintainers to use;"
@echo "it deletes files that may require special tools to rebuild."
maintainer-clean: maintainer-clean-am
.PHONY: uninstall-docDATA install-docDATA tags distdir info-am info \
dvi-am dvi check check-am installcheck-am installcheck install-exec-am \
install-exec install-data-am install-data install-am install \
uninstall-am uninstall all-redirect all-am all installdirs \
mostlyclean-generic distclean-generic clean-generic \
maintainer-clean-generic clean mostlyclean distclean maintainer-clean
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

View File

@ -1,251 +0,0 @@
#!/bin/sh
#
# install - install a program, script, or datafile
# This comes from X11R5 (mit/util/scripts/install.sh).
#
# Copyright 1991 by the Massachusetts Institute of Technology
#
# Permission to use, copy, modify, distribute, and sell this software and its
# documentation for any purpose is hereby granted without fee, provided that
# the above copyright notice appear in all copies and that both that
# copyright notice and this permission notice appear in supporting
# documentation, and that the name of M.I.T. not be used in advertising or
# publicity pertaining to distribution of the software without specific,
# written prior permission. M.I.T. makes no representations about the
# suitability of this software for any purpose. It is provided "as is"
# without express or implied warranty.
#
# Calling this script install-sh is preferred over install.sh, to prevent
# `make' implicit rules from creating a file called install from it
# when there is no Makefile.
#
# This script is compatible with the BSD install script, but was written
# from scratch. It can only install one file at a time, a restriction
# shared with many OS's install programs.
# set DOITPROG to echo to test this script
# Don't use :- since 4.3BSD and earlier shells don't like it.
doit="${DOITPROG-}"
# put in absolute paths if you don't have them in your path; or use env. vars.
mvprog="${MVPROG-mv}"
cpprog="${CPPROG-cp}"
chmodprog="${CHMODPROG-chmod}"
chownprog="${CHOWNPROG-chown}"
chgrpprog="${CHGRPPROG-chgrp}"
stripprog="${STRIPPROG-strip}"
rmprog="${RMPROG-rm}"
mkdirprog="${MKDIRPROG-mkdir}"
transformbasename=""
transform_arg=""
instcmd="$mvprog"
chmodcmd="$chmodprog 0755"
chowncmd=""
chgrpcmd=""
stripcmd=""
rmcmd="$rmprog -f"
mvcmd="$mvprog"
src=""
dst=""
dir_arg=""
while [ x"$1" != x ]; do
case $1 in
-c) instcmd="$cpprog"
shift
continue;;
-d) dir_arg=true
shift
continue;;
-m) chmodcmd="$chmodprog $2"
shift
shift
continue;;
-o) chowncmd="$chownprog $2"
shift
shift
continue;;
-g) chgrpcmd="$chgrpprog $2"
shift
shift
continue;;
-s) stripcmd="$stripprog"
shift
continue;;
-t=*) transformarg=`echo $1 | sed 's/-t=//'`
shift
continue;;
-b=*) transformbasename=`echo $1 | sed 's/-b=//'`
shift
continue;;
*) if [ x"$src" = x ]
then
src=$1
else
# this colon is to work around a 386BSD /bin/sh bug
:
dst=$1
fi
shift
continue;;
esac
done
if [ x"$src" = x ]
then
echo "install: no input file specified"
exit 1
else
true
fi
if [ x"$dir_arg" != x ]; then
dst=$src
src=""
if [ -d $dst ]; then
instcmd=:
chmodcmd=""
else
instcmd=mkdir
fi
else
# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
# might cause directories to be created, which would be especially bad
# if $src (and thus $dsttmp) contains '*'.
if [ -f $src -o -d $src ]
then
true
else
echo "install: $src does not exist"
exit 1
fi
if [ x"$dst" = x ]
then
echo "install: no destination specified"
exit 1
else
true
fi
# If destination is a directory, append the input filename; if your system
# does not like double slashes in filenames, you may need to add some logic
if [ -d $dst ]
then
dst="$dst"/`basename $src`
else
true
fi
fi
## this sed command emulates the dirname command
dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
# Make sure that the destination directory exists.
# this part is taken from Noah Friedman's mkinstalldirs script
# Skip lots of stat calls in the usual case.
if [ ! -d "$dstdir" ]; then
defaultIFS='
'
IFS="${IFS-${defaultIFS}}"
oIFS="${IFS}"
# Some sh's can't handle IFS=/ for some reason.
IFS='%'
set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
IFS="${oIFS}"
pathcomp=''
while [ $# -ne 0 ] ; do
pathcomp="${pathcomp}${1}"
shift
if [ ! -d "${pathcomp}" ] ;
then
$mkdirprog "${pathcomp}"
else
true
fi
pathcomp="${pathcomp}/"
done
fi
if [ x"$dir_arg" != x ]
then
$doit $instcmd $dst &&
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
else
# If we're going to rename the final executable, determine the name now.
if [ x"$transformarg" = x ]
then
dstfile=`basename $dst`
else
dstfile=`basename $dst $transformbasename |
sed $transformarg`$transformbasename
fi
# don't allow the sed command to completely eliminate the filename
if [ x"$dstfile" = x ]
then
dstfile=`basename $dst`
else
true
fi
# Make a temp file name in the proper directory.
dsttmp=$dstdir/#inst.$$#
# Move or copy the file name to the temp name
$doit $instcmd $src $dsttmp &&
trap "rm -f ${dsttmp}" 0 &&
# and set any options; do chmod last to preserve setuid bits
# If any of these fail, we abort the whole thing. If we want to
# ignore errors from any of these, just make sure not to ignore
# errors from the above "$doit $instcmd $src $dsttmp" command.
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
# Now rename the file to the real destination.
$doit $rmcmd -f $dstdir/$dstfile &&
$doit $mvcmd $dsttmp $dstdir/$dstfile
fi &&
exit 0

View File

@ -1,77 +0,0 @@
## Process this file with automake to produce Makefile.in. -*-Makefile-*-
# $Id: Makefile.am,v 1.49 2003/03/17 22:40:57 jm Exp $
# Disable automatic dependency tracking if using other tools than gcc and gmake
#AUTOMAKE_OPTIONS = no-dependencies
lib_LTLIBRARIES = libspeex.la
# Sources for compilation in the library
libspeex_la_SOURCES = nb_celp.c \
sb_celp.c \
lpc.c \
ltp.c \
lsp.c \
quant_lsp.c \
lsp_tables_nb.c \
gain_table.c \
gain_table_lbr.c \
cb_search.c \
filters.c \
bits.c \
modes.c \
vq.c \
high_lsp_tables.c \
vbr.c \
hexc_table.c \
exc_5_256_table.c \
exc_5_64_table.c \
exc_8_128_table.c \
exc_10_32_table.c \
exc_10_16_table.c \
exc_20_32_table.c \
hexc_10_32_table.c \
misc.c \
speex_header.c \
speex_callbacks.c \
math_approx.c \
stereo.c
include_HEADERS = speex.h \
speex_bits.h \
speex_header.h \
speex_callbacks.h \
speex_stereo.h
noinst_HEADERS = lsp.h \
nb_celp.h \
lpc.h \
ltp.h \
quant_lsp.h \
cb_search.h \
filters.h \
stack_alloc.h \
vq.h \
modes.h \
sb_celp.h \
vbr.h \
misc.h \
ltp_sse.h \
filters_sse.h \
math_approx.h
libspeex_la_LDFLAGS = -version-info @SPEEX_LT_CURRENT@:@SPEEX_LT_REVISION@:@SPEEX_LT_AGE@
noinst_PROGRAMS = testenc testenc_wb testenc_uwb
testenc_SOURCES = testenc.c
testenc_LDADD = libspeex.la
testenc_wb_SOURCES = testenc_wb.c
testenc_wb_LDADD = libspeex.la
testenc_uwb_SOURCES = testenc_uwb.c
testenc_uwb_LDADD = libspeex.la

View File

@ -1,450 +0,0 @@
# Makefile.in generated automatically by automake 1.4-p6 from Makefile.am
# Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
# $Id: Makefile.am,v 1.49 2003/03/17 22:40:57 jm Exp $
# Disable automatic dependency tracking if using other tools than gcc and gmake
#AUTOMAKE_OPTIONS = no-dependencies
SHELL = @SHELL@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
sbindir = @sbindir@
libexecdir = @libexecdir@
datadir = @datadir@
sysconfdir = @sysconfdir@
sharedstatedir = @sharedstatedir@
localstatedir = @localstatedir@
libdir = @libdir@
infodir = @infodir@
mandir = @mandir@
includedir = @includedir@
oldincludedir = /usr/include
DESTDIR =
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
top_builddir = ..
ACLOCAL = @ACLOCAL@
AUTOCONF = @AUTOCONF@
AUTOMAKE = @AUTOMAKE@
AUTOHEADER = @AUTOHEADER@
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
INSTALL_DATA = @INSTALL_DATA@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
transform = @program_transform_name@
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
host_alias = @host_alias@
host_triplet = @host@
AS = @AS@
CC = @CC@
DLLTOOL = @DLLTOOL@
ECHO = @ECHO@
EXEEXT = @EXEEXT@
LIBTOOL = @LIBTOOL@
LN_S = @LN_S@
MAINT = @MAINT@
MAKEINFO = @MAKEINFO@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
OGG_INCLUDES = @OGG_INCLUDES@
OGG_LDFLAGS = @OGG_LDFLAGS@
OGG_LIBS = @OGG_LIBS@
PACKAGE = @PACKAGE@
RANLIB = @RANLIB@
SPEEX_LT_AGE = @SPEEX_LT_AGE@
SPEEX_LT_CURRENT = @SPEEX_LT_CURRENT@
SPEEX_LT_REVISION = @SPEEX_LT_REVISION@
STRIP = @STRIP@
VERSION = @VERSION@
src = @src@
lib_LTLIBRARIES = libspeex.la
# Sources for compilation in the library
libspeex_la_SOURCES = nb_celp.c sb_celp.c lpc.c ltp.c lsp.c quant_lsp.c lsp_tables_nb.c gain_table.c gain_table_lbr.c cb_search.c filters.c bits.c modes.c vq.c high_lsp_tables.c vbr.c hexc_table.c exc_5_256_table.c exc_5_64_table.c exc_8_128_table.c exc_10_32_table.c exc_10_16_table.c exc_20_32_table.c hexc_10_32_table.c misc.c speex_header.c speex_callbacks.c math_approx.c stereo.c
include_HEADERS = speex.h speex_bits.h speex_header.h speex_callbacks.h speex_stereo.h
noinst_HEADERS = lsp.h nb_celp.h lpc.h ltp.h quant_lsp.h cb_search.h filters.h stack_alloc.h vq.h modes.h sb_celp.h vbr.h misc.h ltp_sse.h filters_sse.h math_approx.h
libspeex_la_LDFLAGS = -version-info @SPEEX_LT_CURRENT@:@SPEEX_LT_REVISION@:@SPEEX_LT_AGE@
noinst_PROGRAMS = testenc testenc_wb testenc_uwb
testenc_SOURCES = testenc.c
testenc_LDADD = libspeex.la
testenc_wb_SOURCES = testenc_wb.c
testenc_wb_LDADD = libspeex.la
testenc_uwb_SOURCES = testenc_uwb.c
testenc_uwb_LDADD = libspeex.la
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_CLEAN_FILES =
LTLIBRARIES = $(lib_LTLIBRARIES)
DEFS = @DEFS@ -I. -I$(srcdir)
CPPFLAGS = @CPPFLAGS@
LDFLAGS = @LDFLAGS@
LIBS = @LIBS@
libspeex_la_LIBADD =
libspeex_la_OBJECTS = nb_celp.lo sb_celp.lo lpc.lo ltp.lo lsp.lo \
quant_lsp.lo lsp_tables_nb.lo gain_table.lo gain_table_lbr.lo \
cb_search.lo filters.lo bits.lo modes.lo vq.lo high_lsp_tables.lo \
vbr.lo hexc_table.lo exc_5_256_table.lo exc_5_64_table.lo \
exc_8_128_table.lo exc_10_32_table.lo exc_10_16_table.lo \
exc_20_32_table.lo hexc_10_32_table.lo misc.lo speex_header.lo \
speex_callbacks.lo math_approx.lo stereo.lo
noinst_PROGRAMS = testenc$(EXEEXT) testenc_wb$(EXEEXT) \
testenc_uwb$(EXEEXT)
PROGRAMS = $(noinst_PROGRAMS)
testenc_OBJECTS = testenc.$(OBJEXT)
testenc_DEPENDENCIES = libspeex.la
testenc_LDFLAGS =
testenc_wb_OBJECTS = testenc_wb.$(OBJEXT)
testenc_wb_DEPENDENCIES = libspeex.la
testenc_wb_LDFLAGS =
testenc_uwb_OBJECTS = testenc_uwb.$(OBJEXT)
testenc_uwb_DEPENDENCIES = libspeex.la
testenc_uwb_LDFLAGS =
CFLAGS = @CFLAGS@
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
CCLD = $(CC)
LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@
HEADERS = $(include_HEADERS) $(noinst_HEADERS)
DIST_COMMON = Makefile.am Makefile.in
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
TAR = gtar
GZIP_ENV = --best
SOURCES = $(libspeex_la_SOURCES) $(testenc_SOURCES) $(testenc_wb_SOURCES) $(testenc_uwb_SOURCES)
OBJECTS = $(libspeex_la_OBJECTS) $(testenc_OBJECTS) $(testenc_wb_OBJECTS) $(testenc_uwb_OBJECTS)
all: all-redirect
.SUFFIXES:
.SUFFIXES: .S .c .lo .o .obj .s
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps libspeex/Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
cd $(top_builddir) \
&& CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
mostlyclean-libLTLIBRARIES:
clean-libLTLIBRARIES:
-test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)
distclean-libLTLIBRARIES:
maintainer-clean-libLTLIBRARIES:
install-libLTLIBRARIES: $(lib_LTLIBRARIES)
@$(NORMAL_INSTALL)
$(mkinstalldirs) $(DESTDIR)$(libdir)
@list='$(lib_LTLIBRARIES)'; for p in $$list; do \
if test -f $$p; then \
echo "$(LIBTOOL) --mode=install $(INSTALL) $$p $(DESTDIR)$(libdir)/$$p"; \
$(LIBTOOL) --mode=install $(INSTALL) $$p $(DESTDIR)$(libdir)/$$p; \
else :; fi; \
done
uninstall-libLTLIBRARIES:
@$(NORMAL_UNINSTALL)
list='$(lib_LTLIBRARIES)'; for p in $$list; do \
$(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(libdir)/$$p; \
done
.c.o:
$(COMPILE) -c $<
# FIXME: We should only use cygpath when building on Windows,
# and only if it is available.
.c.obj:
$(COMPILE) -c `cygpath -w $<`
.s.o:
$(COMPILE) -c $<
.S.o:
$(COMPILE) -c $<
mostlyclean-compile:
-rm -f *.o core *.core
-rm -f *.$(OBJEXT)
clean-compile:
distclean-compile:
-rm -f *.tab.c
maintainer-clean-compile:
.c.lo:
$(LIBTOOL) --mode=compile $(COMPILE) -c $<
.s.lo:
$(LIBTOOL) --mode=compile $(COMPILE) -c $<
.S.lo:
$(LIBTOOL) --mode=compile $(COMPILE) -c $<
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
distclean-libtool:
maintainer-clean-libtool:
libspeex.la: $(libspeex_la_OBJECTS) $(libspeex_la_DEPENDENCIES)
$(LINK) -rpath $(libdir) $(libspeex_la_LDFLAGS) $(libspeex_la_OBJECTS) $(libspeex_la_LIBADD) $(LIBS)
mostlyclean-noinstPROGRAMS:
clean-noinstPROGRAMS:
-test -z "$(noinst_PROGRAMS)" || rm -f $(noinst_PROGRAMS)
distclean-noinstPROGRAMS:
maintainer-clean-noinstPROGRAMS:
testenc$(EXEEXT): $(testenc_OBJECTS) $(testenc_DEPENDENCIES)
@rm -f testenc$(EXEEXT)
$(LINK) $(testenc_LDFLAGS) $(testenc_OBJECTS) $(testenc_LDADD) $(LIBS)
testenc_wb$(EXEEXT): $(testenc_wb_OBJECTS) $(testenc_wb_DEPENDENCIES)
@rm -f testenc_wb$(EXEEXT)
$(LINK) $(testenc_wb_LDFLAGS) $(testenc_wb_OBJECTS) $(testenc_wb_LDADD) $(LIBS)
testenc_uwb$(EXEEXT): $(testenc_uwb_OBJECTS) $(testenc_uwb_DEPENDENCIES)
@rm -f testenc_uwb$(EXEEXT)
$(LINK) $(testenc_uwb_LDFLAGS) $(testenc_uwb_OBJECTS) $(testenc_uwb_LDADD) $(LIBS)
install-includeHEADERS: $(include_HEADERS)
@$(NORMAL_INSTALL)
$(mkinstalldirs) $(DESTDIR)$(includedir)
@list='$(include_HEADERS)'; for p in $$list; do \
if test -f "$$p"; then d= ; else d="$(srcdir)/"; fi; \
echo " $(INSTALL_DATA) $$d$$p $(DESTDIR)$(includedir)/$$p"; \
$(INSTALL_DATA) $$d$$p $(DESTDIR)$(includedir)/$$p; \
done
uninstall-includeHEADERS:
@$(NORMAL_UNINSTALL)
list='$(include_HEADERS)'; for p in $$list; do \
rm -f $(DESTDIR)$(includedir)/$$p; \
done
tags: TAGS
ID: $(HEADERS) $(SOURCES) $(LISP)
list='$(SOURCES) $(HEADERS)'; \
unique=`for i in $$list; do echo $$i; done | \
awk ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
here=`pwd` && cd $(srcdir) \
&& mkid -f$$here/ID $$unique $(LISP)
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS)'; \
unique=`for i in $$list; do echo $$i; done | \
awk ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \
|| (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS)
mostlyclean-tags:
clean-tags:
distclean-tags:
-rm -f TAGS ID
maintainer-clean-tags:
distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
subdir = libspeex
distdir: $(DISTFILES)
@for file in $(DISTFILES); do \
d=$(srcdir); \
if test -d $$d/$$file; then \
cp -pr $$d/$$file $(distdir)/$$file; \
else \
test -f $(distdir)/$$file \
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
|| cp -p $$d/$$file $(distdir)/$$file || :; \
fi; \
done
bits.lo bits.o : bits.c speex_bits.h misc.h
cb_search.lo cb_search.o : cb_search.c cb_search.h speex_bits.h \
filters.h stack_alloc.h vq.h misc.h
exc_10_16_table.lo exc_10_16_table.o : exc_10_16_table.c
exc_10_32_table.lo exc_10_32_table.o : exc_10_32_table.c
exc_20_32_table.lo exc_20_32_table.o : exc_20_32_table.c
exc_5_256_table.lo exc_5_256_table.o : exc_5_256_table.c
exc_5_64_table.lo exc_5_64_table.o : exc_5_64_table.c
exc_8_128_table.lo exc_8_128_table.o : exc_8_128_table.c
filters.lo filters.o : filters.c filters.h stack_alloc.h
gain_table.lo gain_table.o : gain_table.c
gain_table_lbr.lo gain_table_lbr.o : gain_table_lbr.c
hexc_10_32_table.lo hexc_10_32_table.o : hexc_10_32_table.c
hexc_table.lo hexc_table.o : hexc_table.c
high_lsp_tables.lo high_lsp_tables.o : high_lsp_tables.c
lpc.lo lpc.o : lpc.c lpc.h
lsp.lo lsp.o : lsp.c lsp.h stack_alloc.h
lsp_tables_nb.lo lsp_tables_nb.o : lsp_tables_nb.c
ltp.lo ltp.o : ltp.c ltp.h speex_bits.h stack_alloc.h filters.h
math_approx.lo math_approx.o : math_approx.c math_approx.h
misc.lo misc.o : misc.c misc.h
modes.lo modes.o : modes.c modes.h speex.h speex_bits.h ltp.h \
quant_lsp.h cb_search.h sb_celp.h nb_celp.h speex_callbacks.h \
vbr.h filters.h misc.h
nb_celp.lo nb_celp.o : nb_celp.c nb_celp.h modes.h speex.h speex_bits.h \
speex_callbacks.h vbr.h filters.h lpc.h lsp.h ltp.h quant_lsp.h \
cb_search.h stack_alloc.h vq.h misc.h
quant_lsp.lo quant_lsp.o : quant_lsp.c quant_lsp.h speex_bits.h
sb_celp.lo sb_celp.o : sb_celp.c sb_celp.h modes.h speex.h speex_bits.h \
nb_celp.h speex_callbacks.h vbr.h filters.h lpc.h lsp.h \
stack_alloc.h cb_search.h quant_lsp.h vq.h ltp.h misc.h
speex_callbacks.lo speex_callbacks.o : speex_callbacks.c \
speex_callbacks.h speex.h speex_bits.h misc.h
speex_header.lo speex_header.o : speex_header.c speex_header.h misc.h \
speex.h speex_bits.h
stereo.lo stereo.o : stereo.c speex_stereo.h speex_bits.h \
speex_callbacks.h speex.h vq.h
testenc.o: testenc.c speex.h speex_bits.h speex_callbacks.h
testenc_uwb.o: testenc_uwb.c speex.h speex_bits.h
testenc_wb.o: testenc_wb.c speex.h speex_bits.h
vbr.lo vbr.o : vbr.c vbr.h
vq.lo vq.o : vq.c vq.h
info-am:
info: info-am
dvi-am:
dvi: dvi-am
check-am: all-am
check: check-am
installcheck-am:
installcheck: installcheck-am
install-exec-am: install-libLTLIBRARIES
install-exec: install-exec-am
install-data-am: install-includeHEADERS
install-data: install-data-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
install: install-am
uninstall-am: uninstall-libLTLIBRARIES uninstall-includeHEADERS
uninstall: uninstall-am
all-am: Makefile $(LTLIBRARIES) $(PROGRAMS) $(HEADERS)
all-redirect: all-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
installdirs:
$(mkinstalldirs) $(DESTDIR)$(libdir) $(DESTDIR)$(includedir)
mostlyclean-generic:
clean-generic:
distclean-generic:
-rm -f Makefile $(CONFIG_CLEAN_FILES)
-rm -f config.cache config.log stamp-h stamp-h[0-9]*
maintainer-clean-generic:
mostlyclean-am: mostlyclean-libLTLIBRARIES mostlyclean-compile \
mostlyclean-libtool mostlyclean-noinstPROGRAMS \
mostlyclean-tags mostlyclean-generic
mostlyclean: mostlyclean-am
clean-am: clean-libLTLIBRARIES clean-compile clean-libtool \
clean-noinstPROGRAMS clean-tags clean-generic \
mostlyclean-am
clean: clean-am
distclean-am: distclean-libLTLIBRARIES distclean-compile \
distclean-libtool distclean-noinstPROGRAMS \
distclean-tags distclean-generic clean-am
-rm -f libtool
distclean: distclean-am
maintainer-clean-am: maintainer-clean-libLTLIBRARIES \
maintainer-clean-compile maintainer-clean-libtool \
maintainer-clean-noinstPROGRAMS maintainer-clean-tags \
maintainer-clean-generic distclean-am
@echo "This command is intended for maintainers to use;"
@echo "it deletes files that may require special tools to rebuild."
maintainer-clean: maintainer-clean-am
.PHONY: mostlyclean-libLTLIBRARIES distclean-libLTLIBRARIES \
clean-libLTLIBRARIES maintainer-clean-libLTLIBRARIES \
uninstall-libLTLIBRARIES install-libLTLIBRARIES mostlyclean-compile \
distclean-compile clean-compile maintainer-clean-compile \
mostlyclean-libtool distclean-libtool clean-libtool \
maintainer-clean-libtool mostlyclean-noinstPROGRAMS \
distclean-noinstPROGRAMS clean-noinstPROGRAMS \
maintainer-clean-noinstPROGRAMS uninstall-includeHEADERS \
install-includeHEADERS tags mostlyclean-tags distclean-tags clean-tags \
maintainer-clean-tags distdir info-am info dvi-am dvi check check-am \
installcheck-am installcheck install-exec-am install-exec \
install-data-am install-data install-am install uninstall-am uninstall \
all-redirect all-am all installdirs mostlyclean-generic \
distclean-generic clean-generic maintainer-clean-generic clean \
mostlyclean distclean maintainer-clean
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

View File

@ -1,352 +0,0 @@
/* Copyright (C) 2002 Jean-Marc Valin
File: speex_bits.c
Handles bit packing/unpacking
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of the Xiph.org Foundation nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "speex_bits.h"
#include "misc.h"
void speex_bits_init(SpeexBits *bits)
{
int i;
bits->bytes = (char*)speex_alloc(MAX_BYTES_PER_FRAME);
bits->buf_size = MAX_BYTES_PER_FRAME;
for (i=0;i<bits->buf_size;i++)
bits->bytes[i]=0;
bits->nbBits=0;
bits->bytePtr=0;
bits->bitPtr=0;
bits->owner=1;
bits->overflow=0;
}
void speex_bits_init_buffer(SpeexBits *bits, void *buff, int buf_size)
{
int i;
bits->bytes = (char*)buff;
bits->buf_size = buf_size;
for (i=0;i<buf_size;i++)
bits->bytes[i]=0;
bits->nbBits=0;
bits->bytePtr=0;
bits->bitPtr=0;
bits->owner=0;
bits->overflow=0;
}
void speex_bits_destroy(SpeexBits *bits)
{
if (bits->owner)
speex_free(bits->bytes);
/* Will do something once the allocation is dynamic */
}
void speex_bits_reset(SpeexBits *bits)
{
int i;
for (i=0;i<bits->buf_size;i++)
bits->bytes[i]=0;
bits->nbBits=0;
bits->bytePtr=0;
bits->bitPtr=0;
bits->overflow=0;
}
void speex_bits_rewind(SpeexBits *bits)
{
bits->bytePtr=0;
bits->bitPtr=0;
bits->overflow=0;
}
void speex_bits_read_from(SpeexBits *bits, char *bytes, int len)
{
int i;
if (len > bits->buf_size)
{
speex_warning_int("Packet if larger than allocated buffer: ", len);
if (bits->owner)
{
char *tmp = (char*)speex_realloc(bits->bytes, len);
if (tmp)
{
bits->buf_size=len;
bits->bytes=tmp;
} else {
len=bits->buf_size;
speex_warning("Could not resize input buffer: truncating input");
}
} else {
speex_warning("Do not own input buffer: truncating input");
len=bits->buf_size;
}
}
for (i=0;i<len;i++)
bits->bytes[i]=bytes[i];
bits->nbBits=len<<3;
bits->bytePtr=0;
bits->bitPtr=0;
bits->overflow=0;
}
static void speex_bits_flush(SpeexBits *bits)
{
int i;
if (bits->bytePtr>0)
{
for (i=bits->bytePtr;i<((bits->nbBits+7)>>3);i++)
bits->bytes[i-bits->bytePtr]=bits->bytes[i];
}
bits->nbBits -= bits->bytePtr<<3;
bits->bytePtr=0;
}
void speex_bits_read_whole_bytes(SpeexBits *bits, char *bytes, int len)
{
int i,pos;
if ((bits->nbBits>>3)+len+1 > bits->buf_size)
{
speex_warning_int("Packet if larger than allocated buffer: ", len);
if (bits->owner)
{
char *tmp = (char*)speex_realloc(bits->bytes, (bits->nbBits>>3)+len+1);
if (tmp)
{
bits->buf_size=(bits->nbBits>>3)+len+1;
bits->bytes=tmp;
} else {
len=bits->buf_size-(bits->nbBits>>3)-1;
speex_warning("Could not resize input buffer: truncating input");
}
} else {
speex_warning("Do not own input buffer: truncating input");
len=bits->buf_size;
}
}
speex_bits_flush(bits);
pos=bits->nbBits>>3;
for (i=0;i<len;i++)
bits->bytes[pos+i]=bytes[i];
bits->nbBits+=len<<3;
}
int speex_bits_write(SpeexBits *bits, char *bytes, int max_len)
{
int i;
if (max_len > ((bits->nbBits+7)>>3))
max_len = ((bits->nbBits+7)>>3);
for (i=0;i<max_len;i++)
bytes[i]=bits->bytes[i];
return max_len;
}
int speex_bits_write_whole_bytes(SpeexBits *bits, char *bytes, int max_len)
{
int i;
if (max_len > ((bits->nbBits)>>3))
max_len = ((bits->nbBits)>>3);
for (i=0;i<max_len;i++)
bytes[i]=bits->bytes[i];
if (bits->bitPtr>0)
bits->bytes[0]=bits->bytes[max_len];
else
bits->bytes[0]=0;
for (i=1;i<((bits->nbBits)>>3)+1;i++)
bits->bytes[i]=0;
bits->bytePtr=0;
bits->nbBits &= 7;
return max_len;
}
void speex_bits_pack(SpeexBits *bits, int data, int nbBits)
{
int i;
unsigned int d=data;
if (bits->bytePtr+((nbBits+bits->bitPtr)>>3) >= bits->buf_size)
{
speex_warning("Buffer too small to pack bits");
if (bits->owner)
{
char *tmp = (char*)speex_realloc(bits->bytes, ((bits->buf_size+5)*3)>>1);
if (tmp)
{
for (i=bits->buf_size;i<(((bits->buf_size+5)*3)>>1);i++)
tmp[i]=0;
bits->buf_size=((bits->buf_size+5)*3)>>1;
bits->bytes=tmp;
} else {
speex_warning("Could not resize input buffer: not packing");
return;
}
} else {
speex_warning("Do not own input buffer: not packing");
return;
}
}
while(nbBits)
{
int bit;
bit = (d>>(nbBits-1))&1;
bits->bytes[bits->bytePtr] |= bit<<(7-bits->bitPtr);
bits->bitPtr++;
if (bits->bitPtr==8)
{
bits->bitPtr=0;
bits->bytePtr++;
}
bits->nbBits++;
nbBits--;
}
}
int speex_bits_unpack_signed(SpeexBits *bits, int nbBits)
{
unsigned int d=speex_bits_unpack_unsigned(bits,nbBits);
/* If number is negative */
if (d>>(nbBits-1))
{
d |= (-1)<<nbBits;
}
return d;
}
unsigned int speex_bits_unpack_unsigned(SpeexBits *bits, int nbBits)
{
unsigned int d=0;
if ((bits->bytePtr<<3)+bits->bitPtr+nbBits>bits->nbBits)
bits->overflow=1;
if (bits->overflow)
return 0;
while(nbBits)
{
d<<=1;
d |= (bits->bytes[bits->bytePtr]>>(7-bits->bitPtr))&1;
bits->bitPtr++;
if (bits->bitPtr==8)
{
bits->bitPtr=0;
bits->bytePtr++;
}
nbBits--;
}
return d;
}
unsigned int speex_bits_peek_unsigned(SpeexBits *bits, int nbBits)
{
unsigned int d=0;
int bitPtr, bytePtr;
char *bytes;
if ((bits->bytePtr<<3)+bits->bitPtr+nbBits>bits->nbBits)
bits->overflow=1;
if (bits->overflow)
return 0;
bitPtr=bits->bitPtr;
bytePtr=bits->bytePtr;
bytes = bits->bytes;
while(nbBits)
{
d<<=1;
d |= (bytes[bytePtr]>>(7-bitPtr))&1;
bitPtr++;
if (bitPtr==8)
{
bitPtr=0;
bytePtr++;
}
nbBits--;
}
return d;
}
int speex_bits_peek(SpeexBits *bits)
{
if ((bits->bytePtr<<3)+bits->bitPtr+1>bits->nbBits)
bits->overflow=1;
if (bits->overflow)
return 0;
return (bits->bytes[bits->bytePtr]>>(7-bits->bitPtr))&1;
}
void speex_bits_advance(SpeexBits *bits, int n)
{
int nbytes, nbits;
if ((bits->bytePtr<<3)+bits->bitPtr+n>bits->nbBits)
bits->overflow=1;
if (bits->overflow)
return;
nbytes = n >> 3;
nbits = n & 7;
bits->bytePtr += nbytes;
bits->bitPtr += nbits;
if (bits->bitPtr>7)
{
bits->bitPtr-=8;
bits->bytePtr++;
}
}
int speex_bits_remaining(SpeexBits *bits)
{
if (bits->overflow)
return -1;
else
return bits->nbBits-((bits->bytePtr<<3)+bits->bitPtr);
}
int speex_bits_nbytes(SpeexBits *bits)
{
return ((bits->nbBits+7)>>3);
}
void speex_bits_insert_terminator(SpeexBits *bits)
{
if (bits->bitPtr<7)
speex_bits_pack(bits, 0, 1);
while (bits->bitPtr<7)
speex_bits_pack(bits, 1, 1);
}

View File

@ -1,387 +0,0 @@
/* Copyright (C) 2002 Jean-Marc Valin
File: cb_search.c
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of the Xiph.org Foundation nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "cb_search.h"
#include "filters.h"
#include "stack_alloc.h"
#include "vq.h"
#include "misc.h"
void split_cb_search_shape_sign(
float target[], /* target vector */
float ak[], /* LPCs for this subframe */
float awk1[], /* Weighted LPCs for this subframe */
float awk2[], /* Weighted LPCs for this subframe */
void *par, /* Codebook/search parameters*/
int p, /* number of LPC coeffs */
int nsf, /* number of samples in subframe */
float *exc,
float *r,
SpeexBits *bits,
char *stack,
int complexity
)
{
int i,j,k,m,n,q;
float *resp;
float *t, *e, *E, *r2;
float *tmp;
float *ndist, *odist;
int *itmp;
float **ot, **nt;
int **nind, **oind;
int *ind;
signed char *shape_cb;
int shape_cb_size, subvect_size, nb_subvect;
split_cb_params *params;
int N=2;
int *best_index;
float *best_dist;
int have_sign;
N=complexity;
if (N>10)
N=10;
ot=PUSH(stack, N, float*);
nt=PUSH(stack, N, float*);
oind=PUSH(stack, N, int*);
nind=PUSH(stack, N, int*);
params = (split_cb_params *) par;
subvect_size = params->subvect_size;
nb_subvect = params->nb_subvect;
shape_cb_size = 1<<params->shape_bits;
shape_cb = params->shape_cb;
have_sign = params->have_sign;
resp = PUSH(stack, shape_cb_size*subvect_size, float);
t = PUSH(stack, nsf, float);
e = PUSH(stack, nsf, float);
r2 = PUSH(stack, nsf, float);
E = PUSH(stack, shape_cb_size, float);
ind = PUSH(stack, nb_subvect, int);
tmp = PUSH(stack, 2*N*nsf, float);
for (i=0;i<N;i++)
{
ot[i]=tmp;
tmp += nsf;
nt[i]=tmp;
tmp += nsf;
}
best_index = PUSH(stack, N, int);
best_dist = PUSH(stack, N, float);
ndist = PUSH(stack, N, float);
odist = PUSH(stack, N, float);
itmp = PUSH(stack, 2*N*nb_subvect, int);
for (i=0;i<N;i++)
{
nind[i]=itmp;
itmp+=nb_subvect;
oind[i]=itmp;
itmp+=nb_subvect;
for (j=0;j<nb_subvect;j++)
nind[i][j]=oind[i][j]=-1;
}
for (j=0;j<N;j++)
for (i=0;i<nsf;i++)
ot[j][i]=target[i];
for (i=0;i<nsf;i++)
t[i]=target[i];
/* Pre-compute codewords response and energy */
for (i=0;i<shape_cb_size;i++)
{
float *res;
signed char *shape;
res = resp+i*subvect_size;
shape = shape_cb+i*subvect_size;
/* Compute codeword response using convolution with impulse response */
for(j=0;j<subvect_size;j++)
{
res[j]=0;
for (k=0;k<=j;k++)
res[j] += 0.03125*shape[k]*r[j-k];
}
/* Compute codeword energy */
E[i]=0;
for(j=0;j<subvect_size;j++)
E[i]+=res[j]*res[j];
}
for (j=0;j<N;j++)
odist[j]=0;
/*For all subvectors*/
for (i=0;i<nb_subvect;i++)
{
/*"erase" nbest list*/
for (j=0;j<N;j++)
ndist[j]=-1;
/*For all n-bests of previous subvector*/
for (j=0;j<N;j++)
{
float *x=ot[j]+subvect_size*i;
/*Find new n-best based on previous n-best j*/
if (have_sign)
vq_nbest_sign(x, resp, subvect_size, shape_cb_size, E, N, best_index, best_dist);
else
vq_nbest(x, resp, subvect_size, shape_cb_size, E, N, best_index, best_dist);
/*For all new n-bests*/
for (k=0;k<N;k++)
{
float *ct;
float err=0;
ct = ot[j];
/*update target*/
/*previous target*/
for (m=i*subvect_size;m<(i+1)*subvect_size;m++)
t[m]=ct[m];
/* New code: update only enough of the target to calculate error*/
{
int rind;
float *res;
float sign=1;
rind = best_index[k];
if (rind>=shape_cb_size)
{
sign=-1;
rind-=shape_cb_size;
}
res = resp+rind*subvect_size;
if (sign>0)
for (m=0;m<subvect_size;m++)
t[subvect_size*i+m] -= res[m];
else
for (m=0;m<subvect_size;m++)
t[subvect_size*i+m] += res[m];
}
/*compute error (distance)*/
err=odist[j];
for (m=i*subvect_size;m<(i+1)*subvect_size;m++)
err += t[m]*t[m];
/*update n-best list*/
if (err<ndist[N-1] || ndist[N-1]<-.5)
{
/*previous target (we don't care what happened before*/
for (m=(i+1)*subvect_size;m<nsf;m++)
t[m]=ct[m];
/* New code: update the rest of the target only if it's worth it */
for (m=0;m<subvect_size;m++)
{
float g;
int rind;
float sign=1;
rind = best_index[k];
if (rind>=shape_cb_size)
{
sign=-1;
rind-=shape_cb_size;
}
g=sign*0.03125*shape_cb[rind*subvect_size+m];
q=subvect_size-m;
for (n=subvect_size*(i+1);n<nsf;n++,q++)
t[n] -= g*r[q];
}
for (m=0;m<N;m++)
{
if (err < ndist[m] || ndist[m]<-.5)
{
for (n=N-1;n>m;n--)
{
for (q=(i+1)*subvect_size;q<nsf;q++)
nt[n][q]=nt[n-1][q];
for (q=0;q<nb_subvect;q++)
nind[n][q]=nind[n-1][q];
ndist[n]=ndist[n-1];
}
for (q=(i+1)*subvect_size;q<nsf;q++)
nt[m][q]=t[q];
for (q=0;q<nb_subvect;q++)
nind[m][q]=oind[j][q];
nind[m][i]=best_index[k];
ndist[m]=err;
break;
}
}
}
}
if (i==0)
break;
}
/*update old-new data*/
/* just swap pointers instead of a long copy */
{
float **tmp2;
tmp2=ot;
ot=nt;
nt=tmp2;
}
for (j=0;j<N;j++)
for (m=0;m<nb_subvect;m++)
oind[j][m]=nind[j][m];
for (j=0;j<N;j++)
odist[j]=ndist[j];
}
/*save indices*/
for (i=0;i<nb_subvect;i++)
{
ind[i]=nind[0][i];
speex_bits_pack(bits,ind[i],params->shape_bits+have_sign);
}
/* Put everything back together */
for (i=0;i<nb_subvect;i++)
{
int rind;
float sign=1;
rind = ind[i];
if (rind>=shape_cb_size)
{
sign=-1;
rind-=shape_cb_size;
}
for (j=0;j<subvect_size;j++)
e[subvect_size*i+j]=sign*0.03125*shape_cb[rind*subvect_size+j];
}
/* Update excitation */
for (j=0;j<nsf;j++)
exc[j]+=e[j];
/* Update target */
syn_percep_zero(e, ak, awk1, awk2, r2, nsf,p, stack);
for (j=0;j<nsf;j++)
target[j]-=r2[j];
}
void split_cb_shape_sign_unquant(
float *exc,
void *par, /* non-overlapping codebook */
int nsf, /* number of samples in subframe */
SpeexBits *bits,
char *stack
)
{
int i,j;
int *ind, *signs;
signed char *shape_cb;
int shape_cb_size, subvect_size, nb_subvect;
split_cb_params *params;
int have_sign;
params = (split_cb_params *) par;
subvect_size = params->subvect_size;
nb_subvect = params->nb_subvect;
shape_cb_size = 1<<params->shape_bits;
shape_cb = params->shape_cb;
have_sign = params->have_sign;
ind = PUSH(stack, nb_subvect, int);
signs = PUSH(stack, nb_subvect, int);
/* Decode codewords and gains */
for (i=0;i<nb_subvect;i++)
{
if (have_sign)
signs[i] = speex_bits_unpack_unsigned(bits, 1);
else
signs[i] = 0;
ind[i] = speex_bits_unpack_unsigned(bits, params->shape_bits);
}
/* Compute decoded excitation */
for (i=0;i<nb_subvect;i++)
{
float s=1;
if (signs[i])
s=-1;
for (j=0;j<subvect_size;j++)
exc[subvect_size*i+j]+=s*0.03125*shape_cb[ind[i]*subvect_size+j];
}
}
void noise_codebook_quant(
float target[], /* target vector */
float ak[], /* LPCs for this subframe */
float awk1[], /* Weighted LPCs for this subframe */
float awk2[], /* Weighted LPCs for this subframe */
void *par, /* Codebook/search parameters*/
int p, /* number of LPC coeffs */
int nsf, /* number of samples in subframe */
float *exc,
float *r,
SpeexBits *bits,
char *stack,
int complexity
)
{
int i;
float *tmp=PUSH(stack, nsf, float);
residue_percep_zero(target, ak, awk1, awk2, tmp, nsf, p, stack);
for (i=0;i<nsf;i++)
exc[i]+=tmp[i];
for (i=0;i<nsf;i++)
target[i]=0;
}
void noise_codebook_unquant(
float *exc,
void *par, /* non-overlapping codebook */
int nsf, /* number of samples in subframe */
SpeexBits *bits,
char *stack
)
{
speex_rand_vec(1, exc, nsf);
}

View File

@ -1,95 +0,0 @@
/* Copyright (C) 2002 Jean-Marc Valin & David Rowe
File: cb_search.c
Overlapped codebook search
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of the Xiph.org Foundation nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef CB_SEARCH_H
#define CB_SEARCH_H
#include "speex_bits.h"
typedef struct split_cb_params {
int subvect_size;
int nb_subvect;
signed char *shape_cb;
int shape_bits;
int have_sign;
} split_cb_params;
void split_cb_search_shape_sign(
float target[], /* target vector */
float ak[], /* LPCs for this subframe */
float awk1[], /* Weighted LPCs for this subframe */
float awk2[], /* Weighted LPCs for this subframe */
void *par, /* Codebook/search parameters*/
int p, /* number of LPC coeffs */
int nsf, /* number of samples in subframe */
float *exc,
float *r,
SpeexBits *bits,
char *stack,
int complexity
);
void split_cb_shape_sign_unquant(
float *exc,
void *par, /* non-overlapping codebook */
int nsf, /* number of samples in subframe */
SpeexBits *bits,
char *stack
);
void noise_codebook_quant(
float target[], /* target vector */
float ak[], /* LPCs for this subframe */
float awk1[], /* Weighted LPCs for this subframe */
float awk2[], /* Weighted LPCs for this subframe */
void *par, /* Codebook/search parameters*/
int p, /* number of LPC coeffs */
int nsf, /* number of samples in subframe */
float *exc,
float *r,
SpeexBits *bits,
char *stack,
int complexity
);
void noise_codebook_unquant(
float *exc,
void *par, /* non-overlapping codebook */
int nsf, /* number of samples in subframe */
SpeexBits *bits,
char *stack
);
#endif

View File

@ -1,50 +0,0 @@
/* Copyright (C) 2002 Jean-Marc Valin
File: exc_10_16_table.c
Codebook for excitation in narrowband CELP mode (3200 bps)
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of the Xiph.org Foundation nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
signed char exc_10_16_table[160] = {
22,39,14,44,11,35,-2,23,-4,6,
46,-28,13,-27,-23,12,4,20,-5,9,
37,-18,-23,23,0,9,-6,-20,4,-1,
-17,-5,-4,17,0,1,9,-2,1,2,
2,-12,8,-25,39,15,9,16,-55,-11,
9,11,5,10,-2,-60,8,13,-6,11,
-16,27,-47,-12,11,1,16,-7,9,-3,
-29,9,-14,25,-19,34,36,12,40,-10,
-3,-24,-14,-37,-21,-35,-2,-36,3,-6,
67,28,6,-17,-3,-12,-16,-15,-17,-7,
-59,-36,-13,1,7,1,2,10,2,11,
13,10,8,-2,7,3,5,4,2,2,
-3,-8,4,-5,6,7,-42,15,35,-2,
-46,38,28,-20,-9,1,7,-3,0,-2,
0,0,0,0,0,0,0,0,0,0,
-15,-28,52,32,5,-5,-17,-20,-10,-1};

View File

@ -1,66 +0,0 @@
/* Copyright (C) 2002 Jean-Marc Valin
File: exc_10_32_table.c
Codebook for excitation in narrowband CELP mode (4000 bps)
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of the Xiph.org Foundation nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
signed char exc_10_32_table[320] = {
7,17,17,27,25,22,12,4,-3,0,
28,-36,39,-24,-15,3,-9,15,-5,10,
31,-28,11,31,-21,9,-11,-11,-2,-7,
-25,14,-22,31,4,-14,19,-12,14,-5,
4,-7,4,-5,9,0,-2,42,-47,-16,
1,8,0,9,23,-57,0,28,-11,6,
-31,55,-45,3,-5,4,2,-2,4,-7,
-3,6,-2,7,-3,12,5,8,54,-10,
8,-7,-8,-24,-25,-27,-14,-5,8,5,
44,23,5,-9,-11,-11,-13,-9,-12,-8,
-29,-8,-22,6,-15,3,-12,-1,-5,-3,
34,-1,29,-16,17,-4,12,2,1,4,
-2,-4,2,-1,11,-3,-52,28,30,-9,
-32,25,44,-20,-24,4,6,-1,0,0,
0,0,0,0,0,0,0,0,0,0,
-25,-10,22,29,13,-13,-22,-13,-4,0,
-4,-16,10,15,-36,-24,28,25,-1,-3,
66,-33,-11,-15,6,0,3,4,-2,5,
24,-20,-47,29,19,-2,-4,-1,0,-1,
-2,3,1,8,-11,5,5,-57,28,28,
0,-16,4,-4,12,-6,-1,2,-20,61,
-9,24,-22,-42,29,6,17,8,4,2,
-65,15,8,10,5,6,5,3,2,-2,
-3,5,-9,4,-5,23,13,23,-3,-63,
3,-5,-4,-6,0,-3,23,-36,-46,9,
5,5,8,4,9,-5,1,-3,10,1,
-6,10,-11,24,-47,31,22,-12,14,-10,
6,11,-7,-7,7,-31,51,-12,-6,7,
6,-17,9,-11,-20,52,-19,3,-6,-6,
-8,-5,23,-41,37,1,-21,10,-14,8,
7,5,-15,-15,23,39,-26,-33,7,2,
-32,-30,-21,-8,4,12,17,15,14,11};

View File

@ -1,66 +0,0 @@
/* Copyright (C) 2002 Jean-Marc Valin
File: exc_20_32_table.c
Codebook for excitation in narrowband CELP mode (2000 bps)
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of the Xiph.org Foundation nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
signed char exc_20_32_table[640] = {
12,32,25,46,36,33,9,14,-3,6,1,-8,0,-10,-5,-7,-7,-7,-5,-5,
31,-27,24,-32,-4,10,-11,21,-3,19,23,-9,22,24,-10,-1,-10,-13,-7,-11,
42,-33,31,19,-8,0,-10,-16,1,-21,-17,10,-8,14,8,4,11,-2,5,-2,
-33,11,-16,33,11,-4,9,-4,11,2,6,-5,8,-5,11,-4,-6,26,-36,-16,
0,4,-2,-8,12,6,-1,34,-46,-22,9,9,21,9,5,-66,-5,26,2,10,
13,2,19,9,12,-81,3,13,13,0,-14,22,-35,6,-7,-4,6,-6,10,-6,
-31,38,-33,0,-10,-11,5,-12,12,-17,5,0,-6,13,-9,10,8,25,33,2,
-12,8,-6,10,-2,21,7,17,43,5,11,-7,-9,-20,-36,-20,-23,-4,-4,-3,
27,-9,-9,-49,-39,-38,-11,-9,6,5,23,25,5,3,3,4,1,2,-3,-1,
87,39,17,-21,-9,-19,-9,-15,-13,-14,-17,-11,-10,-11,-8,-6,-1,-3,-3,-1,
-54,-34,-27,-8,-11,-4,-5,0,0,4,8,6,9,7,9,7,6,5,5,5,
48,10,19,-10,12,-1,9,-3,2,5,-3,2,-2,-2,0,-2,-26,6,9,-7,
-16,-9,2,7,7,-5,-43,11,22,-11,-9,34,37,-15,-13,-6,1,-1,1,1,
-64,56,52,-11,-27,5,4,3,1,2,1,3,-1,-4,-4,-10,-7,-4,-4,2,
-1,-7,-7,-12,-10,-15,-9,-5,-5,-11,-16,-13,6,16,4,-13,-16,-10,-4,2,
-47,-13,25,47,19,-14,-20,-8,-17,0,-3,-13,1,6,-17,-14,15,1,10,6,
-24,0,-10,19,-69,-8,14,49,17,-5,33,-29,3,-4,0,2,-8,5,-6,2,
120,-56,-12,-47,23,-9,6,-5,1,2,-5,1,-10,4,-1,-1,4,-1,0,-3,
30,-52,-67,30,22,11,-1,-4,3,0,7,2,0,1,-10,-4,-8,-13,5,1,
1,-1,5,13,-9,-3,-10,-62,22,48,-4,-6,2,3,5,1,1,4,1,13,
3,-20,10,-9,13,-2,-4,9,-20,44,-1,20,-32,-67,19,0,28,11,8,2,
-11,15,-19,-53,31,2,34,10,6,-4,-58,8,10,13,14,1,12,2,0,0,
-128,37,-8,44,-9,26,-3,18,2,6,11,-1,9,1,5,3,0,1,1,2,
12,3,-2,-3,7,25,9,18,-6,-37,3,-8,-16,3,-10,-7,17,-34,-44,11,
17,-15,-3,-16,-1,-13,11,-46,-65,-2,8,13,2,4,4,5,15,5,9,6,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-9,19,-12,12,-28,38,29,-1,12,2,5,23,-10,3,4,-15,21,-4,3,3,
6,17,-9,-4,-8,-20,26,5,-10,6,1,-19,18,-15,-12,47,-6,-2,-7,-9,
-1,-17,-2,-2,-14,30,-14,2,-7,-4,-1,-12,11,-25,16,-3,-12,11,-7,7,
-17,1,19,-28,31,-7,-10,7,-10,3,12,5,-16,6,24,41,-29,-54,0,1,
7,-1,5,-6,13,10,-4,-8,8,-9,-27,-53,-38,-1,10,19,17,16,12,12,
0,3,-7,-4,13,12,-31,-14,6,-5,3,5,17,43,50,25,10,1,-6,-2};

View File

@ -1,290 +0,0 @@
/* Copyright (C) 2002 Jean-Marc Valin
File: exc_5_256_table.c
Codebook for excitation in narrowband CELP mode (12800 bps)
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of the Xiph.org Foundation nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
signed char exc_5_256_table[1280] = {
-8,-37,5,-43,5,
73,61,39,12,-3,
-61,-32,2,42,30,
-3,17,-27,9,34,
20,-1,-5,2,23,
-7,-46,26,53,-47,
20,-2,-33,-89,-51,
-64,27,11,15,-34,
-5,-56,25,-9,-1,
-29,1,40,67,-23,
-16,16,33,19,7,
14,85,22,-10,-10,
-12,-7,-1,52,89,
29,11,-20,-37,-46,
-15,17,-24,-28,24,
2,1,0,23,-101,
23,14,-1,-23,-18,
9,5,-13,38,1,
-28,-28,4,27,51,
-26,34,-40,35,47,
54,38,-54,-26,-6,
42,-25,13,-30,-36,
18,41,-4,-33,23,
-32,-7,-4,51,-3,
17,-52,56,-47,36,
-2,-21,36,10,8,
-33,31,19,9,-5,
-40,10,-9,-21,19,
18,-78,-18,-5,0,
-26,-36,-47,-51,-44,
18,40,27,-2,29,
49,-26,2,32,-54,
30,-73,54,3,-5,
36,22,53,10,-1,
-84,-53,-29,-5,3,
-44,53,-51,4,22,
71,-35,-1,33,-5,
-27,-7,36,17,-23,
-39,16,-9,-55,-15,
-20,39,-35,6,-39,
-14,18,48,-64,-17,
-15,9,39,81,37,
-68,37,47,-21,-6,
-104,13,6,9,-2,
35,8,-23,18,42,
45,21,33,-5,-49,
9,-6,-43,-56,39,
2,-16,-25,87,1,
-3,-9,17,-25,-11,
-9,-1,10,2,-14,
-14,4,-1,-10,28,
-23,40,-32,26,-9,
26,4,-27,-23,3,
42,-60,1,49,-3,
27,10,-52,-40,-2,
18,45,-23,17,-44,
3,-3,17,-46,52,
-40,-47,25,75,31,
-49,53,30,-30,-32,
-36,38,-6,-15,-16,
54,-27,-48,3,38,
-29,-32,-22,-14,-4,
-23,-13,32,-39,9,
8,-45,-13,34,-16,
49,40,32,31,28,
23,23,32,47,59,
-68,8,62,44,25,
-14,-24,-65,-16,36,
67,-25,-38,-21,4,
-33,-2,42,5,-63,
40,11,26,-42,-23,
-61,79,-31,23,-20,
10,-32,53,-25,-36,
10,-26,-5,3,0,
-71,5,-10,-37,1,
-24,21,-54,-17,1,
-29,-25,-15,-27,32,
68,45,-16,-37,-18,
-5,1,0,-77,71,
-6,3,-20,71,-67,
29,-35,10,-30,19,
4,16,17,5,0,
-14,19,2,28,26,
59,3,2,24,39,
55,-50,-45,-18,-17,
33,-35,14,-1,1,
8,87,-35,-29,0,
-27,13,-7,23,-13,
37,-40,50,-35,14,
19,-7,-14,49,54,
-5,22,-2,-29,-8,
-27,38,13,27,48,
12,-41,-21,-15,28,
7,-16,-24,-19,-20,
11,-20,9,2,13,
23,-20,11,27,-27,
71,-69,8,2,-6,
22,12,16,16,9,
-16,-8,-17,1,25,
1,40,-37,-33,66,
94,53,4,-22,-25,
-41,-42,25,35,-16,
-15,57,31,-29,-32,
21,16,-60,45,15,
-1,7,57,-26,-47,
-29,11,8,15,19,
-105,-8,54,27,10,
-17,6,-12,-1,-10,
4,0,23,-10,31,
13,11,10,12,-64,
23,-3,-8,-19,16,
52,24,-40,16,10,
40,5,9,0,-13,
-7,-21,-8,-6,-7,
-21,59,16,-53,18,
-60,11,-47,14,-18,
25,-13,-24,4,-39,
16,-28,54,26,-67,
30,27,-20,-52,20,
-12,55,12,18,-16,
39,-14,-6,-26,56,
-88,-55,12,25,26,
-37,6,75,0,-34,
-81,54,-30,1,-7,
49,-23,-14,21,10,
-62,-58,-57,-47,-34,
15,-4,34,-78,31,
25,-11,7,50,-10,
42,-63,14,-36,-4,
57,55,57,53,42,
-42,-1,15,40,37,
15,25,-11,6,1,
31,-2,-6,-1,-7,
-64,34,28,30,-1,
3,21,0,-88,-12,
-56,25,-28,40,8,
-28,-14,9,12,2,
-6,-17,22,49,-6,
-26,14,28,-20,4,
-12,50,35,40,13,
-38,-58,-29,17,30,
22,60,26,-54,-39,
-12,58,-28,-63,10,
-21,-8,-12,26,-62,
6,-10,-11,-22,-6,
-7,4,1,18,2,
-70,11,14,4,13,
19,-24,-34,24,67,
17,51,-21,13,23,
54,-30,48,1,-13,
80,26,-16,-2,13,
-4,6,-30,29,-24,
73,-58,30,-27,20,
-2,-21,41,45,30,
-27,-3,-5,-18,-20,
-49,-3,-35,10,42,
-19,-67,-53,-11,9,
13,-15,-33,-51,-30,
15,7,25,-30,4,
28,-22,-34,54,-29,
39,-46,20,16,34,
-4,47,75,1,-44,
-55,-24,7,-1,9,
-42,50,-8,-36,41,
68,0,-4,-10,-23,
-15,-50,64,36,-9,
-27,12,25,-38,-47,
-37,32,-49,51,-36,
2,-4,69,-26,19,
7,45,67,46,13,
-63,46,15,-47,4,
-41,13,-6,5,-21,
37,26,-55,-7,33,
-1,-28,10,-17,-64,
-14,0,-36,-17,93,
-3,-9,-66,44,-21,
3,-12,38,-6,-13,
-12,19,13,43,-43,
-10,-12,6,-5,9,
-49,32,-5,2,4,
5,15,-16,10,-21,
8,-62,-8,64,8,
79,-1,-66,-49,-18,
5,40,-5,-30,-45,
1,-6,21,-32,93,
-18,-30,-21,32,21,
-18,22,8,5,-41,
-54,80,22,-10,-7,
-8,-23,-64,66,56,
-14,-30,-41,-46,-14,
-29,-37,27,-14,42,
-2,-9,-29,34,14,
33,-14,22,4,10,
26,26,28,32,23,
-72,-32,3,0,-14,
35,-42,-78,-32,6,
29,-18,-45,-5,7,
-33,-45,-3,-22,-34,
8,-8,4,-51,-25,
-9,59,-78,21,-5,
-25,-48,66,-15,-17,
-24,-49,-13,25,-23,
-64,-6,40,-24,-19,
-11,57,-33,-8,1,
10,-52,-54,28,39,
49,34,-11,-61,-41,
-43,10,15,-15,51,
30,15,-51,32,-34,
-2,-34,14,18,16,
1,1,-3,-3,1,
1,-18,6,16,48,
12,-5,-42,7,36,
48,7,-20,-10,7,
12,2,54,39,-38,
37,54,4,-11,-8,
-46,-10,5,-10,-34,
46,-12,29,-37,39,
36,-11,24,56,17,
14,20,25,0,-25,
-28,55,-7,-5,27,
3,9,-26,-8,6,
-24,-10,-30,-31,-34,
18,4,22,21,40,
-1,-29,-37,-8,-21,
92,-29,11,-3,11,
73,23,22,7,4,
-44,-9,-11,21,-13,
11,9,-78,-1,47,
114,-12,-37,-19,-5,
-11,-22,19,12,-30,
7,38,45,-21,-8,
-9,55,-45,56,-21,
7,17,46,-57,-87,
-6,27,31,31,7,
-56,-12,46,21,-5,
-12,36,3,3,-21,
43,19,12,-7,9,
-14,0,-9,-33,-91,
7,26,3,-11,64,
83,-31,-46,25,2,
9,5,2,2,-1,
20,-17,10,-5,-27,
-8,20,8,-19,16,
-21,-13,-31,5,5,
42,24,9,34,-20,
28,-61,22,11,-39,
64,-20,-1,-30,-9,
-20,24,-25,-24,-29,
22,-60,6,-5,41,
-9,-87,14,34,15,
-57,52,69,15,-3,
-102,58,16,3,6,
60,-75,-32,26,7,
-57,-27,-32,-24,-21,
-29,-16,62,-46,31,
30,-27,-15,7,15};

View File

@ -1,98 +0,0 @@
/* Copyright (C) 2002 Jean-Marc Valin
File: exc_5_64_table.c
Codebook for excitation in narrowband CELP mode (9600 bps)
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of the Xiph.org Foundation nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
signed char exc_5_64_table[320]={
1,5,-15,49,-66,
-48,-4,50,-44,7,
37,16,-18,25,-26,
-26,-15,19,19,-27,
-47,28,57,5,-17,
-32,-41,68,21,-2,
64,56,8,-16,-13,
-26,-9,-16,11,6,
-39,25,-19,22,-31,
20,-45,55,-43,10,
-16,47,-40,40,-20,
-51,3,-17,-14,-15,
-24,53,-20,-46,46,
27,-68,32,3,-18,
-5,9,-31,16,-9,
-10,-1,-23,48,95,
47,25,-41,-32,-3,
15,-25,-55,36,41,
-27,20,5,13,14,
-22,5,2,-23,18,
46,-15,17,-18,-34,
-5,-8,27,-55,73,
16,2,-1,-17,40,
-78,33,0,2,19,
4,53,-16,-15,-16,
-28,-3,-13,49,8,
-7,-29,27,-13,32,
20,32,-61,16,14,
41,44,40,24,20,
7,4,48,-60,-77,
17,-6,-48,65,-15,
32,-30,-71,-10,-3,
-6,10,-2,-7,-29,
-56,67,-30,7,-5,
86,-6,-10,0,5,
-31,60,34,-38,-3,
24,10,-2,30,23,
24,-41,12,70,-43,
15,-17,6,13,16,
-13,8,30,-15,-8,
5,23,-34,-98,-4,
-13,13,-48,-31,70,
12,31,25,24,-24,
26,-7,33,-16,8,
5,-11,-14,-8,-65,
13,10,-2,-9,0,
-3,-68,5,35,7,
0,-31,-1,-17,-9,
-9,16,-37,-18,-1,
69,-48,-28,22,-21,
-11,5,49,55,23,
-86,-36,16,2,13,
63,-51,30,-11,13,
24,-18,-6,14,-19,
1,41,9,-5,27,
-36,-44,-34,-37,-21,
-26,31,-39,15,43,
5,-8,29,20,-8,
-20,-52,-28,-1,13,
26,-34,-10,-9,27,
-8,8,27,-66,4,
12,-22,49,10,-77,
32,-18,3,-38,12,
-3,-1,2,2,0};

View File

@ -1,162 +0,0 @@
/* Copyright (C) 2002 Jean-Marc Valin
File: exc_8_128_table.c
Codebook for excitation in narrowband CELP mode (7000 bps)
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of the Xiph.org Foundation nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
signed char exc_8_128_table[1024] = {
-14,9,13,-32,2,-10,31,-10,
-8,-8,6,-4,-1,10,-64,23,
6,20,13,6,8,-22,16,34,
7,42,-49,-28,5,26,4,-15,
41,34,41,32,33,24,23,14,
8,40,34,4,-24,-41,-19,-15,
13,-13,33,-54,24,27,-44,33,
27,-15,-15,24,-19,14,-36,14,
-9,24,-12,-4,37,-5,16,-34,
5,10,33,-15,-54,-16,12,25,
12,1,2,0,3,-1,-4,-4,
11,2,-56,54,27,-20,13,-6,
-46,-41,-33,-11,-5,7,12,14,
-14,-5,8,20,6,3,4,-8,
-5,-42,11,8,-14,25,-2,2,
13,11,-22,39,-9,9,5,-45,
-9,7,-9,12,-7,34,-17,-102,
7,2,-42,18,35,-9,-34,11,
-5,-2,3,22,46,-52,-25,-9,
-94,8,11,-5,-5,-5,4,-7,
-35,-7,54,5,-32,3,24,-9,
-22,8,65,37,-1,-12,-23,-6,
-9,-28,55,-33,14,-3,2,18,
-60,41,-17,8,-16,17,-11,0,
-11,29,-28,37,9,-53,33,-14,
-9,7,-25,-7,-11,26,-32,-8,
24,-21,22,-19,19,-10,29,-14,
0,0,0,0,0,0,0,0,
-5,-52,10,41,6,-30,-4,16,
32,22,-27,-22,32,-3,-28,-3,
3,-35,6,17,23,21,8,2,
4,-45,-17,14,23,-4,-31,-11,
-3,14,1,19,-11,2,61,-8,
9,-12,7,-10,12,-3,-24,99,
-48,23,50,-37,-5,-23,0,8,
-14,35,-64,-5,46,-25,13,-1,
-49,-19,-15,9,34,50,25,11,
-6,-9,-16,-20,-32,-33,-32,-27,
10,-8,12,-15,56,-14,-32,33,
3,-9,1,65,-9,-9,-10,-2,
-6,-23,9,17,3,-28,13,-32,
4,-2,-10,4,-16,76,12,-52,
6,13,33,-6,4,-14,-9,-3,
1,-15,-16,28,1,-15,11,16,
9,4,-21,-37,-40,-6,22,12,
-15,-23,-14,-17,-16,-9,-10,-9,
13,-39,41,5,-9,16,-38,25,
46,-47,4,49,-14,17,-2,6,
18,5,-6,-33,-22,44,50,-2,
1,3,-6,7,7,-3,-21,38,
-18,34,-14,-41,60,-13,6,16,
-24,35,19,-13,-36,24,3,-17,
-14,-10,36,44,-44,-29,-3,3,
-54,-8,12,55,26,4,-2,-5,
2,-11,22,-23,2,22,1,-25,
-39,66,-49,21,-8,-2,10,-14,
-60,25,6,10,27,-25,16,5,
-2,-9,26,-13,-20,58,-2,7,
52,-9,2,5,-4,-15,23,-1,
-38,23,8,27,-6,0,-27,-7,
39,-10,-14,26,11,-45,-12,9,
-5,34,4,-35,10,43,-22,-11,
56,-7,20,1,10,1,-26,9,
94,11,-27,-14,-13,1,-11,0,
14,-5,-6,-10,-4,-15,-8,-41,
21,-5,1,-28,-8,22,-9,33,
-23,-4,-4,-12,39,4,-7,3,
-60,80,8,-17,2,-6,12,-5,
1,9,15,27,31,30,27,23,
61,47,26,10,-5,-8,-12,-13,
5,-18,25,-15,-4,-15,-11,12,
-2,-2,-16,-2,-6,24,12,11,
-4,9,1,-9,14,-45,57,12,
20,-35,26,11,-64,32,-10,-10,
42,-4,-9,-16,32,24,7,10,
52,-11,-57,29,0,8,0,-6,
17,-17,-56,-40,7,20,18,12,
-6,16,5,7,-1,9,1,10,
29,12,16,13,-2,23,7,9,
-3,-4,-5,18,-64,13,55,-25,
9,-9,24,14,-25,15,-11,-40,
-30,37,1,-19,22,-5,-31,13,
-2,0,7,-4,16,-67,12,66,
-36,24,-8,18,-15,-23,19,0,
-45,-7,4,3,-13,13,35,5,
13,33,10,27,23,0,-7,-11,
43,-74,36,-12,2,5,-8,6,
-33,11,-16,-14,-5,-7,-3,17,
-34,27,-16,11,-9,15,33,-31,
8,-16,7,-6,-7,63,-55,-17,
11,-1,20,-46,34,-30,6,9,
19,28,-9,5,-24,-8,-23,-2,
31,-19,-16,-5,-15,-18,0,26,
18,37,-5,-15,-2,17,5,-27,
21,-33,44,12,-27,-9,17,11,
25,-21,-31,-7,13,33,-8,-25,
-7,7,-10,4,-6,-9,48,-82,
-23,-8,6,11,-23,3,-3,49,
-29,25,31,4,14,16,9,-4,
-18,10,-26,3,5,-44,-9,9,
-47,-55,15,9,28,1,4,-3,
46,6,-6,-38,-29,-31,-15,-6,
3,0,14,-6,8,-54,-50,33,
-5,1,-14,33,-48,26,-4,-5,
-3,-5,-3,-5,-28,-22,77,55,
-1,2,10,10,-9,-14,-66,-49,
11,-36,-6,-20,10,-10,16,12,
4,-1,-16,45,-44,-50,31,-2,
25,42,23,-32,-22,0,11,20,
-40,-35,-40,-36,-32,-26,-21,-13,
52,-22,6,-24,-20,17,-5,-8,
36,-25,-11,21,-26,6,34,-8,
7,20,-3,5,-25,-8,18,-5,
-9,-4,1,-9,20,20,39,48,
-24,9,5,-65,22,29,4,3,
-43,-11,32,-6,9,19,-27,-10,
-47,-14,24,10,-7,-36,-7,-1,
-4,-5,-5,16,53,25,-26,-29,
-4,-12,45,-58,-34,33,-5,2,
-1,27,-48,31,-15,22,-5,4,
7,7,-25,-3,11,-22,16,-12,
8,-3,7,-11,45,14,-73,-19,
56,-46,24,-20,28,-12,-2,-1,
-36,-3,-33,19,-6,7,2,-15,
5,-31,-45,8,35,13,20,0,
-9,48,-13,-43,-3,-13,2,-5,
72,-68,-27,2,1,-2,-7,5,
36,33,-40,-12,-4,-5,23,19};

View File

@ -1,292 +0,0 @@
/* Copyright (C) 2002 Jean-Marc Valin
File: filters.c
Various analysis/synthesis filters
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of the Xiph.org Foundation nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "filters.h"
#include "stack_alloc.h"
#include <math.h>
void bw_lpc(float gamma, float *lpc_in, float *lpc_out, int order)
{
int i;
float tmp=1;
for (i=0;i<order+1;i++)
{
lpc_out[i] = tmp * lpc_in[i];
tmp *= gamma;
}
}
#ifdef _USE_SSE
#include "filters_sse.h"
#else
void filter_mem2(float *x, float *num, float *den, float *y, int N, int ord, float *mem)
{
int i,j;
float xi,yi;
for (i=0;i<N;i++)
{
xi=x[i];
y[i] = num[0]*xi + mem[0];
yi=y[i];
for (j=0;j<ord-1;j++)
{
mem[j] = mem[j+1] + num[j+1]*xi - den[j+1]*yi;
}
mem[ord-1] = num[ord]*xi - den[ord]*yi;
}
}
void iir_mem2(float *x, float *den, float *y, int N, int ord, float *mem)
{
int i,j;
for (i=0;i<N;i++)
{
y[i] = x[i] + mem[0];
for (j=0;j<ord-1;j++)
{
mem[j] = mem[j+1] - den[j+1]*y[i];
}
mem[ord-1] = - den[ord]*y[i];
}
}
#endif
void fir_mem2(float *x, float *num, float *y, int N, int ord, float *mem)
{
int i,j;
float xi;
for (i=0;i<N;i++)
{
xi=x[i];
y[i] = num[0]*xi + mem[0];
for (j=0;j<ord-1;j++)
{
mem[j] = mem[j+1] + num[j+1]*xi;
}
mem[ord-1] = num[ord]*xi;
}
}
void syn_percep_zero(float *xx, float *ak, float *awk1, float *awk2, float *y, int N, int ord, char *stack)
{
int i;
float *mem = PUSH(stack,ord, float);
for (i=0;i<ord;i++)
mem[i]=0;
filter_mem2(xx, awk1, ak, y, N, ord, mem);
for (i=0;i<ord;i++)
mem[i]=0;
iir_mem2(y, awk2, y, N, ord, mem);
}
void residue_percep_zero(float *xx, float *ak, float *awk1, float *awk2, float *y, int N, int ord, char *stack)
{
int i;
float *mem = PUSH(stack,ord, float);
for (i=0;i<ord;i++)
mem[i]=0;
filter_mem2(xx, ak, awk1, y, N, ord, mem);
for (i=0;i<ord;i++)
mem[i]=0;
fir_mem2(y, awk2, y, N, ord, mem);
}
void qmf_decomp(float *xx, float *aa, float *y1, float *y2, int N, int M, float *mem, char *stack)
{
int i,j,k,M2;
float *a;
float *x;
float *x2;
a = PUSH(stack, M, float);
x = PUSH(stack, N+M-1, float);
x2=x+M-1;
M2=M>>1;
for (i=0;i<M;i++)
a[M-i-1]=aa[i];
for (i=0;i<M-1;i++)
x[i]=mem[M-i-2];
for (i=0;i<N;i++)
x[i+M-1]=xx[i];
for (i=0,k=0;i<N;i+=2,k++)
{
y1[k]=0;
y2[k]=0;
for (j=0;j<M2;j++)
{
y1[k]+=a[j]*(x[i+j]+x2[i-j]);
y2[k]-=a[j]*(x[i+j]-x2[i-j]);
j++;
y1[k]+=a[j]*(x[i+j]+x2[i-j]);
y2[k]+=a[j]*(x[i+j]-x2[i-j]);
}
}
for (i=0;i<M-1;i++)
mem[i]=xx[N-i-1];
}
/* By segher */
void fir_mem_up(float *x, float *a, float *y, int N, int M, float *mem, char *stack)
/* assumptions:
all odd x[i] are zero -- well, actually they are left out of the array now
N and M are multiples of 4 */
{
int i, j;
float *xx=PUSH(stack, M+N-1, float);
for (i = 0; i < N/2; i++)
xx[2*i] = x[N/2-1-i];
for (i = 0; i < M - 1; i += 2)
xx[N+i] = mem[i+1];
for (i = 0; i < N; i += 4) {
float y0, y1, y2, y3;
float x0;
y0 = y1 = y2 = y3 = 0.f;
x0 = xx[N-4-i];
for (j = 0; j < M; j += 4) {
float x1;
float a0, a1;
a0 = a[j];
a1 = a[j+1];
x1 = xx[N-2+j-i];
y0 += a0 * x1;
y1 += a1 * x1;
y2 += a0 * x0;
y3 += a1 * x0;
a0 = a[j+2];
a1 = a[j+3];
x0 = xx[N+j-i];
y0 += a0 * x0;
y1 += a1 * x0;
y2 += a0 * x1;
y3 += a1 * x1;
}
y[i] = y0;
y[i+1] = y1;
y[i+2] = y2;
y[i+3] = y3;
}
for (i = 0; i < M - 1; i += 2)
mem[i+1] = xx[i];
}
void comp_filter_mem_init (CombFilterMem *mem)
{
mem->last_pitch=0;
mem->last_pitch_gain[0]=mem->last_pitch_gain[1]=mem->last_pitch_gain[2]=0;
mem->smooth_gain=1;
}
void comb_filter(
float *exc, /*decoded excitation*/
float *new_exc, /*enhanced excitation*/
float *ak, /*LPC filter coefs*/
int p, /*LPC order*/
int nsf, /*sub-frame size*/
int pitch, /*pitch period*/
float *pitch_gain, /*pitch gain (3-tap)*/
float comb_gain, /*gain of comb filter*/
CombFilterMem *mem
)
{
int i;
float exc_energy=0, new_exc_energy=0;
float gain;
float step;
float fact;
/*Compute excitation energy prior to enhancement*/
for (i=0;i<nsf;i++)
exc_energy+=exc[i]*exc[i];
/*Some gain adjustment is pitch is too high or if unvoiced*/
{
float g=0;
g = .5*fabs(pitch_gain[0]+pitch_gain[1]+pitch_gain[2] +
mem->last_pitch_gain[0] + mem->last_pitch_gain[1] + mem->last_pitch_gain[2]);
if (g>1.3)
comb_gain*=1.3/g;
if (g<.5)
comb_gain*=2*g;
}
step = 1.0/nsf;
fact=0;
/*Apply pitch comb-filter (filter out noise between pitch harmonics)*/
for (i=0;i<nsf;i++)
{
fact += step;
new_exc[i] = exc[i] + comb_gain * fact * (
pitch_gain[0]*exc[i-pitch+1] +
pitch_gain[1]*exc[i-pitch] +
pitch_gain[2]*exc[i-pitch-1]
)
+ comb_gain * (1-fact) * (
mem->last_pitch_gain[0]*exc[i-mem->last_pitch+1] +
mem->last_pitch_gain[1]*exc[i-mem->last_pitch] +
mem->last_pitch_gain[2]*exc[i-mem->last_pitch-1]
);
}
mem->last_pitch_gain[0] = pitch_gain[0];
mem->last_pitch_gain[1] = pitch_gain[1];
mem->last_pitch_gain[2] = pitch_gain[2];
mem->last_pitch = pitch;
/*Gain after enhancement*/
for (i=0;i<nsf;i++)
new_exc_energy+=new_exc[i]*new_exc[i];
/*Compute scaling factor and normalize energy*/
gain = sqrt(exc_energy)/sqrt(.1+new_exc_energy);
if (gain < .5)
gain=.5;
if (gain>1)
gain=1;
for (i=0;i<nsf;i++)
{
mem->smooth_gain = .96*mem->smooth_gain + .04*gain;
new_exc[i] *= mem->smooth_gain;
}
}

View File

@ -1,79 +0,0 @@
/* Copyright (C) 2002 Jean-Marc Valin
File: filters.h
Various analysis/synthesis filters
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of the Xiph.org Foundation nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef FILTERS_H
#define FILTERS_H
typedef struct CombFilterMem {
int last_pitch;
float last_pitch_gain[3];
float smooth_gain;
} CombFilterMem;
void qmf_decomp(float *xx, float *aa, float *y1, float *y2, int N, int M, float *mem, char *stack);
void fir_mem_up(float *x, float *a, float *y, int N, int M, float *mem, char *stack);
void filter_mem2(float *x, float *num, float *den, float *y, int N, int ord, float *mem);
void fir_mem2(float *x, float *num, float *y, int N, int ord, float *mem);
void iir_mem2(float *x, float *den, float *y, int N, int ord, float *mem);
/* Apply bandwidth expansion on LPC coef */
void bw_lpc(float gamma, float *lpc_in, float *lpc_out, int order);
/* FIR filter */
void fir_decim_mem(float *x, float *a, float *y, int N, int M, float *mem);
void syn_percep_zero(float *x, float *ak, float *awk1, float *awk2, float *y, int N, int ord, char *stack);
void residue_percep_zero(float *xx, float *ak, float *awk1, float *awk2, float *y, int N, int ord, char *stack);
void comp_filter_mem_init (CombFilterMem *mem);
void comb_filter(
float *exc, /*decoded excitation*/
float *new_exc, /*enhanced excitation*/
float *ak, /*LPC filter coefs*/
int p, /*LPC order*/
int nsf, /*sub-frame size*/
int pitch, /*pitch period*/
float *pitch_gain, /*pitch gain (3-tap)*/
float comb_gain, /*gain of comb filter*/
CombFilterMem *mem
);
#endif

View File

@ -1,289 +0,0 @@
/* Copyright (C) 2002 Jean-Marc Valin
File: filters.c
Various analysis/synthesis filters
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of the Xiph.org Foundation nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
void filter_mem2(float *x, float *_num, float *_den, float *y, int N, int ord, float *_mem)
{
float __num[20], __den[20], __mem[20];
float *num, *den, *mem;
int i;
num = (float*)(((int)(__num+4))&0xfffffff0)-1;
den = (float*)(((int)(__den+4))&0xfffffff0)-1;
mem = (float*)(((int)(__mem+4))&0xfffffff0)-1;
for (i=0;i<=10;i++)
num[i]=den[i]=0;
for (i=0;i<10;i++)
mem[i]=0;
for (i=0;i<ord+1;i++)
{
num[i]=_num[i];
den[i]=_den[i];
}
for (i=0;i<ord;i++)
mem[i]=_mem[i];
for (i=0;i<N;i+=4)
{
__asm__ __volatile__
(
"\tmovss (%1), %%xmm0\n"
"\tmovss (%0), %%xmm1\n"
"\taddss %%xmm0, %%xmm1\n"
"\tmovss %%xmm1, (%2)\n"
"\tshufps $0x00, %%xmm0, %%xmm0\n"
"\tshufps $0x00, %%xmm1, %%xmm1\n"
"\tmovaps 4(%3), %%xmm2\n"
"\tmovaps 4(%4), %%xmm3\n"
"\tmulps %%xmm0, %%xmm2\n"
"\tmulps %%xmm1, %%xmm3\n"
"\tmovaps 20(%3), %%xmm4\n"
"\tmulps %%xmm0, %%xmm4\n"
"\taddps 4(%0), %%xmm2\n"
"\tmovaps 20(%4), %%xmm5\n"
"\tmulps %%xmm1, %%xmm5\n"
"\taddps 20(%0), %%xmm4\n"
"\tsubps %%xmm3, %%xmm2\n"
"\tmovups %%xmm2, (%0)\n"
"\tsubps %%xmm5, %%xmm4\n"
"\tmovups %%xmm4, 16(%0)\n"
"\tmovss 36(%3), %%xmm2\n"
"\tmulss %%xmm0, %%xmm2\n"
"\tmovss 36(%4), %%xmm3\n"
"\tmulss %%xmm1, %%xmm3\n"
"\taddss 36(%0), %%xmm2\n"
"\tmovss 40(%3), %%xmm4\n"
"\tmulss %%xmm0, %%xmm4\n"
"\tmovss 40(%4), %%xmm5\n"
"\tmulss %%xmm1, %%xmm5\n"
"\tsubss %%xmm3, %%xmm2\n"
"\tmovss %%xmm2, 32(%0) \n"
"\tsubss %%xmm5, %%xmm4\n"
"\tmovss %%xmm4, 36(%0)\n"
"\tmovss 4(%1), %%xmm0\n"
"\tmovss (%0), %%xmm1\n"
"\taddss %%xmm0, %%xmm1\n"
"\tmovss %%xmm1, 4(%2)\n"
"\tshufps $0x00, %%xmm0, %%xmm0\n"
"\tshufps $0x00, %%xmm1, %%xmm1\n"
"\tmovaps 4(%3), %%xmm2\n"
"\tmovaps 4(%4), %%xmm3\n"
"\tmulps %%xmm0, %%xmm2\n"
"\tmulps %%xmm1, %%xmm3\n"
"\tmovaps 20(%3), %%xmm4\n"
"\tmulps %%xmm0, %%xmm4\n"
"\taddps 4(%0), %%xmm2\n"
"\tmovaps 20(%4), %%xmm5\n"
"\tmulps %%xmm1, %%xmm5\n"
"\taddps 20(%0), %%xmm4\n"
"\tsubps %%xmm3, %%xmm2\n"
"\tmovups %%xmm2, (%0)\n"
"\tsubps %%xmm5, %%xmm4\n"
"\tmovups %%xmm4, 16(%0)\n"
"\tmovss 36(%3), %%xmm2\n"
"\tmulss %%xmm0, %%xmm2\n"
"\tmovss 36(%4), %%xmm3\n"
"\tmulss %%xmm1, %%xmm3\n"
"\taddss 36(%0), %%xmm2\n"
"\tmovss 40(%3), %%xmm4\n"
"\tmulss %%xmm0, %%xmm4\n"
"\tmovss 40(%4), %%xmm5\n"
"\tmulss %%xmm1, %%xmm5\n"
"\tsubss %%xmm3, %%xmm2\n"
"\tmovss %%xmm2, 32(%0) \n"
"\tsubss %%xmm5, %%xmm4\n"
"\tmovss %%xmm4, 36(%0)\n"
"\tmovss 8(%1), %%xmm0\n"
"\tmovss (%0), %%xmm1\n"
"\taddss %%xmm0, %%xmm1\n"
"\tmovss %%xmm1, 8(%2)\n"
"\tshufps $0x00, %%xmm0, %%xmm0\n"
"\tshufps $0x00, %%xmm1, %%xmm1\n"
"\tmovaps 4(%3), %%xmm2\n"
"\tmovaps 4(%4), %%xmm3\n"
"\tmulps %%xmm0, %%xmm2\n"
"\tmulps %%xmm1, %%xmm3\n"
"\tmovaps 20(%3), %%xmm4\n"
"\tmulps %%xmm0, %%xmm4\n"
"\taddps 4(%0), %%xmm2\n"
"\tmovaps 20(%4), %%xmm5\n"
"\tmulps %%xmm1, %%xmm5\n"
"\taddps 20(%0), %%xmm4\n"
"\tsubps %%xmm3, %%xmm2\n"
"\tmovups %%xmm2, (%0)\n"
"\tsubps %%xmm5, %%xmm4\n"
"\tmovups %%xmm4, 16(%0)\n"
"\tmovss 36(%3), %%xmm2\n"
"\tmulss %%xmm0, %%xmm2\n"
"\tmovss 36(%4), %%xmm3\n"
"\tmulss %%xmm1, %%xmm3\n"
"\taddss 36(%0), %%xmm2\n"
"\tmovss 40(%3), %%xmm4\n"
"\tmulss %%xmm0, %%xmm4\n"
"\tmovss 40(%4), %%xmm5\n"
"\tmulss %%xmm1, %%xmm5\n"
"\tsubss %%xmm3, %%xmm2\n"
"\tmovss %%xmm2, 32(%0) \n"
"\tsubss %%xmm5, %%xmm4\n"
"\tmovss %%xmm4, 36(%0)\n"
"\tmovss 12(%1), %%xmm0\n"
"\tmovss (%0), %%xmm1\n"
"\taddss %%xmm0, %%xmm1\n"
"\tmovss %%xmm1, 12(%2)\n"
"\tshufps $0x00, %%xmm0, %%xmm0\n"
"\tshufps $0x00, %%xmm1, %%xmm1\n"
"\tmovaps 4(%3), %%xmm2\n"
"\tmovaps 4(%4), %%xmm3\n"
"\tmulps %%xmm0, %%xmm2\n"
"\tmulps %%xmm1, %%xmm3\n"
"\tmovaps 20(%3), %%xmm4\n"
"\tmulps %%xmm0, %%xmm4\n"
"\taddps 4(%0), %%xmm2\n"
"\tmovaps 20(%4), %%xmm5\n"
"\tmulps %%xmm1, %%xmm5\n"
"\taddps 20(%0), %%xmm4\n"
"\tsubps %%xmm3, %%xmm2\n"
"\tmovups %%xmm2, (%0)\n"
"\tsubps %%xmm5, %%xmm4\n"
"\tmovups %%xmm4, 16(%0)\n"
"\tmovss 36(%3), %%xmm2\n"
"\tmulss %%xmm0, %%xmm2\n"
"\tmovss 36(%4), %%xmm3\n"
"\tmulss %%xmm1, %%xmm3\n"
"\taddss 36(%0), %%xmm2\n"
"\tmovss 40(%3), %%xmm4\n"
"\tmulss %%xmm0, %%xmm4\n"
"\tmovss 40(%4), %%xmm5\n"
"\tmulss %%xmm1, %%xmm5\n"
"\tsubss %%xmm3, %%xmm2\n"
"\tmovss %%xmm2, 32(%0) \n"
"\tsubss %%xmm5, %%xmm4\n"
"\tmovss %%xmm4, 36(%0)\n"
: : "r" (mem), "r" (x+i), "r" (y+i), "r" (num), "r" (den)
: "memory" );
}
for (i=0;i<ord;i++)
_mem[i]=mem[i];
}
void iir_mem2(float *x, float *_den, float *y, int N, int ord, float *_mem)
{
float __den[20], __mem[20];
float *den, *mem;
int i;
den = (float*)(((int)(__den+4))&0xfffffff0)-1;
mem = (float*)(((int)(__mem+4))&0xfffffff0)-1;
for (i=0;i<=10;i++)
den[i]=0;
for (i=0;i<10;i++)
mem[i]=0;
for (i=0;i<ord+1;i++)
{
den[i]=_den[i];
}
for (i=0;i<ord;i++)
mem[i]=_mem[i];
for (i=0;i<N;i++)
{
#if 0
y[i] = x[i] + mem[0];
for (j=0;j<ord-1;j++)
{
mem[j] = mem[j+1] - den[j+1]*y[i];
}
mem[ord-1] = - den[ord]*y[i];
#else
__asm__ __volatile__
(
"\tmovss (%1), %%xmm0\n"
"\tmovss (%0), %%xmm1\n"
"\taddss %%xmm0, %%xmm1\n"
"\tmovss %%xmm1, (%2)\n"
"\tshufps $0x00, %%xmm0, %%xmm0\n"
"\tshufps $0x00, %%xmm1, %%xmm1\n"
"\tmovaps 4(%3), %%xmm2\n"
"\tmovaps 20(%3), %%xmm3\n"
"\tmulps %%xmm1, %%xmm2\n"
"\tmulps %%xmm1, %%xmm3\n"
"\tmovss 36(%3), %%xmm4\n"
"\tmovss 40(%3), %%xmm5\n"
"\tmulss %%xmm1, %%xmm4\n"
"\tmulss %%xmm1, %%xmm5\n"
"\tmovaps 4(%0), %%xmm6\n"
"\tsubps %%xmm2, %%xmm6\n"
"\tmovups %%xmm6, (%0)\n"
"\tmovaps 20(%0), %%xmm7\n"
"\tsubps %%xmm3, %%xmm7\n"
"\tmovups %%xmm7, 16(%0)\n"
"\tmovss 36(%0), %%xmm7\n"
"\tsubss %%xmm4, %%xmm7\n"
"\tmovss %%xmm7, 32(%0) \n"
"\txorps %%xmm2, %%xmm2\n"
"\tsubss %%xmm5, %%xmm2\n"
"\tmovss %%xmm2, 36(%0)\n"
: : "r" (mem), "r" (x+i), "r" (y+i), "r" (den)
: "memory" );
#endif
}
for (i=0;i<ord;i++)
_mem[i]=mem[i];
}

View File

@ -1,160 +0,0 @@
/* Copyright (C) 2002 Jean-Marc Valin
File: gain_table.c
Codebook for 3-tap pitch prediction gain (128 entries)
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. The name of the author may not be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
signed char gain_cdbk_nb[384] = {
-32,-32,-32,
-28,-67,-5,
-42,-6,-32,
-57,-10,-54,
-16,27,-41,
19,-19,-40,
-45,24,-21,
-8,-14,-18,
1,14,-58,
-18,-88,-39,
-38,21,-18,
-19,20,-43,
10,17,-48,
-52,-58,-13,
-44,-1,-11,
-12,-11,-34,
14,0,-46,
-37,-35,-34,
-25,44,-30,
6,-4,-63,
-31,43,-41,
-23,30,-43,
-43,26,-14,
-33,1,-13,
-13,18,-37,
-46,-73,-45,
-36,24,-25,
-36,-11,-20,
-25,12,-18,
-36,-69,-59,
-45,6,8,
-22,-14,-24,
-1,13,-44,
-39,-48,-26,
-32,31,-37,
-33,15,-46,
-24,30,-36,
-41,31,-23,
-50,22,-4,
-22,2,-21,
-17,30,-34,
-7,-60,-28,
-38,42,-28,
-44,-11,21,
-16,8,-44,
-39,-55,-43,
-11,-35,26,
-9,0,-34,
-8,121,-81,
7,-16,-22,
-37,33,-31,
-27,-7,-36,
-34,70,-57,
-37,-11,-48,
-40,17,-1,
-33,6,-6,
-9,0,-20,
-21,69,-33,
-29,33,-31,
-55,12,-1,
-33,27,-22,
-50,-33,-47,
-50,54,51,
-1,-5,-44,
-4,22,-40,
-39,-66,-25,
-33,1,-26,
-24,-23,-25,
-11,21,-45,
-25,-45,-19,
-43,105,-16,
5,-21,1,
-16,11,-33,
-13,-99,-4,
-37,33,-15,
-25,37,-63,
-36,24,-31,
-53,-56,-38,
-41,-4,4,
-33,13,-30,
49,52,-94,
-5,-30,-15,
1,38,-40,
-23,12,-36,
-17,40,-47,
-37,-41,-39,
-49,34,0,
-18,-7,-4,
-16,17,-27,
30,5,-62,
4,48,-68,
-43,11,-11,
-18,19,-15,
-23,-62,-39,
-42,10,-2,
-21,-13,-13,
-9,13,-47,
-23,-62,-24,
-44,60,-21,
-18,-3,-52,
-22,22,-36,
-75,57,16,
-19,3,10,
-29,23,-38,
-5,-62,-51,
-51,40,-18,
-42,13,-24,
-34,14,-20,
-56,-75,-26,
-26,32,15,
-26,17,-29,
-7,28,-52,
-12,-30,5,
-5,-48,-5,
2,2,-43,
21,16,16,
-25,-45,-32,
-43,18,-10,
9,0,-1,
-1,7,-30,
19,-48,-4,
-28,25,-29,
-22,0,-31,
-32,17,-10,
-64,-41,-62,
-52,15,16,
-30,-22,-32,
-7,9,-38};

View File

@ -1,64 +0,0 @@
/* Copyright (C) 2002 Jean-Marc Valin
File: gain_table_lbr.c
Codebook for 3-tap pitch prediction gain (32 entries)
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. The name of the author may not be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
signed char gain_cdbk_lbr[96] = {
-32,-32,-32,
-31,-58,-16,
-41,-24,-43,
-56,-22,-55,
-13,33,-41,
-4,-39,-9,
-41,15,-12,
-8,-15,-12,
1,2,-44,
-22,-66,-42,
-38,28,-23,
-21,14,-37,
0,21,-50,
-53,-71,-27,
-37,-1,-19,
-19,-5,-28,
6,65,-44,
-33,-48,-33,
-40,57,-14,
-17,4,-45,
-31,38,-33,
-23,28,-40,
-43,29,-12,
-34,13,-23,
-16,15,-27,
-14,-82,-15,
-31,25,-32,
-21,5,-5,
-47,-63,-51,
-46,12,3,
-28,-17,-29,
-10,14,-40};

View File

@ -1,66 +0,0 @@
/* Copyright (C) 2002 Jean-Marc Valin
File: hexc_10_32_table.c
Codebook for high-band excitation in SB-CELP mode (4000 bps)
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of the Xiph.org Foundation nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
signed char hexc_10_32_table[320] = {
-3, -2, -1, 0, -4, 5, 35, -40, -9, 13,
-44, 5, -27, -1, -7, 6, -11, 7, -8, 7,
19, -14, 15, -4, 9, -10, 10, -8, 10, -9,
-1, 1, 0, 0, 2, 5, -18, 22, -53, 50,
1, -23, 50, -36, 15, 3, -13, 14, -10, 6,
1, 5, -3, 4, -2, 5, -32, 25, 5, -2,
-1, -4, 1, 11, -29, 26, -6, -15, 30, -18,
0, 15, -17, 40, -41, 3, 9, -2, -2, 3,
-3, -1, -5, 2, 21, -6, -16, -21, 23, 2,
60, 15, 16, -16, -9, 14, 9, -1, 7, -9,
0, 1, 1, 0, -1, -6, 17, -28, 54, -45,
-1, 1, -1, -6, -6, 2, 11, 26, -29, -2,
46, -21, 34, 12, -23, 32, -23, 16, -10, 3,
66, 19, -20, 24, 7, 11, -3, 0, -3, -1,
-50, -46, 2, -18, -3, 4, -1, -2, 3, -3,
-19, 41, -36, 9, 11, -24, 21, -16, 9, -3,
-25, -3, 10, 18, -9, -2, -5, -1, -5, 6,
-4, -3, 2, -26, 21, -19, 35, -15, 7, -13,
17, -19, 39, -43, 48, -31, 16, -9, 7, -2,
-5, 3, -4, 9, -19, 27, -55, 63, -35, 10,
26, -44, -2, 9, 4, 1, -6, 8, -9, 5,
-8, -1, -3, -16, 45, -42, 5, 15, -16, 10,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-16, 24, -55, 47, -38, 27, -19, 7, -3, 1,
16, 27, 20, -19, 18, 5, -7, 1, -5, 2,
-6, 8, -22, 0, -3, -3, 8, -1, 7, -8,
1, -3, 5, 0, 17, -48, 58, -52, 29, -7,
-2, 3, -10, 6, -26, 58, -31, 1, -6, 3,
93, -29, 39, 3, 17, 5, 6, -1, -1, -1,
27, 13, 10, 19, -7, -34, 12, 10, -4, 9,
-76, 9, 8, -28, -2, -11, 2, -1, 3, 1,
-83, 38, -39, 4, -16, -6, -2, -5, 5, -2,
};

View File

@ -1,162 +0,0 @@
/* Copyright (C) 2002 Jean-Marc Valin
File: hexc_table.c
Codebook for high-band excitation in SB-CELP mode (8000 bps with sign)
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of the Xiph.org Foundation nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
signed char hexc_table[1024] = {
-24, 21, -20, 5, -5, -7, 14, -10,
2, -27, 16, -20, 0, -32, 26, 19,
8, -11, -41, 31, 28, -27, -32, 34,
42, 34, -17, 22, -10, 13, -29, 18,
-12, -26, -24, 11, 22, 5, -5, -5,
54, -68, -43, 57, -25, 24, 4, 4,
26, -8, -12, -17, 54, 30, -45, 1,
10, -15, 18, -41, 11, 68, -67, 37,
-16, -24, -16, 38, -22, 6, -29, 30,
66, -27, 5, 7, -16, 13, 2, -12,
-7, -3, -20, 36, 4, -28, 9, 3,
32, 48, 26, 39, 3, 0, 7, -21,
-13, 5, -82, -7, 73, -20, 34, -9,
-5, 1, -1, 10, -5, -10, -1, 9,
1, -9, 10, 0, -14, 11, -1, -2,
-1, 11, 20, 96, -81, -22, -12, -9,
-58, 9, 24, -30, 26, -35, 27, -12,
13, -18, 56, -59, 15, -7, 23, -15,
-1, 6, -25, 14, -22, -20, 47, -11,
16, 2, 38, -23, -19, -30, -9, 40,
-11, 5, 4, -6, 8, 26, -21, -11,
131, 4, 1, 6, -9, 2, -7, -2,
-3, 7, -5, 10, -19, 7, -106, 91,
-3, 9, -4, 21, -8, 26, -80, 8,
1, -2, -10, -17, -17, -27, 32, 71,
6, -29, 11, -23, 54, -38, 29, -22,
39, 87, -31, -12, -20, 3, -2, -2,
2, 20, 0, -1, -35, 27, 9, -6,
-12, 3, -12, -6, 13, 1, 14, -22,
-59, -15, -17, -25, 13, -7, 7, 3,
0, 1, -7, 6, -3, 61, -37, -23,
-23, -29, 38, -31, 27, 1, -8, 2,
-27, 23, -26, 36, -34, 5, 24, -24,
-6, 7, 3, -59, 78, -62, 44, -16,
1, 6, 0, 17, 8, 45, 0, -110,
6, 14, -2, 32, -77, -56, 62, -3,
3, -13, 4, -16, 102, -15, -36, -1,
9, -113, 6, 23, 0, 9, 9, 5,
-8, -1, -14, 5, -12, 121, -53, -27,
-8, -9, 22, -13, 3, 2, -3, 1,
-2, -71, 95, 38, -19, 15, -16, -5,
71, 10, 2, -32, -13, -5, 15, -1,
-2, -14, -85, 30, 29, 6, 3, 2,
0, 0, 0, 0, 0, 0, 0, 0,
2, -65, -56, -9, 18, 18, 23, -14,
-2, 0, 12, -29, 26, -12, 1, 2,
-12, -64, 90, -6, 4, 1, 5, -5,
-110, -3, -31, 22, -29, 9, 0, 8,
-40, -5, 21, -5, -5, 13, 10, -18,
40, 1, 35, -20, 30, -28, 11, -6,
19, 7, 14, 18, -64, 9, -6, 16,
51, 68, 8, 16, 12, -8, 0, -9,
20, -22, 25, 7, -4, -13, 41, -35,
93, -18, -54, 11, -1, 1, -9, 4,
-66, 66, -31, 20, -22, 25, -23, 11,
10, 9, 19, 15, 11, -5, -31, -10,
-23, -28, -6, -6, -3, -4, 5, 3,
-28, 22, -11, -42, 25, -25, -16, 41,
34, 47, -6, 2, 42, -19, -22, 5,
-39, 32, 6, -35, 22, 17, -30, 8,
-26, -11, -11, 3, -12, 33, 33, -37,
21, -1, 6, -4, 3, 0, -5, 5,
12, -12, 57, 27, -61, -3, 20, -17,
2, 0, 4, 0, -2, -33, -58, 81,
-23, 39, -10, -5, 2, 6, -7, 5,
4, -3, -2, -13, -23, -72, 107, 15,
-5, 0, -7, -3, -6, 5, -4, 15,
47, 12, -31, 25, -16, 8, 22, -25,
-62, -56, -18, 14, 28, 12, 2, -11,
74, -66, 41, -20, -7, 16, -20, 16,
-8, 0, -16, 4, -19, 92, 12, -59,
-14, -39, 49, -25, -16, 23, -27, 19,
-3, -33, 19, 85, -29, 6, -7, -10,
16, -7, -12, 1, -6, 2, 4, -2,
64, 10, -25, 41, -2, -31, 15, 0,
110, 50, 69, 35, 28, 19, -10, 2,
-43, -49, -56, -15, -16, 10, 3, 12,
-1, -8, 1, 26, -12, -1, 7, -11,
-27, 41, 25, 1, -11, -18, 22, -7,
-1, -47, -8, 23, -3, -17, -7, 18,
-125, 59, -5, 3, 18, 1, 2, 3,
27, -35, 65, -53, 50, -46, 37, -21,
-28, 7, 14, -37, -5, -5, 12, 5,
-8, 78, -19, 21, -6, -16, 8, -7,
5, 2, 7, 2, 10, -6, 12, -60,
44, 11, -36, -32, 31, 0, 2, -2,
2, 1, -3, 7, -10, 17, -21, 10,
6, -2, 19, -2, 59, -38, -86, 38,
8, -41, -30, -45, -33, 7, 15, 28,
29, -7, 24, -40, 7, 7, 5, -2,
9, 24, -23, -18, 6, -29, 30, 2,
28, 49, -11, -46, 10, 43, -13, -9,
-1, -3, -7, -7, -17, -6, 97, -33,
-21, 3, 5, 1, 12, -43, -8, 28,
7, -43, -7, 17, -20, 19, -1, 2,
-13, 9, 54, 34, 9, -28, -11, -9,
-17, 110, -59, 44, -26, 0, 3, -12,
-47, 73, -34, -43, 38, -33, 16, -5,
-46, -4, -6, -2, -25, 19, -29, 28,
-13, 5, 14, 27, -40, -43, 4, 32,
-13, -2, -35, -4, 112, -42, 9, -12,
37, -28, 17, 14, -19, 35, -39, 23,
3, -14, -1, -57, -5, 94, -9, 3,
-39, 5, 30, -10, -32, 42, -13, -14,
-97, -63, 30, -9, 1, -7, 12, 5,
20, 17, -9, -36, -30, 25, 47, -9,
-15, 12, -22, 98, -8, -50, 15, -27,
21, -16, -11, 2, 12, -10, 10, -3,
33, 36, -96, 0, -17, 31, -9, 9,
3, -20, 13, -11, 8, -4, 10, -10,
9, 1, 112, -70, -27, 5, -21, 2,
-57, -3, -29, 10, 19, -21, 21, -10,
-66, -3, 91, -35, 30, -12, 0, -7,
59, -28, 26, 2, 14, -18, 1, 1,
11, 17, 20, -54, -59, 27, 4, 29,
32, 5, 19, 12, -4, 1, 7, -10,
5, -2, 10, 0, 23, -5, 28, -104,
46, 11, 16, 3, 29, 1, -8, -14,
1, 7, -50, 88, -62, 26, 8, -17,
-14, 50, 0, 32, -12, -3, -27, 18,
-8, -5, 8, 3, -20, -11, 37, -12,
9, 33, 46, -101, -1, -4, 1, 6,
-1, 28, -42, -15, 16, 5, -1, -2,
-55, 85, 38, -9, -4, 11, -2, -9,
-6, 3, -20, -10, -77, 89, 24, -3,
-104, -57, -26, -31, -20, -6, -9, 14,
20, -23, 46, -15, -31, 28, 1, -15,
-2, 6, -2, 31, 45, -76, 23, -25,
};

View File

@ -1,163 +0,0 @@
/* Copyright (C) 2002 Jean-Marc Valin
File: high_lsp_tables.c
Codebooks for high-band LSPs in SB-CELP mode
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. The name of the author may not be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
signed char high_lsp_cdbk[512]={
39,12,-14,-20,-29,-61,-67,-76,
-32,-71,-67,68,77,46,34,5,
-13,-48,-46,-72,-81,-84,-60,-58,
-40,-28,82,93,68,45,29,3,
-19,-47,-28,-43,-35,-30,-8,-13,
-39,-91,-91,-123,-96,10,10,-6,
-18,-55,-60,-91,-56,-36,-27,-16,
-48,-75,40,28,-10,-28,35,9,
37,19,1,-20,-31,-41,-18,-25,
-35,-68,-80,45,27,-1,47,13,
0,-29,-35,-57,-50,-79,-73,-38,
-19,5,35,14,-10,-23,16,-8,
5,-24,-40,-62,-23,-27,-22,-16,
-18,-46,-72,-77,43,21,33,1,
-80,-70,-70,-64,-56,-52,-39,-33,
-31,-38,-19,-19,-15,32,33,-2,
7,-15,-15,-24,-23,-33,-41,-56,
-24,-57,5,89,64,41,27,5,
-9,-47,-60,-97,-97,-124,-20,-9,
-44,-73,31,29,-4,64,48,7,
-35,-57,0,-3,-26,-47,-3,-6,
-40,-76,-79,-48,12,81,55,10,
9,-24,-43,-73,-57,-69,16,5,
-28,-53,18,29,20,0,-4,-11,
6,-13,23,7,-17,-35,-37,-37,
-30,-68,-63,6,24,-9,-14,3,
21,-13,-27,-57,-49,-80,-24,-41,
-5,-16,-5,1,45,25,12,-7,
3,-15,-6,-16,-15,-8,6,-13,
-42,-81,-80,-87,14,1,-10,-3,
-43,-69,-46,-24,-28,-29,36,6,
-43,-56,-12,12,54,79,43,9,
54,22,2,8,-12,-43,-46,-52,
-38,-69,-89,-5,75,38,33,5,
-13,-53,-62,-87,-89,-113,-99,-55,
-34,-37,62,55,33,16,21,-2,
-17,-46,-29,-38,-38,-48,-39,-42,
-36,-75,-72,-88,-48,-30,21,2,
-15,-57,-64,-98,-84,-76,25,1,
-46,-80,-12,18,-7,3,34,6,
38,31,23,4,-1,20,14,-15,
-43,-78,-91,-24,14,-3,54,16,
0,-27,-28,-44,-56,-83,-92,-89,
-3,34,56,41,36,22,20,-8,
-7,-35,-42,-62,-49,3,12,-10,
-50,-87,-96,-66,92,70,38,9,
-70,-71,-62,-42,-39,-43,-11,-7,
-50,-79,-58,-50,-31,32,31,-6,
-4,-25,7,-17,-38,-70,-58,-27,
-43,-83,-28,59,36,20,31,2,
-27,-71,-80,-109,-98,-75,-33,-32,
-31,-2,33,15,-6,43,33,-5,
0,-22,-10,-27,-34,-49,-11,-20,
-41,-91,-100,-121,-39,57,41,10,
-19,-50,-38,-59,-60,-70,-18,-20,
-8,-31,-8,-15,1,-14,-26,-25,
33,21,32,17,1,-19,-19,-26,
-58,-81,-35,-22,45,30,11,-11,
3,-26,-48,-87,-67,-83,-58,3,
-1,-26,-20,44,10,25,39,5,
-9,-35,-27,-38,7,10,4,-9,
-42,-85,-102,-127,52,44,28,10,
-47,-61,-40,-39,-17,-1,-10,-33,
-42,-74,-48,21,-4,70,52,10};
signed char high_lsp_cdbk2[512]={
-36,-62,6,-9,-10,-14,-56,23,
1,-26,23,-48,-17,12,8,-7,
23,29,-36,-28,-6,-29,-17,-5,
40,23,10,10,-46,-13,36,6,
4,-30,-29,62,32,-32,-1,22,
-14,1,-4,-22,-45,2,54,4,
-30,-57,-59,-12,27,-3,-31,8,
-9,5,10,-14,32,66,19,9,
2,-25,-37,23,-15,18,-38,-31,
5,-9,-21,15,0,22,62,30,
15,-12,-14,-46,77,21,33,3,
34,29,-19,50,2,11,9,-38,
-12,-37,62,1,-15,54,32,6,
2,-24,20,35,-21,2,19,24,
-13,55,4,9,39,-19,30,-1,
-21,73,54,33,8,18,3,15,
6,-19,-47,6,-3,-48,-50,1,
26,20,8,-23,-50,65,-14,-55,
-17,-31,-37,-28,53,-1,-17,-53,
1,57,11,-8,-25,-30,-37,64,
5,-52,-45,15,23,31,15,14,
-25,24,33,-2,-44,-56,-18,6,
-21,-43,4,-12,17,-37,20,-10,
34,15,2,15,55,21,-11,-31,
-6,46,25,16,-9,-25,-8,-62,
28,17,20,-32,-29,26,30,25,
-19,2,-16,-17,26,-51,2,50,
42,19,-66,23,29,-2,3,19,
-19,-37,32,15,6,30,-34,13,
11,-5,40,31,10,-42,4,-9,
26,-9,-70,17,-2,-23,20,-22,
-55,51,-24,-31,22,-22,15,-13,
3,-10,-28,-16,56,4,-63,11,
-18,-15,-18,-38,-35,16,-7,34,
-1,-21,-49,-47,9,-37,7,8,
69,55,20,6,-33,-45,-10,-9,
6,-9,12,71,15,-3,-42,-7,
-24,32,-35,-2,-42,-17,-5,0,
-2,-33,-54,13,-12,-34,47,23,
19,55,7,-8,74,31,14,16,
-23,-26,19,12,-18,-49,-28,-31,
-20,2,-14,-20,-47,78,40,13,
-23,-11,21,-6,18,1,47,5,
38,35,32,46,22,8,13,16,
-14,18,51,19,40,39,11,-26,
-1,-17,47,2,-53,-15,31,-22,
38,21,-15,-16,5,-33,53,15,
-38,86,11,-3,-24,49,13,-4,
-11,-18,28,20,-12,-27,-26,35,
-25,-35,-3,-20,-61,30,10,-55,
-12,-22,-52,-54,-14,19,-32,-12,
45,15,-8,-48,-9,11,-32,8,
-16,-34,-13,51,18,38,-2,-32,
-17,22,-2,-18,-28,-70,59,27,
-28,-19,-10,-20,-9,-9,-8,-21,
21,-8,35,-2,45,-3,-9,12,
0,30,7,-39,43,27,-38,-91,
30,26,19,-55,-4,63,14,-17,
13,9,13,2,7,4,6,61,
72,-1,-17,29,-1,-22,-17,8,
-28,-37,63,44,41,3,2,14,
9,-6,75,-8,-7,-12,-15,-12,
13,9,-4,30,-22,-65,15,0,
-45,4,-4,1,5,22,11,23};

View File

@ -1,119 +0,0 @@
/*
Copyright 1992, 1993, 1994 by Jutta Degener and Carsten Bormann,
Technische Universitaet Berlin
Any use of this software is permitted provided that this notice is not
removed and that neither the authors nor the Technische Universitaet Berlin
are deemed to have made any representations as to the suitability of this
software for any purpose nor are held responsible for any defects of
this software. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE.
As a matter of courtesy, the authors request to be informed about uses
this software has found, about bugs in this software, and about any
improvements that may be of general interest.
Berlin, 28.11.1994
Jutta Degener
Carsten Bormann
Code slightly modified by Jean-Marc Valin
Speex License:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of the Xiph.org Foundation nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/* LPC- and Reflection Coefficients
*
* The next two functions calculate linear prediction coefficients
* and/or the related reflection coefficients from the first P_MAX+1
* values of the autocorrelation function.
*/
/* Invented by N. Levinson in 1947, modified by J. Durbin in 1959.
*/
#include "lpc.h"
float /* returns minimum mean square error */
wld(
float * lpc, /* [0...p-1] LPC coefficients */
const float * ac, /* in: [0...p] autocorrelation values */
float * ref, /* out: [0...p-1] reflection coef's */
int p
)
{
int i, j; float r, error = ac[0];
if (ac[0] == 0) {
for (i = 0; i < p; i++) ref[i] = 0; return 0; }
for (i = 0; i < p; i++) {
/* Sum up this iteration's reflection coefficient.
*/
r = -ac[i + 1];
for (j = 0; j < i; j++) r -= lpc[j] * ac[i - j];
ref[i] = r /= error;
/* Update LPC coefficients and total error.
*/
lpc[i] = r;
for (j = 0; j < i/2; j++) {
float tmp = lpc[j];
lpc[j] += r * lpc[i-1-j];
lpc[i-1-j] += r * tmp;
}
if (i % 2) lpc[j] += lpc[j] * r;
error *= 1.0 - r * r;
}
return error;
}
/* Compute the autocorrelation
* ,--,
* ac(i) = > x(n) * x(n-i) for all n
* `--'
* for lags between 0 and lag-1, and x == 0 outside 0...n-1
*/
void _spx_autocorr(
const float * x, /* in: [0...n-1] samples x */
float *ac, /* out: [0...lag-1] ac values */
int lag, int n)
{
float d; int i;
while (lag--) {
for (i = lag, d = 0; i < n; i++) d += x[i] * x[i-lag];
ac[lag] = d;
}
}

View File

@ -1,50 +0,0 @@
/* Copyright (C) 2002 Jean-Marc Valin
File: lpc.h
Functions for LPC (Linear Prediction Coefficients) analysis
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of the Xiph.org Foundation nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef LPC_H
#define LPC_H
void _spx_autocorr(
const float * x, /* in: [0...n-1] samples x */
float *ac, /* out: [0...lag-1] ac values */
int lag, int n);
float /* returns minimum mean square error */
wld(
float * lpc, /* [0...p-1] LPC coefficients */
const float * ac, /* in: [0...p] autocorrelation values */
float * ref, /* out: [0...p-1] reflection coef's */
int p
);
#endif

View File

@ -1,328 +0,0 @@
/*---------------------------------------------------------------------------*\
Original copyright
FILE........: AKSLSPD.C
TYPE........: Turbo C
COMPANY.....: Voicetronix
AUTHOR......: David Rowe
DATE CREATED: 24/2/93
Modified by Jean-Marc Valin
This file contains functions for converting Linear Prediction
Coefficients (LPC) to Line Spectral Pair (LSP) and back. Note that the
LSP coefficients are not in radians format but in the x domain of the
unit circle.
Speex License:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of the Xiph.org Foundation nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <math.h>
#include "lsp.h"
#include "stack_alloc.h"
#ifndef M_PI
#define M_PI 3.14159265358979323846 /* pi */
#endif
#ifndef NULL
#define NULL 0
#endif
/*---------------------------------------------------------------------------*\
FUNCTION....: cheb_poly_eva()
AUTHOR......: David Rowe
DATE CREATED: 24/2/93
This function evaluates a series of Chebyshev polynomials
\*---------------------------------------------------------------------------*/
static float cheb_poly_eva(float *coef,float x,int m,char *stack)
/* float coef[] coefficients of the polynomial to be evaluated */
/* float x the point where polynomial is to be evaluated */
/* int m order of the polynomial */
{
int i;
float *T,sum;
int m2=m>>1;
/* Allocate memory for Chebyshev series formulation */
T=PUSH(stack, m2+1, float);
/* Initialise values */
T[0]=1;
T[1]=x;
/* Evaluate Chebyshev series formulation using iterative approach */
/* Evaluate polynomial and return value also free memory space */
sum = coef[m2] + coef[m2-1]*x;
x *= 2;
for(i=2;i<=m2;i++)
{
T[i] = x*T[i-1] - T[i-2];
sum += coef[m2-i] * T[i];
}
return sum;
}
/*---------------------------------------------------------------------------*\
FUNCTION....: lpc_to_lsp()
AUTHOR......: David Rowe
DATE CREATED: 24/2/93
This function converts LPC coefficients to LSP
coefficients.
\*---------------------------------------------------------------------------*/
int lpc_to_lsp (float *a,int lpcrdr,float *freq,int nb,float delta, char *stack)
/* float *a lpc coefficients */
/* int lpcrdr order of LPC coefficients (10) */
/* float *freq LSP frequencies in the x domain */
/* int nb number of sub-intervals (4) */
/* float delta grid spacing interval (0.02) */
{
float psuml,psumr,psumm,temp_xr,xl,xr,xm=0;
float temp_psumr/*,temp_qsumr*/;
int i,j,m,flag,k;
float *Q; /* ptrs for memory allocation */
float *P;
float *px; /* ptrs of respective P'(z) & Q'(z) */
float *qx;
float *p;
float *q;
float *pt; /* ptr used for cheb_poly_eval()
whether P' or Q' */
int roots=0; /* DR 8/2/94: number of roots found */
flag = 1; /* program is searching for a root when,
1 else has found one */
m = lpcrdr/2; /* order of P'(z) & Q'(z) polynomials */
/* Allocate memory space for polynomials */
Q = PUSH(stack, (m+1), float);
P = PUSH(stack, (m+1), float);
/* determine P'(z)'s and Q'(z)'s coefficients where
P'(z) = P(z)/(1 + z^(-1)) and Q'(z) = Q(z)/(1-z^(-1)) */
px = P; /* initialise ptrs */
qx = Q;
p = px;
q = qx;
*px++ = 1.0;
*qx++ = 1.0;
for(i=1;i<=m;i++){
*px++ = a[i]+a[lpcrdr+1-i]-*p++;
*qx++ = a[i]-a[lpcrdr+1-i]+*q++;
}
px = P;
qx = Q;
for(i=0;i<m;i++){
*px = 2**px;
*qx = 2**qx;
px++;
qx++;
}
px = P; /* re-initialise ptrs */
qx = Q;
/* Search for a zero in P'(z) polynomial first and then alternate to Q'(z).
Keep alternating between the two polynomials as each zero is found */
xr = 0; /* initialise xr to zero */
xl = 1.0; /* start at point xl = 1 */
for(j=0;j<lpcrdr;j++){
if(j%2) /* determines whether P' or Q' is eval. */
pt = qx;
else
pt = px;
psuml = cheb_poly_eva(pt,xl,lpcrdr,stack); /* evals poly. at xl */
flag = 1;
while(flag && (xr >= -1.0)){
float dd;
/* Modified by JMV to provide smaller steps around x=+-1 */
dd=(delta*(1-.9*xl*xl));
if (fabs(psuml)<.2)
dd *= .5;
xr = xl - dd; /* interval spacing */
psumr = cheb_poly_eva(pt,xr,lpcrdr,stack);/* poly(xl-delta_x) */
temp_psumr = psumr;
temp_xr = xr;
/* if no sign change increment xr and re-evaluate poly(xr). Repeat til
sign change.
if a sign change has occurred the interval is bisected and then
checked again for a sign change which determines in which
interval the zero lies in.
If there is no sign change between poly(xm) and poly(xl) set interval
between xm and xr else set interval between xl and xr and repeat till
root is located within the specified limits */
if((psumr*psuml)<0.0){
roots++;
psumm=psuml;
for(k=0;k<=nb;k++){
xm = (xl+xr)/2; /* bisect the interval */
psumm=cheb_poly_eva(pt,xm,lpcrdr,stack);
if(psumm*psuml>0.){
psuml=psumm;
xl=xm;
}
else{
psumr=psumm;
xr=xm;
}
}
/* once zero is found, reset initial interval to xr */
freq[j] = (xm);
xl = xm;
flag = 0; /* reset flag for next search */
}
else{
psuml=temp_psumr;
xl=temp_xr;
}
}
}
return(roots);
}
/*---------------------------------------------------------------------------*\
FUNCTION....: lsp_to_lpc()
AUTHOR......: David Rowe
DATE CREATED: 24/2/93
lsp_to_lpc: This function converts LSP coefficients to LPC
coefficients.
\*---------------------------------------------------------------------------*/
void lsp_to_lpc(float *freq,float *ak,int lpcrdr, char *stack)
/* float *freq array of LSP frequencies in the x domain */
/* float *ak array of LPC coefficients */
/* int lpcrdr order of LPC coefficients */
{
int i,j;
float xout1,xout2,xin1,xin2;
float *Wp;
float *pw,*n1,*n2,*n3,*n4=NULL;
int m = lpcrdr/2;
Wp = PUSH(stack, 4*m+2, float);
pw = Wp;
/* initialise contents of array */
for(i=0;i<=4*m+1;i++){ /* set contents of buffer to 0 */
*pw++ = 0.0;
}
/* Set pointers up */
pw = Wp;
xin1 = 1.0;
xin2 = 1.0;
/* reconstruct P(z) and Q(z) by cascading second order
polynomials in form 1 - 2xz(-1) +z(-2), where x is the
LSP coefficient */
for(j=0;j<=lpcrdr;j++){
int i2=0;
for(i=0;i<m;i++,i2+=2){
n1 = pw+(i*4);
n2 = n1 + 1;
n3 = n2 + 1;
n4 = n3 + 1;
xout1 = xin1 - 2*(freq[i2]) * *n1 + *n2;
xout2 = xin2 - 2*(freq[i2+1]) * *n3 + *n4;
*n2 = *n1;
*n4 = *n3;
*n1 = xin1;
*n3 = xin2;
xin1 = xout1;
xin2 = xout2;
}
xout1 = xin1 + *(n4+1);
xout2 = xin2 - *(n4+2);
ak[j] = (xout1 + xout2)*0.5;
*(n4+1) = xin1;
*(n4+2) = xin2;
xin1 = 0.0;
xin2 = 0.0;
}
}
/*Added by JMV
Makes sure the LSPs are stable*/
void lsp_enforce_margin(float *lsp, int len, float margin)
{
int i;
if (lsp[0]<margin)
lsp[0]=margin;
if (lsp[len-1]>M_PI-margin)
lsp[len-1]=M_PI-margin;
for (i=1;i<len-1;i++)
{
if (lsp[i]<lsp[i-1]+margin)
lsp[i]=lsp[i-1]+margin;
if (lsp[i]>lsp[i+1]-margin)
lsp[i]= .5* (lsp[i] + lsp[i+1]-margin);
}
}

View File

@ -1,57 +0,0 @@
/*---------------------------------------------------------------------------*\
Original Copyright
FILE........: AK2LSPD.H
TYPE........: Turbo C header file
COMPANY.....: Voicetronix
AUTHOR......: James Whitehall
DATE CREATED: 21/11/95
Modified by Jean-Marc Valin
This file contains functions for converting Linear Prediction
Coefficients (LPC) to Line Spectral Pair (LSP) and back. Note that the
LSP coefficients are not in radians format but in the x domain of the
unit circle.
\*---------------------------------------------------------------------------*/
/* Speex License:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of the Xiph.org Foundation nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __AK2LSPD__
#define __AK2LSPD__
int lpc_to_lsp (float *a, int lpcrdr, float *freq, int nb, float delta, char *stack);
void lsp_to_lpc(float *freq, float *ak, int lpcrdr, char *stack);
/*Added by JMV*/
void lsp_enforce_margin(float *lsp, int len, float margin);
#endif /* __AK2LSPD__ */

View File

@ -1,360 +0,0 @@
/* Copyright (C) 2002 Jean-Marc Valin
File: lsp_tables_nb.c
Codebooks for LSPs in narrowband CELP mode
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. The name of the author may not be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
signed char cdbk_nb[640]={
30,19,38,34,40,32,46,43,58,43,
5,-18,-25,-40,-33,-55,-52,20,34,28,
-20,-63,-97,-92,61,53,47,49,53,75,
-14,-53,-77,-79,0,-3,-5,19,22,26,
-9,-53,-55,66,90,72,85,68,74,52,
-4,-41,-58,-31,-18,-31,27,32,30,18,
24,3,8,5,-12,-3,26,28,74,63,
-2,-39,-67,-77,-106,-74,59,59,73,65,
44,40,71,72,82,83,98,88,89,60,
-6,-31,-47,-48,-13,-39,-9,7,2,79,
-1,-39,-60,-17,87,81,65,50,45,19,
-21,-67,-91,-87,-41,-50,7,18,39,74,
10,-31,-28,39,24,13,23,5,56,45,
29,10,-5,-13,-11,-35,-18,-8,-10,-8,
-25,-71,-77,-21,2,16,50,63,87,87,
5,-32,-40,-51,-68,0,12,6,54,34,
5,-12,32,52,68,64,69,59,65,45,
14,-16,-31,-40,-65,-67,41,49,47,37,
-11,-52,-75,-84,-4,57,48,42,42,33,
-11,-51,-68,-6,13,0,8,-8,26,32,
-23,-53,0,36,56,76,97,105,111,97,
-1,-28,-39,-40,-43,-54,-44,-40,-18,35,
16,-20,-19,-28,-42,29,47,38,74,45,
3,-29,-48,-62,-80,-104,-33,56,59,59,
10,17,46,72,84,101,117,123,123,106,
-7,-33,-49,-51,-70,-67,-27,-31,70,67,
-16,-62,-85,-20,82,71,86,80,85,74,
-19,-58,-75,-45,-29,-33,-18,-25,45,57,
-12,-42,-5,12,28,36,52,64,81,82,
13,-9,-27,-28,22,3,2,22,26,6,
-6,-44,-51,2,15,10,48,43,49,34,
-19,-62,-84,-89,-102,-24,8,17,61,68,
39,24,23,19,16,-5,12,15,27,15,
-8,-44,-49,-60,-18,-32,-28,52,54,62,
-8,-48,-77,-70,66,101,83,63,61,37,
-12,-50,-75,-64,33,17,13,25,15,77,
1,-42,-29,72,64,46,49,31,61,44,
-8,-47,-54,-46,-30,19,20,-1,-16,0,
16,-12,-18,-9,-26,-27,-10,-22,53,45,
-10,-47,-75,-82,-105,-109,8,25,49,77,
50,65,114,117,124,118,115,96,90,61,
-9,-45,-63,-60,-75,-57,8,11,20,29,
0,-35,-49,-43,40,47,35,40,55,38,
-24,-76,-103,-112,-27,3,23,34,52,75,
8,-29,-43,12,63,38,35,29,24,8,
25,11,1,-15,-18,-43,-7,37,40,21,
-20,-56,-19,-19,-4,-2,11,29,51,63,
-2,-44,-62,-75,-89,30,57,51,74,51,
50,46,68,64,65,52,63,55,65,43,
18,-9,-26,-35,-55,-69,3,6,8,17,
-15,-61,-86,-97,1,86,93,74,78,67,
-1,-38,-66,-48,48,39,29,25,17,-1,
13,13,29,39,50,51,69,82,97,98,
-2,-36,-46,-27,-16,-30,-13,-4,-7,-4,
25,-5,-11,-6,-25,-21,33,12,31,29,
-8,-38,-52,-63,-68,-89,-33,-1,10,74,
-2,-15,59,91,105,105,101,87,84,62,
-7,-33,-50,-35,-54,-47,25,17,82,81,
-13,-56,-83,21,58,31,42,25,72,65,
-24,-66,-91,-56,9,-2,21,10,69,75,
2,-24,11,22,25,28,38,34,48,33,
7,-29,-26,17,15,-1,14,0,-2,0,
-6,-41,-67,6,-2,-9,19,2,85,74,
-22,-67,-84,-71,-50,3,11,-9,2,62};
signed char cdbk_nb_low1[320]={
-34,-52,-15,45,2,
23,21,52,24,-33,
-9,-1,9,-44,-41,
-13,-17,44,22,-17,
-6,-4,-1,22,38,
26,16,2,50,27,
-35,-34,-9,-41,6,
0,-16,-34,51,8,
-14,-31,-49,15,-33,
45,49,33,-11,-37,
-62,-54,45,11,-5,
-72,11,-1,-12,-11,
24,27,-11,-43,46,
43,33,-12,-9,-1,
1,-4,-23,-57,-71,
11,8,16,17,-8,
-20,-31,-41,53,48,
-16,3,65,-24,-8,
-23,-32,-37,-32,-49,
-10,-17,6,38,5,
-9,-17,-46,8,52,
3,6,45,40,39,
-7,-6,-34,-74,31,
8,1,-16,43,68,
-11,-19,-31,4,6,
0,-6,-17,-16,-38,
-16,-30,2,9,-39,
-16,-1,43,-10,48,
3,3,-16,-31,-3,
62,68,43,13,3,
-10,8,20,-56,12,
12,-2,-18,22,-15,
-40,-36,1,7,41,
0,1,46,-6,-62,
-4,-12,-2,-11,-83,
-13,-2,91,33,-10,
0,4,-11,-16,79,
32,37,14,9,51,
-21,-28,-56,-34,0,
21,9,-26,11,28,
-42,-54,-23,-2,-15,
31,30,8,-39,-66,
-39,-36,31,-28,-40,
-46,35,40,22,24,
33,48,23,-34,14,
40,32,17,27,-3,
25,26,-13,-61,-17,
11,4,31,60,-6,
-26,-41,-64,13,16,
-26,54,31,-11,-23,
-9,-11,-34,-71,-21,
-34,-35,55,50,29,
-22,-27,-50,-38,57,
33,42,57,48,26,
11,0,-49,-31,26,
-4,-14,5,78,37,
17,0,-49,-12,-23,
26,14,2,2,-43,
-17,-12,10,-8,-4,
8,18,12,-6,20,
-12,-6,-13,-25,34,
15,40,49,7,8,
13,20,20,-19,-22,
-2,-8,2,51,-51};
signed char cdbk_nb_low2[320]={
-6,53,-21,-24,4,
26,17,-4,-37,25,
17,-36,-13,31,3,
-6,27,15,-10,31,
28,26,-10,-10,-40,
16,-7,15,13,41,
-9,0,-4,50,-6,
-7,14,38,22,0,
-48,2,1,-13,-19,
32,-3,-60,11,-17,
-1,-24,-34,-1,35,
-5,-27,28,44,13,
25,15,42,-11,15,
51,35,-36,20,8,
-4,-12,-29,19,-47,
49,-15,-4,16,-29,
-39,14,-30,4,25,
-9,-5,-51,-14,-3,
-40,-32,38,5,-9,
-8,-4,-1,-22,71,
-3,14,26,-18,-22,
24,-41,-25,-24,6,
23,19,-10,39,-26,
-27,65,45,2,-7,
-26,-8,22,-12,16,
15,16,-35,-5,33,
-21,-8,0,23,33,
34,6,21,36,6,
-7,-22,8,-37,-14,
31,38,11,-4,-3,
-39,-32,-8,32,-23,
-6,-12,16,20,-28,
-4,23,13,-52,-1,
22,6,-33,-40,-6,
4,-62,13,5,-26,
35,39,11,2,57,
-11,9,-20,-28,-33,
52,-5,-6,-2,22,
-14,-16,-48,35,1,
-58,20,13,33,-1,
-74,56,-18,-22,-31,
12,6,-14,4,-2,
-9,-47,10,-3,29,
-17,-5,61,14,47,
-12,2,72,-39,-17,
92,64,-53,-51,-15,
-30,-38,-41,-29,-28,
27,9,36,9,-35,
-42,81,-21,20,25,
-16,-5,-17,-35,21,
15,-28,48,2,-2,
9,-19,29,-40,30,
-18,-18,18,-16,-57,
15,-20,-12,-15,-37,
-15,33,-39,21,-22,
-13,35,11,13,-38,
-63,29,23,-27,32,
18,3,-26,42,33,
-64,-66,-17,16,56,
2,36,3,31,21,
-41,-39,8,-57,14,
37,-2,19,-36,-19,
-23,-29,-16,1,-3,
-8,-10,31,64,-65};
signed char cdbk_nb_high1[320]={
-26,-8,29,21,4,
19,-39,33,-7,-36,
56,54,48,40,29,
-4,-24,-42,-66,-43,
-60,19,-2,37,41,
-10,-37,-60,-64,18,
-22,77,73,40,25,
4,19,-19,-66,-2,
11,5,21,14,26,
-25,-86,-4,18,1,
26,-37,10,37,-1,
24,-12,-59,-11,20,
-6,34,-16,-16,42,
19,-28,-51,53,32,
4,10,62,21,-12,
-34,27,4,-48,-48,
-50,-49,31,-7,-21,
-42,-25,-4,-43,-22,
59,2,27,12,-9,
-6,-16,-8,-32,-58,
-16,-29,-5,41,23,
-30,-33,-46,-13,-10,
-38,52,52,1,-17,
-9,10,26,-25,-6,
33,-20,53,55,25,
-32,-5,-42,23,21,
66,5,-28,20,9,
75,29,-7,-42,-39,
15,3,-23,21,6,
11,1,-29,14,63,
10,54,26,-24,-51,
-49,7,-23,-51,15,
-66,1,60,25,10,
0,-30,-4,-15,17,
19,59,40,4,-5,
33,6,-22,-58,-70,
-5,23,-6,60,44,
-29,-16,-47,-29,52,
-19,50,28,16,35,
31,36,0,-21,6,
21,27,22,42,7,
-66,-40,-8,7,19,
46,0,-4,60,36,
45,-7,-29,-6,-32,
-39,2,6,-9,33,
20,-51,-34,18,-6,
19,6,11,5,-19,
-29,-2,42,-11,-45,
-21,-55,57,37,2,
-14,-67,-16,-27,-38,
69,48,19,2,-17,
20,-20,-16,-34,-17,
-25,-61,10,73,45,
16,-40,-64,-17,-29,
-22,56,17,-39,8,
-11,8,-25,-18,-13,
-19,8,54,57,36,
-17,-26,-4,6,-21,
40,42,-4,20,31,
53,10,-34,-53,31,
-17,35,0,15,-6,
-20,-63,-73,22,25,
29,17,8,-29,-39,
-69,18,15,-15,-5};
signed char cdbk_nb_high2[320]={
11,47,16,-9,-46,
-32,26,-64,34,-5,
38,-7,47,20,2,
-73,-99,-3,-45,20,
70,-52,15,-6,-7,
-82,31,21,47,51,
39,-3,9,0,-41,
-7,-15,-54,2,0,
27,-31,9,-45,-22,
-38,-24,-24,8,-33,
23,5,50,-36,-17,
-18,-51,-2,13,19,
43,12,-15,-12,61,
38,38,7,13,0,
6,-1,3,62,9,
27,22,-33,38,-35,
-9,30,-43,-9,-32,
-1,4,-4,1,-5,
-11,-8,38,31,11,
-10,-42,-21,-37,1,
43,15,-13,-35,-19,
-18,15,23,-26,59,
1,-21,53,8,-41,
-50,-14,-28,4,21,
25,-28,-40,5,-40,
-41,4,51,-33,-8,
-8,1,17,-60,12,
25,-41,17,34,43,
19,45,7,-37,24,
-15,56,-2,35,-10,
48,4,-47,-2,5,
-5,-54,5,-3,-33,
-10,30,-2,-44,-24,
-38,9,-9,42,4,
6,-56,44,-16,9,
-40,-26,18,-20,10,
28,-41,-21,-4,13,
-18,32,-30,-3,37,
15,22,28,50,-40,
3,-29,-64,7,51,
-19,-11,17,-27,-40,
-64,24,-12,-7,-27,
3,37,48,-1,2,
-9,-38,-34,46,1,
27,-6,19,-13,26,
10,34,20,25,40,
50,-6,-7,30,9,
-24,0,-23,71,-61,
22,58,-34,-4,2,
-49,-33,25,30,-8,
-6,-16,77,2,38,
-8,-35,-6,-30,56,
78,31,33,-20,13,
-39,20,22,4,21,
-8,4,-6,10,-83,
-41,9,-25,-43,15,
-7,-12,-34,-39,-37,
-33,19,30,16,-33,
42,-25,25,-68,44,
-15,-11,-4,23,50,
14,4,-39,-43,20,
-30,60,9,-20,7,
16,19,-33,37,29,
16,-35,7,38,-27};

View File

@ -1,548 +0,0 @@
/* Copyright (C) 2002 Jean-Marc Valin
File: ltp.c
Long-Term Prediction functions
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of the Xiph.org Foundation nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <math.h>
#include "ltp.h"
#include "stack_alloc.h"
#include "filters.h"
#include "speex_bits.h"
#ifdef _USE_SSE
#include "ltp_sse.h"
#else
static float inner_prod(float *x, float *y, int len)
{
int i;
float sum1=0,sum2=0,sum3=0,sum4=0;
for (i=0;i<len;)
{
sum1 += x[i]*y[i];
sum2 += x[i+1]*y[i+1];
sum3 += x[i+2]*y[i+2];
sum4 += x[i+3]*y[i+3];
i+=4;
}
return sum1+sum2+sum3+sum4;
}
#endif
/*Original, non-optimized version*/
/*static float inner_prod(float *x, float *y, int len)
{
int i;
float sum=0;
for (i=0;i<len;i++)
sum += x[i]*y[i];
return sum;
}
*/
void open_loop_nbest_pitch(float *sw, int start, int end, int len, int *pitch, float *gain, int N, char *stack)
{
int i,j,k;
/*float corr=0;*/
/*float energy;*/
float *best_score;
float e0;
float *corr, *energy, *score;
best_score = PUSH(stack,N, float);
corr = PUSH(stack,end-start+1, float);
energy = PUSH(stack,end-start+2, float);
score = PUSH(stack,end-start+1, float);
for (i=0;i<N;i++)
{
best_score[i]=-1;
gain[i]=0;
}
energy[0]=inner_prod(sw-start, sw-start, len);
e0=inner_prod(sw, sw, len);
for (i=start;i<=end;i++)
{
/* Update energy for next pitch*/
energy[i-start+1] = energy[i-start] + sw[-i-1]*sw[-i-1] - sw[-i+len-1]*sw[-i+len-1];
}
for (i=start;i<=end;i++)
{
corr[i-start]=0;
score[i-start]=0;
}
for (i=start;i<=end;i++)
{
/* Compute correlation*/
corr[i-start]=inner_prod(sw, sw-i, len);
score[i-start]=corr[i-start]*corr[i-start]/(energy[i-start]+1);
}
for (i=start;i<=end;i++)
{
if (score[i-start]>best_score[N-1])
{
float g1, g;
g1 = corr[i-start]/(energy[i-start]+10);
g = sqrt(g1*corr[i-start]/(e0+10));
if (g>g1)
g=g1;
if (g<0)
g=0;
for (j=0;j<N;j++)
{
if (score[i-start] > best_score[j])
{
for (k=N-1;k>j;k--)
{
best_score[k]=best_score[k-1];
pitch[k]=pitch[k-1];
gain[k] = gain[k-1];
}
best_score[j]=score[i-start];
pitch[j]=i;
gain[j]=g;
break;
}
}
}
}
}
/** Finds the best quantized 3-tap pitch predictor by analysis by synthesis */
float pitch_gain_search_3tap(
float target[], /* Target vector */
float ak[], /* LPCs for this subframe */
float awk1[], /* Weighted LPCs #1 for this subframe */
float awk2[], /* Weighted LPCs #2 for this subframe */
float exc[], /* Excitation */
void *par,
int pitch, /* Pitch value */
int p, /* Number of LPC coeffs */
int nsf, /* Number of samples in subframe */
SpeexBits *bits,
char *stack,
float *exc2,
float *r,
int *cdbk_index
)
{
int i,j;
float *tmp, *tmp2;
float *x[3];
float *e[3];
float corr[3];
float A[3][3];
float gain[3];
int gain_cdbk_size;
signed char *gain_cdbk;
float err1,err2;
ltp_params *params;
params = (ltp_params*) par;
gain_cdbk=params->gain_cdbk;
gain_cdbk_size=1<<params->gain_bits;
tmp = PUSH(stack, 3*nsf, float);
tmp2 = PUSH(stack, 3*nsf, float);
x[0]=tmp;
x[1]=tmp+nsf;
x[2]=tmp+2*nsf;
e[0]=tmp2;
e[1]=tmp2+nsf;
e[2]=tmp2+2*nsf;
for (i=2;i>=0;i--)
{
int pp=pitch+1-i;
for (j=0;j<nsf;j++)
{
if (j-pp<0)
e[i][j]=exc2[j-pp];
else if (j-pp-pitch<0)
e[i][j]=exc2[j-pp-pitch];
else
e[i][j]=0;
}
if (i==2)
syn_percep_zero(e[i], ak, awk1, awk2, x[i], nsf, p, stack);
else {
for (j=0;j<nsf-1;j++)
x[i][j+1]=x[i+1][j];
x[i][0]=0;
for (j=0;j<nsf;j++)
x[i][j]+=e[i][0]*r[j];
}
}
for (i=0;i<3;i++)
corr[i]=inner_prod(x[i],target,nsf);
for (i=0;i<3;i++)
for (j=0;j<=i;j++)
A[i][j]=A[j][i]=inner_prod(x[i],x[j],nsf);
{
float C[9];
signed char *ptr=gain_cdbk;
int best_cdbk=0;
float best_sum=0;
C[0]=corr[2];
C[1]=corr[1];
C[2]=corr[0];
C[3]=A[1][2];
C[4]=A[0][1];
C[5]=A[0][2];
C[6]=A[2][2];
C[7]=A[1][1];
C[8]=A[0][0];
for (i=0;i<gain_cdbk_size;i++)
{
float sum=0;
float g0,g1,g2;
ptr = gain_cdbk+3*i;
g0=0.015625*ptr[0]+.5;
g1=0.015625*ptr[1]+.5;
g2=0.015625*ptr[2]+.5;
sum += C[0]*g0;
sum += C[1]*g1;
sum += C[2]*g2;
sum -= C[3]*g0*g1;
sum -= C[4]*g2*g1;
sum -= C[5]*g2*g0;
sum -= .5*C[6]*g0*g0;
sum -= .5*C[7]*g1*g1;
sum -= .5*C[8]*g2*g2;
/* If 1, force "safe" pitch values to handle packet loss better */
if (0) {
float tot = fabs(ptr[1]);
if (ptr[0]>0)
tot+=ptr[0];
if (ptr[2]>0)
tot+=ptr[2];
if (tot>1)
continue;
}
if (sum>best_sum || i==0)
{
best_sum=sum;
best_cdbk=i;
}
}
gain[0] = 0.015625*gain_cdbk[best_cdbk*3] + .5;
gain[1] = 0.015625*gain_cdbk[best_cdbk*3+1]+ .5;
gain[2] = 0.015625*gain_cdbk[best_cdbk*3+2]+ .5;
*cdbk_index=best_cdbk;
}
for (i=0;i<nsf;i++)
exc[i]=gain[0]*e[2][i]+gain[1]*e[1][i]+gain[2]*e[0][i];
err1=0;
err2=0;
for (i=0;i<nsf;i++)
err1+=target[i]*target[i];
for (i=0;i<nsf;i++)
err2+=(target[i]-gain[2]*x[0][i]-gain[1]*x[1][i]-gain[0]*x[2][i])
* (target[i]-gain[2]*x[0][i]-gain[1]*x[1][i]-gain[0]*x[2][i]);
return err2;
}
/** Finds the best quantized 3-tap pitch predictor by analysis by synthesis */
int pitch_search_3tap(
float target[], /* Target vector */
float *sw,
float ak[], /* LPCs for this subframe */
float awk1[], /* Weighted LPCs #1 for this subframe */
float awk2[], /* Weighted LPCs #2 for this subframe */
float exc[], /* Excitation */
void *par,
int start, /* Smallest pitch value allowed */
int end, /* Largest pitch value allowed */
float pitch_coef, /* Voicing (pitch) coefficient */
int p, /* Number of LPC coeffs */
int nsf, /* Number of samples in subframe */
SpeexBits *bits,
char *stack,
float *exc2,
float *r,
int complexity
)
{
int i,j;
int cdbk_index, pitch=0, best_gain_index=0;
float *best_exc;
int best_pitch=0;
float err, best_err=-1;
int N;
ltp_params *params;
int *nbest;
float *gains;
N=complexity;
if (N>10)
N=10;
nbest=PUSH(stack, N, int);
gains = PUSH(stack, N, float);
params = (ltp_params*) par;
if (N==0 || end<start)
{
speex_bits_pack(bits, 0, params->pitch_bits);
speex_bits_pack(bits, 0, params->gain_bits);
for (i=0;i<nsf;i++)
exc[i]=0;
return start;
}
best_exc=PUSH(stack,nsf, float);
if (N>end-start+1)
N=end-start+1;
open_loop_nbest_pitch(sw, start, end, nsf, nbest, gains, N, stack);
for (i=0;i<N;i++)
{
pitch=nbest[i];
for (j=0;j<nsf;j++)
exc[j]=0;
err=pitch_gain_search_3tap(target, ak, awk1, awk2, exc, par, pitch, p, nsf,
bits, stack, exc2, r, &cdbk_index);
if (err<best_err || best_err<0)
{
for (j=0;j<nsf;j++)
best_exc[j]=exc[j];
best_err=err;
best_pitch=pitch;
best_gain_index=cdbk_index;
}
}
/*printf ("pitch: %d %d\n", best_pitch, best_gain_index);*/
speex_bits_pack(bits, best_pitch-start, params->pitch_bits);
speex_bits_pack(bits, best_gain_index, params->gain_bits);
/*printf ("encode pitch: %d %d\n", best_pitch, best_gain_index);*/
for (i=0;i<nsf;i++)
exc[i]=best_exc[i];
return pitch;
}
void pitch_unquant_3tap(
float exc[], /* Excitation */
int start, /* Smallest pitch value allowed */
int end, /* Largest pitch value allowed */
float pitch_coef, /* Voicing (pitch) coefficient */
void *par,
int nsf, /* Number of samples in subframe */
int *pitch_val,
float *gain_val,
SpeexBits *bits,
char *stack,
int count_lost,
int subframe_offset,
float last_pitch_gain)
{
int i;
int pitch;
int gain_index;
float gain[3];
signed char *gain_cdbk;
ltp_params *params;
params = (ltp_params*) par;
gain_cdbk=params->gain_cdbk;
pitch = speex_bits_unpack_unsigned(bits, params->pitch_bits);
pitch += start;
gain_index = speex_bits_unpack_unsigned(bits, params->gain_bits);
/*printf ("decode pitch: %d %d\n", pitch, gain_index);*/
gain[0] = 0.015625*gain_cdbk[gain_index*3]+.5;
gain[1] = 0.015625*gain_cdbk[gain_index*3+1]+.5;
gain[2] = 0.015625*gain_cdbk[gain_index*3+2]+.5;
if (count_lost && pitch > subframe_offset)
{
float gain_sum;
if (1) {
float tmp = count_lost < 4 ? last_pitch_gain : 0.4 * last_pitch_gain;
if (tmp>.95)
tmp=.95;
gain_sum = fabs(gain[1]);
if (gain[0]>0)
gain_sum += gain[0];
else
gain_sum -= .5*gain[0];
if (gain[2]>0)
gain_sum += gain[2];
else
gain_sum -= .5*gain[2];
if (gain_sum > tmp) {
float fact = tmp/gain_sum;
for (i=0;i<3;i++)
gain[i]*=fact;
}
}
if (0) {
gain_sum = fabs(gain[0])+fabs(gain[1])+fabs(gain[2]);
if (gain_sum>.95) {
float fact = .95/gain_sum;
for (i=0;i<3;i++)
gain[i]*=fact;
}
}
}
*pitch_val = pitch;
/**gain_val = gain[0]+gain[1]+gain[2];*/
gain_val[0]=gain[0];
gain_val[1]=gain[1];
gain_val[2]=gain[2];
{
float *e[3];
float *tmp2;
tmp2=PUSH(stack, 3*nsf, float);
e[0]=tmp2;
e[1]=tmp2+nsf;
e[2]=tmp2+2*nsf;
for (i=0;i<3;i++)
{
int j;
int pp=pitch+1-i;
#if 0
for (j=0;j<nsf;j++)
{
if (j-pp<0)
e[i][j]=exc[j-pp];
else if (j-pp-pitch<0)
e[i][j]=exc[j-pp-pitch];
else
e[i][j]=0;
}
#else
{
int tmp1, tmp3;
tmp1=nsf;
if (tmp1>pp)
tmp1=pp;
for (j=0;j<tmp1;j++)
e[i][j]=exc[j-pp];
tmp3=nsf;
if (tmp3>pp+pitch)
tmp3=pp+pitch;
for (j=tmp1;j<tmp3;j++)
e[i][j]=exc[j-pp-pitch];
for (j=tmp3;j<nsf;j++)
e[i][j]=0;
}
#endif
}
for (i=0;i<nsf;i++)
exc[i]=gain[0]*e[2][i]+gain[1]*e[1][i]+gain[2]*e[0][i];
}
}
/** Forced pitch delay and gain */
int forced_pitch_quant(
float target[], /* Target vector */
float *sw,
float ak[], /* LPCs for this subframe */
float awk1[], /* Weighted LPCs #1 for this subframe */
float awk2[], /* Weighted LPCs #2 for this subframe */
float exc[], /* Excitation */
void *par,
int start, /* Smallest pitch value allowed */
int end, /* Largest pitch value allowed */
float pitch_coef, /* Voicing (pitch) coefficient */
int p, /* Number of LPC coeffs */
int nsf, /* Number of samples in subframe */
SpeexBits *bits,
char *stack,
float *exc2,
float *r,
int complexity
)
{
int i;
if (pitch_coef>.99)
pitch_coef=.99;
for (i=0;i<nsf;i++)
{
exc[i]=exc[i-start]*pitch_coef;
}
return start;
}
/** Unquantize forced pitch delay and gain */
void forced_pitch_unquant(
float exc[], /* Excitation */
int start, /* Smallest pitch value allowed */
int end, /* Largest pitch value allowed */
float pitch_coef, /* Voicing (pitch) coefficient */
void *par,
int nsf, /* Number of samples in subframe */
int *pitch_val,
float *gain_val,
SpeexBits *bits,
char *stack,
int count_lost,
int subframe_offset,
float last_pitch_gain)
{
int i;
/*pitch_coef=.9;*/
if (pitch_coef>.99)
pitch_coef=.99;
for (i=0;i<nsf;i++)
{
exc[i]=exc[i-start]*pitch_coef;
}
*pitch_val = start;
gain_val[0]=gain_val[2]=0;
gain_val[1] = pitch_coef;
}

View File

@ -1,138 +0,0 @@
/* Copyright (C) 2002 Jean-Marc Valin
File: ltp.h
Long-Term Prediction functions
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of the Xiph.org Foundation nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "speex_bits.h"
typedef struct ltp_params {
signed char *gain_cdbk;
int gain_bits;
int pitch_bits;
} ltp_params;
void open_loop_nbest_pitch(float *sw, int start, int end, int len, int *pitch, float *gain, int N, char *stack);
/** Finds the best quantized 3-tap pitch predictor by analysis by synthesis */
int pitch_search_3tap(
float target[], /* Target vector */
float *sw,
float ak[], /* LPCs for this subframe */
float awk1[], /* Weighted LPCs #1 for this subframe */
float awk2[], /* Weighted LPCs #2 for this subframe */
float exc[], /* Overlapping codebook */
void *par,
int start, /* Smallest pitch value allowed */
int end, /* Largest pitch value allowed */
float pitch_coef, /* Voicing (pitch) coefficient */
int p, /* Number of LPC coeffs */
int nsf, /* Number of samples in subframe */
SpeexBits *bits,
char *stack,
float *exc2,
float *r,
int complexity
);
/*Unquantize adaptive codebook and update pitch contribution*/
void pitch_unquant_3tap(
float exc[], /* Excitation */
int start, /* Smallest pitch value allowed */
int end, /* Largest pitch value allowed */
float pitch_coef, /* Voicing (pitch) coefficient */
void *par,
int nsf, /* Number of samples in subframe */
int *pitch_val,
float *gain_val,
SpeexBits *bits,
char *stack,
int lost,
int subframe_offset,
float last_pitch_gain
);
float pitch_gain_search_3tap(
float target[], /* Target vector */
float ak[], /* LPCs for this subframe */
float awk1[], /* Weighted LPCs #1 for this subframe */
float awk2[], /* Weighted LPCs #2 for this subframe */
float exc[], /* Excitation */
void *par,
int pitch, /* Pitch value */
int p, /* Number of LPC coeffs */
int nsf, /* Number of samples in subframe */
SpeexBits *bits,
char *stack,
float *exc2,
float *r,
int *cdbk_index
);
/** Forced pitch delay and gain */
int forced_pitch_quant(
float target[], /* Target vector */
float *sw,
float ak[], /* LPCs for this subframe */
float awk1[], /* Weighted LPCs #1 for this subframe */
float awk2[], /* Weighted LPCs #2 for this subframe */
float exc[], /* Excitation */
void *par,
int start, /* Smallest pitch value allowed */
int end, /* Largest pitch value allowed */
float pitch_coef, /* Voicing (pitch) coefficient */
int p, /* Number of LPC coeffs */
int nsf, /* Number of samples in subframe */
SpeexBits *bits,
char *stack,
float *exc2,
float *r,
int complexity
);
/** Unquantize forced pitch delay and gain */
void forced_pitch_unquant(
float exc[], /* Excitation */
int start, /* Smallest pitch value allowed */
int end, /* Largest pitch value allowed */
float pitch_coef, /* Voicing (pitch) coefficient */
void *par,
int nsf, /* Number of samples in subframe */
int *pitch_val,
float *gain_val,
SpeexBits *bits,
char *stack,
int lost,
int subframe_offset,
float last_pitch_gain
);

View File

@ -1,95 +0,0 @@
/* Copyright (C) 2002 Jean-Marc Valin
File: ltp.c
Lont-Term Prediction functions
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of the Xiph.org Foundation nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
static float inner_prod(float *a, float *b, int len)
{
float sum;
__asm__ __volatile__ (
"\tpush %%eax\n"
"\tpush %%edi\n"
"\tpush %%ecx\n"
"\txorps %%xmm3, %%xmm3\n"
"\txorps %%xmm4, %%xmm4\n"
"\tsub $20, %%ecx\n"
".mul20_loop%=:\n"
"\tmovups (%%eax), %%xmm0\n"
"\tmovups (%%edi), %%xmm1\n"
"\tmulps %%xmm0, %%xmm1\n"
"\tmovups 16(%%eax), %%xmm5\n"
"\tmovups 16(%%edi), %%xmm6\n"
"\tmulps %%xmm5, %%xmm6\n"
"\taddps %%xmm1, %%xmm3\n"
"\tmovups 32(%%eax), %%xmm0\n"
"\tmovups 32(%%edi), %%xmm1\n"
"\tmulps %%xmm0, %%xmm1\n"
"\taddps %%xmm6, %%xmm4\n"
"\tmovups 48(%%eax), %%xmm5\n"
"\tmovups 48(%%edi), %%xmm6\n"
"\tmulps %%xmm5, %%xmm6\n"
"\taddps %%xmm1, %%xmm3\n"
"\tmovups 64(%%eax), %%xmm0\n"
"\tmovups 64(%%edi), %%xmm1\n"
"\tmulps %%xmm0, %%xmm1\n"
"\taddps %%xmm6, %%xmm4\n"
"\taddps %%xmm1, %%xmm3\n"
"\tadd $80, %%eax\n"
"\tadd $80, %%edi\n"
"\tsub $20, %%ecx\n"
"\tjae .mul20_loop%=\n"
"\taddps %%xmm4, %%xmm3\n"
"\tmovhlps %%xmm3, %%xmm4\n"
"\taddps %%xmm4, %%xmm3\n"
"\tmovaps %%xmm3, %%xmm4\n"
"\tshufps $0x55, %%xmm4, %%xmm4\n"
"\taddss %%xmm4, %%xmm3\n"
"\tmovss %%xmm3, (%%edx)\n"
"\tpop %%ecx\n"
"\tpop %%edi\n"
"\tpop %%eax\n"
: : "a" (a), "D" (b), "c" (len), "d" (&sum) : "memory");
return sum;
}

View File

@ -1,105 +0,0 @@
/* Copyright (C) 2002 Jean-Marc Valin
File: math_approx.c
Various math approximation functions for Speex
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of the Xiph.org Foundation nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <math.h>
#include "math_approx.h"
#ifdef SLOW_TRIG
float cos_sin[102] = {
1.00000000, 0.00000000,
0.99804751, 0.06245932,
0.99219767, 0.12467473,
0.98247331, 0.18640330,
0.96891242, 0.24740396,
0.95156795, 0.30743851,
0.93050762, 0.36627253,
0.90581368, 0.42367626,
0.87758256, 0.47942554,
0.84592450, 0.53330267,
0.81096312, 0.58509727,
0.77283495, 0.63460708,
0.73168887, 0.68163876,
0.68768556, 0.72600866,
0.64099686, 0.76754350,
0.59180508, 0.80608111,
0.54030231, 0.84147098,
0.48668967, 0.87357494,
0.43117652, 0.90226759,
0.37397963, 0.92743692,
0.31532236, 0.94898462,
0.25543377, 0.96682656,
0.19454771, 0.98089306,
0.13290194, 0.99112919,
0.07073720, 0.99749499,
0.00829623, 0.99996559,
-0.05417714, 0.99853134,
-0.11643894, 0.99319785,
-0.17824606, 0.98398595,
-0.23935712, 0.97093160,
-0.29953351, 0.95408578,
-0.35854022, 0.93351428,
-0.41614684, 0.90929743,
-0.47212841, 0.88152979,
-0.52626633, 0.85031979,
-0.57834920, 0.81578931,
-0.62817362, 0.77807320,
-0.67554504, 0.73731872,
-0.72027847, 0.69368503,
-0.76219923, 0.64734252,
-0.80114362, 0.59847214,
-0.83695955, 0.54726475,
-0.86950718, 0.49392030,
-0.89865940, 0.43864710,
-0.92430238, 0.38166099,
-0.94633597, 0.32318451,
-0.96467415, 0.26344599,
-0.97924529, 0.20267873,
-0.98999250, 0.14112001,
-0.99687381, 0.07901022,
-0.99986235, 0.01659189
};
float speex_cos(float x)
{
int ind;
float delta;
ind = (int)floor(x*16+.5);
delta = x-0.062500*ind;
ind <<= 1;
return cos_sin[ind] - delta*(cos_sin[ind+1] +
.5*delta*(cos_sin[ind] -
.3333333*delta*cos_sin[ind+1]));
}
#endif

View File

@ -1,39 +0,0 @@
/* Copyright (C) 2002 Jean-Marc Valin
File: math_approx.c
Various math approximation functions for Speex
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of the Xiph.org Foundation nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef MATH_APPROX_H
#define MATH_APPROX_H
float speex_cos(float x);
#endif

View File

@ -1,145 +0,0 @@
/* Copyright (C) 2002 Jean-Marc Valin
File: mics.c
Various utility routines for Speex
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of the Xiph.org Foundation nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "misc.h"
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#ifndef RELEASE
void print_vec(float *vec, int len, char *name)
{
int i;
printf ("%s ", name);
for (i=0;i<len;i++)
printf (" %f", vec[i]);
printf ("\n");
}
#endif
unsigned int be_int(unsigned int i)
{
unsigned int ret=i;
#ifndef WORDS_BIGENDIAN
ret = i>>24;
ret += (i>>8)&0x0000ff00;
ret += (i<<8)&0x00ff0000;
ret += (i<<24);
#endif
return ret;
}
unsigned int le_int(unsigned int i)
{
unsigned int ret=i;
#ifdef WORDS_BIGENDIAN
ret = i>>24;
ret += (i>>8)&0x0000ff00;
ret += (i<<8)&0x00ff0000;
ret += (i<<24);
#endif
return ret;
}
unsigned short be_short(unsigned short s)
{
unsigned short ret=s;
#ifndef WORDS_BIGENDIAN
ret = s>>8;
ret += s<<8;
#endif
return ret;
}
unsigned short le_short(unsigned short s)
{
unsigned short ret=s;
#ifdef WORDS_BIGENDIAN
ret = s>>8;
ret += s<<8;
#endif
return ret;
}
void *speex_alloc (int size)
{
return calloc(size,1);
}
void *speex_realloc (void *ptr, int size)
{
return realloc(ptr, size);
}
void speex_free (void *ptr)
{
free(ptr);
}
void *speex_move (void *dest, void *src, int n)
{
return memmove(dest,src,n);
}
void speex_error(char *str)
{
fprintf (stderr, "Fatal error: %s\n", str);
exit(1);
}
void speex_warning(char *str)
{
fprintf (stderr, "warning: %s\n", str);
}
void speex_warning_int(char *str, int val)
{
fprintf (stderr, "warning: %s %d\n", str, val);
}
void speex_rand_vec(float std, float *data, int len)
{
int i;
for (i=0;i<len;i++)
data[i]+=3*std*((((float)rand())/RAND_MAX)-.5);
}
float speex_rand(float std)
{
return 3*std*((((float)rand())/RAND_MAX)-.5);
}
void _speex_putc(int ch, void *file)
{
FILE *f = (FILE *)file;
fputc(ch, f);
}

View File

@ -1,83 +0,0 @@
/* Copyright (C) 2002 Jean-Marc Valin */
/**
@file misc.h
@brief Various compatibility routines for Speex
*/
/*
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of the Xiph.org Foundation nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef MISC_H
#define MISC_H
#ifndef VERSION
#define VERSION "speex-1.0"
#endif
/*Disable some warnings on VC++*/
#ifdef _MSC_VER
#pragma warning(disable : 4244)
#pragma warning(disable : 4305)
#endif
#ifndef RELEASE
void print_vec(float *vec, int len, char *name);
#endif
unsigned int be_int(unsigned int i);
unsigned int le_int(unsigned int i);
unsigned short be_short(unsigned short s);
unsigned short le_short(unsigned short s);
/** Speex wrapper for calloc. To do your own dynamic allocation, all you need to do is replace this function, speex_realloc and speex_free */
void *speex_alloc (int size);
/** Speex wrapper for realloc. To do your own dynamic allocation, all you need to do is replace this function, speex_alloc and speex_free */
void *speex_realloc (void *ptr, int size);
/** Speex wrapper for calloc. To do your own dynamic allocation, all you need to do is replace this function, speex_realloc and speex_alloc */
void speex_free (void *ptr);
/** Speex wrapper for mem_move */
void *speex_move (void *dest, void *src, int n);
void speex_error(char *str);
void speex_warning(char *str);
void speex_warning_int(char *str, int val);
void speex_rand_vec(float std, float *data, int len);
float speex_rand(float std);
void _speex_putc(int ch, void *file);
#endif

View File

@ -1,650 +0,0 @@
/* Copyright (C) 2002 Jean-Marc Valin
File: modes.c
Describes the different modes of the codec
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of the Xiph.org Foundation nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "modes.h"
#include "ltp.h"
#include "quant_lsp.h"
#include "cb_search.h"
#include "sb_celp.h"
#include "nb_celp.h"
#include "vbr.h"
#include "misc.h"
#ifndef NULL
#define NULL 0
#endif
SpeexMode *speex_mode_list[SPEEX_NB_MODES] = {&speex_nb_mode, &speex_wb_mode, &speex_uwb_mode};
/* Extern declarations for all codebooks we use here */
extern signed char gain_cdbk_nb[];
extern signed char gain_cdbk_lbr[];
extern signed char hexc_table[];
extern signed char exc_5_256_table[];
extern signed char exc_5_64_table[];
extern signed char exc_8_128_table[];
extern signed char exc_10_32_table[];
extern signed char exc_10_16_table[];
extern signed char exc_20_32_table[];
extern signed char hexc_10_32_table[];
static int nb_mode_query(void *mode, int request, void *ptr);
static int wb_mode_query(void *mode, int request, void *ptr);
/* Parameters for Long-Term Prediction (LTP)*/
static ltp_params ltp_params_nb = {
gain_cdbk_nb,
7,
7
};
/* Parameters for Long-Term Prediction (LTP)*/
static ltp_params ltp_params_vlbr = {
gain_cdbk_lbr,
5,
0
};
/* Parameters for Long-Term Prediction (LTP)*/
static ltp_params ltp_params_lbr = {
gain_cdbk_lbr,
5,
7
};
/* Parameters for Long-Term Prediction (LTP)*/
static ltp_params ltp_params_med = {
gain_cdbk_lbr,
5,
7
};
/* Split-VQ innovation parameters for very low bit-rate narrowband */
static split_cb_params split_cb_nb_vlbr = {
10, /*subvect_size*/
4, /*nb_subvect*/
exc_10_16_table, /*shape_cb*/
4, /*shape_bits*/
0,
};
/* Split-VQ innovation parameters for very low bit-rate narrowband */
static split_cb_params split_cb_nb_ulbr = {
20, /*subvect_size*/
2, /*nb_subvect*/
exc_20_32_table, /*shape_cb*/
5, /*shape_bits*/
0,
};
/* Split-VQ innovation parameters for low bit-rate narrowband */
static split_cb_params split_cb_nb_lbr = {
10, /*subvect_size*/
4, /*nb_subvect*/
exc_10_32_table, /*shape_cb*/
5, /*shape_bits*/
0,
};
/* Split-VQ innovation parameters narrowband */
static split_cb_params split_cb_nb = {
5, /*subvect_size*/
8, /*nb_subvect*/
exc_5_64_table, /*shape_cb*/
6, /*shape_bits*/
0,
};
/* Split-VQ innovation parameters narrowband */
static split_cb_params split_cb_nb_med = {
8, /*subvect_size*/
5, /*nb_subvect*/
exc_8_128_table, /*shape_cb*/
7, /*shape_bits*/
0,
};
/* Split-VQ innovation for low-band wideband */
static split_cb_params split_cb_sb = {
5, /*subvect_size*/
8, /*nb_subvect*/
exc_5_256_table, /*shape_cb*/
8, /*shape_bits*/
0,
};
/* Split-VQ innovation for high-band wideband */
static split_cb_params split_cb_high = {
8, /*subvect_size*/
5, /*nb_subvect*/
hexc_table, /*shape_cb*/
7, /*shape_bits*/
1,
};
/* Split-VQ innovation for high-band wideband */
static split_cb_params split_cb_high_lbr = {
10, /*subvect_size*/
4, /*nb_subvect*/
hexc_10_32_table, /*shape_cb*/
5, /*shape_bits*/
0,
};
/* 2150 bps "vocoder-like" mode for comfort noise */
static SpeexSubmode nb_submode1 = {
0,
1,
0,
0,
/* LSP quantization */
lsp_quant_lbr,
lsp_unquant_lbr,
/* No pitch quantization */
forced_pitch_quant,
forced_pitch_unquant,
NULL,
/* No innovation quantization (noise only) */
noise_codebook_quant,
noise_codebook_unquant,
NULL,
.7, .7, -1,
43
};
/* 3.95 kbps very low bit-rate mode */
static SpeexSubmode nb_submode8 = {
0,
1,
0,
0,
/*LSP quantization*/
lsp_quant_lbr,
lsp_unquant_lbr,
/*No pitch quantization*/
forced_pitch_quant,
forced_pitch_unquant,
NULL,
/*Innovation quantization*/
split_cb_search_shape_sign,
split_cb_shape_sign_unquant,
&split_cb_nb_ulbr,
0.7, 0.5, .65,
79
};
/* 5.95 kbps very low bit-rate mode */
static SpeexSubmode nb_submode2 = {
0,
0,
0,
0,
/*LSP quantization*/
lsp_quant_lbr,
lsp_unquant_lbr,
/*No pitch quantization*/
pitch_search_3tap,
pitch_unquant_3tap,
&ltp_params_vlbr,
/*Innovation quantization*/
split_cb_search_shape_sign,
split_cb_shape_sign_unquant,
&split_cb_nb_vlbr,
0.7, 0.5, .55,
119
};
/* 8 kbps low bit-rate mode */
static SpeexSubmode nb_submode3 = {
-1,
0,
1,
0,
/*LSP quantization*/
lsp_quant_lbr,
lsp_unquant_lbr,
/*Pitch quantization*/
pitch_search_3tap,
pitch_unquant_3tap,
&ltp_params_lbr,
/*Innovation quantization*/
split_cb_search_shape_sign,
split_cb_shape_sign_unquant,
&split_cb_nb_lbr,
0.7, 0.55, .45,
160
};
/* 11 kbps medium bit-rate mode */
static SpeexSubmode nb_submode4 = {
-1,
0,
1,
0,
/*LSP quantization*/
lsp_quant_lbr,
lsp_unquant_lbr,
/*Pitch quantization*/
pitch_search_3tap,
pitch_unquant_3tap,
&ltp_params_med,
/*Innovation quantization*/
split_cb_search_shape_sign,
split_cb_shape_sign_unquant,
&split_cb_nb_med,
0.7, 0.63, .35,
220
};
/* 15 kbps high bit-rate mode */
static SpeexSubmode nb_submode5 = {
-1,
0,
3,
0,
/*LSP quantization*/
lsp_quant_nb,
lsp_unquant_nb,
/*Pitch quantization*/
pitch_search_3tap,
pitch_unquant_3tap,
&ltp_params_nb,
/*Innovation quantization*/
split_cb_search_shape_sign,
split_cb_shape_sign_unquant,
&split_cb_nb,
0.7, 0.65, .25,
300
};
/* 18.2 high bit-rate mode */
static SpeexSubmode nb_submode6 = {
-1,
0,
3,
0,
/*LSP quantization*/
lsp_quant_nb,
lsp_unquant_nb,
/*Pitch quantization*/
pitch_search_3tap,
pitch_unquant_3tap,
&ltp_params_nb,
/*Innovation quantization*/
split_cb_search_shape_sign,
split_cb_shape_sign_unquant,
&split_cb_sb,
0.68, 0.65, .1,
364
};
/* 24.6 kbps high bit-rate mode */
static SpeexSubmode nb_submode7 = {
-1,
0,
3,
1,
/*LSP quantization*/
lsp_quant_nb,
lsp_unquant_nb,
/*Pitch quantization*/
pitch_search_3tap,
pitch_unquant_3tap,
&ltp_params_nb,
/*Innovation quantization*/
split_cb_search_shape_sign,
split_cb_shape_sign_unquant,
&split_cb_nb,
0.65, 0.65, -1,
492
};
/* Default mode for narrowband */
static SpeexNBMode nb_mode = {
160, /*frameSize*/
40, /*subframeSize*/
10, /*lpcSize*/
640, /*bufSize*/
17, /*pitchStart*/
144, /*pitchEnd*/
0.9, /*gamma1*/
0.6, /*gamma2*/
.01, /*lag_factor*/
1.0001, /*lpc_floor*/
0.0, /*preemph*/
{NULL, &nb_submode1, &nb_submode2, &nb_submode3, &nb_submode4, &nb_submode5, &nb_submode6, &nb_submode7,
&nb_submode8, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
5,
{1, 8, 2, 3, 3, 4, 4, 5, 5, 6, 7}
};
/* Default mode for narrowband */
SpeexMode speex_nb_mode = {
&nb_mode,
nb_mode_query,
"narrowband",
0,
4,
&nb_encoder_init,
&nb_encoder_destroy,
&nb_encode,
&nb_decoder_init,
&nb_decoder_destroy,
&nb_decode,
&nb_encoder_ctl,
&nb_decoder_ctl,
};
/* Wideband part */
static SpeexSubmode wb_submode1 = {
0,
0,
1,
0,
/*LSP quantization*/
lsp_quant_high,
lsp_unquant_high,
/*Pitch quantization*/
NULL,
NULL,
NULL,
/*No innovation quantization*/
NULL,
NULL,
NULL,
.75, .75, -1,
36
};
static SpeexSubmode wb_submode2 = {
0,
0,
1,
0,
/*LSP quantization*/
lsp_quant_high,
lsp_unquant_high,
/*Pitch quantization*/
NULL,
NULL,
NULL,
/*Innovation quantization*/
split_cb_search_shape_sign,
split_cb_shape_sign_unquant,
&split_cb_high_lbr,
.85, .6, -1,
112
};
static SpeexSubmode wb_submode3 = {
0,
0,
1,
0,
/*LSP quantization*/
lsp_quant_high,
lsp_unquant_high,
/*Pitch quantization*/
NULL,
NULL,
NULL,
/*Innovation quantization*/
split_cb_search_shape_sign,
split_cb_shape_sign_unquant,
&split_cb_high,
.75, .7, -1,
192
};
static SpeexSubmode wb_submode4 = {
0,
0,
1,
1,
/*LSP quantization*/
lsp_quant_high,
lsp_unquant_high,
/*Pitch quantization*/
NULL,
NULL,
NULL,
/*Innovation quantization*/
split_cb_search_shape_sign,
split_cb_shape_sign_unquant,
&split_cb_high,
.75, .75, -1,
352
};
/* Split-band wideband CELP mode*/
static SpeexSBMode sb_wb_mode = {
&speex_nb_mode,
160, /*frameSize*/
40, /*subframeSize*/
8, /*lpcSize*/
640, /*bufSize*/
.9, /*gamma1*/
0.6, /*gamma2*/
.002, /*lag_factor*/
1.0001, /*lpc_floor*/
0.0, /*preemph*/
0.9,
{NULL, &wb_submode1, &wb_submode2, &wb_submode3, &wb_submode4, NULL, NULL, NULL},
3,
{1, 8, 2, 3, 4, 5, 5, 6, 6, 7, 7},
{1, 1, 1, 1, 1, 1, 2, 2, 3, 3, 4},
vbr_hb_thresh,
5
};
SpeexMode speex_wb_mode = {
&sb_wb_mode,
wb_mode_query,
"wideband (sub-band CELP)",
1,
4,
&sb_encoder_init,
&sb_encoder_destroy,
&sb_encode,
&sb_decoder_init,
&sb_decoder_destroy,
&sb_decode,
&sb_encoder_ctl,
&sb_decoder_ctl,
};
/* "Ultra-wideband" mode stuff */
/* Split-band "ultra-wideband" (32 kbps) CELP mode*/
static SpeexSBMode sb_uwb_mode = {
&speex_wb_mode,
320, /*frameSize*/
80, /*subframeSize*/
8, /*lpcSize*/
1280, /*bufSize*/
.9, /*gamma1*/
0.6, /*gamma2*/
.002, /*lag_factor*/
1.0001, /*lpc_floor*/
0.0, /*preemph*/
0.7,
{NULL, &wb_submode1, NULL, NULL, NULL, NULL, NULL, NULL},
1,
{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10},
{0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
vbr_uhb_thresh,
2
};
SpeexMode speex_uwb_mode = {
&sb_uwb_mode,
wb_mode_query,
"ultra-wideband (sub-band CELP)",
2,
4,
&sb_encoder_init,
&sb_encoder_destroy,
&sb_encode,
&sb_decoder_init,
&sb_decoder_destroy,
&sb_decode,
&sb_encoder_ctl,
&sb_decoder_ctl,
};
void *speex_encoder_init(SpeexMode *mode)
{
return mode->enc_init(mode);
}
void *speex_decoder_init(SpeexMode *mode)
{
return mode->dec_init(mode);
}
void speex_encoder_destroy(void *state)
{
(*((SpeexMode**)state))->enc_destroy(state);
}
int speex_encode(void *state, float *in, SpeexBits *bits)
{
return (*((SpeexMode**)state))->enc(state, in, bits);
}
void speex_decoder_destroy(void *state)
{
(*((SpeexMode**)state))->dec_destroy(state);
}
int speex_decode(void *state, SpeexBits *bits, float *out)
{
return (*((SpeexMode**)state))->dec(state, bits, out);
}
int speex_encoder_ctl(void *state, int request, void *ptr)
{
return (*((SpeexMode**)state))->enc_ctl(state, request, ptr);
}
int speex_decoder_ctl(void *state, int request, void *ptr)
{
return (*((SpeexMode**)state))->dec_ctl(state, request, ptr);
}
static int nb_mode_query(void *mode, int request, void *ptr)
{
SpeexNBMode *m = (SpeexNBMode*)mode;
switch (request)
{
case SPEEX_MODE_FRAME_SIZE:
*((int*)ptr)=m->frameSize;
break;
case SPEEX_SUBMODE_BITS_PER_FRAME:
if (*((int*)ptr)==0)
*((int*)ptr) = NB_SUBMODE_BITS+1;
else if (m->submodes[*((int*)ptr)]==NULL)
*((int*)ptr) = -1;
else
*((int*)ptr) = m->submodes[*((int*)ptr)]->bits_per_frame;
break;
default:
speex_warning_int("Unknown nb_mode_query request: ", request);
return -1;
}
return 0;
}
static int wb_mode_query(void *mode, int request, void *ptr)
{
SpeexSBMode *m = (SpeexSBMode*)mode;
switch (request)
{
case SPEEX_MODE_FRAME_SIZE:
*((int*)ptr)=2*m->frameSize;
break;
case SPEEX_SUBMODE_BITS_PER_FRAME:
if (*((int*)ptr)==0)
*((int*)ptr) = SB_SUBMODE_BITS+1;
else if (m->submodes[*((int*)ptr)]==NULL)
*((int*)ptr) = -1;
else
*((int*)ptr) = m->submodes[*((int*)ptr)]->bits_per_frame;
break;
default:
speex_warning_int("Unknown wb_mode_query request: ", request);
return -1;
}
return 0;
}
int speex_mode_query(SpeexMode *mode, int request, void *ptr)
{
return mode->query(mode->mode, request, ptr);
}

View File

@ -1,146 +0,0 @@
/* Copyright (C) 2002 Jean-Marc Valin */
/**
@file modes.h
@brief Describes the different modes of the codec
*/
/*
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of the Xiph.org Foundation nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef MODES_H
#define MODES_H
#include "speex.h"
#include "speex_bits.h"
#define NB_SUBMODES 16
#define NB_SUBMODE_BITS 4
#define SB_SUBMODES 8
#define SB_SUBMODE_BITS 3
/** Quantizes LSPs */
typedef void (*lsp_quant_func)(float *, float *, int, SpeexBits *);
/** Decodes quantized LSPs */
typedef void (*lsp_unquant_func)(float *, int, SpeexBits *);
/** Long-term predictor quantization */
typedef int (*ltp_quant_func)(float *, float *, float *, float *,
float *, float *, void *, int, int, float,
int, int, SpeexBits*, char *, float *, float *, int);
/** Long-term un-quantize */
typedef void (*ltp_unquant_func)(float *, int, int, float, void *, int, int *,
float *, SpeexBits*, char*, int, int, float);
/** Innovation quantization function */
typedef void (*innovation_quant_func)(float *, float *, float *, float *, void *, int, int,
float *, float *, SpeexBits *, char *, int);
/** Innovation unquantization function */
typedef void (*innovation_unquant_func)(float *, void *, int, SpeexBits*, char *);
/** Description of a Speex sub-mode (wither narrowband or wideband */
typedef struct SpeexSubmode {
int lbr_pitch; /**< Set to -1 for "normal" modes, otherwise encode pitch using a global pitch and allowing a +- lbr_pitch variation (for low not-rates)*/
int forced_pitch_gain; /**< Use the same (forced) pitch gain for all sub-frames */
int have_subframe_gain; /**< Number of bits to use as sub-frame innovation gain */
int double_codebook; /**< Apply innovation quantization twice for higher quality (and higher bit-rate)*/
/*LSP functions*/
lsp_quant_func lsp_quant; /**< LSP quantization function */
lsp_unquant_func lsp_unquant; /**< LSP unquantization function */
/*Lont-term predictor functions*/
ltp_quant_func ltp_quant; /**< Long-term predictor (pitch) quantizer */
ltp_unquant_func ltp_unquant; /**< Long-term predictor (pitch) un-quantizer */
void *ltp_params; /**< Pitch parameters (options) */
/*Quantization of innovation*/
innovation_quant_func innovation_quant; /**< Innovation quantization */
innovation_unquant_func innovation_unquant; /**< Innovation un-quantization */
void *innovation_params; /**< Innovation quantization parameters*/
/*Synthesis filter enhancement*/
float lpc_enh_k1; /**< Enhancer constant */
float lpc_enh_k2; /**< Enhancer constant */
float comb_gain; /**< Gain of enhancer comb filter */
int bits_per_frame; /**< Number of bits per frame after encoding*/
} SpeexSubmode;
/** Struct defining the encoding/decoding mode*/
typedef struct SpeexNBMode {
int frameSize; /**< Size of frames used for encoding */
int subframeSize; /**< Size of sub-frames used for encoding */
int lpcSize; /**< Order of LPC filter */
int bufSize; /**< Size of signal buffer to use in encoder */
int pitchStart; /**< Smallest pitch value allowed */
int pitchEnd; /**< Largest pitch value allowed */
float gamma1; /**< Perceptual filter parameter #1 */
float gamma2; /**< Perceptual filter parameter #2 */
float lag_factor; /**< Lag-windowing parameter */
float lpc_floor; /**< Noise floor for LPC analysis */
float preemph; /**< Pre-emphasis */
SpeexSubmode *submodes[NB_SUBMODES]; /**< Sub-mode data for the mode */
int defaultSubmode; /**< Default sub-mode to use when encoding */
int quality_map[11]; /**< Mode corresponding to each quality setting */
} SpeexNBMode;
/** Struct defining the encoding/decoding mode for SB-CELP (wideband) */
typedef struct SpeexSBMode {
SpeexMode *nb_mode; /**< Embedded narrowband mode */
int frameSize; /**< Size of frames used for encoding */
int subframeSize; /**< Size of sub-frames used for encoding */
int lpcSize; /**< Order of LPC filter */
int bufSize; /**< Signal buffer size in encoder */
float gamma1; /**< Perceptual filter parameter #1 */
float gamma2; /**< Perceptual filter parameter #1 */
float lag_factor; /**< Lag-windowing parameter */
float lpc_floor; /**< Noise floor for LPC analysis */
float preemph; /**< Pre-emphasis */
float folding_gain;
SpeexSubmode *submodes[SB_SUBMODES]; /**< Sub-mode data for the mode */
int defaultSubmode; /**< Default sub-mode to use when encoding */
int low_quality_map[11]; /**< Mode corresponding to each quality setting */
int quality_map[11]; /**< Mode corresponding to each quality setting */
float (*vbr_thresh)[11];
int nb_modes;
} SpeexSBMode;
#endif

File diff suppressed because it is too large Load Diff

View File

@ -1,202 +0,0 @@
/* Copyright (C) 2002 Jean-Marc Valin */
/**
@file nb_celp.h
@brief Narrowband CELP encoder/decoder
*/
/*
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of the Xiph.org Foundation nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef NB_CELP_H
#define NB_CELP_H
#include "modes.h"
#include "speex_bits.h"
#include "speex_callbacks.h"
#include "vbr.h"
#include "filters.h"
/**Structure representing the full state of the narrowband encoder*/
typedef struct EncState {
SpeexMode *mode; /**< Mode corresponding to the state */
int first; /**< Is this the first frame? */
int frameSize; /**< Size of frames */
int subframeSize; /**< Size of sub-frames */
int nbSubframes; /**< Number of sub-frames */
int windowSize; /**< Analysis (LPC) window length */
int lpcSize; /**< LPC order */
int bufSize; /**< Buffer size */
int min_pitch; /**< Minimum pitch value allowed */
int max_pitch; /**< Maximum pitch value allowed */
int safe_pitch; /**< Don't use too large values for pitch (in case we lose a packet) */
int bounded_pitch; /**< Next frame should not rely on previous frames for pitch */
int ol_pitch; /**< Open-loop pitch */
int ol_voiced; /**< Open-loop voiced/non-voiced decision */
int *pitch;
float gamma1; /**< Perceptual filter: A(z/gamma1) */
float gamma2; /**< Perceptual filter: A(z/gamma2) */
float lag_factor; /**< Lag windowing Gaussian width */
float lpc_floor; /**< Noise floor multiplier for A[0] in LPC analysis*/
float preemph; /**< Pre-emphasis: P(z) = 1 - a*z^-1*/
float pre_mem; /**< 1-element memory for pre-emphasis */
float pre_mem2; /**< 1-element memory for pre-emphasis */
char *stack; /**< Pseudo-stack allocation for temporary memory */
float *inBuf; /**< Input buffer (original signal) */
float *frame; /**< Start of original frame */
float *excBuf; /**< Excitation buffer */
float *exc; /**< Start of excitation frame */
float *exc2Buf; /**< "Pitch enhanced" excitation */
float *exc2; /**< "Pitch enhanced" excitation */
float *swBuf; /**< Weighted signal buffer */
float *sw; /**< Start of weighted signal frame */
float *innov; /**< Innovation for the frame */
float *window; /**< Temporary (Hanning) window */
float *buf2; /**< 2nd temporary buffer */
float *autocorr; /**< auto-correlation */
float *lagWindow; /**< Window applied to auto-correlation */
float *lpc; /**< LPCs for current frame */
float *lsp; /**< LSPs for current frame */
float *qlsp; /**< Quantized LSPs for current frame */
float *old_lsp; /**< LSPs for previous frame */
float *old_qlsp; /**< Quantized LSPs for previous frame */
float *interp_lsp; /**< Interpolated LSPs */
float *interp_qlsp; /**< Interpolated quantized LSPs */
float *interp_lpc; /**< Interpolated LPCs */
float *interp_qlpc; /**< Interpolated quantized LPCs */
float *bw_lpc1; /**< LPCs after bandwidth expansion by gamma1 for perceptual weighting*/
float *bw_lpc2; /**< LPCs after bandwidth expansion by gamma2 for perceptual weighting*/
float *rc; /**< Reflection coefficients */
float *mem_sp; /**< Filter memory for signal synthesis */
float *mem_sw; /**< Filter memory for perceptually-weighted signal */
float *mem_sw_whole; /**< Filter memory for perceptually-weighted signal (whole frame)*/
float *mem_exc; /**< Filter memory for excitation (whole frame) */
float *pi_gain; /**< Gain of LPC filter at theta=pi (fe/2) */
VBRState *vbr; /**< State of the VBR data */
float vbr_quality; /**< Quality setting for VBR encoding */
float relative_quality; /**< Relative quality that will be needed by VBR */
int vbr_enabled; /**< 1 for enabling VBR, 0 otherwise */
int vad_enabled; /**< 1 for enabling VAD, 0 otherwise */
int dtx_enabled; /**< 1 for enabling DTX, 0 otherwise */
int dtx_count; /**< Number of consecutive DTX frames */
int abr_enabled; /**< ABR setting (in bps), 0 if off */
float abr_drift;
float abr_drift2;
float abr_count;
int complexity; /**< Complexity setting (0-10 from least complex to most complex) */
int sampling_rate;
SpeexSubmode **submodes; /**< Sub-mode data */
int submodeID; /**< Activated sub-mode */
int submodeSelect; /**< Mode chosen by the user (may differ from submodeID if VAD is on) */
} EncState;
/**Structure representing the full state of the narrowband decoder*/
typedef struct DecState {
SpeexMode *mode; /**< Mode corresponding to the state */
int first; /**< Is this the first frame? */
int count_lost; /**< Was the last frame lost? */
int frameSize; /**< Size of frames */
int subframeSize; /**< Size of sub-frames */
int nbSubframes; /**< Number of sub-frames */
int windowSize; /**< Analysis (LPC) window length */
int lpcSize; /**< LPC order */
int bufSize; /**< Buffer size */
int min_pitch; /**< Minimum pitch value allowed */
int max_pitch; /**< Maximum pitch value allowed */
int sampling_rate;
float last_ol_gain; /**< Open-loop gain for previous frame */
float gamma1; /**< Perceptual filter: A(z/gamma1) */
float gamma2; /**< Perceptual filter: A(z/gamma2) */
float preemph; /**< Pre-emphasis: P(z) = 1 - a*z^-1*/
float pre_mem; /**< 1-element memory for pre-emphasis */
char *stack; /**< Pseudo-stack allocation for temporary memory */
float *inBuf; /**< Input buffer (original signal) */
float *frame; /**< Start of original frame */
float *excBuf; /**< Excitation buffer */
float *exc; /**< Start of excitation frame */
float *innov; /**< Innovation for the frame */
float *qlsp; /**< Quantized LSPs for current frame */
float *old_qlsp; /**< Quantized LSPs for previous frame */
float *interp_qlsp; /**< Interpolated quantized LSPs */
float *interp_qlpc; /**< Interpolated quantized LPCs */
float *mem_sp; /**< Filter memory for synthesis signal */
float *pi_gain; /**< Gain of LPC filter at theta=pi (fe/2) */
int last_pitch; /**< Pitch of last correctly decoded frame */
float last_pitch_gain; /**< Pitch gain of last correctly decoded frame */
float pitch_gain_buf[3]; /**< Pitch gain of last decoded frames */
int pitch_gain_buf_idx; /**< Tail of the buffer */
SpeexSubmode **submodes; /**< Sub-mode data */
int submodeID; /**< Activated sub-mode */
int lpc_enh_enabled; /**< 1 when LPC enhancer is on, 0 otherwise */
CombFilterMem *comb_mem;
SpeexCallback speex_callbacks[SPEEX_MAX_CALLBACKS];
SpeexCallback user_callback;
/*Vocoder data*/
float voc_m1;
float voc_m2;
float voc_mean;
int voc_offset;
int dtx_enabled;
} DecState;
/** Initializes encoder state*/
void *nb_encoder_init(SpeexMode *m);
/** De-allocates encoder state resources*/
void nb_encoder_destroy(void *state);
/** Encodes one frame*/
int nb_encode(void *state, float *in, SpeexBits *bits);
/** Initializes decoder state*/
void *nb_decoder_init(SpeexMode *m);
/** De-allocates decoder state resources*/
void nb_decoder_destroy(void *state);
/** Decodes one frame*/
int nb_decode(void *state, SpeexBits *bits, float *out);
/** ioctl-like function for controlling a narrowband encoder */
int nb_encoder_ctl(void *state, int request, void *ptr);
/** ioctl-like function for controlling a narrowband decoder */
int nb_decoder_ctl(void *state, int request, void *ptr);
#endif

View File

@ -1,311 +0,0 @@
/* Copyright (C) 2002 Jean-Marc Valin
File: quant_lsp.c
LSP vector quantization
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of the Xiph.org Foundation nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "quant_lsp.h"
#include <math.h>
extern int lsp_nb_vqid[64];
static float quant_weight[MAX_LSP_SIZE];
/* Note: x is modified*/
static int lsp_quant(float *x, signed char *cdbk, int nbVec, int nbDim)
{
int i,j;
float dist, tmp;
float best_dist=0;
int best_id=0;
signed char *ptr=cdbk;
for (i=0;i<nbVec;i++)
{
dist=0;
for (j=0;j<nbDim;j++)
{
tmp=(x[j]-*ptr++);
dist+=tmp*tmp;
}
if (dist<best_dist || i==0)
{
best_dist=dist;
best_id=i;
}
}
for (j=0;j<nbDim;j++)
x[j] -= cdbk[best_id*nbDim+j];
return best_id;
}
/* Note: x is modified*/
static int lsp_weight_quant(float *x, float *weight, signed char *cdbk, int nbVec, int nbDim)
{
int i,j;
float dist, tmp;
float best_dist=0;
int best_id=0;
signed char *ptr=cdbk;
for (i=0;i<nbVec;i++)
{
dist=0;
for (j=0;j<nbDim;j++)
{
tmp=(x[j]-*ptr++);
dist+=weight[j]*tmp*tmp;
}
if (dist<best_dist || i==0)
{
best_dist=dist;
best_id=i;
}
}
for (j=0;j<nbDim;j++)
x[j] -= cdbk[best_id*nbDim+j];
return best_id;
}
void lsp_quant_nb(float *lsp, float *qlsp, int order, SpeexBits *bits)
{
int i;
float tmp1, tmp2;
int id;
for (i=0;i<order;i++)
qlsp[i]=lsp[i];
quant_weight[0] = 1/(qlsp[1]-qlsp[0]);
quant_weight[order-1] = 1/(qlsp[order-1]-qlsp[order-2]);
for (i=1;i<order-1;i++)
{
#if 1
tmp1 = 1/((.15+qlsp[i]-qlsp[i-1])*(.15+qlsp[i]-qlsp[i-1]));
tmp2 = 1/((.15+qlsp[i+1]-qlsp[i])*(.15+qlsp[i+1]-qlsp[i]));
#else
tmp1 = 1/(qlsp[i]-qlsp[i-1]);
tmp2 = 1/(qlsp[i+1]-qlsp[i]);
#endif
quant_weight[i] = tmp1 > tmp2 ? tmp1 : tmp2;
}
for (i=0;i<order;i++)
qlsp[i]-=(.25*i+.25);
for (i=0;i<order;i++)
qlsp[i]*=256;
id = lsp_quant(qlsp, cdbk_nb, NB_CDBK_SIZE, order);
speex_bits_pack(bits, id, 6);
for (i=0;i<order;i++)
qlsp[i]*=2;
id = lsp_weight_quant(qlsp, quant_weight, cdbk_nb_low1, NB_CDBK_SIZE_LOW1, 5);
speex_bits_pack(bits, id, 6);
for (i=0;i<5;i++)
qlsp[i]*=2;
id = lsp_weight_quant(qlsp, quant_weight, cdbk_nb_low2, NB_CDBK_SIZE_LOW2, 5);
speex_bits_pack(bits, id, 6);
id = lsp_weight_quant(qlsp+5, quant_weight+5, cdbk_nb_high1, NB_CDBK_SIZE_HIGH1, 5);
speex_bits_pack(bits, id, 6);
for (i=5;i<10;i++)
qlsp[i]*=2;
id = lsp_weight_quant(qlsp+5, quant_weight+5, cdbk_nb_high2, NB_CDBK_SIZE_HIGH2, 5);
speex_bits_pack(bits, id, 6);
for (i=0;i<order;i++)
qlsp[i]*=.00097656;
for (i=0;i<order;i++)
qlsp[i]=lsp[i]-qlsp[i];
}
void lsp_unquant_nb(float *lsp, int order, SpeexBits *bits)
{
int i, id;
for (i=0;i<order;i++)
lsp[i]=.25*i+.25;
id=speex_bits_unpack_unsigned(bits, 6);
for (i=0;i<10;i++)
lsp[i] += 0.0039062*cdbk_nb[id*10+i];
id=speex_bits_unpack_unsigned(bits, 6);
for (i=0;i<5;i++)
lsp[i] += 0.0019531 * cdbk_nb_low1[id*5+i];
id=speex_bits_unpack_unsigned(bits, 6);
for (i=0;i<5;i++)
lsp[i] += 0.00097656 * cdbk_nb_low2[id*5+i];
id=speex_bits_unpack_unsigned(bits, 6);
for (i=0;i<5;i++)
lsp[i+5] += 0.0019531 * cdbk_nb_high1[id*5+i];
id=speex_bits_unpack_unsigned(bits, 6);
for (i=0;i<5;i++)
lsp[i+5] += 0.00097656 * cdbk_nb_high2[id*5+i];
}
void lsp_quant_lbr(float *lsp, float *qlsp, int order, SpeexBits *bits)
{
int i;
float tmp1, tmp2;
int id;
for (i=0;i<order;i++)
qlsp[i]=lsp[i];
quant_weight[0] = 1/(qlsp[1]-qlsp[0]);
quant_weight[order-1] = 1/(qlsp[order-1]-qlsp[order-2]);
for (i=1;i<order-1;i++)
{
#if 1
tmp1 = 1/((.15+qlsp[i]-qlsp[i-1])*(.15+qlsp[i]-qlsp[i-1]));
tmp2 = 1/((.15+qlsp[i+1]-qlsp[i])*(.15+qlsp[i+1]-qlsp[i]));
#else
tmp1 = 1/(qlsp[i]-qlsp[i-1]);
tmp2 = 1/(qlsp[i+1]-qlsp[i]);
#endif
quant_weight[i] = tmp1 > tmp2 ? tmp1 : tmp2;
}
for (i=0;i<order;i++)
qlsp[i]-=(.25*i+.25);
for (i=0;i<order;i++)
qlsp[i]*=256;
id = lsp_quant(qlsp, cdbk_nb, NB_CDBK_SIZE, order);
speex_bits_pack(bits, id, 6);
for (i=0;i<order;i++)
qlsp[i]*=2;
id = lsp_weight_quant(qlsp, quant_weight, cdbk_nb_low1, NB_CDBK_SIZE_LOW1, 5);
speex_bits_pack(bits, id, 6);
id = lsp_weight_quant(qlsp+5, quant_weight+5, cdbk_nb_high1, NB_CDBK_SIZE_HIGH1, 5);
speex_bits_pack(bits, id, 6);
for (i=0;i<order;i++)
qlsp[i]*=0.0019531;
for (i=0;i<order;i++)
qlsp[i]=lsp[i]-qlsp[i];
}
void lsp_unquant_lbr(float *lsp, int order, SpeexBits *bits)
{
int i, id;
for (i=0;i<order;i++)
lsp[i]=.25*i+.25;
id=speex_bits_unpack_unsigned(bits, 6);
for (i=0;i<10;i++)
lsp[i] += 0.0039062*cdbk_nb[id*10+i];
id=speex_bits_unpack_unsigned(bits, 6);
for (i=0;i<5;i++)
lsp[i] += 0.0019531*cdbk_nb_low1[id*5+i];
id=speex_bits_unpack_unsigned(bits, 6);
for (i=0;i<5;i++)
lsp[i+5] += 0.0019531*cdbk_nb_high1[id*5+i];
}
extern signed char high_lsp_cdbk[];
extern signed char high_lsp_cdbk2[];
void lsp_quant_high(float *lsp, float *qlsp, int order, SpeexBits *bits)
{
int i;
float tmp1, tmp2;
int id;
for (i=0;i<order;i++)
qlsp[i]=lsp[i];
quant_weight[0] = 1/(qlsp[1]-qlsp[0]);
quant_weight[order-1] = 1/(qlsp[order-1]-qlsp[order-2]);
for (i=1;i<order-1;i++)
{
tmp1 = 1/(qlsp[i]-qlsp[i-1]);
tmp2 = 1/(qlsp[i+1]-qlsp[i]);
quant_weight[i] = tmp1 > tmp2 ? tmp1 : tmp2;
}
for (i=0;i<order;i++)
qlsp[i]-=(.3125*i+.75);
for (i=0;i<order;i++)
qlsp[i]*=256;
id = lsp_quant(qlsp, high_lsp_cdbk, 64, order);
speex_bits_pack(bits, id, 6);
for (i=0;i<order;i++)
qlsp[i]*=2;
id = lsp_weight_quant(qlsp, quant_weight, high_lsp_cdbk2, 64, order);
speex_bits_pack(bits, id, 6);
for (i=0;i<order;i++)
qlsp[i]*=0.0019531;
for (i=0;i<order;i++)
qlsp[i]=lsp[i]-qlsp[i];
}
void lsp_unquant_high(float *lsp, int order, SpeexBits *bits)
{
int i, id;
for (i=0;i<order;i++)
lsp[i]=.3125*i+.75;
id=speex_bits_unpack_unsigned(bits, 6);
for (i=0;i<order;i++)
lsp[i] += 0.0039062*high_lsp_cdbk[id*order+i];
id=speex_bits_unpack_unsigned(bits, 6);
for (i=0;i<order;i++)
lsp[i] += 0.0019531*high_lsp_cdbk2[id*order+i];
}

View File

@ -1,71 +0,0 @@
/* Copyright (C) 2002 Jean-Marc Valin
File: quant_lsp.h
LSP vector quantization
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of the Xiph.org Foundation nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef QUANT_LSP_H
#define QUANT_LSP_H
#include "speex_bits.h"
#define MAX_LSP_SIZE 20
#define NB_CDBK_SIZE 64
#define NB_CDBK_SIZE_LOW1 64
#define NB_CDBK_SIZE_LOW2 64
#define NB_CDBK_SIZE_HIGH1 64
#define NB_CDBK_SIZE_HIGH2 64
/*Narrowband codebooks*/
extern signed char cdbk_nb[];
extern signed char cdbk_nb_low1[];
extern signed char cdbk_nb_low2[];
extern signed char cdbk_nb_high1[];
extern signed char cdbk_nb_high2[];
/* Quantizes narrowband LSPs with 30 bits */
void lsp_quant_nb(float *lsp, float *qlsp, int order, SpeexBits *bits);
/* Decodes quantized narrowband LSPs */
void lsp_unquant_nb(float *lsp, int order, SpeexBits *bits);
/* Quantizes low bit-rate narrowband LSPs with 18 bits */
void lsp_quant_lbr(float *lsp, float *qlsp, int order, SpeexBits *bits);
/* Decodes quantized low bit-rate narrowband LSPs */
void lsp_unquant_lbr(float *lsp, int order, SpeexBits *bits);
/* Quantizes high-band LSPs with 12 bits */
void lsp_quant_high(float *lsp, float *qlsp, int order, SpeexBits *bits);
/* Decodes high-band LSPs */
void lsp_unquant_high(float *lsp, int order, SpeexBits *bits);
#endif

File diff suppressed because it is too large Load Diff

View File

@ -1,167 +0,0 @@
/* Copyright (C) 2002 Jean-Marc Valin */
/**
@file sb_celp.h
@brief Sub-band CELP mode used for wideband encoding
*/
/*
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of the Xiph.org Foundation nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef SB_CELP_H
#define SB_CELP_H
#include "modes.h"
#include "speex_bits.h"
#include "nb_celp.h"
/**Structure representing the full state of the sub-band encoder*/
typedef struct SBEncState {
SpeexMode *mode; /**< Pointer to the mode (containing for vtable info) */
void *st_low; /**< State of the low-band (narrowband) encoder */
int full_frame_size; /**< Length of full-band frames*/
int frame_size; /**< Length of high-band frames*/
int subframeSize; /**< Length of high-band sub-frames*/
int nbSubframes; /**< Number of high-band sub-frames*/
int windowSize; /**< Length of high-band LPC window*/
int lpcSize; /**< Order of high-band LPC analysis */
int bufSize; /**< Buffer size */
int first; /**< First frame? */
float lag_factor; /**< Lag-windowing control parameter */
float lpc_floor; /**< Controls LPC analysis noise floor */
float gamma1; /**< Perceptual weighting coef 1 */
float gamma2; /**< Perceptual weighting coef 2 */
char *stack; /**< Temporary allocation stack */
float *x0d, *x1d; /**< QMF filter signals*/
float *high; /**< High-band signal (buffer) */
float *y0, *y1; /**< QMF synthesis signals */
float *h0_mem, *h1_mem, *g0_mem, *g1_mem; /**< QMF memories */
float *excBuf; /**< High-band excitation */
float *exc; /**< High-band excitation (for QMF only)*/
float *buf; /**< Temporary buffer */
float *res; /**< Zero-input response (ringing) */
float *sw; /**< Perceptually weighted signal */
float *target; /**< Weighted target signal (analysis by synthesis) */
float *window; /**< LPC analysis window */
float *lagWindow; /**< Auto-correlation window */
float *autocorr; /**< Auto-correlation (for LPC analysis) */
float *rc; /**< Reflection coefficients (unused) */
float *lpc; /**< LPC coefficients */
float *lsp; /**< LSP coefficients */
float *qlsp; /**< Quantized LSPs */
float *old_lsp; /**< LSPs of previous frame */
float *old_qlsp; /**< Quantized LSPs of previous frame */
float *interp_lsp; /**< Interpolated LSPs for current sub-frame */
float *interp_qlsp; /**< Interpolated quantized LSPs for current sub-frame */
float *interp_lpc; /**< Interpolated LPCs for current sub-frame */
float *interp_qlpc; /**< Interpolated quantized LPCs for current sub-frame */
float *bw_lpc1; /**< Bandwidth-expanded version of LPCs (#1) */
float *bw_lpc2; /**< Bandwidth-expanded version of LPCs (#2) */
float *mem_sp; /**< Synthesis signal memory */
float *mem_sp2;
float *mem_sw; /**< Perceptual signal memory */
float *pi_gain;
float vbr_quality; /**< Quality setting for VBR encoding */
int vbr_enabled; /**< 1 for enabling VBR, 0 otherwise */
int abr_enabled; /**< ABR setting (in bps), 0 if off */
float abr_drift;
float abr_drift2;
float abr_count;
int vad_enabled; /**< 1 for enabling VAD, 0 otherwise */
float relative_quality;
SpeexSubmode **submodes;
int submodeID;
int submodeSelect;
int complexity;
int sampling_rate;
} SBEncState;
/**Structure representing the full state of the sub-band decoder*/
typedef struct SBDecState {
SpeexMode *mode; /**< Pointer to the mode (containing for vtable info) */
void *st_low; /**< State of the low-band (narrowband) encoder */
int full_frame_size;
int frame_size;
int subframeSize;
int nbSubframes;
int lpcSize;
int first;
int sampling_rate;
int lpc_enh_enabled;
char *stack;
float *x0d, *x1d;
float *high;
float *y0, *y1;
float *h0_mem, *h1_mem, *g0_mem, *g1_mem;
float *exc;
float *qlsp;
float *old_qlsp;
float *interp_qlsp;
float *interp_qlpc;
float *mem_sp;
float *pi_gain;
SpeexSubmode **submodes;
int submodeID;
} SBDecState;
/**Initializes encoder state*/
void *sb_encoder_init(SpeexMode *m);
/**De-allocates encoder state resources*/
void sb_encoder_destroy(void *state);
/**Encodes one frame*/
int sb_encode(void *state, float *in, SpeexBits *bits);
/**Initializes decoder state*/
void *sb_decoder_init(SpeexMode *m);
/**De-allocates decoder state resources*/
void sb_decoder_destroy(void *state);
/**Decodes one frame*/
int sb_decode(void *state, SpeexBits *bits, float *out);
int sb_encoder_ctl(void *state, int request, void *ptr);
int sb_decoder_ctl(void *state, int request, void *ptr);
#endif

View File

@ -1,331 +0,0 @@
/* Copyright (C) 2002 Jean-Marc Valin*/
/**
@file speex.h
@brief Describes the different modes of the codec
*/
/*
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of the Xiph.org Foundation nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef SPEEX_H
#define SPEEX_H
#include "speex_bits.h"
#ifdef __cplusplus
extern "C" {
#endif
/* Values allowed for *ctl() requests */
/** Set enhancement on/off (decoder only) */
#define SPEEX_SET_ENH 0
/** Get enhancement state (decoder only) */
#define SPEEX_GET_ENH 1
/*Would be SPEEX_SET_FRAME_SIZE, but it's (currently) invalid*/
/** Obtain frame size used by encoder/decoder */
#define SPEEX_GET_FRAME_SIZE 3
/** Set quality value */
#define SPEEX_SET_QUALITY 4
/** Get current quality setting */
#define SPEEX_GET_QUALITY 5
/** Set sub-mode to use */
#define SPEEX_SET_MODE 6
/** Get current sub-mode in use */
#define SPEEX_GET_MODE 7
/** Set low-band sub-mode to use (wideband only)*/
#define SPEEX_SET_LOW_MODE 8
/** Get current low-band mode in use (wideband only)*/
#define SPEEX_GET_LOW_MODE 9
/** Set high-band sub-mode to use (wideband only)*/
#define SPEEX_SET_HIGH_MODE 10
/** Get current high-band mode in use (wideband only)*/
#define SPEEX_GET_HIGH_MODE 11
/** Set VBR on (1) or off (0) */
#define SPEEX_SET_VBR 12
/** Get VBR status (1 for on, 0 for off) */
#define SPEEX_GET_VBR 13
/** Set quality value for VBR encoding (0-10) */
#define SPEEX_SET_VBR_QUALITY 14
/** Get current quality value for VBR encoding (0-10) */
#define SPEEX_GET_VBR_QUALITY 15
/** Set complexity of the encoder (0-10) */
#define SPEEX_SET_COMPLEXITY 16
/** Get current complexity of the encoder (0-10) */
#define SPEEX_GET_COMPLEXITY 17
/** Set bit-rate used by the encoder (or lower) */
#define SPEEX_SET_BITRATE 18
/** Get current bit-rate used by the encoder or decoder */
#define SPEEX_GET_BITRATE 19
/**Define a handler function for in-band Speex request*/
#define SPEEX_SET_HANDLER 20
/**Define a handler function for in-band user-defined request*/
#define SPEEX_SET_USER_HANDLER 22
/** Set sampling rate used in bit-rate computation */
#define SPEEX_SET_SAMPLING_RATE 24
/** Get sampling rate used in bit-rate computation */
#define SPEEX_GET_SAMPLING_RATE 25
/** Reset the encoder/decoder memories to zero*/
#define SPEEX_RESET_STATE 26
/** Get VBR info (mostly used internally) */
#define SPEEX_GET_RELATIVE_QUALITY 29
/** Set VAD status (1 for on, 0 for off) */
#define SPEEX_SET_VAD 30
/** Get VAD status (1 for on, 0 for off) */
#define SPEEX_GET_VAD 31
/** Set Average Bit-Rate (ABR) to n bits per seconds */
#define SPEEX_SET_ABR 32
/** Get Average Bit-Rate (ABR) setting (in bps) */
#define SPEEX_GET_ABR 33
/** Set DTX status (1 for on, 0 for off) */
#define SPEEX_SET_DTX 34
/** Get DTX status (1 for on, 0 for off) */
#define SPEEX_GET_DTX 35
/* Used internally, not to be used in applications */
/** Used internally*/
#define SPEEX_GET_PI_GAIN 100
/** Used internally*/
#define SPEEX_GET_EXC 101
/** Used internally*/
#define SPEEX_GET_INNOV 102
/** Used internally*/
#define SPEEX_GET_DTX_STATUS 103
/* Preserving compatibility:*/
/** Equivalent to SPEEX_SET_ENH */
#define SPEEX_SET_PF 0
/** Equivalent to SPEEX_GET_ENH */
#define SPEEX_GET_PF 1
/* Values allowed for mode queries */
/** Query the frame size of a mode */
#define SPEEX_MODE_FRAME_SIZE 0
/** Query the size of an encoded frame for a particular sub-mode */
#define SPEEX_SUBMODE_BITS_PER_FRAME 1
/** Number of defined modes in Speex */
#define SPEEX_NB_MODES 3
struct SpeexMode;
/* Prototypes for mode function pointers */
/** Encoder state initialization function */
typedef void *(*encoder_init_func)(struct SpeexMode *mode);
/** Encoder state destruction function */
typedef void (*encoder_destroy_func)(void *st);
/** Main encoding function */
typedef int (*encode_func)(void *state, float *in, SpeexBits *bits);
/** Function for controlling the encoder options */
typedef int (*encoder_ctl_func)(void *state, int request, void *ptr);
/** Decoder state initialization function */
typedef void *(*decoder_init_func)(struct SpeexMode *mode);
/** Decoder state destruction function */
typedef void (*decoder_destroy_func)(void *st);
/** Main decoding function */
typedef int (*decode_func)(void *state, SpeexBits *bits, float *out);
/** Function for controlling the decoder options */
typedef int (*decoder_ctl_func)(void *state, int request, void *ptr);
/** Query function for a mode */
typedef int (*mode_query_func)(void *mode, int request, void *ptr);
/** Struct defining a Speex mode */
typedef struct SpeexMode {
/** Pointer to the low-level mode data */
void *mode;
/** Pointer to the mode query function */
mode_query_func query;
/** The name of the mode (you should not rely on this to identify the mode)*/
char *modeName;
/**ID of the mode*/
int modeID;
/**Version number of the bitstream (incremented every time we break
bitstream compatibility*/
int bitstream_version;
/** Pointer to encoder initialization function */
encoder_init_func enc_init;
/** Pointer to encoder destruction function */
encoder_destroy_func enc_destroy;
/** Pointer to frame encoding function */
encode_func enc;
/** Pointer to decoder initialization function */
decoder_init_func dec_init;
/** Pointer to decoder destruction function */
decoder_destroy_func dec_destroy;
/** Pointer to frame decoding function */
decode_func dec;
/** ioctl-like requests for encoder */
encoder_ctl_func enc_ctl;
/** ioctl-like requests for decoder */
decoder_ctl_func dec_ctl;
} SpeexMode;
/**
* Returns a handle to a newly created Speex encoder state structure. For now,
* the "mode" argument can be &nb_mode or &wb_mode . In the future, more modes
* may be added. Note that for now if you have more than one channels to
* encode, you need one state per channel.
*
* @param mode The mode to use (either speex_nb_mode or speex_wb.mode)
* @return A newly created encoder
*/
void *speex_encoder_init(SpeexMode *mode);
/** Frees all resources associated to an existing Speex encoder state.
* @param state Encoder state to be destroyed */
void speex_encoder_destroy(void *state);
/** Uses an existing encoder state to encode one frame of speech pointed to by
"in". The encoded bit-stream is saved in "bits".
@param state Encoder state
@param in Frame that will be encoded with a +-2^16 range
@param bits Bit-stream where the data will be written
*/
int speex_encode(void *state, float *in, SpeexBits *bits);
/** Used like the ioctl function to control the encoder parameters
*
* @param state Encoder state
* @param request ioctl-type request (one of the SPEEX_* macros)
* @param ptr Data exchanged to-from function
* @return 0 if frame needs not be transmitted (DTX only), 1 otherwise
*/
int speex_encoder_ctl(void *state, int request, void *ptr);
/** Returns a handle to a newly created decoder state structure. For now,
* the mode argument can be &nb_mode or &wb_mode . In the future, more modes
* may be added. Note that for now if you have more than one channels to
* decode, you need one state per channel.
*
* @param mode Speex mode (one of speex_nb_mode or speex_wb_mode)
* @return A newly created decoder state
*/
void *speex_decoder_init(SpeexMode *mode);
/** Frees all resources associated to an existing decoder state.
*
* @param state State to be destroyed
*/
void speex_decoder_destroy(void *state);
/** Uses an existing decoder state to decode one frame of speech from
* bit-stream bits. The output speech is saved written to out.
*
* @param state Decoder state
* @param bits Bit-stream from which to decode the frame (NULL if the packet was lost)
* @param out Where to write the decoded frame
* @return return status (0 for no error, -1 for end of stream, -2 other)
*/
int speex_decode(void *state, SpeexBits *bits, float *out);
/** Used like the ioctl function to control the encoder parameters
*
* @param state Decoder state
* @param request ioctl-type request (one of the SPEEX_* macros)
* @param ptr Data exchanged to-from function
* @return 0 for no error, 1 if a terminator is reached, 2 for another error
*/
int speex_decoder_ctl(void *state, int request, void *ptr);
/** Query function for mode information
*
* @param mode Speex mode
* @param request ioctl-type request (one of the SPEEX_* macros)
* @param ptr Data exchanged to-from function
*/
int speex_mode_query(SpeexMode *mode, int request, void *ptr);
/** Default narrowband mode */
extern SpeexMode speex_nb_mode;
/** Default wideband mode */
extern SpeexMode speex_wb_mode;
/** Default "ultra-wideband" mode */
extern SpeexMode speex_uwb_mode;
/** List of all modes available */
extern SpeexMode *speex_mode_list[SPEEX_NB_MODES];
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,154 +0,0 @@
/* Copyright (C) 2002 Jean-Marc Valin */
/**
@file speex_bits.h
@brief Handles bit packing/unpacking
*/
/*
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of the Xiph.org Foundation nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef BITS_H
#define BITS_H
#ifdef __cplusplus
extern "C" {
#endif
/** Maximum size of the bit-stream (for fixed-size allocation) */
#define MAX_BYTES_PER_FRAME 2000
/** Bit-packing data structure representing (part of) a bit-stream. */
typedef struct SpeexBits {
char *bytes; /**< "raw" data */
int nbBits; /**< Total number of bits stored in the stream*/
int bytePtr; /**< Position of the byte "cursor" */
int bitPtr; /**< Position of the bit "cursor" within the current byte */
int owner; /**< Does the struct "own" the "raw" buffer (member "bytes") */
int overflow;/**< Set to one if we try to read past the valid data */
int buf_size;/**< Allocated size for buffer */
int reserved1; /**< Reserved for future use */
void *reserved2; /**< Reserved for future use */
} SpeexBits;
/** Initializes and allocates resources for a SpeexBits struct */
void speex_bits_init(SpeexBits *bits);
/** Initializes SpeexBits struct using a pre-allocated buffer*/
void speex_bits_init_buffer(SpeexBits *bits, void *buff, int buf_size);
/** Frees all resources associated to a SpeexBits struct. Right now this does nothing since no resources are allocated, but this could change in the future.*/
void speex_bits_destroy(SpeexBits *bits);
/** Resets bits to initial value (just after initialization, erasing content)*/
void speex_bits_reset(SpeexBits *bits);
/** Rewind the bit-stream to the beginning (ready for read) without erasing the content */
void speex_bits_rewind(SpeexBits *bits);
/** Initializes the bit-stream from the data in an area of memory */
void speex_bits_read_from(SpeexBits *bits, char *bytes, int len);
/** Append bytes to the bit-stream
* @param bits Bit-stream to operate on
* @param bytes pointer to the bytes what will be appended
* @param len Number of bytes of append
*/
void speex_bits_read_whole_bytes(SpeexBits *bits, char *bytes, int len);
/** Write the content of a bit-stream to an area of memory */
int speex_bits_write(SpeexBits *bits, char *bytes, int max_len);
/** Like speex_bits_write, but writes only the complete bytes in the stream. Also removes the written bytes from the stream */
int speex_bits_write_whole_bytes(SpeexBits *bits, char *bytes, int max_len);
/** Append bits to the bit-stream
* @param bits Bit-stream to operate on
* @param data Value to append as integer
* @param nbBits number of bits to consider in "data"
*/
void speex_bits_pack(SpeexBits *bits, int data, int nbBits);
/** Interpret the next bits in the bit-stream as a signed integer
*
* @param bits Bit-stream to operate on
* @param nbBits Number of bits to interpret
* @return A signed integer represented by the bits read
*/
int speex_bits_unpack_signed(SpeexBits *bits, int nbBits);
/** Interpret the next bits in the bit-stream as an unsigned integer
*
* @param bits Bit-stream to operate on
* @param nbBits Number of bits to interpret
* @return An unsigned integer represented by the bits read
*/
unsigned int speex_bits_unpack_unsigned(SpeexBits *bits, int nbBits);
/** Returns the number of bytes in the bit-stream, including the last one even if it is not "full"
*
* @param bits Bit-stream to operate on
* @return Number of bytes in the stream
*/
int speex_bits_nbytes(SpeexBits *bits);
/** Same as speex_bits_unpack_unsigned, but without modifying the cursor position */
unsigned int speex_bits_peek_unsigned(SpeexBits *bits, int nbBits);
/** Get the value of the next bit in the stream, without modifying the
* "cursor" position
*
* @param bits Bit-stream to operate on
*/
int speex_bits_peek(SpeexBits *bits);
/** Advances the position of the "bit cursor" in the stream
*
* @param bits Bit-stream to operate on
* @param n Number of bits to advance
*/
void speex_bits_advance(SpeexBits *bits, int n);
/** Returns the number of bits remaining to be read in a stream
*
* @param bits Bit-stream to operate on
*/
int speex_bits_remaining(SpeexBits *bits);
/** Insert a terminator so that the data can be sent as a packet while auto-detecting
* the number of frames in each packet
*
* @param bits Bit-stream to operate on
*/
void speex_bits_insert_terminator(SpeexBits *bits);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,135 +0,0 @@
/* Copyright (C) 2002 Jean-Marc Valin
File speex_callbacks.c
Callback handling and in-band signalling
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of the Xiph.org Foundation nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "speex_callbacks.h"
#include "misc.h"
int speex_inband_handler(SpeexBits *bits, SpeexCallback *callback_list, void *state)
{
int id;
SpeexCallback *callback;
/*speex_bits_advance(bits, 5);*/
id=speex_bits_unpack_unsigned(bits, 4);
callback = callback_list+id;
if (callback->func)
{
return callback->func(bits, state, callback->data);
} else
/*If callback is not registered, skip the right number of bits*/
{
int adv;
if (id<2)
adv = 1;
else if (id<8)
adv = 4;
else if (id<10)
adv = 8;
else if (id<12)
adv = 16;
else if (id<14)
adv = 32;
else
adv = 64;
speex_bits_advance(bits, adv);
}
return 0;
}
int speex_std_mode_request_handler(SpeexBits *bits, void *state, void *data)
{
int m;
m = speex_bits_unpack_unsigned(bits, 4);
speex_encoder_ctl(data, SPEEX_SET_MODE, &m);
return 0;
}
int speex_std_low_mode_request_handler(SpeexBits *bits, void *state, void *data)
{
int m;
m = speex_bits_unpack_unsigned(bits, 4);
speex_encoder_ctl(data, SPEEX_SET_LOW_MODE, &m);
return 0;
}
int speex_std_high_mode_request_handler(SpeexBits *bits, void *state, void *data)
{
int m;
m = speex_bits_unpack_unsigned(bits, 4);
speex_encoder_ctl(data, SPEEX_SET_HIGH_MODE, &m);
return 0;
}
int speex_std_vbr_request_handler(SpeexBits *bits, void *state, void *data)
{
int vbr;
vbr = speex_bits_unpack_unsigned(bits, 1);
speex_encoder_ctl(data, SPEEX_SET_VBR, &vbr);
return 0;
}
int speex_std_enh_request_handler(SpeexBits *bits, void *state, void *data)
{
int enh;
enh = speex_bits_unpack_unsigned(bits, 1);
speex_decoder_ctl(data, SPEEX_SET_ENH, &enh);
return 0;
}
int speex_std_vbr_quality_request_handler(SpeexBits *bits, void *state, void *data)
{
int qual;
qual = speex_bits_unpack_unsigned(bits, 4);
speex_encoder_ctl(data, SPEEX_SET_VBR_QUALITY, &qual);
return 0;
}
int speex_std_char_handler(SpeexBits *bits, void *state, void *data)
{
unsigned char ch;
ch = speex_bits_unpack_unsigned(bits, 8);
_speex_putc(ch, data);
return 0;
}
/* Default handler for user callbacks: skip it */
int speex_default_user_handler(SpeexBits *bits, void *state, void *data)
{
int req_size = speex_bits_unpack_unsigned(bits, 4);
speex_bits_advance(bits, 5+8*req_size);
return 0;
}

View File

@ -1,128 +0,0 @@
/* Copyright (C) 2002 Jean-Marc Valin*/
/**
@file speex_callbacks.h
@brief Describes callback handling and in-band signalling
*/
/*
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of the Xiph.org Foundation nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef SPEEX_CALLBACKS_H
#define SPEEX_CALLBACKS_H
#include "speex.h"
#ifdef __cplusplus
extern "C" {
#endif
/** Total number of callbacks */
#define SPEEX_MAX_CALLBACKS 16
/* Describes all the in-band requests */
/*These are 1-bit requests*/
/** Request for perceptual enhancement (1 for on, 0 for off) */
#define SPEEX_INBAND_ENH_REQUEST 0
/** Reserved */
#define SPEEX_INBAND_RESERVED1 1
/*These are 4-bit requests*/
/** Request for a mode change */
#define SPEEX_INBAND_MODE_REQUEST 2
/** Request for a low mode change */
#define SPEEX_INBAND_LOW_MODE_REQUEST 3
/** Request for a high mode change */
#define SPEEX_INBAND_HIGH_MODE_REQUEST 4
/** Request for VBR (1 on, 0 off) */
#define SPEEX_INBAND_VBR_QUALITY_REQUEST 5
/** Request to be sent acknowledge */
#define SPEEX_INBAND_ACKNOWLEDGE_REQUEST 6
/** Request for VBR (1 for on, 0 for off) */
#define SPEEX_INBAND_VBR_REQUEST 7
/*These are 8-bit requests*/
/** Send a character in-band */
#define SPEEX_INBAND_CHAR 8
/** Intensity stereo information */
#define SPEEX_INBAND_STEREO 9
/*These are 16-bit requests*/
/** Transmit max bit-rate allowed */
#define SPEEX_INBAND_MAX_BITRATE 10
/*These are 32-bit requests*/
/** Acknowledge packet reception */
#define SPEEX_INBAND_ACKNOWLEDGE 12
/** Callback function type */
typedef int (*speex_callback_func)(SpeexBits *bits, void *state, void *data);
/** Callback information */
typedef struct SpeexCallback {
int callback_id; /**< ID associated to the callback */
speex_callback_func func; /**< Callback handler function */
void *data; /**< Data that will be sent to the handler */
void *reserved1; /**< Reserved for future use */
int reserved2; /**< Reserved for future use */
} SpeexCallback;
/** Handle in-band request */
int speex_inband_handler(SpeexBits *bits, SpeexCallback *callback_list, void *state);
/** Standard handler for mode request (change mode, no questions asked) */
int speex_std_mode_request_handler(SpeexBits *bits, void *state, void *data);
/** Standard handler for high mode request (change high mode, no questions asked) */
int speex_std_high_mode_request_handler(SpeexBits *bits, void *state, void *data);
/** Standard handler for in-band characters (write to stderr) */
int speex_std_char_handler(SpeexBits *bits, void *state, void *data);
/** Default handler for user-defined requests: in this case, just ignore */
int speex_default_user_handler(SpeexBits *bits, void *state, void *data);
int speex_std_low_mode_request_handler(SpeexBits *bits, void *state, void *data);
int speex_std_vbr_request_handler(SpeexBits *bits, void *state, void *data);
int speex_std_enh_request_handler(SpeexBits *bits, void *state, void *data);
int speex_std_vbr_quality_request_handler(SpeexBits *bits, void *state, void *data);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,162 +0,0 @@
/* Copyright (C) 2002 Jean-Marc Valin
File: speex_header.c
Describes the Speex header
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of the Xiph.org Foundation nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "speex_header.h"
#include "misc.h"
#include "speex.h"
#ifndef NULL
#define NULL 0
#endif
#define ENDIAN_SWITCH(x) {x=le_int(x);}
/*
typedef struct SpeexHeader {
char speex_string[8];
char speex_version[SPEEX_HEADER_VERSION_LENGTH];
int speex_version_id;
int header_size;
int rate;
int mode;
int mode_bitstream_version;
int nb_channels;
int bitrate;
int frame_size;
int vbr;
int frames_per_packet;
int extra_headers;
int reserved1;
int reserved2;
} SpeexHeader;
*/
void speex_init_header(SpeexHeader *header, int rate, int nb_channels, SpeexMode *m)
{
int i;
char *h="Speex ";
/*
strncpy(header->speex_string, "Speex ", 8);
strncpy(header->speex_version, VERSION, SPEEX_HEADER_VERSION_LENGTH-1);
header->speex_version[SPEEX_HEADER_VERSION_LENGTH-1]=0;
*/
for (i=0;i<8;i++)
header->speex_string[i]=h[i];
for (i=0;i<SPEEX_HEADER_VERSION_LENGTH-1 && VERSION[i];i++)
header->speex_version[i]=VERSION[i];
for (;i<SPEEX_HEADER_VERSION_LENGTH;i++)
header->speex_version[i]=0;
header->speex_version_id = 1;
header->header_size = sizeof(SpeexHeader);
header->rate = rate;
header->mode = m->modeID;
header->mode_bitstream_version = m->bitstream_version;
if (m->modeID<0)
speex_warning("This mode is meant to be used alone");
header->nb_channels = nb_channels;
header->bitrate = -1;
speex_mode_query(m, SPEEX_MODE_FRAME_SIZE, &header->frame_size);
header->vbr = 0;
header->frames_per_packet = 0;
header->extra_headers = 0;
header->reserved1 = 0;
header->reserved2 = 0;
}
char *speex_header_to_packet(SpeexHeader *header, int *size)
{
SpeexHeader *le_header;
le_header = (SpeexHeader*)speex_alloc(sizeof(SpeexHeader));
speex_move(le_header, header, sizeof(SpeexHeader));
/*Make sure everything is now little-endian*/
ENDIAN_SWITCH(le_header->speex_version_id);
ENDIAN_SWITCH(le_header->header_size);
ENDIAN_SWITCH(le_header->rate);
ENDIAN_SWITCH(le_header->mode);
ENDIAN_SWITCH(le_header->mode_bitstream_version);
ENDIAN_SWITCH(le_header->nb_channels);
ENDIAN_SWITCH(le_header->bitrate);
ENDIAN_SWITCH(le_header->frame_size);
ENDIAN_SWITCH(le_header->vbr);
ENDIAN_SWITCH(le_header->frames_per_packet);
ENDIAN_SWITCH(le_header->extra_headers);
*size = sizeof(SpeexHeader);
return (char *)le_header;
}
SpeexHeader *speex_packet_to_header(char *packet, int size)
{
int i;
SpeexHeader *le_header;
char *h = "Speex ";
for (i=0;i<8;i++)
if (packet[i]!=h[i])
{
speex_warning ("This doesn't look like a Speex file");
return NULL;
}
/*FIXME: Do we allow larger headers?*/
if (size < sizeof(SpeexHeader))
{
speex_warning("Speex header too small");
return NULL;
}
le_header = (SpeexHeader*)speex_alloc(sizeof(SpeexHeader));
speex_move(le_header, packet, sizeof(SpeexHeader));
/*Make sure everything is converted correctly from little-endian*/
ENDIAN_SWITCH(le_header->speex_version_id);
ENDIAN_SWITCH(le_header->header_size);
ENDIAN_SWITCH(le_header->rate);
ENDIAN_SWITCH(le_header->mode);
ENDIAN_SWITCH(le_header->mode_bitstream_version);
ENDIAN_SWITCH(le_header->nb_channels);
ENDIAN_SWITCH(le_header->bitrate);
ENDIAN_SWITCH(le_header->frame_size);
ENDIAN_SWITCH(le_header->vbr);
ENDIAN_SWITCH(le_header->frames_per_packet);
ENDIAN_SWITCH(le_header->extra_headers);
return le_header;
}

View File

@ -1,82 +0,0 @@
/* Copyright (C) 2002 Jean-Marc Valin */
/**
@file speex_header.h
@brief Describes the Speex header
*/
/*
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of the Xiph.org Foundation nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef SPEEX_HEADER_H
#define SPEEX_HEADER_H
#ifdef __cplusplus
extern "C" {
#endif
struct SpeexMode;
/** Maximum number of characters for encoding the Speex version number in the header */
#define SPEEX_HEADER_VERSION_LENGTH 20
/** Speex header info for file-based formats */
typedef struct SpeexHeader {
char speex_string[8]; /**< Identifies a Speex bit-stream, always set to "Speex " */
char speex_version[SPEEX_HEADER_VERSION_LENGTH]; /**< Speex version */
int speex_version_id; /**< Version for Speex (for checking compatibility) */
int header_size; /**< Total size of the header ( sizeof(SpeexHeader) ) */
int rate; /**< Sampling rate used */
int mode; /**< Mode used (0 for narrowband, 1 for wideband) */
int mode_bitstream_version; /**< Version ID of the bit-stream */
int nb_channels; /**< Number of channels encoded */
int bitrate; /**< Bit-rate used */
int frame_size; /**< Size of frames */
int vbr; /**< 1 for a VBR encoding, 0 otherwise */
int frames_per_packet; /**< Number of frames stored per Ogg packet */
int extra_headers; /**< Number of additional headers after the comments */
int reserved1; /**< Reserved for future use, must be zero */
int reserved2; /**< Reserved for future use, must be zero */
} SpeexHeader;
/** Initializes a SpeexHeader using basic information */
void speex_init_header(SpeexHeader *header, int rate, int nb_channels, struct SpeexMode *m);
/** Creates the header packet from the header itself (mostly involves endianness conversion) */
char *speex_header_to_packet(SpeexHeader *header, int *size);
/** Creates a SpeexHeader from a packet */
SpeexHeader *speex_packet_to_header(char *packet, int size);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,62 +0,0 @@
/* Copyright (C) 2002 Jean-Marc Valin*/
/**
@file speex_stereo.h
@brief Describes the handling for intensity stereo
*/
/*
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of the Xiph.org Foundation nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef STEREO_H
#define STEREO_H
#include "speex_bits.h"
/** State used for decoding (intensity) stereo information */
typedef struct SpeexStereoState {
float balance; /**< Left/right balance info */
float e_ratio; /**< Ratio of energies: E(left+right)/[E(left)+E(right)] */
float smooth_left; /**< Smoothed left channel gain */
float smooth_right; /**< Smoothed right channel gain */
float reserved1; /**< Reserved for future use */
float reserved2; /**< Reserved for future use */
} SpeexStereoState;
/** Initialization value for a stereo state */
#define SPEEX_STEREO_STATE_INIT {1,.5,1,1}
/** Transforms a stereo frame into a mono frame and stores intensity stereo info in 'bits' */
void speex_encode_stereo(float *data, int frame_size, SpeexBits *bits);
/** Transforms a mono frame into a stereo frame using intensity stereo info */
void speex_decode_stereo(float *data, int frame_size, SpeexStereoState *stereo);
/** Callback handler for intensity stereo info */
int speex_std_stereo_request_handler(SpeexBits *bits, void *state, void *data);
#endif

View File

@ -1,62 +0,0 @@
/* Copyright (C) 2002 Jean-Marc Valin
File: stack_alloc.h
Temporary memory allocation on stack
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of the Xiph.org Foundation nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef STACK_ALLOC_H
#define STACK_ALLOC_H
#if 0
/*Aligns the stack to a 'size' boundary */
#define ALIGN(stack, size) (stack=(void*)((((int)stack)+((size)-1)) & (-(size))))
/*Aligns the stack to a 'size' boundary minus k */
#define ALIGN_1(stack, size, k) (stack=(void*)(((((int)stack)+((size)-1+(k))) & (-(size)))-(k)))
/* Allocates 'size' elements of type 'type' on the stack */
#define PUSH(stack, size, type) (ALIGN(stack,sizeof(type)),stack=(void*)(((int)stack)+((size)*sizeof(type))),(type*)(((int)stack)-((size)*sizeof(type))))
#else
/*Aligns the stack to a 'size' boundary */
#define ALIGN(stack, size) ((stack) += ((size) - (int)(stack)) & ((size) - 1))
/* Allocates 'size' elements of type 'type' on the stack */
#define PUSH(stack, size, type) (ALIGN((stack),sizeof(type)),(stack)+=((size)*sizeof(type)),(type*)((stack)-((size)*sizeof(type))))
/* Allocates a struct stack */
#define PUSHS(stack, type) (ALIGN((stack),sizeof(long)),(stack)+=(sizeof(type)),(type*)((stack)-(sizeof(type))))
#endif
#endif

View File

@ -1,122 +0,0 @@
/* Copyright (C) 2002 Jean-Marc Valin
File: stereo.c
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of the Xiph.org Foundation nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "speex_stereo.h"
#include "speex_callbacks.h"
#include "vq.h"
#include <math.h>
/*float e_ratio_quant[4] = {1, 1.26, 1.587, 2};*/
static float e_ratio_quant[4] = {.25, .315, .397, .5};
void speex_encode_stereo(float *data, int frame_size, SpeexBits *bits)
{
int i, tmp;
float e_left=0, e_right=0, e_tot=0;
float balance, e_ratio;
for (i=0;i<frame_size;i++)
{
e_left += data[2*i]*data[2*i];
e_right += data[2*i+1]*data[2*i+1];
data[i] = .5*(data[2*i]+data[2*i+1]);
e_tot += data[i]*data[i];
}
balance=(e_left+1)/(e_right+1);
e_ratio = e_tot/(1+e_left+e_right);
/*Quantization*/
speex_bits_pack(bits, 14, 5);
speex_bits_pack(bits, SPEEX_INBAND_STEREO, 4);
balance=4*log(balance);
/*Pack sign*/
if (balance>0)
speex_bits_pack(bits, 0, 1);
else
speex_bits_pack(bits, 1, 1);
balance=floor(.5+fabs(balance));
if (balance>30)
balance=31;
speex_bits_pack(bits, (int)balance, 5);
/*Quantize energy ratio*/
tmp=vq_index(&e_ratio, e_ratio_quant, 1, 4);
speex_bits_pack(bits, tmp, 2);
}
void speex_decode_stereo(float *data, int frame_size, SpeexStereoState *stereo)
{
float balance, e_ratio;
int i;
float e_tot=0, e_left, e_right, e_sum;
balance=stereo->balance;
e_ratio=stereo->e_ratio;
for (i=frame_size-1;i>=0;i--)
{
e_tot += data[i]*data[i];
}
e_sum=e_tot/e_ratio;
e_left = e_sum*balance / (1+balance);
e_right = e_sum-e_left;
e_left = sqrt(e_left/(e_tot+.01));
e_right = sqrt(e_right/(e_tot+.01));
for (i=frame_size-1;i>=0;i--)
{
float ftmp=data[i];
stereo->smooth_left = .98*stereo->smooth_left + .02*e_left;
stereo->smooth_right = .98*stereo->smooth_right + .02*e_right;
data[2*i] = stereo->smooth_left*ftmp;
data[2*i+1] = stereo->smooth_right*ftmp;
}
}
int speex_std_stereo_request_handler(SpeexBits *bits, void *state, void *data)
{
SpeexStereoState *stereo;
float sign=1;
int tmp;
stereo = (SpeexStereoState*)data;
if (speex_bits_unpack_unsigned(bits, 1))
sign=-1;
tmp = speex_bits_unpack_unsigned(bits, 5);
stereo->balance = exp(sign*.25*tmp);
tmp = speex_bits_unpack_unsigned(bits, 2);
stereo->e_ratio = e_ratio_quant[tmp];
return 0;
}

View File

@ -1,127 +0,0 @@
#include "speex.h"
#include <stdio.h>
#include <stdlib.h>
#include "speex_callbacks.h"
#define FRAME_SIZE 160
#include <math.h>
int main(int argc, char **argv)
{
char *inFile, *outFile, *bitsFile;
FILE *fin, *fout, *fbits=NULL;
short in[FRAME_SIZE];
float input[FRAME_SIZE], bak[FRAME_SIZE], bak2[FRAME_SIZE];
char cbits[200];
int nbBits;
int i;
void *st;
void *dec;
SpeexBits bits;
int tmp;
int bitCount=0;
SpeexCallback callback;
for (i=0;i<FRAME_SIZE;i++)
bak2[i]=0;
st = speex_encoder_init(&speex_nb_mode);
dec = speex_decoder_init(&speex_nb_mode);
callback.callback_id = SPEEX_INBAND_CHAR;
callback.func = speex_std_char_handler;
callback.data = stderr;
speex_decoder_ctl(dec, SPEEX_SET_HANDLER, &callback);
callback.callback_id = SPEEX_INBAND_MODE_REQUEST;
callback.func = speex_std_mode_request_handler;
callback.data = st;
speex_decoder_ctl(dec, SPEEX_SET_HANDLER, &callback);
tmp=0;
speex_decoder_ctl(dec, SPEEX_SET_ENH, &tmp);
tmp=0;
speex_encoder_ctl(st, SPEEX_SET_VBR, &tmp);
tmp=8;
speex_encoder_ctl(st, SPEEX_SET_QUALITY, &tmp);
tmp=1;
speex_encoder_ctl(st, SPEEX_SET_COMPLEXITY, &tmp);
speex_mode_query(&speex_nb_mode, SPEEX_MODE_FRAME_SIZE, &tmp);
fprintf (stderr, "frame size: %d\n", tmp);
if (argc != 4 && argc != 3)
{
fprintf (stderr, "Usage: encode [in file] [out file] [bits file]\nargc = %d", argc);
exit(1);
}
inFile = argv[1];
fin = fopen(inFile, "r");
outFile = argv[2];
fout = fopen(outFile, "w");
if (argc==4)
{
bitsFile = argv[3];
fbits = fopen(bitsFile, "w");
}
speex_bits_init(&bits);
while (!feof(fin))
{
fread(in, sizeof(short), FRAME_SIZE, fin);
if (feof(fin))
break;
for (i=0;i<FRAME_SIZE;i++)
bak[i]=input[i]=in[i];
speex_bits_reset(&bits);
/*
speex_bits_pack(&bits, 14, 5);
speex_bits_pack(&bits, SPEEX_INBAND_CHAR, 4);
speex_bits_pack(&bits, 'A', 8);
speex_bits_pack(&bits, 14, 5);
speex_bits_pack(&bits, SPEEX_INBAND_MODE_REQUEST, 4);
speex_bits_pack(&bits, 7, 4);
speex_bits_pack(&bits, 15, 5);
speex_bits_pack(&bits, 2, 4);
speex_bits_pack(&bits, 0, 16);
*/
speex_encode(st, input, &bits);
nbBits = speex_bits_write(&bits, cbits, 200);
bitCount+=bits.nbBits;
printf ("Encoding frame in %d bits\n", nbBits*8);
if (argc==4)
fwrite(cbits, 1, nbBits, fbits);
{
float enoise=0, esig=0, snr;
for (i=0;i<FRAME_SIZE;i++)
{
enoise+=(bak2[i]-input[i])*(bak2[i]-input[i]);
esig += bak2[i]*bak2[i];
}
snr = 10*log10((esig+1)/(enoise+1));
printf ("real SNR = %f\n", snr);
}
speex_bits_rewind(&bits);
speex_decode(dec, &bits, input);
/* Save the bits here */
for (i=0;i<FRAME_SIZE;i++)
{
if (input[i]>32000)
input[i]=32000;
else if (input[i]<-32000)
input[i]=-32000;
}
speex_bits_reset(&bits);
for (i=0;i<FRAME_SIZE;i++)
in[i]=(short)input[i];
for (i=0;i<FRAME_SIZE;i++)
bak2[i]=bak[i];
fwrite(in, sizeof(short), FRAME_SIZE, fout);
}
fprintf (stderr, "Total encoded size: %d bits\n", bitCount);
speex_encoder_destroy(st);
speex_decoder_destroy(dec);
return 1;
}

View File

@ -1,106 +0,0 @@
#include "speex.h"
#include <stdio.h>
#include <stdlib.h>
#define FRAME_SIZE 640
#include <math.h>
int main(int argc, char **argv)
{
char *inFile, *outFile, *bitsFile;
FILE *fin, *fout, *fbits=NULL;
short in[FRAME_SIZE];
float input[FRAME_SIZE], bak[FRAME_SIZE], bak2[FRAME_SIZE];
char cbits[200];
int nbBits;
int i;
void *st;
void *dec;
SpeexBits bits;
int tmp;
int bitCount=0;
for (i=0;i<FRAME_SIZE;i++)
bak2[i]=0;
st = speex_encoder_init(&speex_uwb_mode);
dec = speex_decoder_init(&speex_uwb_mode);
tmp=0;
/*speex_decoder_ctl(dec, SPEEX_SET_ENH, &tmp);
tmp=0;
speex_encoder_ctl(st, SPEEX_SET_VBR, &tmp);
tmp=10;
speex_encoder_ctl(st, SPEEX_SET_QUALITY, &tmp);
tmp=3;
speex_encoder_ctl(st, SPEEX_SET_COMPLEXITY, &tmp);
tmp=3;
speex_encoder_ctl(st, SPEEX_SET_HIGH_MODE, &tmp);
tmp=6;
speex_encoder_ctl(st, SPEEX_SET_LOW_MODE, &tmp);
*/
if (argc != 4 && argc != 3)
{
fprintf (stderr, "Usage: encode [in file] [out file] [bits file]\nargc = %d", argc);
exit(1);
}
inFile = argv[1];
fin = fopen(inFile, "r");
outFile = argv[2];
fout = fopen(outFile, "w");
if (argc==4)
{
bitsFile = argv[3];
fbits = fopen(bitsFile, "w");
}
speex_bits_init(&bits);
while (!feof(fin))
{
fread(in, sizeof(short), FRAME_SIZE, fin);
if (feof(fin))
break;
for (i=0;i<FRAME_SIZE;i++)
bak[i]=input[i]=in[i];
speex_bits_reset(&bits);
speex_encode(st, input, &bits);
nbBits = speex_bits_write(&bits, cbits, 200);
bitCount+=bits.nbBits;
printf ("Encoding frame in %d bits\n", nbBits*8);
if (argc==4)
fwrite(cbits, 1, nbBits, fbits);
{
float enoise=0, esig=0, snr;
for (i=0;i<FRAME_SIZE;i++)
{
enoise+=(bak2[i]-input[i])*(bak2[i]-input[i]);
esig += bak2[i]*bak2[i];
}
snr = 10*log10((esig+1)/(enoise+1));
printf ("real SNR = %f\n", snr);
}
speex_bits_rewind(&bits);
speex_decode(dec, &bits, input);
/* Save the bits here */
for (i=0;i<FRAME_SIZE;i++)
{
if (input[i]>32000)
input[i]=32000;
else if (input[i]<-32000)
input[i]=-32000;
}
speex_bits_reset(&bits);
for (i=0;i<FRAME_SIZE;i++)
in[i]=(short)input[i];
for (i=0;i<FRAME_SIZE;i++)
bak2[i]=bak[i];
fwrite(in, sizeof(short), FRAME_SIZE, fout);
}
fprintf (stderr, "Total encoded size: %d bits\n", bitCount);
speex_encoder_destroy(st);
speex_decoder_destroy(dec);
speex_bits_destroy(&bits);
fclose(fin);
fclose(fout);
return 1;
}

View File

@ -1,106 +0,0 @@
#include "speex.h"
#include <stdio.h>
#include <stdlib.h>
#define FRAME_SIZE 320
#include <math.h>
int main(int argc, char **argv)
{
char *inFile, *outFile, *bitsFile;
FILE *fin, *fout, *fbits=NULL;
short in[FRAME_SIZE];
float input[FRAME_SIZE], bak[FRAME_SIZE], bak2[FRAME_SIZE];
char cbits[200];
int nbBits;
int i;
void *st;
void *dec;
SpeexBits bits;
int tmp;
int bitCount=0;
for (i=0;i<FRAME_SIZE;i++)
bak2[i]=0;
st = speex_encoder_init(&speex_wb_mode);
dec = speex_decoder_init(&speex_wb_mode);
tmp=0;
speex_decoder_ctl(dec, SPEEX_SET_ENH, &tmp);
tmp=0;
speex_encoder_ctl(st, SPEEX_SET_VBR, &tmp);
tmp=10;
speex_encoder_ctl(st, SPEEX_SET_QUALITY, &tmp);
tmp=3;
speex_encoder_ctl(st, SPEEX_SET_COMPLEXITY, &tmp);
tmp=3;
speex_encoder_ctl(st, SPEEX_SET_HIGH_MODE, &tmp);
tmp=6;
speex_encoder_ctl(st, SPEEX_SET_LOW_MODE, &tmp);
if (argc != 4 && argc != 3)
{
fprintf (stderr, "Usage: encode [in file] [out file] [bits file]\nargc = %d", argc);
exit(1);
}
inFile = argv[1];
fin = fopen(inFile, "r");
outFile = argv[2];
fout = fopen(outFile, "w");
if (argc==4)
{
bitsFile = argv[3];
fbits = fopen(bitsFile, "w");
}
speex_bits_init(&bits);
while (!feof(fin))
{
fread(in, sizeof(short), FRAME_SIZE, fin);
if (feof(fin))
break;
for (i=0;i<FRAME_SIZE;i++)
bak[i]=input[i]=in[i];
speex_bits_reset(&bits);
speex_encode(st, input, &bits);
nbBits = speex_bits_write(&bits, cbits, 200);
bitCount+=bits.nbBits;
printf ("Encoding frame in %d bits\n", nbBits*8);
if (argc==4)
fwrite(cbits, 1, nbBits, fbits);
{
float enoise=0, esig=0, snr;
for (i=0;i<FRAME_SIZE;i++)
{
enoise+=(bak2[i]-input[i])*(bak2[i]-input[i]);
esig += bak2[i]*bak2[i];
}
snr = 10*log10((esig+1)/(enoise+1));
printf ("real SNR = %f\n", snr);
}
speex_bits_rewind(&bits);
speex_decode(dec, &bits, input);
/* Save the bits here */
for (i=0;i<FRAME_SIZE;i++)
{
if (input[i]>32000)
input[i]=32000;
else if (input[i]<-32000)
input[i]=-32000;
}
speex_bits_reset(&bits);
for (i=0;i<FRAME_SIZE;i++)
in[i]=(short)input[i];
for (i=0;i<FRAME_SIZE;i++)
bak2[i]=bak[i];
fwrite(in, sizeof(short), FRAME_SIZE, fout);
}
fprintf (stderr, "Total encoded size: %d bits\n", bitCount);
speex_encoder_destroy(st);
speex_decoder_destroy(dec);
speex_bits_destroy(&bits);
fclose(fin);
fclose(fout);
return 1;
}

View File

@ -1,268 +0,0 @@
/* Copyright (C) 2002 Jean-Marc Valin
File: vbr.c
VBR-related routines
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of the Xiph.org Foundation nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "vbr.h"
#include <math.h>
#define sqr(x) ((x)*(x))
#define MIN_ENERGY 6000
#define NOISE_POW .3
float vbr_nb_thresh[9][11]={
{-1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0}, /* CNG */
{ 3.5, 2.5, 2.0, 1.2, 0.5, 0.0, -0.5, -0.7, -0.8, -0.9, -1.0}, /* 2 kbps */
{10.0, 6.5, 5.2, 4.5, 3.9, 3.5, 3.0, 2.5, 2.3, 1.8, 1.0}, /* 6 kbps */
{11.0, 8.8, 7.5, 6.5, 5.0, 3.9, 3.9, 3.9, 3.5, 3.0, 1.0}, /* 8 kbps */
{11.0, 11.0, 9.9, 9.0, 8.0, 7.0, 6.5, 6.0, 5.0, 4.0, 2.0}, /* 11 kbps */
{11.0, 11.0, 11.0, 11.0, 9.5, 9.0, 8.0, 7.0, 6.5, 5.0, 3.0}, /* 15 kbps */
{11.0, 11.0, 11.0, 11.0, 11.0, 11.0, 9.5, 8.5, 8.0, 6.5, 4.0}, /* 18 kbps */
{11.0, 11.0, 11.0, 11.0, 11.0, 11.0, 11.0, 11.0, 9.8, 7.5, 5.5}, /* 24 kbps */
{ 8.0, 5.0, 3.7, 3.0, 2.5, 2.0, 1.8, 1.5, 1.0, 0.0, 0.0} /* 4 kbps */
};
float vbr_hb_thresh[5][11]={
{-1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0}, /* silence */
{-1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0}, /* 2 kbps */
{11.0, 11.0, 9.5, 8.5, 7.5, 6.0, 5.0, 3.9, 3.0, 2.0, 1.0}, /* 6 kbps */
{11.0, 11.0, 11.0, 11.0, 11.0, 9.5, 8.7, 7.8, 7.0, 6.5, 4.0}, /* 10 kbps */
{11.0, 11.0, 11.0, 11.0, 11.0, 11.0, 11.0, 11.0, 9.8, 7.5, 5.5} /* 18 kbps */
};
float vbr_uhb_thresh[2][11]={
{-1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0}, /* silence */
{ 3.9, 2.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -1.0} /* 2 kbps */
};
void vbr_init(VBRState *vbr)
{
int i;
vbr->average_energy=0;
vbr->last_energy=1;
vbr->accum_sum=0;
vbr->energy_alpha=.1;
vbr->soft_pitch=0;
vbr->last_pitch_coef=0;
vbr->last_quality=0;
vbr->noise_accum = .05*pow(MIN_ENERGY, NOISE_POW);
vbr->noise_accum_count=.05;
vbr->noise_level=vbr->noise_accum/vbr->noise_accum_count;
vbr->consec_noise=0;
for (i=0;i<VBR_MEMORY_SIZE;i++)
vbr->last_log_energy[i] = log(MIN_ENERGY);
}
/*
This function should analyse the signal and decide how critical the
coding error will be perceptually. The following factors should be
taken into account:
-Attacks (positive energy derivative) should be coded with more bits
-Stationary voiced segments should receive more bits
-Segments with (very) low absolute energy should receive less bits (maybe
only shaped noise?)
-DTX for near-zero energy?
-Stationary fricative segments should have less bits
-Temporal masking: when energy slope is decreasing, decrease the bit-rate
-Decrease bit-rate for males (low pitch)?
-(wideband only) less bits in the high-band when signal is very
non-stationary (harder to notice high-frequency noise)???
*/
float vbr_analysis(VBRState *vbr, float *sig, int len, int pitch, float pitch_coef)
{
int i;
float ener=0, ener1=0, ener2=0;
float qual=7;
int va;
float log_energy;
float non_st=0;
float voicing;
float pow_ener;
for (i=0;i<len>>1;i++)
ener1 += sig[i]*sig[i];
for (i=len>>1;i<len;i++)
ener2 += sig[i]*sig[i];
ener=ener1+ener2;
log_energy = log(ener+MIN_ENERGY);
for (i=0;i<VBR_MEMORY_SIZE;i++)
non_st += sqr(log_energy-vbr->last_log_energy[i]);
non_st = non_st/(30*VBR_MEMORY_SIZE);
if (non_st>1)
non_st=1;
voicing = 3*(pitch_coef-.4)*fabs(pitch_coef-.4);
vbr->average_energy = (1-vbr->energy_alpha)*vbr->average_energy + vbr->energy_alpha*ener;
vbr->noise_level=vbr->noise_accum/vbr->noise_accum_count;
pow_ener = pow(ener,NOISE_POW);
if (vbr->noise_accum_count<.06 && ener>MIN_ENERGY)
vbr->noise_accum = .05*pow_ener;
if ((voicing<.3 && non_st < .2 && pow_ener < 1.2*vbr->noise_level)
|| (voicing<.3 && non_st < .05 && pow_ener < 1.5*vbr->noise_level)
|| (voicing<.4 && non_st < .05 && pow_ener < 1.2*vbr->noise_level)
|| (voicing<0 && non_st < .05))
{
float tmp;
va = 0;
vbr->consec_noise++;
if (pow_ener > 3*vbr->noise_level)
tmp = 3*vbr->noise_level;
else
tmp = pow_ener;
if (vbr->consec_noise>=4)
{
vbr->noise_accum = .95*vbr->noise_accum + .05*tmp;
vbr->noise_accum_count = .95*vbr->noise_accum_count + .05;
}
} else {
va = 1;
vbr->consec_noise=0;
}
if (pow_ener < vbr->noise_level && ener>MIN_ENERGY)
{
vbr->noise_accum = .95*vbr->noise_accum + .05*pow_ener;
vbr->noise_accum_count = .95*vbr->noise_accum_count + .05;
}
/* Checking for very low absolute energy */
if (ener < 30000)
{
qual -= .7;
if (ener < 10000)
qual-=.7;
if (ener < 3000)
qual-=.7;
} else {
float short_diff, long_diff;
short_diff = log((ener+1)/(1+vbr->last_energy));
long_diff = log((ener+1)/(1+vbr->average_energy));
/*fprintf (stderr, "%f %f\n", short_diff, long_diff);*/
if (long_diff<-5)
long_diff=-5;
if (long_diff>2)
long_diff=2;
if (long_diff>0)
qual += .6*long_diff;
if (long_diff<0)
qual += .5*long_diff;
if (short_diff>0)
{
if (short_diff>5)
short_diff=5;
qual += .5*short_diff;
}
/* Checking for energy increases */
if (ener2 > 1.6*ener1)
qual += .5;
}
vbr->last_energy = ener;
vbr->soft_pitch = .6*vbr->soft_pitch + .4*pitch_coef;
qual += 2.2*((pitch_coef-.4) + (vbr->soft_pitch-.4));
if (qual < vbr->last_quality)
qual = .5*qual + .5*vbr->last_quality;
if (qual<4)
qual=4;
if (qual>10)
qual=10;
/*
if (vbr->consec_noise>=2)
qual-=1.3;
if (vbr->consec_noise>=5)
qual-=1.3;
if (vbr->consec_noise>=12)
qual-=1.3;
*/
if (vbr->consec_noise>=3)
qual=4;
if (vbr->consec_noise)
qual -= 1.0 * (log(3.0 + vbr->consec_noise)-log(3));
if (qual<0)
qual=0;
if (ener<60000)
{
if (vbr->consec_noise>2)
qual-=0.5*(log(3.0 + vbr->consec_noise)-log(3));
if (ener<10000&&vbr->consec_noise>2)
qual-=0.5*(log(3.0 + vbr->consec_noise)-log(3));
if (qual<0)
qual=0;
qual += .3*log(ener/60000.0);
}
if (qual<-1)
qual=-1;
/*printf ("%f %f %f %f %d\n", qual, voicing, non_st, pow_ener/(.01+vbr->noise_level), va);*/
vbr->last_pitch_coef = pitch_coef;
vbr->last_quality = qual;
for (i=VBR_MEMORY_SIZE-1;i>0;i--)
vbr->last_log_energy[i] = vbr->last_log_energy[i-1];
vbr->last_log_energy[0] = log_energy;
/*printf ("VBR: %f %f %f %d %f\n", (float)(log_energy-log(vbr->average_energy+MIN_ENERGY)), non_st, voicing, va, vbr->noise_level);*/
return qual;
}
void vbr_destroy(VBRState *vbr)
{
}

View File

@ -1,66 +0,0 @@
/* Copyright (C) 2002 Jean-Marc Valin
File: vbr.h
VBR-related routines
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of the Xiph.org Foundation nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef VBR_H
#define VBR_H
#define VBR_MEMORY_SIZE 5
extern float vbr_nb_thresh[9][11];
extern float vbr_hb_thresh[5][11];
extern float vbr_uhb_thresh[2][11];
typedef struct VBRState {
float energy_alpha;
float average_energy;
float last_energy;
float last_log_energy[VBR_MEMORY_SIZE];
float accum_sum;
float last_pitch_coef;
float soft_pitch;
float last_quality;
float noise_level;
float noise_accum;
float noise_accum_count;
int consec_noise;
} VBRState;
void vbr_init(VBRState *vbr);
float vbr_analysis(VBRState *vbr, float *sig, int len, int pitch, float pitch_coef);
void vbr_destroy(VBRState *vbr);
#endif

View File

@ -1,116 +0,0 @@
/* Copyright (C) 2002 Jean-Marc Valin
File: vq.c
Vector quantization
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of the Xiph.org Foundation nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "vq.h"
/*Finds the index of the entry in a codebook that best matches the input*/
int vq_index(float *in, float *codebook, int len, int entries)
{
int i,j;
float min_dist=0;
int best_index=0;
for (i=0;i<entries;i++)
{
float dist=0;
for (j=0;j<len;j++)
{
float tmp = in[j]-*codebook++;
dist += tmp*tmp;
}
if (i==0 || dist<min_dist)
{
min_dist=dist;
best_index=i;
}
}
return best_index;
}
/*Finds the indices of the n-best entries in a codebook*/
void vq_nbest(float *in, float *codebook, int len, int entries, float *E, int N, int *nbest, float *best_dist)
{
int i,j,k,used;
used = 0;
for (i=0;i<entries;i++)
{
float dist=.5*E[i];
for (j=0;j<len;j++)
dist -= in[j]**codebook++;
if (i<N || dist<best_dist[N-1])
{
for (k=N-1; (k >= 1) && (k > used || dist < best_dist[k-1]); k--)
{
best_dist[k]=best_dist[k-1];
nbest[k] = nbest[k-1];
}
best_dist[k]=dist;
nbest[k]=i;
used++;
}
}
}
/*Finds the indices of the n-best entries in a codebook with sign*/
void vq_nbest_sign(float *in, float *codebook, int len, int entries, float *E, int N, int *nbest, float *best_dist)
{
int i,j,k, sign, used;
used=0;
for (i=0;i<entries;i++)
{
float dist=0;
for (j=0;j<len;j++)
dist -= in[j]**codebook++;
if (dist>0)
{
sign=1;
dist=-dist;
} else
{
sign=0;
}
dist += .5*E[i];
if (i<N || dist<best_dist[N-1])
{
for (k=N-1; (k >= 1) && (k > used || dist < best_dist[k-1]); k--)
{
best_dist[k]=best_dist[k-1];
nbest[k] = nbest[k-1];
}
best_dist[k]=dist;
nbest[k]=i;
used++;
if (sign)
nbest[k]+=entries;
}
}
}

View File

@ -1,42 +0,0 @@
/* Copyright (C) 2002 Jean-Marc Valin
File: vq.h
Vector quantization
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of the Xiph.org Foundation nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef VQ_H
#define VQ_H
int vq_index(float *in, float *codebook, int len, int entries);
void vq_nbest(float *in, float *codebook, int len, int entries, float *E, int N, int *nbest, float *best_dist);
void vq_nbest_sign(float *in, float *codebook, int len, int entries, float *E, int N, int *nbest, float *best_dist);
#endif

File diff suppressed because it is too large Load Diff

View File

@ -1,198 +0,0 @@
#! /bin/sh
# Common stub for a few missing GNU programs while installing.
# Copyright (C) 1996, 1997, 2001, 2002 Free Software Foundation, Inc.
# Franc,ois Pinard <pinard@iro.umontreal.ca>, 1996.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.
if test $# -eq 0; then
echo 1>&2 "Try \`$0 --help' for more information"
exit 1
fi
# In the cases where this matters, `missing' is being run in the
# srcdir already.
if test -f configure.in; then
configure_ac=configure.ac
else
configure_ac=configure.in
fi
case "$1" in
-h|--h|--he|--hel|--help)
echo "\
$0 [OPTION]... PROGRAM [ARGUMENT]...
Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
error status if there is no known handling for PROGRAM.
Options:
-h, --help display this help and exit
-v, --version output version information and exit
Supported PROGRAM values:
aclocal touch file \`aclocal.m4'
autoconf touch file \`configure'
autoheader touch file \`config.h.in'
automake touch all \`Makefile.in' files
bison create \`y.tab.[ch]', if possible, from existing .[ch]
flex create \`lex.yy.c', if possible, from existing .c
lex create \`lex.yy.c', if possible, from existing .c
makeinfo touch the output file
yacc create \`y.tab.[ch]', if possible, from existing .[ch]"
;;
-v|--v|--ve|--ver|--vers|--versi|--versio|--version)
echo "missing - GNU libit 0.0"
;;
-*)
echo 1>&2 "$0: Unknown \`$1' option"
echo 1>&2 "Try \`$0 --help' for more information"
exit 1
;;
aclocal*)
echo 1>&2 "\
WARNING: \`$1' is missing on your system. You should only need it if
you modified \`acinclude.m4' or \`$configure_ac'. You might want
to install the \`Automake' and \`Perl' packages. Grab them from
any GNU archive site."
touch aclocal.m4
;;
autoconf)
echo 1>&2 "\
WARNING: \`$1' is missing on your system. You should only need it if
you modified \`$configure_ac'. You might want to install the
\`Autoconf' and \`GNU m4' packages. Grab them from any GNU
archive site."
touch configure
;;
autoheader)
echo 1>&2 "\
WARNING: \`$1' is missing on your system. You should only need it if
you modified \`acconfig.h' or \`$configure_ac'. You might want
to install the \`Autoconf' and \`GNU m4' packages. Grab them
from any GNU archive site."
files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' $configure_ac`
test -z "$files" && files="config.h"
touch_files=
for f in $files; do
case "$f" in
*:*) touch_files="$touch_files "`echo "$f" |
sed -e 's/^[^:]*://' -e 's/:.*//'`;;
*) touch_files="$touch_files $f.in";;
esac
done
touch $touch_files
;;
automake*)
echo 1>&2 "\
WARNING: \`$1' is missing on your system. You should only need it if
you modified \`Makefile.am', \`acinclude.m4' or \`$configure_ac'.
You might want to install the \`Automake' and \`Perl' packages.
Grab them from any GNU archive site."
find . -type f -name Makefile.am -print |
sed 's/\.am$/.in/' |
while read f; do touch "$f"; done
;;
bison|yacc)
echo 1>&2 "\
WARNING: \`$1' is missing on your system. You should only need it if
you modified a \`.y' file. You may need the \`Bison' package
in order for those modifications to take effect. You can get
\`Bison' from any GNU archive site."
rm -f y.tab.c y.tab.h
if [ $# -ne 1 ]; then
eval LASTARG="\${$#}"
case "$LASTARG" in
*.y)
SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
if [ -f "$SRCFILE" ]; then
cp "$SRCFILE" y.tab.c
fi
SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
if [ -f "$SRCFILE" ]; then
cp "$SRCFILE" y.tab.h
fi
;;
esac
fi
if [ ! -f y.tab.h ]; then
echo >y.tab.h
fi
if [ ! -f y.tab.c ]; then
echo 'main() { return 0; }' >y.tab.c
fi
;;
lex|flex)
echo 1>&2 "\
WARNING: \`$1' is missing on your system. You should only need it if
you modified a \`.l' file. You may need the \`Flex' package
in order for those modifications to take effect. You can get
\`Flex' from any GNU archive site."
rm -f lex.yy.c
if [ $# -ne 1 ]; then
eval LASTARG="\${$#}"
case "$LASTARG" in
*.l)
SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
if [ -f "$SRCFILE" ]; then
cp "$SRCFILE" lex.yy.c
fi
;;
esac
fi
if [ ! -f lex.yy.c ]; then
echo 'main() { return 0; }' >lex.yy.c
fi
;;
makeinfo)
echo 1>&2 "\
WARNING: \`$1' is missing on your system. You should only need it if
you modified a \`.texi' or \`.texinfo' file, or any other file
indirectly affecting the aspect of the manual. The spurious
call might also be the consequence of using a buggy \`make' (AIX,
DU, IRIX). You might want to install the \`Texinfo' package or
the \`GNU make' package. Grab either from any GNU archive site."
file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
if test -z "$file"; then
file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file`
fi
touch $file
;;
*)
echo 1>&2 "\
WARNING: \`$1' is needed, and you do not seem to have it handy on your
system. You might have modified some files without having the
proper tools for further handling them. Check the \`README' file,
it often tells you about the needed prerequirements for installing
this package. You may also peek at any GNU archive site, in case
some other package would contain this missing \`$1' program."
exit 1
;;
esac
exit 0

View File

@ -1,40 +0,0 @@
#! /bin/sh
# mkinstalldirs --- make directory hierarchy
# Author: Noah Friedman <friedman@prep.ai.mit.edu>
# Created: 1993-05-16
# Public domain
# $Id: mkinstalldirs,v 1.13 1999/01/05 03:18:55 bje Exp $
errstatus=0
for file
do
set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
shift
pathcomp=
for d
do
pathcomp="$pathcomp$d"
case "$pathcomp" in
-* ) pathcomp=./$pathcomp ;;
esac
if test ! -d "$pathcomp"; then
echo "mkdir $pathcomp"
mkdir "$pathcomp" || lasterr=$?
if test ! -d "$pathcomp"; then
errstatus=$lasterr
fi
fi
pathcomp="$pathcomp/"
done
done
exit $errstatus
# mkinstalldirs ends here

View File

@ -1,24 +0,0 @@
## Process this file with automake to produce Makefile.in. -*-Makefile-*-
# $Id: Makefile.am,v 1.9.2.1 2003/05/31 06:10:43 jm Exp $
# Disable automatic dependency tracking if using other tools than gcc and gmake
#AUTOMAKE_OPTIONS = no-dependencies
INCLUDES = -I$(top_srcdir)/libspeex $(OGG_INCLUDES)
mandir = $(prefix)/share/man
man_MANS = speexenc.1 speexdec.1
EXTRA_DIST = $(man_MANS) getopt_win.h getopt.c getopt1.c wave_out.c wave_out.h
include_HEADERS =
noinst_HEADERS = wav_io.h
bin_PROGRAMS = speexenc speexdec
speexenc_SOURCES = speexenc.c wav_io.c
speexenc_LDADD = $(top_builddir)/libspeex/libspeex.la $(OGG_LDFLAGS) $(OGG_LIBS)
speexdec_SOURCES = speexdec.c wav_io.c
speexdec_LDADD = $(top_builddir)/libspeex/libspeex.la $(OGG_LDFLAGS) $(OGG_LIBS)

View File

@ -1,418 +0,0 @@
# Makefile.in generated automatically by automake 1.4-p6 from Makefile.am
# Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
# $Id: Makefile.am,v 1.9.2.1 2003/05/31 06:10:43 jm Exp $
# Disable automatic dependency tracking if using other tools than gcc and gmake
#AUTOMAKE_OPTIONS = no-dependencies
SHELL = @SHELL@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
sbindir = @sbindir@
libexecdir = @libexecdir@
datadir = @datadir@
sysconfdir = @sysconfdir@
sharedstatedir = @sharedstatedir@
localstatedir = @localstatedir@
libdir = @libdir@
infodir = @infodir@
includedir = @includedir@
oldincludedir = /usr/include
DESTDIR =
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
top_builddir = ..
ACLOCAL = @ACLOCAL@
AUTOCONF = @AUTOCONF@
AUTOMAKE = @AUTOMAKE@
AUTOHEADER = @AUTOHEADER@
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
INSTALL_DATA = @INSTALL_DATA@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
transform = @program_transform_name@
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
host_alias = @host_alias@
host_triplet = @host@
AS = @AS@
CC = @CC@
DLLTOOL = @DLLTOOL@
ECHO = @ECHO@
EXEEXT = @EXEEXT@
LIBTOOL = @LIBTOOL@
LN_S = @LN_S@
MAINT = @MAINT@
MAKEINFO = @MAKEINFO@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
OGG_INCLUDES = @OGG_INCLUDES@
OGG_LDFLAGS = @OGG_LDFLAGS@
OGG_LIBS = @OGG_LIBS@
PACKAGE = @PACKAGE@
RANLIB = @RANLIB@
SPEEX_LT_AGE = @SPEEX_LT_AGE@
SPEEX_LT_CURRENT = @SPEEX_LT_CURRENT@
SPEEX_LT_REVISION = @SPEEX_LT_REVISION@
STRIP = @STRIP@
VERSION = @VERSION@
src = @src@
INCLUDES = -I$(top_srcdir)/libspeex $(OGG_INCLUDES)
mandir = $(prefix)/share/man
man_MANS = speexenc.1 speexdec.1
EXTRA_DIST = $(man_MANS) getopt_win.h getopt.c getopt1.c wave_out.c wave_out.h
include_HEADERS =
noinst_HEADERS = wav_io.h
bin_PROGRAMS = speexenc speexdec
speexenc_SOURCES = speexenc.c wav_io.c
speexenc_LDADD = $(top_builddir)/libspeex/libspeex.la $(OGG_LDFLAGS) $(OGG_LIBS)
speexdec_SOURCES = speexdec.c wav_io.c
speexdec_LDADD = $(top_builddir)/libspeex/libspeex.la $(OGG_LDFLAGS) $(OGG_LIBS)
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_CLEAN_FILES =
bin_PROGRAMS = speexenc$(EXEEXT) speexdec$(EXEEXT)
PROGRAMS = $(bin_PROGRAMS)
DEFS = @DEFS@ -I. -I$(srcdir)
CPPFLAGS = @CPPFLAGS@
LDFLAGS = @LDFLAGS@
LIBS = @LIBS@
speexenc_OBJECTS = speexenc.$(OBJEXT) wav_io.$(OBJEXT)
speexenc_DEPENDENCIES = $(top_builddir)/libspeex/libspeex.la
speexenc_LDFLAGS =
speexdec_OBJECTS = speexdec.$(OBJEXT) wav_io.$(OBJEXT)
speexdec_DEPENDENCIES = $(top_builddir)/libspeex/libspeex.la
speexdec_LDFLAGS =
CFLAGS = @CFLAGS@
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
CCLD = $(CC)
LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@
man1dir = $(mandir)/man1
MANS = $(man_MANS)
NROFF = nroff
HEADERS = $(include_HEADERS) $(noinst_HEADERS)
DIST_COMMON = Makefile.am Makefile.in
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
TAR = gtar
GZIP_ENV = --best
SOURCES = $(speexenc_SOURCES) $(speexdec_SOURCES)
OBJECTS = $(speexenc_OBJECTS) $(speexdec_OBJECTS)
all: all-redirect
.SUFFIXES:
.SUFFIXES: .S .c .lo .o .obj .s
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps src/Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
cd $(top_builddir) \
&& CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
mostlyclean-binPROGRAMS:
clean-binPROGRAMS:
-test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS)
distclean-binPROGRAMS:
maintainer-clean-binPROGRAMS:
install-binPROGRAMS: $(bin_PROGRAMS)
@$(NORMAL_INSTALL)
$(mkinstalldirs) $(DESTDIR)$(bindir)
@list='$(bin_PROGRAMS)'; for p in $$list; do \
if test -f $$p; then \
echo " $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`"; \
$(LIBTOOL) --mode=install $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \
else :; fi; \
done
uninstall-binPROGRAMS:
@$(NORMAL_UNINSTALL)
list='$(bin_PROGRAMS)'; for p in $$list; do \
rm -f $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \
done
.c.o:
$(COMPILE) -c $<
# FIXME: We should only use cygpath when building on Windows,
# and only if it is available.
.c.obj:
$(COMPILE) -c `cygpath -w $<`
.s.o:
$(COMPILE) -c $<
.S.o:
$(COMPILE) -c $<
mostlyclean-compile:
-rm -f *.o core *.core
-rm -f *.$(OBJEXT)
clean-compile:
distclean-compile:
-rm -f *.tab.c
maintainer-clean-compile:
.c.lo:
$(LIBTOOL) --mode=compile $(COMPILE) -c $<
.s.lo:
$(LIBTOOL) --mode=compile $(COMPILE) -c $<
.S.lo:
$(LIBTOOL) --mode=compile $(COMPILE) -c $<
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
distclean-libtool:
maintainer-clean-libtool:
speexenc$(EXEEXT): $(speexenc_OBJECTS) $(speexenc_DEPENDENCIES)
@rm -f speexenc$(EXEEXT)
$(LINK) $(speexenc_LDFLAGS) $(speexenc_OBJECTS) $(speexenc_LDADD) $(LIBS)
speexdec$(EXEEXT): $(speexdec_OBJECTS) $(speexdec_DEPENDENCIES)
@rm -f speexdec$(EXEEXT)
$(LINK) $(speexdec_LDFLAGS) $(speexdec_OBJECTS) $(speexdec_LDADD) $(LIBS)
install-man1:
$(mkinstalldirs) $(DESTDIR)$(man1dir)
@list='$(man1_MANS)'; \
l2='$(man_MANS)'; for i in $$l2; do \
case "$$i" in \
*.1*) list="$$list $$i" ;; \
esac; \
done; \
for i in $$list; do \
if test -f $(srcdir)/$$i; then file=$(srcdir)/$$i; \
else file=$$i; fi; \
ext=`echo $$i | sed -e 's/^.*\\.//'`; \
inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
inst=`echo $$inst | sed '$(transform)'`.$$ext; \
echo " $(INSTALL_DATA) $$file $(DESTDIR)$(man1dir)/$$inst"; \
$(INSTALL_DATA) $$file $(DESTDIR)$(man1dir)/$$inst; \
done
uninstall-man1:
@list='$(man1_MANS)'; \
l2='$(man_MANS)'; for i in $$l2; do \
case "$$i" in \
*.1*) list="$$list $$i" ;; \
esac; \
done; \
for i in $$list; do \
ext=`echo $$i | sed -e 's/^.*\\.//'`; \
inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
inst=`echo $$inst | sed '$(transform)'`.$$ext; \
echo " rm -f $(DESTDIR)$(man1dir)/$$inst"; \
rm -f $(DESTDIR)$(man1dir)/$$inst; \
done
install-man: $(MANS)
@$(NORMAL_INSTALL)
$(MAKE) $(AM_MAKEFLAGS) install-man1
uninstall-man:
@$(NORMAL_UNINSTALL)
$(MAKE) $(AM_MAKEFLAGS) uninstall-man1
install-includeHEADERS: $(include_HEADERS)
@$(NORMAL_INSTALL)
$(mkinstalldirs) $(DESTDIR)$(includedir)
@list='$(include_HEADERS)'; for p in $$list; do \
if test -f "$$p"; then d= ; else d="$(srcdir)/"; fi; \
echo " $(INSTALL_DATA) $$d$$p $(DESTDIR)$(includedir)/$$p"; \
$(INSTALL_DATA) $$d$$p $(DESTDIR)$(includedir)/$$p; \
done
uninstall-includeHEADERS:
@$(NORMAL_UNINSTALL)
list='$(include_HEADERS)'; for p in $$list; do \
rm -f $(DESTDIR)$(includedir)/$$p; \
done
tags: TAGS
ID: $(HEADERS) $(SOURCES) $(LISP)
list='$(SOURCES) $(HEADERS)'; \
unique=`for i in $$list; do echo $$i; done | \
awk ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
here=`pwd` && cd $(srcdir) \
&& mkid -f$$here/ID $$unique $(LISP)
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS)'; \
unique=`for i in $$list; do echo $$i; done | \
awk ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \
|| (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS)
mostlyclean-tags:
clean-tags:
distclean-tags:
-rm -f TAGS ID
maintainer-clean-tags:
distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
subdir = src
distdir: $(DISTFILES)
@for file in $(DISTFILES); do \
d=$(srcdir); \
if test -d $$d/$$file; then \
cp -pr $$d/$$file $(distdir)/$$file; \
else \
test -f $(distdir)/$$file \
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
|| cp -p $$d/$$file $(distdir)/$$file || :; \
fi; \
done
speexdec.o: speexdec.c ../libspeex/speex.h ../libspeex/speex_bits.h \
wav_io.h ../libspeex/speex_header.h ../libspeex/speex_stereo.h \
../libspeex/speex_callbacks.h ../libspeex/misc.h
speexenc.o: speexenc.c ../libspeex/speex.h ../libspeex/speex_bits.h \
wav_io.h ../libspeex/speex_header.h ../libspeex/speex_stereo.h \
../libspeex/misc.h
wav_io.o: wav_io.c ../libspeex/misc.h
info-am:
info: info-am
dvi-am:
dvi: dvi-am
check-am: all-am
check: check-am
installcheck-am:
installcheck: installcheck-am
install-exec-am: install-binPROGRAMS
install-exec: install-exec-am
install-data-am: install-man install-includeHEADERS
install-data: install-data-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
install: install-am
uninstall-am: uninstall-binPROGRAMS uninstall-man \
uninstall-includeHEADERS
uninstall: uninstall-am
all-am: Makefile $(PROGRAMS) $(MANS) $(HEADERS)
all-redirect: all-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
installdirs:
$(mkinstalldirs) $(DESTDIR)$(bindir) $(DESTDIR)$(mandir)/man1 \
$(DESTDIR)$(includedir)
mostlyclean-generic:
clean-generic:
distclean-generic:
-rm -f Makefile $(CONFIG_CLEAN_FILES)
-rm -f config.cache config.log stamp-h stamp-h[0-9]*
maintainer-clean-generic:
mostlyclean-am: mostlyclean-binPROGRAMS mostlyclean-compile \
mostlyclean-libtool mostlyclean-tags \
mostlyclean-generic
mostlyclean: mostlyclean-am
clean-am: clean-binPROGRAMS clean-compile clean-libtool clean-tags \
clean-generic mostlyclean-am
clean: clean-am
distclean-am: distclean-binPROGRAMS distclean-compile distclean-libtool \
distclean-tags distclean-generic clean-am
-rm -f libtool
distclean: distclean-am
maintainer-clean-am: maintainer-clean-binPROGRAMS \
maintainer-clean-compile maintainer-clean-libtool \
maintainer-clean-tags maintainer-clean-generic \
distclean-am
@echo "This command is intended for maintainers to use;"
@echo "it deletes files that may require special tools to rebuild."
maintainer-clean: maintainer-clean-am
.PHONY: mostlyclean-binPROGRAMS distclean-binPROGRAMS clean-binPROGRAMS \
maintainer-clean-binPROGRAMS uninstall-binPROGRAMS install-binPROGRAMS \
mostlyclean-compile distclean-compile clean-compile \
maintainer-clean-compile mostlyclean-libtool distclean-libtool \
clean-libtool maintainer-clean-libtool install-man1 uninstall-man1 \
install-man uninstall-man uninstall-includeHEADERS \
install-includeHEADERS tags mostlyclean-tags distclean-tags clean-tags \
maintainer-clean-tags distdir info-am info dvi-am dvi check check-am \
installcheck-am installcheck install-exec-am install-exec \
install-data-am install-data install-am install uninstall-am uninstall \
all-redirect all-am all installdirs mostlyclean-generic \
distclean-generic clean-generic maintainer-clean-generic clean \
mostlyclean distclean maintainer-clean
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

File diff suppressed because it is too large Load Diff

View File

@ -1,188 +0,0 @@
/* getopt_long and getopt_long_only entry points for GNU getopt.
Copyright (C) 1987,88,89,90,91,92,93,94,96,97,98
Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "getopt_win.h"
#if !defined __STDC__ || !__STDC__
/* This is a separate conditional since some stdc systems
reject `defined (const)'. */
#ifndef const
#define const
#endif
#endif
#include <stdio.h>
/* Comment out all this code if we are using the GNU C Library, and are not
actually compiling the library itself. This code is part of the GNU C
Library, but also included in many other GNU distributions. Compiling
and linking in this code is a waste when using the GNU C library
(especially if it is a shared library). Rather than having every GNU
program understand `configure --with-gnu-libc' and omit the object files,
it is simpler to just do this in the source for each such file. */
#define GETOPT_INTERFACE_VERSION 2
#if !defined _LIBC && defined __GLIBC__ && __GLIBC__ >= 2
#include <gnu-versions.h>
#if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION
#define ELIDE_CODE
#endif
#endif
#ifndef ELIDE_CODE
/* This needs to come after some library #include
to get __GNU_LIBRARY__ defined. */
#ifdef __GNU_LIBRARY__
#include <stdlib.h>
#endif
#ifndef NULL
#define NULL 0
#endif
int
getopt_long (argc, argv, options, long_options, opt_index)
int argc;
char *const *argv;
const char *options;
const struct option *long_options;
int *opt_index;
{
return _getopt_internal (argc, argv, options, long_options, opt_index, 0);
}
/* Like getopt_long, but '-' as well as '--' can indicate a long option.
If an option that starts with '-' (not '--') doesn't match a long option,
but does match a short option, it is parsed as a short option
instead. */
int
getopt_long_only (argc, argv, options, long_options, opt_index)
int argc;
char *const *argv;
const char *options;
const struct option *long_options;
int *opt_index;
{
return _getopt_internal (argc, argv, options, long_options, opt_index, 1);
}
#endif /* Not ELIDE_CODE. */
#ifdef TEST
#include <stdio.h>
int
main (argc, argv)
int argc;
char **argv;
{
int c;
int digit_optind = 0;
while (1)
{
int this_option_optind = optind ? optind : 1;
int option_index = 0;
static struct option long_options[] =
{
{"add", 1, 0, 0},
{"append", 0, 0, 0},
{"delete", 1, 0, 0},
{"verbose", 0, 0, 0},
{"create", 0, 0, 0},
{"file", 1, 0, 0},
{0, 0, 0, 0}
};
c = getopt_long (argc, argv, "abc:d:0123456789",
long_options, &option_index);
if (c == -1)
break;
switch (c)
{
case 0:
printf ("option %s", long_options[option_index].name);
if (optarg)
printf (" with arg %s", optarg);
printf ("\n");
break;
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
if (digit_optind != 0 && digit_optind != this_option_optind)
printf ("digits occur in two different argv-elements.\n");
digit_optind = this_option_optind;
printf ("option %c\n", c);
break;
case 'a':
printf ("option a\n");
break;
case 'b':
printf ("option b\n");
break;
case 'c':
printf ("option c with value `%s'\n", optarg);
break;
case 'd':
printf ("option d with value `%s'\n", optarg);
break;
case '?':
break;
default:
printf ("?? getopt returned character code 0%o ??\n", c);
}
}
if (optind < argc)
{
printf ("non-option ARGV-elements: ");
while (optind < argc)
printf ("%s ", argv[optind++]);
printf ("\n");
}
exit (0);
}
#endif /* TEST */

View File

@ -1,169 +0,0 @@
/* Declarations for getopt.
Copyright (C) 1989,90,91,92,93,94,96,97,98 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#ifndef _GETOPT_H
#ifndef __need_getopt
# define _GETOPT_H 1
#endif
#ifdef __cplusplus
extern "C" {
#endif
/* For communication from `getopt' to the caller.
When `getopt' finds an option that takes an argument,
the argument value is returned here.
Also, when `ordering' is RETURN_IN_ORDER,
each non-option ARGV-element is returned here. */
extern char *optarg;
/* Index in ARGV of the next element to be scanned.
This is used for communication to and from the caller
and for communication between successive calls to `getopt'.
On entry to `getopt', zero means this is the first call; initialize.
When `getopt' returns -1, this is the index of the first of the
non-option elements that the caller should itself scan.
Otherwise, `optind' communicates from one call to the next
how much of ARGV has been scanned so far. */
extern int optind;
/* Callers store zero here to inhibit the error message `getopt' prints
for unrecognized options. */
extern int opterr;
/* Set to an option character which was unrecognized. */
extern int optopt;
#ifndef __need_getopt
/* Describe the long-named options requested by the application.
The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
of `struct option' terminated by an element containing a name which is
zero.
The field `has_arg' is:
no_argument (or 0) if the option does not take an argument,
required_argument (or 1) if the option requires an argument,
optional_argument (or 2) if the option takes an optional argument.
If the field `flag' is not NULL, it points to a variable that is set
to the value given in the field `val' when the option is found, but
left unchanged if the option is not found.
To have a long-named option do something other than set an `int' to
a compiled-in constant, such as set a value from `optarg', set the
option's `flag' field to zero and its `val' field to a nonzero
value (the equivalent single-letter option character, if there is
one). For long options that have a zero `flag' field, `getopt'
returns the contents of the `val' field. */
struct option
{
# if defined __STDC__ && __STDC__
const char *name;
# else
char *name;
# endif
/* has_arg can't be an enum because some compilers complain about
type mismatches in all the code that assumes it is an int. */
int has_arg;
int *flag;
int val;
};
/* Names for the values of the `has_arg' field of `struct option'. */
# define no_argument 0
# define required_argument 1
# define optional_argument 2
#endif /* need getopt */
/* Get definitions and prototypes for functions to process the
arguments in ARGV (ARGC of them, minus the program name) for
options given in OPTS.
Return the option character from OPTS just read. Return -1 when
there are no more options. For unrecognized options, or options
missing arguments, `optopt' is set to the option letter, and '?' is
returned.
The OPTS string is a list of characters which are recognized option
letters, optionally followed by colons, specifying that that letter
takes an argument, to be placed in `optarg'.
If a letter in OPTS is followed by two colons, its argument is
optional. This behavior is specific to the GNU `getopt'.
The argument `--' causes premature termination of argument
scanning, explicitly telling `getopt' that there are no more
options.
If OPTS begins with `--', then non-option arguments are treated as
arguments to the option '\0'. This behavior is specific to the GNU
`getopt'. */
#if defined __STDC__ && __STDC__
# ifdef __GNU_LIBRARY__
/* Many other libraries have conflicting prototypes for getopt, with
differences in the consts, in stdlib.h. To avoid compilation
errors, only prototype getopt for the GNU C library. */
extern int getopt (int __argc, char *const *__argv, const char *__shortopts);
# else /* not __GNU_LIBRARY__ */
extern int getopt ();
# endif /* __GNU_LIBRARY__ */
# ifndef __need_getopt
extern int getopt_long (int __argc, char *const *__argv, const char *__shortopts,
const struct option *__longopts, int *__longind);
extern int getopt_long_only (int __argc, char *const *__argv,
const char *__shortopts,
const struct option *__longopts, int *__longind);
/* Internal only. Users should not call this directly. */
extern int _getopt_internal (int __argc, char *const *__argv,
const char *__shortopts,
const struct option *__longopts, int *__longind,
int __long_only);
# endif
#else /* not __STDC__ */
extern int getopt ();
# ifndef __need_getopt
extern int getopt_long ();
extern int getopt_long_only ();
extern int _getopt_internal ();
# endif
#endif /* __STDC__ */
#ifdef __cplusplus
}
#endif
/* Make sure we later can get all the definitions and declarations. */
#undef __need_getopt
#endif /* getopt.h */

View File

@ -1,184 +0,0 @@
/********************************************************************
* *
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. *
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2002 *
* by the Xiph.Org Foundation http://www.xiph.org/ *
* *
********************************************************************
function: toplevel libogg include
last mod: $Id: ogg.h,v 1.18 2002/07/13 10:28:33 giles Exp $
********************************************************************/
#ifndef _OGG_H
#define _OGG_H
#ifdef __cplusplus
extern "C" {
#endif
#include <os_types.h>
typedef struct {
long endbyte;
int endbit;
unsigned char *buffer;
unsigned char *ptr;
long storage;
} oggpack_buffer;
/* ogg_page is used to encapsulate the data in one Ogg bitstream page *****/
typedef struct {
unsigned char *header;
long header_len;
unsigned char *body;
long body_len;
} ogg_page;
/* ogg_stream_state contains the current encode/decode state of a logical
Ogg bitstream **********************************************************/
typedef struct {
unsigned char *body_data; /* bytes from packet bodies */
long body_storage; /* storage elements allocated */
long body_fill; /* elements stored; fill mark */
long body_returned; /* elements of fill returned */
int *lacing_vals; /* The values that will go to the segment table */
ogg_int64_t *granule_vals; /* granulepos values for headers. Not compact
this way, but it is simple coupled to the
lacing fifo */
long lacing_storage;
long lacing_fill;
long lacing_packet;
long lacing_returned;
unsigned char header[282]; /* working space for header encode */
int header_fill;
int e_o_s; /* set when we have buffered the last packet in the
logical bitstream */
int b_o_s; /* set after we've written the initial page
of a logical bitstream */
long serialno;
long pageno;
ogg_int64_t packetno; /* sequence number for decode; the framing
knows where there's a hole in the data,
but we need coupling so that the codec
(which is in a seperate abstraction
layer) also knows about the gap */
ogg_int64_t granulepos;
} ogg_stream_state;
/* ogg_packet is used to encapsulate the data and metadata belonging
to a single raw Ogg/Vorbis packet *************************************/
typedef struct {
unsigned char *packet;
long bytes;
long b_o_s;
long e_o_s;
ogg_int64_t granulepos;
ogg_int64_t packetno; /* sequence number for decode; the framing
knows where there's a hole in the data,
but we need coupling so that the codec
(which is in a seperate abstraction
layer) also knows about the gap */
} ogg_packet;
typedef struct {
unsigned char *data;
int storage;
int fill;
int returned;
int unsynced;
int headerbytes;
int bodybytes;
} ogg_sync_state;
/* Ogg BITSTREAM PRIMITIVES: bitstream ************************/
extern void oggpack_writeinit(oggpack_buffer *b);
extern void oggpack_writetrunc(oggpack_buffer *b,long bits);
extern void oggpack_writealign(oggpack_buffer *b);
extern void oggpack_writecopy(oggpack_buffer *b,void *source,long bits);
extern void oggpack_reset(oggpack_buffer *b);
extern void oggpack_writeclear(oggpack_buffer *b);
extern void oggpack_readinit(oggpack_buffer *b,unsigned char *buf,int bytes);
extern void oggpack_write(oggpack_buffer *b,unsigned long value,int bits);
extern long oggpack_look(oggpack_buffer *b,int bits);
extern long oggpack_look1(oggpack_buffer *b);
extern void oggpack_adv(oggpack_buffer *b,int bits);
extern void oggpack_adv1(oggpack_buffer *b);
extern long oggpack_read(oggpack_buffer *b,int bits);
extern long oggpack_read1(oggpack_buffer *b);
extern long oggpack_bytes(oggpack_buffer *b);
extern long oggpack_bits(oggpack_buffer *b);
extern unsigned char *oggpack_get_buffer(oggpack_buffer *b);
/* Ogg BITSTREAM PRIMITIVES: encoding **************************/
extern int ogg_stream_packetin(ogg_stream_state *os, ogg_packet *op);
extern int ogg_stream_pageout(ogg_stream_state *os, ogg_page *og);
extern int ogg_stream_flush(ogg_stream_state *os, ogg_page *og);
/* Ogg BITSTREAM PRIMITIVES: decoding **************************/
extern int ogg_sync_init(ogg_sync_state *oy);
extern int ogg_sync_clear(ogg_sync_state *oy);
extern int ogg_sync_reset(ogg_sync_state *oy);
extern int ogg_sync_destroy(ogg_sync_state *oy);
extern char *ogg_sync_buffer(ogg_sync_state *oy, long size);
extern int ogg_sync_wrote(ogg_sync_state *oy, long bytes);
extern long ogg_sync_pageseek(ogg_sync_state *oy,ogg_page *og);
extern int ogg_sync_pageout(ogg_sync_state *oy, ogg_page *og);
extern int ogg_stream_pagein(ogg_stream_state *os, ogg_page *og);
extern int ogg_stream_packetout(ogg_stream_state *os,ogg_packet *op);
extern int ogg_stream_packetpeek(ogg_stream_state *os,ogg_packet *op);
/* Ogg BITSTREAM PRIMITIVES: general ***************************/
extern int ogg_stream_init(ogg_stream_state *os,int serialno);
extern int ogg_stream_clear(ogg_stream_state *os);
extern int ogg_stream_reset(ogg_stream_state *os);
extern int ogg_stream_reset_serialno(ogg_stream_state *os,int serialno);
extern int ogg_stream_destroy(ogg_stream_state *os);
extern int ogg_stream_eos(ogg_stream_state *os);
extern void ogg_page_checksum_set(ogg_page *og);
extern int ogg_page_version(ogg_page *og);
extern int ogg_page_continued(ogg_page *og);
extern int ogg_page_bos(ogg_page *og);
extern int ogg_page_eos(ogg_page *og);
extern ogg_int64_t ogg_page_granulepos(ogg_page *og);
extern int ogg_page_serialno(ogg_page *og);
extern long ogg_page_pageno(ogg_page *og);
extern int ogg_page_packets(ogg_page *og);
extern void ogg_packet_clear(ogg_packet *op);
#ifdef __cplusplus
}
#endif
#endif /* _OGG_H */

View File

@ -1,84 +0,0 @@
/********************************************************************
* *
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. *
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2002 *
* by the Xiph.Org Foundation http://www.xiph.org/ *
* *
********************************************************************
function: #ifdef jail to whip a few platforms into the UNIX ideal.
last mod: $Id: os_types.h,v 1.11 2002/07/19 08:25:51 msmith Exp $
********************************************************************/
#ifndef _OS_TYPES_H
#define _OS_TYPES_H
/* make it easy on the folks that want to compile the libs with a
different malloc than stdlib */
#define _ogg_malloc malloc
#define _ogg_calloc calloc
#define _ogg_realloc realloc
#define _ogg_free free
#ifdef _WIN32
# ifndef __GNUC__
/* MSVC/Borland */
typedef __int64 ogg_int64_t;
typedef __int32 ogg_int32_t;
typedef unsigned __int32 ogg_uint32_t;
typedef __int16 ogg_int16_t;
# else
/* Cygwin */
#include <_G_config.h>
typedef _G_int64_t ogg_int64_t;
typedef _G_int32_t ogg_int32_t;
typedef _G_uint32_t ogg_uint32_t;
typedef _G_int16_t ogg_int16_t;
# endif
#elif defined(__MACOS__)
# include <sys/types.h>
typedef SInt16 ogg_int16_t;
typedef SInt32 ogg_int32_t;
typedef UInt32 ogg_uint32_t;
typedef SInt64 ogg_int64_t;
#elif defined(__MACOSX__) /* MacOS X Framework build */
# include <sys/types.h>
typedef int16_t ogg_int16_t;
typedef int32_t ogg_int32_t;
typedef u_int32_t ogg_uint32_t;
typedef int64_t ogg_int64_t;
#elif defined(__BEOS__)
/* Be */
# include <inttypes.h>
typedef int16_t ogg_int16_t;
typedef int32_t ogg_int32_t;
typedef u_int32_t ogg_uint32_t;
typedef int64_t ogg_int64_t;
#elif defined (__EMX__)
/* OS/2 GCC */
typedef short ogg_int16_t;
typedef int ogg_int32_t;
typedef unsigned int ogg_uint32_t;
typedef long long ogg_int64_t;
#else
# include <sys/types.h>
# include <ogg/config_types.h>
#endif
#endif /* _OS_TYPES_H */

View File

@ -1,78 +0,0 @@
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.29.
.TH SPEEXDEC "1" "December 2002" "speexdec version 1.0" "User Commands"
.SH NAME
speexdec \- manual page for speexdec version 1.0
.SH SYNOPSIS
.B speexdec
[\fIoptions\fR] \fIinput_file.spx \fR[\fIoutput_file\fR]
.SH DESCRIPTION
Decodes a Speex file and produce a WAV file or raw file
.SS "input_file can be:"
.TP
filename.spx
regular Speex file
.TP
-
stdin
.SS "output_file can be:"
.TP
filename.wav
Wav file
.TP
filename.*
Raw PCM file (any extension other that .wav)
.TP
-
stdout
.TP
(nothing)
Will be played to soundcard
.SH OPTIONS
.TP
\fB\-\-enh\fR
Enable perceptual enhancement (default)
.TP
\fB\-\-no\-enh\fR
Disable perceptual enhancement
.TP
\fB\-\-force\-nb\fR
Force decoding in narrowband
.TP
\fB\-\-force\-wb\fR
Force decoding in wideband
.TP
\fB\-\-force\-uwb\fR
Force decoding in ultra-wideband
.TP
\fB\-\-mono\fR
Force decoding in mono
.TP
\fB\-\-stereo\fR
Force decoding in stereo
.TP
\fB\-\-rate\fR n
Force decoding at sampling rate n Hz
.TP
\fB\-\-packet\-loss\fR n
Simulate n % random packet loss
.TP
\fB\-V\fR
Verbose mode (show bit-rate)
.TP
\fB\-h\fR, \fB\-\-help\fR
This help
.TP
\fB\-v\fR, \fB\-\-version\fR
Version information
.TP
\fB\-\-pf\fR
Deprecated, use \fB\-\-enh\fR instead
.TP
\fB\-\-no\-pf\fR
Deprecated, use \fB\-\-no\-enh\fR instead
.PP
More information is available from the Speex site: http://www.speex.org
.PP
Please report bugs to the mailing list `speex-dev@xiph.org'.
.SH COPYRIGHT
Copyright \(co 2002 Jean-Marc Valin

View File

@ -1,686 +0,0 @@
/* Copyright (C) 2002-2003 Jean-Marc Valin
File: speexdec.c
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of the Xiph.org Foundation nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdio.h>
#if !defined WIN32 && !defined _WIN32
#include <unistd.h>
#include <getopt.h>
#endif
#include <stdlib.h>
#include <string.h>
#include "speex.h"
#include "ogg/ogg.h"
#if defined WIN32 || defined _WIN32
#include <windows.h>
#include "getopt_win.h"
#include "wave_out.h"
/* We need the following two to set stdout to binary */
#include <io.h>
#include <fcntl.h>
#endif
#include <math.h>
#ifdef HAVE_SYS_SOUNDCARD_H
#include <sys/soundcard.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#endif
#include <string.h>
#include "wav_io.h"
#include "speex_header.h"
#include "speex_stereo.h"
#include "speex_callbacks.h"
#include "misc.h"
#define MAX_FRAME_SIZE 2000
#define readint(buf, base) (((buf[base+3]<<24)&0xff000000)| \
((buf[base+2]<<16)&0xff0000)| \
((buf[base+1]<<8)&0xff00)| \
(buf[base]&0xff))
static void print_comments(char *comments, int length)
{
char *c=comments;
int len, i, nb_fields;
char *end;
if (length<8)
{
fprintf (stderr, "Invalid/corrupted comments\n");
return;
}
end = c+length;
len=readint(c, 0);
c+=4;
if (c+len>end)
{
fprintf (stderr, "Invalid/corrupted comments\n");
return;
}
fwrite(c, 1, len, stderr);
c+=len;
fprintf (stderr, "\n");
if (c+4>end)
{
fprintf (stderr, "Invalid/corrupted comments\n");
return;
}
nb_fields=readint(c, 0);
c+=4;
for (i=0;i<nb_fields;i++)
{
if (c+4>end)
{
fprintf (stderr, "Invalid/corrupted comments\n");
return;
}
len=readint(c, 0);
c+=4;
if (c+len>end)
{
fprintf (stderr, "Invalid/corrupted comments\n");
return;
}
fwrite(c, 1, len, stderr);
c+=len;
fprintf (stderr, "\n");
}
}
FILE *out_file_open(char *outFile, int rate, int *channels)
{
FILE *fout=NULL;
/*Open output file*/
if (strlen(outFile)==0)
{
#if defined HAVE_SYS_SOUNDCARD_H
int audio_fd, format, stereo;
audio_fd=open("/dev/dsp", O_WRONLY);
if (audio_fd<0)
{
perror("Cannot open /dev/dsp");
exit(1);
}
format=AFMT_S16_NE;
if (ioctl(audio_fd, SNDCTL_DSP_SETFMT, &format)==-1)
{
perror("SNDCTL_DSP_SETFMT");
close(audio_fd);
exit(1);
}
stereo=0;
if (*channels==2)
stereo=1;
if (ioctl(audio_fd, SNDCTL_DSP_STEREO, &stereo)==-1)
{
perror("SNDCTL_DSP_STEREO");
close(audio_fd);
exit(1);
}
if (stereo!=0)
{
if (*channels==1)
fprintf (stderr, "Cannot set mono mode, will decode in stereo\n");
*channels=2;
}
if (ioctl(audio_fd, SNDCTL_DSP_SPEED, &rate)==-1)
{
perror("SNDCTL_DSP_SPEED");
close(audio_fd);
exit(1);
}
fout = fdopen(audio_fd, "w");
#elif defined WIN32 || defined _WIN32
{
unsigned int speex_channels = *channels;
if (Set_WIN_Params (INVALID_FILEDESC, rate, SAMPLE_SIZE, speex_channels))
{
fprintf (stderr, "Can't access %s\n", "WAVE OUT");
exit(1);
}
}
#else
fprintf (stderr, "No soundcard support\n");
exit(1);
#endif
} else {
if (strcmp(outFile,"-")==0)
{
#if defined WIN32 || defined _WIN32
_setmode(_fileno(stdout), _O_BINARY);
#endif
fout=stdout;
}
else
{
#if defined WIN32 || defined _WIN32
fout = fopen(outFile, "wb");
#else
fout = fopen(outFile, "w");
#endif
if (!fout)
{
perror(outFile);
exit(1);
}
if (strcmp(outFile+strlen(outFile)-4,".wav")==0 || strcmp(outFile+strlen(outFile)-4,".WAV")==0)
write_wav_header(fout, rate, *channels, 0, 0);
}
}
return fout;
}
void usage()
{
printf ("Usage: speexdec [options] input_file.spx [output_file]\n");
printf ("\n");
printf ("Decodes a Speex file and produce a WAV file or raw file\n");
printf ("\n");
printf ("input_file can be:\n");
printf (" filename.spx regular Speex file\n");
printf (" - stdin\n");
printf ("\n");
printf ("output_file can be:\n");
printf (" filename.wav Wav file\n");
printf (" filename.* Raw PCM file (any extension other that .wav)\n");
printf (" - stdout\n");
printf (" (nothing) Will be played to soundcard\n");
printf ("\n");
printf ("Options:\n");
printf (" --enh Enable perceptual enhancement (default)\n");
printf (" --no-enh Disable perceptual enhancement\n");
printf (" --force-nb Force decoding in narrowband\n");
printf (" --force-wb Force decoding in wideband\n");
printf (" --force-uwb Force decoding in ultra-wideband\n");
printf (" --mono Force decoding in mono\n");
printf (" --stereo Force decoding in stereo\n");
printf (" --rate n Force decoding at sampling rate n Hz\n");
printf (" --packet-loss n Simulate n %% random packet loss\n");
printf (" -V Verbose mode (show bit-rate)\n");
printf (" -h, --help This help\n");
printf (" -v, --version Version information\n");
printf (" --pf Deprecated, use --enh instead\n");
printf (" --no-pf Deprecated, use --no-enh instead\n");
printf ("\n");
printf ("More information is available from the Speex site: http://www.speex.org\n");
printf ("\n");
printf ("Please report bugs to the mailing list `speex-dev@xiph.org'.\n");
}
void version()
{
printf ("speexdec (Speex decoder) version " VERSION " (compiled " __DATE__ ")\n");
printf ("Copyright (C) 2002-2003 Jean-Marc Valin\n");
}
void version_short()
{
printf ("speexdec version " VERSION "\n");
printf ("Copyright (C) 2002-2003 Jean-Marc Valin\n");
}
static void *process_header(ogg_packet *op, int enh_enabled, int *frame_size, int *rate, int *nframes, int forceMode, int *channels, SpeexStereoState *stereo, int *extra_headers)
{
void *st;
SpeexMode *mode;
SpeexHeader *header;
int modeID;
SpeexCallback callback;
header = speex_packet_to_header((char*)op->packet, op->bytes);
if (!header)
{
fprintf (stderr, "Cannot read header\n");
return NULL;
}
if (header->mode >= SPEEX_NB_MODES)
{
fprintf (stderr, "Mode number %d does not (yet/any longer) exist in this version\n",
header->mode);
return NULL;
}
modeID = header->mode;
if (forceMode!=-1)
modeID = forceMode;
mode = speex_mode_list[modeID];
if (header->speex_version_id > 1)
{
fprintf (stderr, "This file was encoded with Speex bit-stream version %d, which I don't know how to decode\n", header->speex_version_id);
return NULL;
}
if (mode->bitstream_version < header->mode_bitstream_version)
{
fprintf (stderr, "The file was encoded with a newer version of Speex. You need to upgrade in order to play it.\n");
return NULL;
}
if (mode->bitstream_version > header->mode_bitstream_version)
{
fprintf (stderr, "The file was encoded with an older version of Speex. You would need to downgrade the version in order to play it.\n");
return NULL;
}
st = speex_decoder_init(mode);
if (!st)
{
fprintf (stderr, "Decoder initialization failed.\n");
return NULL;
}
speex_decoder_ctl(st, SPEEX_SET_ENH, &enh_enabled);
speex_decoder_ctl(st, SPEEX_GET_FRAME_SIZE, frame_size);
if (!(*channels==1))
{
callback.callback_id = SPEEX_INBAND_STEREO;
callback.func = speex_std_stereo_request_handler;
callback.data = stereo;
speex_decoder_ctl(st, SPEEX_SET_HANDLER, &callback);
}
if (!*rate)
*rate = header->rate;
/* Adjust rate if --force-* options are used */
if (forceMode!=-1)
{
if (header->mode < forceMode)
*rate <<= (forceMode - header->mode);
if (header->mode > forceMode)
*rate >>= (header->mode - forceMode);
}
speex_decoder_ctl(st, SPEEX_SET_SAMPLING_RATE, rate);
*nframes = header->frames_per_packet;
if (*channels==-1)
*channels = header->nb_channels;
fprintf (stderr, "Decoding %d Hz audio using %s mode",
*rate, mode->modeName);
if (*channels==1)
fprintf (stderr, " (mono");
else
fprintf (stderr, " (stereo");
if (header->vbr)
fprintf (stderr, ", VBR)\n");
else
fprintf(stderr, ")\n");
/*fprintf (stderr, "Decoding %d Hz audio at %d bps using %s mode\n",
*rate, mode->bitrate, mode->modeName);*/
*extra_headers = header->extra_headers;
free(header);
return st;
}
int main(int argc, char **argv)
{
int c;
int option_index = 0;
char *inFile, *outFile;
FILE *fin, *fout=NULL;
short out[MAX_FRAME_SIZE];
float output[MAX_FRAME_SIZE];
int frame_size=0;
void *st=NULL;
SpeexBits bits;
int packet_count=0;
int stream_init = 0;
struct option long_options[] =
{
{"help", no_argument, NULL, 0},
{"version", no_argument, NULL, 0},
{"version-short", no_argument, NULL, 0},
{"enh", no_argument, NULL, 0},
{"no-enh", no_argument, NULL, 0},
{"pf", no_argument, NULL, 0},
{"no-pf", no_argument, NULL, 0},
{"force-nb", no_argument, NULL, 0},
{"force-wb", no_argument, NULL, 0},
{"force-uwb", no_argument, NULL, 0},
{"rate", required_argument, NULL, 0},
{"mono", no_argument, NULL, 0},
{"stereo", no_argument, NULL, 0},
{"packet-loss", required_argument, NULL, 0},
{0, 0, 0, 0}
};
ogg_sync_state oy;
ogg_page og;
ogg_packet op;
ogg_stream_state os;
int enh_enabled;
int nframes=2;
int print_bitrate=0;
int close_in=0;
int eos=0;
int forceMode=-1;
int audio_size=0;
float loss_percent=-1;
SpeexStereoState stereo = SPEEX_STEREO_STATE_INIT;
int channels=-1;
int rate=0;
int extra_headers;
int wav_format=0;
enh_enabled = 1;
/*Process options*/
while(1)
{
c = getopt_long (argc, argv, "hvV",
long_options, &option_index);
if (c==-1)
break;
switch(c)
{
case 0:
if (strcmp(long_options[option_index].name,"help")==0)
{
usage();
exit(0);
} else if (strcmp(long_options[option_index].name,"version")==0)
{
version();
exit(0);
} else if (strcmp(long_options[option_index].name,"version-short")==0)
{
version_short();
exit(0);
} else if (strcmp(long_options[option_index].name,"enh")==0)
{
enh_enabled=1;
} else if (strcmp(long_options[option_index].name,"no-enh")==0)
{
enh_enabled=0;
} else if (strcmp(long_options[option_index].name,"pf")==0)
{
fprintf (stderr, "--pf is deprecated, use --enh instead\n");
enh_enabled=1;
} else if (strcmp(long_options[option_index].name,"no-pf")==0)
{
fprintf (stderr, "--no-pf is deprecated, use --no-enh instead\n");
enh_enabled=0;
} else if (strcmp(long_options[option_index].name,"force-nb")==0)
{
forceMode=0;
} else if (strcmp(long_options[option_index].name,"force-wb")==0)
{
forceMode=1;
} else if (strcmp(long_options[option_index].name,"force-uwb")==0)
{
forceMode=2;
} else if (strcmp(long_options[option_index].name,"mono")==0)
{
channels=1;
} else if (strcmp(long_options[option_index].name,"stereo")==0)
{
channels=2;
} else if (strcmp(long_options[option_index].name,"rate")==0)
{
rate=atoi (optarg);
} else if (strcmp(long_options[option_index].name,"packet-loss")==0)
{
loss_percent = atof(optarg);
}
break;
case 'h':
usage();
exit(0);
break;
case 'v':
version();
exit(0);
break;
case 'V':
print_bitrate=1;
break;
case '?':
usage();
exit(1);
break;
}
}
if (argc-optind!=2 && argc-optind!=1)
{
usage();
exit(1);
}
inFile=argv[optind];
if (argc-optind==2)
outFile=argv[optind+1];
else
outFile = "";
wav_format = strlen(outFile)>=4 && (
strcmp(outFile+strlen(outFile)-4,".wav")==0
|| strcmp(inFile+strlen(inFile)-4,".WAV")==0);
/*Open input file*/
if (strcmp(inFile, "-")==0)
{
#if defined WIN32 || defined _WIN32
_setmode(_fileno(stdin), _O_BINARY);
#endif
fin=stdin;
}
else
{
#if defined WIN32 || defined _WIN32
fin = fopen(inFile, "rb");
#else
fin = fopen(inFile, "r");
#endif
if (!fin)
{
perror(inFile);
exit(1);
}
close_in=1;
}
/*Init Ogg data struct*/
ogg_sync_init(&oy);
speex_bits_init(&bits);
/*Main decoding loop*/
while (1)
{
char *data;
int i, j, nb_read;
/*Get the ogg buffer for writing*/
data = ogg_sync_buffer(&oy, 200);
/*Read bitstream from input file*/
nb_read = fread(data, sizeof(char), 200, fin);
ogg_sync_wrote(&oy, nb_read);
/*Loop for all complete pages we got (most likely only one)*/
while (ogg_sync_pageout(&oy, &og)==1)
{
if (stream_init == 0) {
ogg_stream_init(&os, ogg_page_serialno(&og));
stream_init = 1;
}
/*Add page to the bitstream*/
ogg_stream_pagein(&os, &og);
/*Extract all available packets*/
while (!eos && ogg_stream_packetout(&os, &op)==1)
{
/*If first packet, process as Speex header*/
if (packet_count==0)
{
st = process_header(&op, enh_enabled, &frame_size, &rate, &nframes, forceMode, &channels, &stereo, &extra_headers);
if (!nframes)
nframes=1;
if (!st)
exit(1);
fout = out_file_open(outFile, rate, &channels);
} else if (packet_count==1)
{
print_comments((char*)op.packet, op.bytes);
} else if (packet_count<=1+extra_headers)
{
/* Ignore extra headers */
} else {
int lost=0;
if (loss_percent>0 && 100*((float)rand())/RAND_MAX<loss_percent)
lost=1;
/*End of stream condition*/
if (op.e_o_s)
eos=1;
/*Copy Ogg packet to Speex bitstream*/
speex_bits_read_from(&bits, (char*)op.packet, op.bytes);
for (j=0;j!=nframes;j++)
{
int ret;
/*Decode frame*/
if (!lost)
ret = speex_decode(st, &bits, output);
else
ret = speex_decode(st, NULL, output);
if (ret==-1)
break;
if (ret==-2)
{
fprintf (stderr, "Decoding error: corrupted stream?\n");
break;
}
if (speex_bits_remaining(&bits)<0)
{
fprintf (stderr, "Decoding overflow: corrupted stream?\n");
break;
}
if (channels==2)
speex_decode_stereo(output, frame_size, &stereo);
if (print_bitrate) {
int tmp;
char ch=13;
speex_decoder_ctl(st, SPEEX_GET_BITRATE, &tmp);
fputc (ch, stderr);
fprintf (stderr, "Bitrate is use: %d bps ", tmp);
}
/*PCM saturation (just in case)*/
for (i=0;i<frame_size*channels;i++)
{
if (output[i]>32000.0)
output[i]=32000.0;
else if (output[i]<-32000.0)
output[i]=-32000.0;
}
/*Convert to short and save to output file*/
if (strlen(outFile)!=0)
{
for (i=0;i<frame_size*channels;i++)
out[i]=(short)le_short((short)floor(.5+output[i]));
} else {
for (i=0;i<frame_size*channels;i++)
out[i]=(short)floor(.5+output[i]);
}
#if defined WIN32 || defined _WIN32
if (strlen(outFile)==0)
WIN_Play_Samples (out, sizeof(short) * frame_size*channels);
else
#endif
fwrite(out, sizeof(short), frame_size*channels, fout);
audio_size+=sizeof(short)*frame_size*channels;
}
}
packet_count++;
}
}
if (feof(fin))
break;
}
if (wav_format)
{
if (fseek(fout,4,SEEK_SET)==0)
{
int tmp;
tmp = le_int(audio_size+36);
fwrite(&tmp,4,1,fout);
if (fseek(fout,32,SEEK_CUR)==0)
{
tmp = le_int(audio_size);
fwrite(&tmp,4,1,fout);
} else
{
fprintf (stderr, "First seek worked, second didn't\n");
}
} else {
fprintf (stderr, "Cannot seek on wave file, size will be incorrect\n");
}
}
if (st)
speex_decoder_destroy(st);
else
{
fprintf (stderr, "This doesn't look like a Speex file\n");
}
speex_bits_destroy(&bits);
if (stream_init)
ogg_stream_clear(&os);
ogg_sync_clear(&oy);
#if defined WIN32 || defined _WIN32
if (strlen(outFile)==0)
WIN_Audio_close ();
#endif
if (close_in)
fclose(fin);
if (fout != NULL)
fclose(fout);
return 0;
}

View File

@ -1,105 +0,0 @@
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.29.
.TH SPEEXENC "1" "December 2002" "speexenc version 1.0" "User Commands"
.SH NAME
speexenc \- manual page for speexenc version 1.0
.SH SYNOPSIS
.B speexenc
[\fIoptions\fR] \fIinput_file output_file\fR
.SH DESCRIPTION
Encodes input_file using Speex. It can read the WAV or raw files.
.SS "input_file can be:"
.TP
filename.wav
wav file
.TP
filename.*
Raw PCM file (any extension other than .wav)
.TP
-
stdin
.SS "output_file can be:"
.TP
filename.spx
Speex file
.TP
-
stdout
.SH OPTIONS
.TP
\fB\-n\fR, \fB\-\-narrowband\fR
Narrowband (8 kHz) input file
.TP
\fB\-w\fR, \fB\-\-wideband\fR
Wideband (16 kHz) input file
.HP
\fB\-u\fR, \fB\-\-ultra\-wideband\fR "Ultra-wideband" (32 kHz) input file
.TP
\fB\-\-quality\fR n
Encoding quality (0-10), default 3
.TP
\fB\-\-bitrate\fR n
Encoding bit-rate (use bit-rate n or lower)
.TP
\fB\-\-vbr\fR
Enable variable bit-rate (VBR)
.TP
\fB\-\-abr\fR rate
Enable average bit-rate (ABR) at rate bps
.TP
\fB\-\-vad\fR
Enable voice activity detection (VAD)
.TP
\fB\-\-dtx\fR
Enable file-based discontinuous transmission (DTX)
.TP
\fB\-\-comp\fR n
Set encoding complexity (0-10), default 3
.TP
\fB\-\-nframes\fR n
Number of frames per Ogg packet (1-10), default 1
.TP
\fB\-\-comment\fR
Add the given string as an extra comment. This may be
used multiple times.
.TP
\fB\-\-author\fR
Author of this track.
.TP
\fB\-\-title\fR
Title for this track.
.TP
\fB\-h\fR, \fB\-\-help\fR
This help
.TP
\fB\-v\fR, \fB\-\-version\fR
Version information
.TP
\fB\-V\fR
Verbose mode (show bit-rate)
.SS "Raw input options:"
.TP
\fB\-\-rate\fR n
Sampling rate for raw input
.TP
\fB\-\-stereo\fR
Consider raw input as stereo
.TP
\fB\-\-le\fR
Raw input is little-endian
.TP
\fB\-\-be\fR
Raw input is big-endian
.TP
\fB\-\-8bit\fR
Raw input is 8-bit unsigned
.TP
\fB\-\-16bit\fR
Raw input is 16-bit signed
.PP
Default raw PCM input is 16-bit, little-endian, mono
.PP
More information is available from the Speex site: http://www.speex.org
.PP
Please report bugs to the mailing list `speex-dev@xiph.org'.
.SH COPYRIGHT
Copyright \(co 2002 Jean-Marc Valin

View File

@ -1,809 +0,0 @@
/* Copyright (C) 2002-2003 Jean-Marc Valin
File: speexenc.c
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of the Xiph.org Foundation nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdio.h>
#if !defined WIN32 && !defined _WIN32
#include <unistd.h>
#include <getopt.h>
#endif
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "speex.h"
#include <ogg.h>
#include "wav_io.h"
#include "speex_header.h"
#include "speex_stereo.h"
#include "misc.h"
#if defined WIN32 || defined _WIN32
#include "getopt_win.h"
/* We need the following two to set stdout to binary */
#include <io.h>
#include <fcntl.h>
#endif
void comment_init(char **comments, int* length, char *vendor_string);
void comment_add(char **comments, int* length, char *tag, char *val);
/*Write an Ogg page to a file pointer*/
int oe_write_page(ogg_page *page, FILE *fp)
{
int written;
written = fwrite(page->header,1,page->header_len, fp);
written += fwrite(page->body,1,page->body_len, fp);
return written;
}
#define MAX_FRAME_SIZE 2000
#define MAX_FRAME_BYTES 2000
/* Convert input audio bits, endians and channels */
static int read_samples(FILE *fin,int frame_size, int bits, int channels, int lsb, float * input, char *buff, int *size)
{
unsigned char in[MAX_FRAME_BYTES*2];
int i;
short *s;
int nb_read;
if (size && *size<=0)
{
return 1;
}
/*Read input audio*/
if (size)
*size -= bits/8*channels*frame_size;
if (buff)
{
for (i=0;i<12;i++)
in[i]=buff[i];
nb_read = fread(in+12,1,bits/8*channels*frame_size-12, fin) + 12;
if (size)
*size += 12;
} else {
nb_read = fread(in,1,bits/8*channels* frame_size, fin);
}
nb_read /= bits/8*channels;
/*fprintf (stderr, "%d\n", nb_read);*/
if (nb_read==0)
return 1;
s=(short*)in;
if(bits==8)
{
/* Convert 8->16 bits */
for(i=frame_size*channels-1;i>=0;i--)
{
s[i]=(in[i]<<8)^0x8000;
}
} else
{
/* convert to our endian format */
for(i=0;i<frame_size*channels;i++)
{
if(lsb)
s[i]=le_short(s[i]);
else
s[i]=be_short(s[i]);
}
}
/* copy to float input buffer */
for (i=0;i<frame_size*channels;i++)
{
input[i]=(short)s[i];
}
for (i=nb_read*channels;i<frame_size*channels;i++)
{
input[i]=0;
}
return 0;
}
void version()
{
printf ("speexenc (Speex encoder) version " VERSION " (compiled " __DATE__ ")\n");
printf ("Copyright (C) 2002-2003 Jean-Marc Valin\n");
}
void version_short()
{
printf ("speexenc version " VERSION "\n");
printf ("Copyright (C) 2002-2003 Jean-Marc Valin\n");
}
void usage()
{
printf ("Usage: speexenc [options] input_file output_file\n");
printf ("\n");
printf ("Encodes input_file using Speex. It can read the WAV or raw files.\n");
printf ("\n");
printf ("input_file can be:\n");
printf (" filename.wav wav file\n");
printf (" filename.* Raw PCM file (any extension other than .wav)\n");
printf (" - stdin\n");
printf ("\n");
printf ("output_file can be:\n");
printf (" filename.spx Speex file\n");
printf (" - stdout\n");
printf ("\n");
printf ("Options:\n");
printf (" -n, --narrowband Narrowband (8 kHz) input file\n");
printf (" -w, --wideband Wideband (16 kHz) input file\n");
printf (" -u, --ultra-wideband \"Ultra-wideband\" (32 kHz) input file\n");
printf (" --quality n Encoding quality (0-10), default 8\n");
printf (" --bitrate n Encoding bit-rate (use bit-rate n or lower)\n");
printf (" --vbr Enable variable bit-rate (VBR)\n");
printf (" --abr rate Enable average bit-rate (ABR) at rate bps\n");
printf (" --vad Enable voice activity detection (VAD)\n");
printf (" --dtx Enable file-based discontinuous transmission (DTX)\n");
printf (" --comp n Set encoding complexity (0-10), default 3\n");
printf (" --nframes n Number of frames per Ogg packet (1-10), default 1\n");
printf (" --comment Add the given string as an extra comment. This may be\n");
printf (" used multiple times.\n");
printf (" --author Author of this track.\n");
printf (" --title Title for this track.\n");
printf (" -h, --help This help\n");
printf (" -v, --version Version information\n");
printf (" -V Verbose mode (show bit-rate)\n");
printf ("Raw input options:\n");
printf (" --rate n Sampling rate for raw input\n");
printf (" --stereo Consider raw input as stereo\n");
printf (" --le Raw input is little-endian\n");
printf (" --be Raw input is big-endian\n");
printf (" --8bit Raw input is 8-bit unsigned\n");
printf (" --16bit Raw input is 16-bit signed\n");
printf ("Default raw PCM input is 16-bit, little-endian, mono\n");
printf ("\n");
printf ("More information is available from the Speex site: http://www.speex.org\n");
printf ("\n");
printf ("Please report bugs to the mailing list `speex-dev@xiph.org'.\n");
}
int main(int argc, char **argv)
{
int c;
int option_index = 0;
char *inFile, *outFile;
FILE *fin, *fout;
float input[MAX_FRAME_SIZE];
int frame_size;
int vbr_enabled=0;
int abr_enabled=0;
int vad_enabled=0;
int dtx_enabled=0;
int nbBytes;
SpeexMode *mode=NULL;
void *st;
SpeexBits bits;
char cbits[MAX_FRAME_BYTES];
struct option long_options[] =
{
{"wideband", no_argument, NULL, 0},
{"ultra-wideband", no_argument, NULL, 0},
{"narrowband", no_argument, NULL, 0},
{"vbr", no_argument, NULL, 0},
{"abr", required_argument, NULL, 0},
{"vad", no_argument, NULL, 0},
{"dtx", no_argument, NULL, 0},
{"quality", required_argument, NULL, 0},
{"bitrate", required_argument, NULL, 0},
{"nframes", required_argument, NULL, 0},
{"comp", required_argument, NULL, 0},
{"help", no_argument, NULL, 0},
{"le", no_argument, NULL, 0},
{"be", no_argument, NULL, 0},
{"8bit", no_argument, NULL, 0},
{"16bit", no_argument, NULL, 0},
{"stereo", no_argument, NULL, 0},
{"rate", required_argument, NULL, 0},
{"version", no_argument, NULL, 0},
{"version-short", no_argument, NULL, 0},
{"comment", required_argument, NULL, 0},
{"author", required_argument, NULL, 0},
{"title", required_argument, NULL, 0},
{0, 0, 0, 0}
};
int print_bitrate=0;
int rate=0, size;
int chan=1;
int fmt=16;
int quality=-1;
float vbr_quality=-1;
int lsb=1;
ogg_stream_state os;
ogg_page og;
ogg_packet op;
int bytes_written=0, ret, result;
int id=-1;
SpeexHeader header;
int nframes=1;
int complexity=3;
char *vendor_string = "Encoded with Speex " VERSION;
char *comments;
int comments_length;
int close_in=0, close_out=0;
int eos=0;
int bitrate=0;
double cumul_bits=0, enc_frames=0;
char first_bytes[12];
int wave_input=0;
int tmp;
comment_init(&comments, &comments_length, vendor_string);
/*Process command-line options*/
while(1)
{
c = getopt_long (argc, argv, "nwuhvV",
long_options, &option_index);
if (c==-1)
break;
switch(c)
{
case 0:
if (strcmp(long_options[option_index].name,"narrowband")==0)
{
mode=&speex_nb_mode;
} else if (strcmp(long_options[option_index].name,"wideband")==0)
{
mode=&speex_wb_mode;
} else if (strcmp(long_options[option_index].name,"ultra-wideband")==0)
{
mode=&speex_uwb_mode;
} else if (strcmp(long_options[option_index].name,"vbr")==0)
{
vbr_enabled=1;
} else if (strcmp(long_options[option_index].name,"abr")==0)
{
abr_enabled=atoi(optarg);
if (!abr_enabled)
{
fprintf (stderr, "Invalid ABR value: %d\n", abr_enabled);
exit(1);
}
} else if (strcmp(long_options[option_index].name,"vad")==0)
{
vad_enabled=1;
} else if (strcmp(long_options[option_index].name,"dtx")==0)
{
dtx_enabled=1;
} else if (strcmp(long_options[option_index].name,"quality")==0)
{
quality = atoi (optarg);
vbr_quality=atof(optarg);
} else if (strcmp(long_options[option_index].name,"bitrate")==0)
{
bitrate = atoi (optarg);
} else if (strcmp(long_options[option_index].name,"nframes")==0)
{
nframes = atoi (optarg);
if (nframes<1)
nframes=1;
if (nframes>10)
nframes=10;
} else if (strcmp(long_options[option_index].name,"comp")==0)
{
complexity = atoi (optarg);
} else if (strcmp(long_options[option_index].name,"help")==0)
{
usage();
exit(0);
} else if (strcmp(long_options[option_index].name,"version")==0)
{
version();
exit(0);
} else if (strcmp(long_options[option_index].name,"version-short")==0)
{
version_short();
exit(0);
} else if (strcmp(long_options[option_index].name,"le")==0)
{
lsb=1;
} else if (strcmp(long_options[option_index].name,"be")==0)
{
lsb=0;
} else if (strcmp(long_options[option_index].name,"8bit")==0)
{
fmt=8;
} else if (strcmp(long_options[option_index].name,"16bit")==0)
{
fmt=16;
} else if (strcmp(long_options[option_index].name,"stereo")==0)
{
chan=2;
} else if (strcmp(long_options[option_index].name,"rate")==0)
{
rate=atoi (optarg);
} else if (strcmp(long_options[option_index].name,"comment")==0)
{
comment_add(&comments, &comments_length, NULL, optarg);
} else if (strcmp(long_options[option_index].name,"author")==0)
{
comment_add(&comments, &comments_length, "author=", optarg);
} else if (strcmp(long_options[option_index].name,"title")==0)
{
comment_add(&comments, &comments_length, "title=", optarg);
}
break;
case 'n':
mode=&speex_nb_mode;
break;
case 'h':
usage();
exit(0);
break;
case 'v':
version();
exit(0);
break;
case 'V':
print_bitrate=1;
break;
case 'w':
mode=&speex_wb_mode;
break;
case 'u':
mode=&speex_uwb_mode;
break;
case '?':
usage();
exit(1);
break;
}
}
if (argc-optind!=2)
{
usage();
exit(1);
}
inFile=argv[optind];
outFile=argv[optind+1];
/*Initialize Ogg stream struct*/
srand(time(NULL));
if (ogg_stream_init(&os, rand())==-1)
{
fprintf(stderr,"Error: stream init failed\n");
exit(1);
}
if (strcmp(inFile, "-")==0)
{
#if defined WIN32 || defined _WIN32
_setmode(_fileno(stdin), _O_BINARY);
#endif
fin=stdin;
}
else
{
#if defined WIN32 || defined _WIN32
fin = fopen(inFile, "rb");
#else
fin = fopen(inFile, "r");
#endif
if (!fin)
{
perror(inFile);
exit(1);
}
close_in=1;
}
{
fread(first_bytes, 1, 12, fin);
if (strncmp(first_bytes,"RIFF",4)==0 && strncmp(first_bytes,"RIFF",4)==0)
{
if (read_wav_header(fin, &rate, &chan, &fmt, &size)==-1)
exit(1);
wave_input=1;
lsb=1; /* CHECK: exists big-endian .wav ?? */
}
}
if (!mode && !rate)
{
/* By default, use narrowband/8 kHz */
mode=&speex_nb_mode;
rate=8000;
} else if (mode && rate)
{
if (rate>48000)
{
fprintf (stderr, "Error: sampling rate too high: %d Hz, try down-sampling\n", rate);
exit(1);
} else if (rate>25000)
{
if (mode!=&speex_uwb_mode)
{
fprintf (stderr, "Warning: Trying to encode in %s at %d Hz. I'll do it but I suggest you try ultra-wideband instead\n", mode->modeName , rate);
}
} else if (rate>12500)
{
if (mode!=&speex_wb_mode)
{
fprintf (stderr, "Warning: Trying to encode in %s at %d Hz. I'll do it but I suggest you try wideband instead\n", mode->modeName , rate);
}
} else if (rate>=6000)
{
if (mode!=&speex_nb_mode)
{
fprintf (stderr, "Warning: Trying to encode in %s at %d Hz. I'll do it but I suggest you try narrowband instead\n", mode->modeName , rate);
}
} else {
fprintf (stderr, "Error: sampling rate too low: %d Hz\n", rate);
exit(1);
}
} else if (!mode)
{
if (rate>48000)
{
fprintf (stderr, "Error: sampling rate too high: %d Hz, try down-sampling\n", rate);
exit(1);
} else if (rate>25000)
{
mode=&speex_uwb_mode;
} else if (rate>12500)
{
mode=&speex_wb_mode;
} else if (rate>=6000)
{
mode=&speex_nb_mode;
} else {
fprintf (stderr, "Error: Sampling rate too low: %d Hz\n", rate);
exit(1);
}
} else if (!rate)
{
if (mode==&speex_nb_mode)
rate=8000;
else if (mode==&speex_wb_mode)
rate=16000;
else if (mode==&speex_uwb_mode)
rate=32000;
}
if (rate!=8000 && rate!=16000 && rate!=32000)
fprintf (stderr, "Warning: Speex is only optimized for 8, 16 and 32 kHz. It will still work at %d Hz but your mileage may vary\n", rate);
speex_init_header(&header, rate, 1, mode);
header.frames_per_packet=nframes;
header.vbr=vbr_enabled;
header.nb_channels = chan;
{
char *st_string="mono";
if (chan==2)
st_string="stereo";
fprintf (stderr, "Encoding %d Hz audio using %s mode (%s)\n",
header.rate, mode->modeName, st_string);
}
/*fprintf (stderr, "Encoding %d Hz audio at %d bps using %s mode\n",
header.rate, mode->bitrate, mode->modeName);*/
/*Initialize Speex encoder*/
st = speex_encoder_init(mode);
if (strcmp(outFile,"-")==0)
{
#if defined WIN32 || defined _WIN32
_setmode(_fileno(stdout), _O_BINARY);
#endif
fout=stdout;
}
else
{
#if defined WIN32 || defined _WIN32
fout = fopen(outFile, "wb");
#else
fout = fopen(outFile, "w");
#endif
if (!fout)
{
perror(outFile);
exit(1);
}
close_out=1;
}
/*Write header (format will change)*/
{
op.packet = (unsigned char *)speex_header_to_packet(&header, (int*)&(op.bytes));
op.b_o_s = 1;
op.e_o_s = 0;
op.granulepos = 0;
op.packetno = 0;
ogg_stream_packetin(&os, &op);
free(op.packet);
op.packet = (unsigned char *)comments;
op.bytes = comments_length;
op.b_o_s = 0;
op.e_o_s = 0;
op.granulepos = 0;
op.packetno = 1;
ogg_stream_packetin(&os, &op);
while((result = ogg_stream_flush(&os, &og)))
{
if(!result) break;
ret = oe_write_page(&og, fout);
if(ret != og.header_len + og.body_len)
{
fprintf (stderr,"Error: failed writing header to output stream\n");
exit(1);
}
else
bytes_written += ret;
}
}
free(comments);
speex_encoder_ctl(st, SPEEX_GET_FRAME_SIZE, &frame_size);
speex_encoder_ctl(st, SPEEX_SET_COMPLEXITY, &complexity);
speex_encoder_ctl(st, SPEEX_SET_SAMPLING_RATE, &rate);
if (quality >= 0)
{
if (vbr_enabled)
speex_encoder_ctl(st, SPEEX_SET_VBR_QUALITY, &vbr_quality);
else
speex_encoder_ctl(st, SPEEX_SET_QUALITY, &quality);
}
if (bitrate)
{
if (quality >= 0 && vbr_enabled)
fprintf (stderr, "Warning: --bitrate option is overriding --quality\n");
speex_encoder_ctl(st, SPEEX_SET_BITRATE, &bitrate);
}
if (vbr_enabled)
{
tmp=1;
speex_encoder_ctl(st, SPEEX_SET_VBR, &tmp);
} else if (vad_enabled)
{
tmp=1;
speex_encoder_ctl(st, SPEEX_SET_VAD, &tmp);
}
if (dtx_enabled)
speex_encoder_ctl(st, SPEEX_SET_DTX, &tmp);
if (dtx_enabled && !(vbr_enabled || abr_enabled || vad_enabled))
{
fprintf (stderr, "Warning: --dtx is useless without --vad, --vbr or --abr\n");
} else if ((vbr_enabled || abr_enabled) && (vad_enabled))
{
fprintf (stderr, "Warning: --vad is already implied by --vbr or --abr\n");
}
if (abr_enabled)
{
speex_encoder_ctl(st, SPEEX_SET_ABR, &abr_enabled);
}
speex_bits_init(&bits);
if (!wave_input)
{
if (read_samples(fin,frame_size,fmt,chan,lsb,input, first_bytes, NULL))
eos=1;
} else {
if (read_samples(fin,frame_size,fmt,chan,lsb,input, NULL, &size))
eos=1;
}
/*Main encoding loop (one frame per iteration)*/
while (!eos)
{
id++;
/*Encode current frame*/
if (chan==2)
speex_encode_stereo(input, frame_size, &bits);
speex_encode(st, input, &bits);
if (print_bitrate) {
int tmp;
char ch=13;
speex_encoder_ctl(st, SPEEX_GET_BITRATE, &tmp);
fputc (ch, stderr);
cumul_bits += tmp;
enc_frames += 1;
if (vad_enabled || vbr_enabled || abr_enabled)
fprintf (stderr, "Bitrate is use: %d bps (average %d bps) ", tmp, (int)(cumul_bits/enc_frames));
else
fprintf (stderr, "Bitrate is use: %d bps ", tmp);
}
if (wave_input)
{
if (read_samples(fin,frame_size,fmt,chan,lsb,input, NULL, &size))
{
eos=1;
op.e_o_s = 1;
}
} else {
if (read_samples(fin,frame_size,fmt,chan,lsb,input, NULL, NULL))
{
eos=1;
op.e_o_s = 1;
}
}
if ((id+1)%nframes!=0)
continue;
speex_bits_insert_terminator(&bits);
nbBytes = speex_bits_write(&bits, cbits, MAX_FRAME_BYTES);
speex_bits_reset(&bits);
op.packet = (unsigned char *)cbits;
op.bytes = nbBytes;
op.b_o_s = 0;
if (eos)
op.e_o_s = 1;
else
op.e_o_s = 0;
op.granulepos = (id+nframes)*frame_size;
op.packetno = 2+id/nframes;
ogg_stream_packetin(&os, &op);
/*Write all new pages (most likely 0 or 1)*/
while (ogg_stream_pageout(&os,&og))
{
ret = oe_write_page(&og, fout);
if(ret != og.header_len + og.body_len)
{
fprintf (stderr,"Error: failed writing header to output stream\n");
exit(1);
}
else
bytes_written += ret;
}
}
if ((id+1)%nframes!=0)
{
while ((id+1)%nframes!=0)
{
id++;
speex_bits_pack(&bits, 15, 5);
}
nbBytes = speex_bits_write(&bits, cbits, MAX_FRAME_BYTES);
op.packet = (unsigned char *)cbits;
op.bytes = nbBytes;
op.b_o_s = 0;
op.e_o_s = 1;
op.granulepos = (id+nframes)*frame_size;
op.packetno = 2+id/nframes;
ogg_stream_packetin(&os, &op);
}
/*Flush all pages left to be written*/
while (ogg_stream_flush(&os, &og))
{
ret = oe_write_page(&og, fout);
if(ret != og.header_len + og.body_len)
{
fprintf (stderr,"Error: failed writing header to output stream\n");
exit(1);
}
else
bytes_written += ret;
}
speex_encoder_destroy(st);
speex_bits_destroy(&bits);
ogg_stream_clear(&os);
if (close_in)
fclose(fin);
if (close_out)
fclose(fout);
return 0;
}
/*
Comments will be stored in the Vorbis style.
It is describled in the "Structure" section of
http://www.xiph.org/ogg/vorbis/doc/v-comment.html
The comment header is decoded as follows:
1) [vendor_length] = read an unsigned integer of 32 bits
2) [vendor_string] = read a UTF-8 vector as [vendor_length] octets
3) [user_comment_list_length] = read an unsigned integer of 32 bits
4) iterate [user_comment_list_length] times {
5) [length] = read an unsigned integer of 32 bits
6) this iteration's user comment = read a UTF-8 vector as [length] octets
}
7) [framing_bit] = read a single bit as boolean
8) if ( [framing_bit] unset or end of packet ) then ERROR
9) done.
If you have troubles, please write to ymnk@jcraft.com.
*/
#define readint(buf, base) (((buf[base+3]<<24)&0xff000000)| \
((buf[base+2]<<16)&0xff0000)| \
((buf[base+1]<<8)&0xff00)| \
(buf[base]&0xff))
#define writeint(buf, base, val) do{ buf[base+3]=((val)>>24)&0xff; \
buf[base+2]=((val)>>16)&0xff; \
buf[base+1]=((val)>>8)&0xff; \
buf[base]=(val)&0xff; \
}while(0)
void comment_init(char **comments, int* length, char *vendor_string)
{
int vendor_length=strlen(vendor_string);
int user_comment_list_length=0;
int len=4+vendor_length+4;
char *p=(char*)malloc(len);
if(p==NULL){
}
writeint(p, 0, vendor_length);
memcpy(p+4, vendor_string, vendor_length);
writeint(p, 4+vendor_length, user_comment_list_length);
*length=len;
*comments=p;
}
void comment_add(char **comments, int* length, char *tag, char *val)
{
char* p=*comments;
int vendor_length=readint(p, 0);
int user_comment_list_length=readint(p, 4+vendor_length);
int tag_len=(tag?strlen(tag):0);
int val_len=strlen(val);
int len=(*length)+4+tag_len+val_len;
p=(char*)realloc(p, len);
if(p==NULL){
}
writeint(p, *length, tag_len+val_len); /* length of comment */
if(tag) memcpy(p+*length+4, tag, tag_len); /* comment */
memcpy(p+*length+4+tag_len, val, val_len); /* comment */
writeint(p, 4+vendor_length, user_comment_list_length+1);
*comments=p;
*length=len;
}
#undef readint
#undef writeint

View File

@ -1,226 +0,0 @@
/* Copyright (C) 2002 Jean-Marc Valin
File: wav_io.c
Routines to handle wav (RIFF) headers
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of the Xiph.org Foundation nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdio.h>
#include <string.h>
#include "misc.h"
int read_wav_header(FILE *file, int *rate, int *channels, int *format, int *size)
{
char ch[5];
int itmp;
short stmp;
int bpersec;
short balign;
int skip_bytes;
int i;
ch[4]=0;
#if 0
fread(ch, 1, 4, file);
if (strcmp(ch, "RIFF")!=0)
{
fseek(file, 0, SEEK_SET);
return 0;
}
fread(&itmp, 4, 1, file);
*size = le_int(itmp-36);
fread(ch, 1, 4, file);
if (strcmp(ch, "WAVE")!=0)
{
fprintf (stderr, "RIFF file is not a WAVE file\n");
return -1;
}
#endif
fread(ch, 1, 4, file);
while (strcmp(ch, "fmt ")!=0)
{
fread(&itmp, 4, 1, file);
itmp = le_int(itmp);
/*fprintf (stderr, "skip=%d\n", itmp);*/
/*strange way of seeking, but it works even for pipes*/
for (i=0;i<itmp;i++)
fgetc(file);
/*fseek(file, itmp, SEEK_CUR);*/
fread(ch, 1, 4, file);
if (feof(file))
{
fprintf (stderr, "Corrupted WAVE file: no \"fmt \"\n");
return -1;
}
}
/*if (strcmp(ch, "fmt ")!=0)
{
fprintf (stderr, "Corrupted WAVE file: no \"fmt \"\n");
return -1;
}*/
fread(&itmp, 4, 1, file);
itmp = le_int(itmp);
skip_bytes=itmp-16;
/*fprintf (stderr, "skip=%d\n", skip_bytes);*/
fread(&stmp, 2, 1, file);
stmp = le_short(stmp);
if (stmp!=1)
{
fprintf (stderr, "Only PCM encoding is supported\n");
return -1;
}
fread(&stmp, 2, 1, file);
stmp = le_short(stmp);
*channels = stmp;
if (stmp>2)
{
fprintf (stderr, "Only mono and (intensity) stereo supported\n");
return -1;
}
fread(&itmp, 4, 1, file);
itmp = le_int(itmp);
*rate = itmp;
if (*rate != 8000 && *rate != 16000 && *rate != 11025 && *rate != 22050 && *rate != 32000 && *rate != 44100 && *rate != 48000)
{
fprintf (stderr, "Only 8 kHz (narrowband) and 16 kHz (wideband) supported (plus 11.025 kHz and 22.05 kHz, but your mileage may vary)\n");
return -1;
}
fread(&itmp, 4, 1, file);
bpersec = le_int(itmp);
fread(&stmp, 2, 1, file);
balign = le_short(stmp);
fread(&stmp, 2, 1, file);
stmp = le_short(stmp);
if (stmp!=16 && stmp!=8)
{
fprintf (stderr, "Only 8/16-bit linear supported\n");
return -1;
}
*format=stmp;
if (bpersec!=*rate**channels*stmp/8)
{
fprintf (stderr, "Corrupted header: ByteRate mismatch\n");
return -1;
}
if (balign!=*channels*stmp/8)
{
fprintf (stderr, "Corrupted header: BlockAlign mismatch\n");
return -1;
}
/*strange way of seeking, but it works even for pipes*/
if (skip_bytes>0)
for (i=0;i<skip_bytes;i++)
fgetc(file);
/*fseek(file, skip_bytes, SEEK_CUR);*/
fread(ch, 1, 4, file);
while (strcmp(ch, "data")!=0)
{
fread(&itmp, 4, 1, file);
itmp = le_int(itmp);
/*strange way of seeking, but it works even for pipes*/
for (i=0;i<itmp;i++)
fgetc(file);
/*fseek(file, itmp, SEEK_CUR);*/
fread(ch, 1, 4, file);
if (feof(file))
{
fprintf (stderr, "Corrupted WAVE file: no \"data\"\n");
return -1;
}
}
/*Ignore this for now*/
fread(&itmp, 4, 1, file);
itmp = le_int(itmp);
*size=itmp;
return 1;
}
void write_wav_header(FILE *file, int rate, int channels, int format, int size)
{
char ch[5];
int itmp;
short stmp;
ch[4]=0;
fprintf (file, "RIFF");
itmp = 0x7fffffff;
fwrite(&itmp, 4, 1, file);
fprintf (file, "WAVEfmt ");
itmp = le_int(16);
fwrite(&itmp, 4, 1, file);
stmp = le_short(1);
fwrite(&stmp, 2, 1, file);
stmp = le_short(channels);
fwrite(&stmp, 2, 1, file);
itmp = le_int(rate);
fwrite(&itmp, 4, 1, file);
itmp = le_int(rate*channels*2);
fwrite(&itmp, 4, 1, file);
stmp = le_short(2*channels);
fwrite(&stmp, 2, 1, file);
stmp = le_short(16);
fwrite(&stmp, 2, 1, file);
fprintf (file, "data");
itmp = le_int(0x7fffffff);
fwrite(&itmp, 4, 1, file);
}

View File

@ -1,40 +0,0 @@
/* Copyright (C) 2002 Jean-Marc Valin
File: wav_io.h
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of the Xiph.org Foundation nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef WAV_IO_H
#include <stdio.h>
int read_wav_header(FILE *file, int *rate, int *channels, int *format, int *size);
void write_wav_header(FILE *file, int rate, int channels, int format, int size);
#endif

View File

@ -1,216 +0,0 @@
/* Copyright (c) 2002, John Edwards
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of the Xiph.org Foundation nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/* Set TABS = 4 */
/********************************************************************
function: To provide playback of 16 bit PCM wave data in Win32
environments from decoded compressed files.
********************************************************************/
#if defined WIN32 || defined _WIN32
#include <string.h>
#include <errno.h>
#include "wave_out.h"
#define MAXWAVESIZE 4294967040LU
#define MAX_WAVEBLOCKS 32
// This is modified for USE_WIN_AUDIO - ONLY 2002-02-27
static CRITICAL_SECTION cs;
static HWAVEOUT dev = NULL;
static int ScheduledBlocks = 0;
static int PlayedWaveHeadersCount = 0; // free index
static WAVEHDR* PlayedWaveHeaders [MAX_WAVEBLOCKS];
static int
Box ( const char* msg )
{
MessageBox ( NULL, msg, " "VERSION_STRING": Error Message . . .", MB_OK | MB_ICONEXCLAMATION );
return -1;
}
/*
* This function registers already played WAVE chunks. Freeing is done by free_memory(),
*/
static void CALLBACK
wave_callback ( HWAVE hWave, UINT uMsg, DWORD dwInstance, DWORD dwParam1, DWORD dwParam2 )
{
if ( uMsg == WOM_DONE ) {
EnterCriticalSection ( &cs );
PlayedWaveHeaders [PlayedWaveHeadersCount++] = (WAVEHDR*) dwParam1;
LeaveCriticalSection ( &cs );
}
}
static void
free_memory ( void )
{
WAVEHDR* wh;
HGLOBAL hg;
EnterCriticalSection ( &cs );
wh = PlayedWaveHeaders [--PlayedWaveHeadersCount];
ScheduledBlocks--; // decrease the number of USED blocks
LeaveCriticalSection ( &cs );
waveOutUnprepareHeader ( dev, wh, sizeof (WAVEHDR) );
hg = GlobalHandle ( wh -> lpData ); // Deallocate the buffer memory
GlobalUnlock (hg);
GlobalFree (hg);
hg = GlobalHandle ( wh ); // Deallocate the header memory
GlobalUnlock (hg);
GlobalFree (hg);
}
Int
Set_WIN_Params ( FILE_T dummyFile ,
Ldouble SampleFreq,
Uint BitsPerSample,
Uint Channels )
{
WAVEFORMATEX outFormat;
UINT deviceID = WAVE_MAPPER;
(void) dummyFile;
if ( waveOutGetNumDevs () == 0 )
return Box ( "No audio device present." );
outFormat.wFormatTag = WAVE_FORMAT_PCM;
outFormat.wBitsPerSample = BitsPerSample;
outFormat.nChannels = Channels;
outFormat.nSamplesPerSec = (unsigned long)(SampleFreq + 0.5);
outFormat.nBlockAlign = (outFormat.wBitsPerSample + 7) / 8 * outFormat.nChannels;
outFormat.nAvgBytesPerSec = outFormat.nSamplesPerSec * outFormat.nBlockAlign;
switch ( waveOutOpen ( &dev, deviceID, &outFormat, (DWORD)wave_callback, 0, CALLBACK_FUNCTION ) )
{
case MMSYSERR_ALLOCATED: return Box ( "Device is already open." );
case MMSYSERR_BADDEVICEID: return Box ( "The specified device is out of range." );
case MMSYSERR_NODRIVER: return Box ( "There is no audio driver in this system." );
case MMSYSERR_NOMEM: return Box ( "Unable to allocate sound memory." );
case WAVERR_BADFORMAT: return Box ( "This audio format is not supported." );
case WAVERR_SYNC: return Box ( "The device is synchronous." );
default: return Box ( "Unknown media error." );
case MMSYSERR_NOERROR: break;
}
waveOutReset ( dev );
InitializeCriticalSection ( &cs );
SetPriorityClass ( GetCurrentProcess (), HIGH_PRIORITY_CLASS );
return 0;
}
int
WIN_Play_Samples ( const void* data, size_t len )
{
HGLOBAL hg;
HGLOBAL hg2;
LPWAVEHDR wh;
void* allocptr;
do {
while ( PlayedWaveHeadersCount > 0 ) // free used blocks ...
free_memory ();
if ( ScheduledBlocks < sizeof(PlayedWaveHeaders)/sizeof(*PlayedWaveHeaders) ) // wait for a free block ...
break;
Sleep (26);
} while (1);
if ( (hg2 = GlobalAlloc ( GMEM_MOVEABLE, len )) == NULL ) // allocate some memory for a copy of the buffer
return Box ( "GlobalAlloc failed." );
allocptr = GlobalLock (hg2);
CopyMemory ( allocptr, data, len ); // Here we can call any modification output functions we want....
if ( (hg = GlobalAlloc (GMEM_MOVEABLE | GMEM_ZEROINIT, sizeof (WAVEHDR))) == NULL ) // now make a header and WRITE IT!
return -1;
wh = GlobalLock (hg);
wh -> dwBufferLength = len;
wh -> lpData = allocptr;
if ( waveOutPrepareHeader ( dev, wh, sizeof (WAVEHDR)) != MMSYSERR_NOERROR ) {
GlobalUnlock (hg);
GlobalFree (hg);
return -1;
}
if ( waveOutWrite ( dev, wh, sizeof (WAVEHDR)) != MMSYSERR_NOERROR ) {
GlobalUnlock (hg);
GlobalFree (hg);
return -1;
}
EnterCriticalSection ( &cs );
ScheduledBlocks++;
LeaveCriticalSection ( &cs );
return len;
}
int
WIN_Audio_close ( void )
{
if ( dev != NULL ) {
while ( ScheduledBlocks > 0 ) {
Sleep (ScheduledBlocks);
while ( PlayedWaveHeadersCount > 0 ) // free used blocks ...
free_memory ();
}
waveOutReset (dev); // reset the device
waveOutClose (dev); // close the device
dev = NULL;
}
DeleteCriticalSection ( &cs );
ScheduledBlocks = 0;
return 0;
}
#endif
/* end of wave_out.c */

View File

@ -1,65 +0,0 @@
/* Copyright (c) 2002, John Edwards
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of the Xiph.org Foundation nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
// WAVE_OUT.H - Necessary stuff for WIN_AUDIO
#include <stdio.h>
#include <windows.h>
#define VERSION_STRING "\n 0.7.0\n"
#define Cdecl __cdecl
#define __attribute__(x)
#define sleep(__sec) Sleep ((__sec) * 1000)
#define inline __inline
#define restrict
//// constants /////////////////////////////////////////////////////
#define CD_SAMPLE_FREQ 44.1e3
#define SAMPLE_SIZE 16
#define SAMPLE_SIZE_STRING ""
#define WINAUDIO_FD ((FILE_T)-128)
#define FILE_T FILE*
#define INVALID_FILEDESC NULL
//// Simple types //////////////////////////////////////////////////
typedef signed int Int; // at least -32767...+32767, fast type
typedef unsigned int Uint; // at least 0...65535, fast type
typedef long double Ldouble; // most exact floating point format
//// procedures/functions //////////////////////////////////////////
// wave_out.c
Int Set_WIN_Params ( FILE_T dummyFile , Ldouble SampleFreq, Uint BitsPerSample, Uint Channels);
int WIN_Play_Samples ( const void* buff, size_t len );
int WIN_Audio_close ( void );

View File

@ -1,7 +0,0 @@
## Process this file with automake to produce Makefile.in. -*-Makefile-*-
# Disable automatic dependency tracking if using other tools than gcc and gmake
#AUTOMAKE_OPTIONS = no-dependencies
SUBDIRS = libspeex speexenc speexdec

View File

@ -1,294 +0,0 @@
# Makefile.in generated automatically by automake 1.4-p6 from Makefile.am
# Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
# Disable automatic dependency tracking if using other tools than gcc and gmake
#AUTOMAKE_OPTIONS = no-dependencies
SHELL = @SHELL@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
sbindir = @sbindir@
libexecdir = @libexecdir@
datadir = @datadir@
sysconfdir = @sysconfdir@
sharedstatedir = @sharedstatedir@
localstatedir = @localstatedir@
libdir = @libdir@
infodir = @infodir@
mandir = @mandir@
includedir = @includedir@
oldincludedir = /usr/include
DESTDIR =
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
top_builddir = ..
ACLOCAL = @ACLOCAL@
AUTOCONF = @AUTOCONF@
AUTOMAKE = @AUTOMAKE@
AUTOHEADER = @AUTOHEADER@
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
INSTALL_DATA = @INSTALL_DATA@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
transform = @program_transform_name@
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
host_alias = @host_alias@
host_triplet = @host@
AS = @AS@
CC = @CC@
DLLTOOL = @DLLTOOL@
ECHO = @ECHO@
EXEEXT = @EXEEXT@
LIBTOOL = @LIBTOOL@
LN_S = @LN_S@
MAINT = @MAINT@
MAKEINFO = @MAKEINFO@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
OGG_INCLUDES = @OGG_INCLUDES@
OGG_LDFLAGS = @OGG_LDFLAGS@
OGG_LIBS = @OGG_LIBS@
PACKAGE = @PACKAGE@
RANLIB = @RANLIB@
SPEEX_LT_AGE = @SPEEX_LT_AGE@
SPEEX_LT_CURRENT = @SPEEX_LT_CURRENT@
SPEEX_LT_REVISION = @SPEEX_LT_REVISION@
STRIP = @STRIP@
VERSION = @VERSION@
src = @src@
SUBDIRS = libspeex speexenc speexdec
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_CLEAN_FILES =
DIST_COMMON = Makefile.am Makefile.in
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
TAR = gtar
GZIP_ENV = --best
all: all-redirect
.SUFFIXES:
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps win32/Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
cd $(top_builddir) \
&& CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
# This directory's subdirectories are mostly independent; you can cd
# into them and run `make' without going through this Makefile.
# To change the values of `make' variables: instead of editing Makefiles,
# (1) if the variable is set in `config.status', edit `config.status'
# (which will cause the Makefiles to be regenerated when you run `make');
# (2) otherwise, pass the desired values on the `make' command line.
@SET_MAKE@
all-recursive install-data-recursive install-exec-recursive \
installdirs-recursive install-recursive uninstall-recursive \
check-recursive installcheck-recursive info-recursive dvi-recursive:
@set fnord $(MAKEFLAGS); amf=$$2; \
dot_seen=no; \
target=`echo $@ | sed s/-recursive//`; \
list='$(SUBDIRS)'; for subdir in $$list; do \
echo "Making $$target in $$subdir"; \
if test "$$subdir" = "."; then \
dot_seen=yes; \
local_target="$$target-am"; \
else \
local_target="$$target"; \
fi; \
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|| case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
done; \
if test "$$dot_seen" = "no"; then \
$(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
fi; test -z "$$fail"
mostlyclean-recursive clean-recursive distclean-recursive \
maintainer-clean-recursive:
@set fnord $(MAKEFLAGS); amf=$$2; \
dot_seen=no; \
rev=''; list='$(SUBDIRS)'; for subdir in $$list; do \
rev="$$subdir $$rev"; \
test "$$subdir" != "." || dot_seen=yes; \
done; \
test "$$dot_seen" = "no" && rev=". $$rev"; \
target=`echo $@ | sed s/-recursive//`; \
for subdir in $$rev; do \
echo "Making $$target in $$subdir"; \
if test "$$subdir" = "."; then \
local_target="$$target-am"; \
else \
local_target="$$target"; \
fi; \
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|| case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
done && test -z "$$fail"
tags-recursive:
list='$(SUBDIRS)'; for subdir in $$list; do \
test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
done
tags: TAGS
ID: $(HEADERS) $(SOURCES) $(LISP)
list='$(SOURCES) $(HEADERS)'; \
unique=`for i in $$list; do echo $$i; done | \
awk ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
here=`pwd` && cd $(srcdir) \
&& mkid -f$$here/ID $$unique $(LISP)
TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SUBDIRS)'; for subdir in $$list; do \
if test "$$subdir" = .; then :; else \
test -f $$subdir/TAGS && tags="$$tags -i $$here/$$subdir/TAGS"; \
fi; \
done; \
list='$(SOURCES) $(HEADERS)'; \
unique=`for i in $$list; do echo $$i; done | \
awk ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \
|| (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS)
mostlyclean-tags:
clean-tags:
distclean-tags:
-rm -f TAGS ID
maintainer-clean-tags:
distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
subdir = win32
distdir: $(DISTFILES)
@for file in $(DISTFILES); do \
d=$(srcdir); \
if test -d $$d/$$file; then \
cp -pr $$d/$$file $(distdir)/$$file; \
else \
test -f $(distdir)/$$file \
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
|| cp -p $$d/$$file $(distdir)/$$file || :; \
fi; \
done
for subdir in $(SUBDIRS); do \
if test "$$subdir" = .; then :; else \
test -d $(distdir)/$$subdir \
|| mkdir $(distdir)/$$subdir \
|| exit 1; \
chmod 777 $(distdir)/$$subdir; \
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir=../$(top_distdir) distdir=../$(distdir)/$$subdir distdir) \
|| exit 1; \
fi; \
done
info-am:
info: info-recursive
dvi-am:
dvi: dvi-recursive
check-am: all-am
check: check-recursive
installcheck-am:
installcheck: installcheck-recursive
install-exec-am:
install-exec: install-exec-recursive
install-data-am:
install-data: install-data-recursive
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
install: install-recursive
uninstall-am:
uninstall: uninstall-recursive
all-am: Makefile
all-redirect: all-recursive
install-strip:
$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
installdirs: installdirs-recursive
installdirs-am:
mostlyclean-generic:
clean-generic:
distclean-generic:
-rm -f Makefile $(CONFIG_CLEAN_FILES)
-rm -f config.cache config.log stamp-h stamp-h[0-9]*
maintainer-clean-generic:
mostlyclean-am: mostlyclean-tags mostlyclean-generic
mostlyclean: mostlyclean-recursive
clean-am: clean-tags clean-generic mostlyclean-am
clean: clean-recursive
distclean-am: distclean-tags distclean-generic clean-am
-rm -f libtool
distclean: distclean-recursive
maintainer-clean-am: maintainer-clean-tags maintainer-clean-generic \
distclean-am
@echo "This command is intended for maintainers to use;"
@echo "it deletes files that may require special tools to rebuild."
maintainer-clean: maintainer-clean-recursive
.PHONY: install-data-recursive uninstall-data-recursive \
install-exec-recursive uninstall-exec-recursive installdirs-recursive \
uninstalldirs-recursive all-recursive check-recursive \
installcheck-recursive info-recursive dvi-recursive \
mostlyclean-recursive distclean-recursive clean-recursive \
maintainer-clean-recursive tags tags-recursive mostlyclean-tags \
distclean-tags clean-tags maintainer-clean-tags distdir info-am info \
dvi-am dvi check check-am installcheck-am installcheck install-exec-am \
install-exec install-data-am install-data install-am install \
uninstall-am uninstall all-redirect all-am all installdirs-am \
installdirs mostlyclean-generic distclean-generic clean-generic \
maintainer-clean-generic clean mostlyclean distclean maintainer-clean
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

View File

@ -1,6 +0,0 @@
## Process this file with automake to produce Makefile.in. -*-Makefile-*-
# Disable automatic dependency tracking if using other tools than gcc and gmake
#AUTOMAKE_OPTIONS = no-dependencies
EXTRA_DIST = libspeex.dsp libspeex.dsw

Some files were not shown because too many files have changed in this diff Show More