Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/quite/celt.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Marc Valin <Jean-Marc.Valin@csiro.au>2007-11-29 09:01:16 +0300
committerJean-Marc Valin <Jean-Marc.Valin@csiro.au>2007-11-29 09:01:16 +0300
commit63590897db35326cd1ce7784806f9b89a98631ea (patch)
treeb3e1dff3a086f7d518a90fdee4fac164e8e20ef8
Initial commit with the autotools stuff and files taken from Speex and Vorbis.
-rw-r--r--AUTHORS0
-rw-r--r--COPYING7
-rw-r--r--ChangeLog0
-rw-r--r--INSTALL0
-rw-r--r--Makefile.am11
-rw-r--r--NEWS0
-rw-r--r--README3
-rwxr-xr-xautogen.sh116
-rw-r--r--configure.ac132
-rw-r--r--libcelt/Makefile.am22
-rw-r--r--libcelt/arch.h239
-rw-r--r--libcelt/mdct.c564
-rw-r--r--libcelt/mdct.h83
-rw-r--r--libcelt/os_support.h162
-rw-r--r--libcelt/testcelt.c5
15 files changed, 1344 insertions, 0 deletions
diff --git a/AUTHORS b/AUTHORS
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/AUTHORS
diff --git a/COPYING b/COPYING
new file mode 100644
index 0000000..76074de
--- /dev/null
+++ b/COPYING
@@ -0,0 +1,7 @@
+Copyright 2005-2007 Christopher Montgomery, Jean-Marc Valin, CSIRO and other
+contributors
+
+These files in this project are currently licensed under several licenses,
+including the (revised) BSD license and the LGPL. Make sure you're careful
+with what you do with these files -- not that anything in there is really
+working yet!
diff --git a/ChangeLog b/ChangeLog
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/ChangeLog
diff --git a/INSTALL b/INSTALL
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/INSTALL
diff --git a/Makefile.am b/Makefile.am
new file mode 100644
index 0000000..74284e0
--- /dev/null
+++ b/Makefile.am
@@ -0,0 +1,11 @@
+## Process this file with automake to produce Makefile.in. -*-Makefile-*-
+
+# To disable automatic dependency tracking if using other tools than
+# gcc and gmake, add the option 'no-dependencies'
+AUTOMAKE_OPTIONS = 1.6
+
+#Fools KDevelop into including all files
+SUBDIRS = libcelt
+
+rpm: dist
+ rpmbuild -ta ${PACKAGE}-${VERSION}.tar.gz
diff --git a/NEWS b/NEWS
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/NEWS
diff --git a/README b/README
new file mode 100644
index 0000000..7e17091
--- /dev/null
+++ b/README
@@ -0,0 +1,3 @@
+This is an attempt at a better audio codec. Don't bother with this unless
+you're interested in codec development. Certainly don't expect this to
+be ready any time soon.
diff --git a/autogen.sh b/autogen.sh
new file mode 100755
index 0000000..343725d
--- /dev/null
+++ b/autogen.sh
@@ -0,0 +1,116 @@
+#!/bin/sh
+# Run this to set up the build system: configure, makefiles, etc.
+# (based on the version in enlightenment's cvs)
+
+package="ghost"
+
+olddir=`pwd`
+srcdir=`dirname $0`
+test -z "$srcdir" && srcdir=.
+
+cd "$srcdir"
+DIE=0
+
+echo "checking for autoconf... "
+(autoconf --version) < /dev/null > /dev/null 2>&1 || {
+ echo
+ echo "You must have autoconf installed to compile $package."
+ echo "Download the appropriate package for your distribution,"
+ echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/"
+ DIE=1
+}
+
+VERSIONGREP="sed -e s/.*[^0-9\.]\([0-9]\.[0-9]\).*/\1/"
+VERSIONMKINT="sed -e s/[^0-9]//"
+
+# do we need automake?
+if test -r Makefile.am; then
+ AM_NEEDED=`fgrep AUTOMAKE_OPTIONS Makefile.am | $VERSIONGREP`
+ if test -z $AM_NEEDED; then
+ echo -n "checking for automake... "
+ AUTOMAKE=automake
+ ACLOCAL=aclocal
+ if ($AUTOMAKE --version < /dev/null > /dev/null 2>&1); then
+ echo "no"
+ AUTOMAKE=
+ else
+ echo "yes"
+ fi
+ else
+ echo -n "checking for automake $AM_NEEDED or later... "
+ for am in automake-$AM_NEEDED automake$AM_NEEDED automake; do
+ ($am --version < /dev/null > /dev/null 2>&1) || continue
+ ver=`$am --version < /dev/null | head -n 1 | $VERSIONGREP | $VERSIONMKINT`
+ verneeded=`echo $AM_NEEDED | $VERSIONMKINT`
+ if test $ver -ge $verneeded; then
+ AUTOMAKE=$am
+ echo $AUTOMAKE
+ break
+ fi
+ done
+ test -z $AUTOMAKE && echo "no"
+ echo -n "checking for aclocal $AM_NEEDED or later... "
+ for ac in aclocal-$AM_NEEDED aclocal$AM_NEEDED aclocal; do
+ ($ac --version < /dev/null > /dev/null 2>&1) || continue
+ ver=`$ac --version < /dev/null | head -n 1 | $VERSIONGREP | $VERSIONMKINT`
+ verneeded=`echo $AM_NEEDED | $VERSIONMKINT`
+ if test $ver -ge $verneeded; then
+ ACLOCAL=$ac
+ echo $ACLOCAL
+ break
+ fi
+ done
+ test -z $ACLOCAL && echo "no"
+ fi
+ test -z $AUTOMAKE || test -z $ACLOCAL && {
+ echo
+ echo "You must have automake installed to compile $package."
+ echo "Download the appropriate package for your distribution,"
+ echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/"
+ exit 1
+ }
+fi
+
+echo -n "checking for libtool... "
+for LIBTOOLIZE in libtoolize glibtoolize nope; do
+ ($LIBTOOLIZE --version) < /dev/null > /dev/null 2>&1 && break
+done
+if test x$LIBTOOLIZE = xnope; then
+ echo "nope."
+ LIBTOOLIZE=libtoolize
+else
+ echo $LIBTOOLIZE
+fi
+($LIBTOOLIZE --version) < /dev/null > /dev/null 2>&1 || {
+ echo
+ echo "You must have libtool installed to compile $package."
+ echo "Download the appropriate package for your system,"
+ echo "or get the source from one of the GNU ftp sites"
+ echo "listed in http://www.gnu.org/order/ftp.html"
+ DIE=1
+}
+
+if test "$DIE" -eq 1; then
+ exit 1
+fi
+
+if test -z "$*"; then
+ echo "I am going to run ./configure with no arguments - if you wish "
+ echo "to pass any to it, please specify them on the $0 command line."
+fi
+
+echo "Generating configuration files for $package, please wait...."
+
+echo " $ACLOCAL $ACLOCAL_FLAGS"
+$ACLOCAL $ACLOCAL_FLAGS || exit 1
+echo " autoheader"
+autoheader || exit 1
+echo " $LIBTOOLIZE --automake"
+$LIBTOOLIZE --automake || exit 1
+echo " $AUTOMAKE --add-missing $AUTOMAKE_FLAGS"
+$AUTOMAKE --add-missing $AUTOMAKE_FLAGS || exit 1
+echo " autoconf"
+autoconf || exit 1
+
+cd $olddir
+#$srcdir/configure "$@" && echo
diff --git a/configure.ac b/configure.ac
new file mode 100644
index 0000000..c1a0264
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,132 @@
+dnl Process this file with autoconf to produce a configure script. -*-m4-*-
+
+AC_INIT(libghost/ghost.c)
+
+AM_CONFIG_HEADER([config.h])
+
+CELT_MAJOR_VERSION=0
+CELT_MINOR_VERSION=0
+CELT_MICRO_VERSION=0
+CELT_EXTRA_VERSION=
+CELT_VERSION=$GHOST_MAJOR_VERSION.$GHOST_MINOR_VERSION.$GHOST_MICRO_VERSION$GHOST_EXTRA_VERSION
+
+CELT_LT_CURRENT=0
+CELT_LT_REVISION=0
+CELT_LT_AGE=0
+
+AC_SUBST(CELT_LT_CURRENT)
+AC_SUBST(CELT_LT_REVISION)
+AC_SUBST(CELT_LT_AGE)
+
+# For automake.
+VERSION=$CELT_VERSION
+PACKAGE=ghost
+
+AC_SUBST(CELT_VERSION)
+
+AM_INIT_AUTOMAKE($PACKAGE, $VERSION, no-define)
+AM_MAINTAINER_MODE
+
+AC_CANONICAL_HOST
+AM_PROG_LIBTOOL
+
+AC_C_BIGENDIAN
+AC_C_CONST
+AC_C_INLINE
+AC_C_RESTRICT
+
+
+AC_MSG_CHECKING(for C99 variable-size arrays)
+AC_TRY_COMPILE( , [
+int foo=10;
+int array[foo];
+],
+[has_var_arrays=yes;AC_DEFINE([VAR_ARRAYS], [], [Use C99 variable-size arrays])
+],
+has_var_arrays=no
+)
+AC_MSG_RESULT($has_var_arrays)
+
+AC_MSG_CHECKING(for alloca)
+AC_TRY_COMPILE( [#include <alloca.h>], [
+int foo=10;
+int *array = alloca(foo);
+],
+[
+has_alloca=yes;
+if test x$has_var_arrays = "xno" ; then
+AC_DEFINE([USE_ALLOCA], [], [Make use of alloca])
+fi
+],
+has_alloca=no
+)
+AC_MSG_RESULT($has_alloca)
+
+
+AC_CHECK_HEADERS(sys/soundcard.h sys/audioio.h)
+
+XIPH_PATH_OGG([src="src"], [src=""])
+AC_SUBST(src)
+
+AC_CHECK_LIB(m, sin)
+
+# Check for getopt_long; if not found, use included source.
+AC_CHECK_FUNCS([getopt_long],,
+[# FreeBSD has a gnugetopt library.
+ AC_CHECK_LIB([gnugetopt],[getopt_long],
+[AC_DEFINE([HAVE_GETOPT_LONG])],
+[# Use the GNU replacement.
+AC_LIBOBJ(getopt)
+AC_LIBOBJ(getopt1)])])
+
+AC_CHECK_LIB(winmm, main)
+
+AC_DEFINE_UNQUOTED(CELT_VERSION, "${GHOST_VERSION}", [Complete version string])
+AC_DEFINE_UNQUOTED(CELT_MAJOR_VERSION, ${GHOST_MAJOR_VERSION}, [Version major])
+AC_DEFINE_UNQUOTED(CELT_MINOR_VERSION, ${GHOST_MINOR_VERSION}, [Version minor])
+AC_DEFINE_UNQUOTED(CELT_MICRO_VERSION, ${GHOST_MICRO_VERSION}, [Version micro])
+AC_DEFINE_UNQUOTED(CELT_EXTRA_VERSION, "${GHOST_EXTRA_VERSION}", [Version extra])
+
+AC_CHECK_SIZEOF(short)
+AC_CHECK_SIZEOF(int)
+AC_CHECK_SIZEOF(long)
+AC_CHECK_SIZEOF(long long)
+
+if test x$has_char16 = "xyes" ; then
+ case 1 in
+ $ac_cv_sizeof_short) SIZE16="short";;
+ $ac_cv_sizeof_int) SIZE16="int";;
+ esac
+else
+ case 2 in
+ $ac_cv_sizeof_short) SIZE16="short";;
+ $ac_cv_sizeof_int) SIZE16="int";;
+ esac
+fi
+
+if test x$has_char16 = "xyes" ; then
+ case 2 in
+ $ac_cv_sizeof_int) SIZE32="int";;
+ $ac_cv_sizeof_long) SIZE32="long";;
+ $ac_cv_sizeof_short) SIZE32="short";;
+ esac
+else
+ case 4 in
+ $ac_cv_sizeof_int) SIZE32="int";;
+ $ac_cv_sizeof_long) SIZE32="long";;
+ $ac_cv_sizeof_short) SIZE32="short";;
+ esac
+fi
+
+AC_SUBST(SIZE16)
+AC_SUBST(SIZE32)
+
+AC_OUTPUT([Makefile libghost/Makefile libentcode/Makefile])
+
+if test "x$src" = "x"; then
+echo "**IMPORTANT**"
+echo "You don't seem to have the development package for libogg (libogg-devel) installed. Only the library will be built (no encoder/decoder executable)"
+echo "You can download libogg from http://www.vorbis.com/download.psp"
+fi
+
+echo "Type \"make; make install\" to compile and install";
diff --git a/libcelt/Makefile.am b/libcelt/Makefile.am
new file mode 100644
index 0000000..1e3ebc9
--- /dev/null
+++ b/libcelt/Makefile.am
@@ -0,0 +1,22 @@
+# Disable automatic dependency tracking if using other tools than gcc and gmake
+#AUTOMAKE_OPTIONS = no-dependencies
+
+
+#EXTRA_DIST=
+
+#INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/include -I$(top_builddir) @OGG_CFLAGS@
+
+lib_LTLIBRARIES = libcelt.la
+
+# Sources for compilation in the library
+libcelt_la_SOURCES = mdct.c
+
+#noinst_HEADERS =
+
+libcelt_la_LDFLAGS = -version-info @GHOST_LT_CURRENT@:@GHOST_LT_REVISION@:@GHOST_LT_AGE@
+
+noinst_HEADERS = os_support.h arch.h mdct.h
+
+noinst_PROGRAMS = testcelt
+testcelt_SOURCES = testcelt.c
+testcelt_LDADD = $(top_builddir)/libcelt/libcelt.la
diff --git a/libcelt/arch.h b/libcelt/arch.h
new file mode 100644
index 0000000..ec3c901
--- /dev/null
+++ b/libcelt/arch.h
@@ -0,0 +1,239 @@
+/* Copyright (C) 2003 Jean-Marc Valin */
+/**
+ @file arch.h
+ @brief Various architecture definitions 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 ARCH_H
+#define ARCH_H
+
+#ifndef SPEEX_VERSION
+#define SPEEX_MAJOR_VERSION 1 /**< Major Speex version. */
+#define SPEEX_MINOR_VERSION 1 /**< Minor Speex version. */
+#define SPEEX_MICRO_VERSION 15 /**< Micro Speex version. */
+#define SPEEX_EXTRA_VERSION "" /**< Extra Speex version. */
+#define SPEEX_VERSION "speex-1.2beta4" /**< Speex version string. */
+#endif
+
+/* A couple test to catch stupid option combinations */
+#ifdef FIXED_POINT
+
+#ifdef FLOATING_POINT
+#error You cannot compile as floating point and fixed point at the same time
+#endif
+#ifdef _USE_SSE
+#error SSE is only for floating-point
+#endif
+#if ((defined (ARM4_ASM)||defined (ARM4_ASM)) && defined(BFIN_ASM)) || (defined (ARM4_ASM)&&defined(ARM5E_ASM))
+#error Make up your mind. What CPU do you have?
+#endif
+#ifdef VORBIS_PSYCHO
+#error Vorbis-psy model currently not implemented in fixed-point
+#endif
+
+#else
+
+#ifndef FLOATING_POINT
+#error You now need to define either FIXED_POINT or FLOATING_POINT
+#endif
+#if defined (ARM4_ASM) || defined(ARM5E_ASM) || defined(BFIN_ASM)
+#error I suppose you can have a [ARM4/ARM5E/Blackfin] that has float instructions?
+#endif
+#ifdef FIXED_POINT_DEBUG
+#error "Don't you think enabling fixed-point is a good thing to do if you want to debug that?"
+#endif
+
+
+#endif
+
+#ifndef OUTSIDE_SPEEX
+#include "speex/speex_types.h"
+#endif
+
+#define ABS(x) ((x) < 0 ? (-(x)) : (x)) /**< Absolute integer value. */
+#define ABS16(x) ((x) < 0 ? (-(x)) : (x)) /**< Absolute 16-bit value. */
+#define MIN16(a,b) ((a) < (b) ? (a) : (b)) /**< Maximum 16-bit value. */
+#define MAX16(a,b) ((a) > (b) ? (a) : (b)) /**< Maximum 16-bit value. */
+#define ABS32(x) ((x) < 0 ? (-(x)) : (x)) /**< Absolute 32-bit value. */
+#define MIN32(a,b) ((a) < (b) ? (a) : (b)) /**< Maximum 32-bit value. */
+#define MAX32(a,b) ((a) > (b) ? (a) : (b)) /**< Maximum 32-bit value. */
+
+#ifdef FIXED_POINT
+
+typedef spx_int16_t spx_word16_t;
+typedef spx_int32_t spx_word32_t;
+typedef spx_word32_t spx_mem_t;
+typedef spx_word16_t spx_coef_t;
+typedef spx_word16_t spx_lsp_t;
+typedef spx_word32_t spx_sig_t;
+
+#define Q15ONE 32767
+
+#define LPC_SCALING 8192
+#define SIG_SCALING 16384
+#define LSP_SCALING 8192.
+#define GAMMA_SCALING 32768.
+#define GAIN_SCALING 64
+#define GAIN_SCALING_1 0.015625
+
+#define LPC_SHIFT 13
+#define LSP_SHIFT 13
+#define SIG_SHIFT 14
+#define GAIN_SHIFT 6
+
+#define VERY_SMALL 0
+#define VERY_LARGE32 ((spx_word32_t)2147483647)
+#define VERY_LARGE16 ((spx_word16_t)32767)
+#define Q15_ONE ((spx_word16_t)32767)
+
+
+#ifdef FIXED_DEBUG
+#include "fixed_debug.h"
+#else
+
+#include "fixed_generic.h"
+
+#ifdef ARM5E_ASM
+#include "fixed_arm5e.h"
+#elif defined (ARM4_ASM)
+#include "fixed_arm4.h"
+#elif defined (BFIN_ASM)
+#include "fixed_bfin.h"
+#endif
+
+#endif
+
+
+#else
+
+typedef float spx_mem_t;
+typedef float spx_coef_t;
+typedef float spx_lsp_t;
+typedef float spx_sig_t;
+typedef float spx_word16_t;
+typedef float spx_word32_t;
+
+#define Q15ONE 1.0f
+#define LPC_SCALING 1.f
+#define SIG_SCALING 1.f
+#define LSP_SCALING 1.f
+#define GAMMA_SCALING 1.f
+#define GAIN_SCALING 1.f
+#define GAIN_SCALING_1 1.f
+
+
+#define VERY_SMALL 1e-15f
+#define VERY_LARGE32 1e15f
+#define VERY_LARGE16 1e15f
+#define Q15_ONE ((spx_word16_t)1.f)
+
+#define QCONST16(x,bits) (x)
+#define QCONST32(x,bits) (x)
+
+#define NEG16(x) (-(x))
+#define NEG32(x) (-(x))
+#define EXTRACT16(x) (x)
+#define EXTEND32(x) (x)
+#define SHR16(a,shift) (a)
+#define SHL16(a,shift) (a)
+#define SHR32(a,shift) (a)
+#define SHL32(a,shift) (a)
+#define PSHR16(a,shift) (a)
+#define PSHR32(a,shift) (a)
+#define VSHR32(a,shift) (a)
+#define SATURATE16(x,a) (x)
+#define SATURATE32(x,a) (x)
+
+#define PSHR(a,shift) (a)
+#define SHR(a,shift) (a)
+#define SHL(a,shift) (a)
+#define SATURATE(x,a) (x)
+
+#define ADD16(a,b) ((a)+(b))
+#define SUB16(a,b) ((a)-(b))
+#define ADD32(a,b) ((a)+(b))
+#define SUB32(a,b) ((a)-(b))
+#define MULT16_16_16(a,b) ((a)*(b))
+#define MULT16_16(a,b) ((spx_word32_t)(a)*(spx_word32_t)(b))
+#define MAC16_16(c,a,b) ((c)+(spx_word32_t)(a)*(spx_word32_t)(b))
+
+#define MULT16_32_Q11(a,b) ((a)*(b))
+#define MULT16_32_Q13(a,b) ((a)*(b))
+#define MULT16_32_Q14(a,b) ((a)*(b))
+#define MULT16_32_Q15(a,b) ((a)*(b))
+#define MULT16_32_P15(a,b) ((a)*(b))
+
+#define MAC16_32_Q11(c,a,b) ((c)+(a)*(b))
+#define MAC16_32_Q15(c,a,b) ((c)+(a)*(b))
+
+#define MAC16_16_Q11(c,a,b) ((c)+(a)*(b))
+#define MAC16_16_Q13(c,a,b) ((c)+(a)*(b))
+#define MAC16_16_P13(c,a,b) ((c)+(a)*(b))
+#define MULT16_16_Q11_32(a,b) ((a)*(b))
+#define MULT16_16_Q13(a,b) ((a)*(b))
+#define MULT16_16_Q14(a,b) ((a)*(b))
+#define MULT16_16_Q15(a,b) ((a)*(b))
+#define MULT16_16_P15(a,b) ((a)*(b))
+#define MULT16_16_P13(a,b) ((a)*(b))
+#define MULT16_16_P14(a,b) ((a)*(b))
+
+#define DIV32_16(a,b) (((spx_word32_t)(a))/(spx_word16_t)(b))
+#define PDIV32_16(a,b) (((spx_word32_t)(a))/(spx_word16_t)(b))
+#define DIV32(a,b) (((spx_word32_t)(a))/(spx_word32_t)(b))
+#define PDIV32(a,b) (((spx_word32_t)(a))/(spx_word32_t)(b))
+
+
+#endif
+
+
+#if defined (CONFIG_TI_C54X) || defined (CONFIG_TI_C55X)
+
+/* 2 on TI C5x DSP */
+#define BYTES_PER_CHAR 2
+#define BITS_PER_CHAR 16
+#define LOG2_BITS_PER_CHAR 4
+
+#else
+
+#define BYTES_PER_CHAR 1
+#define BITS_PER_CHAR 8
+#define LOG2_BITS_PER_CHAR 3
+
+#endif
+
+
+
+#ifdef FIXED_DEBUG
+long long spx_mips=0;
+#endif
+
+
+#endif
diff --git a/libcelt/mdct.c b/libcelt/mdct.c
new file mode 100644
index 0000000..4e153b3
--- /dev/null
+++ b/libcelt/mdct.c
@@ -0,0 +1,564 @@
+/********************************************************************
+ * *
+ * 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 XIPHOPHORUS Company http://www.xiph.org/ *
+ * *
+ ********************************************************************
+
+ function: normalized modified discrete cosine transform
+ power of two length transform only [64 <= n ]
+ last mod: $Id: mdct.c 7187 2004-07-20 07:24:27Z xiphmont $
+
+ Original algorithm adapted long ago from _The use of multirate filter
+ banks for coding of high quality digital audio_, by T. Sporer,
+ K. Brandenburg and B. Edler, collection of the European Signal
+ Processing Conference (EUSIPCO), Amsterdam, June 1992, Vol.1, pp
+ 211-214
+
+ The below code implements an algorithm that no longer looks much like
+ that presented in the paper, but the basic structure remains if you
+ dig deep enough to see it.
+
+ This module DOES NOT INCLUDE code to generate/apply the window
+ function. Everybody has their own weird favorite including me... I
+ happen to like the properties of y=sin(.5PI*sin^2(x)), but others may
+ vehemently disagree.
+
+ ********************************************************************/
+
+/* this can also be run as an integer transform by uncommenting a
+ define in mdct.h; the integerization is a first pass and although
+ it's likely stable for Vorbis, the dynamic range is constrained and
+ roundoff isn't done (so it's noisy). Consider it functional, but
+ only a starting point. There's no point on a machine with an FPU */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+#include "vorbis/codec.h"
+#include "mdct.h"
+#include "os.h"
+#include "misc.h"
+
+/* build lookups for trig functions; also pre-figure scaling and
+ some window function algebra. */
+
+void mdct_init(mdct_lookup *lookup,int n){
+ int *bitrev=_ogg_malloc(sizeof(*bitrev)*(n/4));
+ DATA_TYPE *T=_ogg_malloc(sizeof(*T)*(n+n/4));
+
+ int i;
+ int n2=n>>1;
+ int log2n=lookup->log2n=rint(log((float)n)/log(2.f));
+ lookup->n=n;
+ lookup->trig=T;
+ lookup->bitrev=bitrev;
+
+/* trig lookups... */
+
+ for(i=0;i<n/4;i++){
+ T[i*2]=FLOAT_CONV(cos((M_PI/n)*(4*i)));
+ T[i*2+1]=FLOAT_CONV(-sin((M_PI/n)*(4*i)));
+ T[n2+i*2]=FLOAT_CONV(cos((M_PI/(2*n))*(2*i+1)));
+ T[n2+i*2+1]=FLOAT_CONV(sin((M_PI/(2*n))*(2*i+1)));
+ }
+ for(i=0;i<n/8;i++){
+ T[n+i*2]=FLOAT_CONV(cos((M_PI/n)*(4*i+2))*.5);
+ T[n+i*2+1]=FLOAT_CONV(-sin((M_PI/n)*(4*i+2))*.5);
+ }
+
+ /* bitreverse lookup... */
+
+ {
+ int mask=(1<<(log2n-1))-1,i,j;
+ int msb=1<<(log2n-2);
+ for(i=0;i<n/8;i++){
+ int acc=0;
+ for(j=0;msb>>j;j++)
+ if((msb>>j)&i)acc|=1<<j;
+ bitrev[i*2]=((~acc)&mask)-1;
+ bitrev[i*2+1]=acc;
+
+ }
+ }
+ lookup->scale=FLOAT_CONV(4.f/n);
+}
+
+/* 8 point butterfly (in place, 4 register) */
+STIN void mdct_butterfly_8(DATA_TYPE *x){
+ REG_TYPE r0 = x[6] + x[2];
+ REG_TYPE r1 = x[6] - x[2];
+ REG_TYPE r2 = x[4] + x[0];
+ REG_TYPE r3 = x[4] - x[0];
+
+ x[6] = r0 + r2;
+ x[4] = r0 - r2;
+
+ r0 = x[5] - x[1];
+ r2 = x[7] - x[3];
+ x[0] = r1 + r0;
+ x[2] = r1 - r0;
+
+ r0 = x[5] + x[1];
+ r1 = x[7] + x[3];
+ x[3] = r2 + r3;
+ x[1] = r2 - r3;
+ x[7] = r1 + r0;
+ x[5] = r1 - r0;
+
+}
+
+/* 16 point butterfly (in place, 4 register) */
+STIN void mdct_butterfly_16(DATA_TYPE *x){
+ REG_TYPE r0 = x[1] - x[9];
+ REG_TYPE r1 = x[0] - x[8];
+
+ x[8] += x[0];
+ x[9] += x[1];
+ x[0] = MULT_NORM((r0 + r1) * cPI2_8);
+ x[1] = MULT_NORM((r0 - r1) * cPI2_8);
+
+ r0 = x[3] - x[11];
+ r1 = x[10] - x[2];
+ x[10] += x[2];
+ x[11] += x[3];
+ x[2] = r0;
+ x[3] = r1;
+
+ r0 = x[12] - x[4];
+ r1 = x[13] - x[5];
+ x[12] += x[4];
+ x[13] += x[5];
+ x[4] = MULT_NORM((r0 - r1) * cPI2_8);
+ x[5] = MULT_NORM((r0 + r1) * cPI2_8);
+
+ r0 = x[14] - x[6];
+ r1 = x[15] - x[7];
+ x[14] += x[6];
+ x[15] += x[7];
+ x[6] = r0;
+ x[7] = r1;
+
+ mdct_butterfly_8(x);
+ mdct_butterfly_8(x+8);
+}
+
+/* 32 point butterfly (in place, 4 register) */
+STIN void mdct_butterfly_32(DATA_TYPE *x){
+ REG_TYPE r0 = x[30] - x[14];
+ REG_TYPE r1 = x[31] - x[15];
+
+ x[30] += x[14];
+ x[31] += x[15];
+ x[14] = r0;
+ x[15] = r1;
+
+ r0 = x[28] - x[12];
+ r1 = x[29] - x[13];
+ x[28] += x[12];
+ x[29] += x[13];
+ x[12] = MULT_NORM( r0 * cPI1_8 - r1 * cPI3_8 );
+ x[13] = MULT_NORM( r0 * cPI3_8 + r1 * cPI1_8 );
+
+ r0 = x[26] - x[10];
+ r1 = x[27] - x[11];
+ x[26] += x[10];
+ x[27] += x[11];
+ x[10] = MULT_NORM(( r0 - r1 ) * cPI2_8);
+ x[11] = MULT_NORM(( r0 + r1 ) * cPI2_8);
+
+ r0 = x[24] - x[8];
+ r1 = x[25] - x[9];
+ x[24] += x[8];
+ x[25] += x[9];
+ x[8] = MULT_NORM( r0 * cPI3_8 - r1 * cPI1_8 );
+ x[9] = MULT_NORM( r1 * cPI3_8 + r0 * cPI1_8 );
+
+ r0 = x[22] - x[6];
+ r1 = x[7] - x[23];
+ x[22] += x[6];
+ x[23] += x[7];
+ x[6] = r1;
+ x[7] = r0;
+
+ r0 = x[4] - x[20];
+ r1 = x[5] - x[21];
+ x[20] += x[4];
+ x[21] += x[5];
+ x[4] = MULT_NORM( r1 * cPI1_8 + r0 * cPI3_8 );
+ x[5] = MULT_NORM( r1 * cPI3_8 - r0 * cPI1_8 );
+
+ r0 = x[2] - x[18];
+ r1 = x[3] - x[19];
+ x[18] += x[2];
+ x[19] += x[3];
+ x[2] = MULT_NORM(( r1 + r0 ) * cPI2_8);
+ x[3] = MULT_NORM(( r1 - r0 ) * cPI2_8);
+
+ r0 = x[0] - x[16];
+ r1 = x[1] - x[17];
+ x[16] += x[0];
+ x[17] += x[1];
+ x[0] = MULT_NORM( r1 * cPI3_8 + r0 * cPI1_8 );
+ x[1] = MULT_NORM( r1 * cPI1_8 - r0 * cPI3_8 );
+
+ mdct_butterfly_16(x);
+ mdct_butterfly_16(x+16);
+
+}
+
+/* N point first stage butterfly (in place, 2 register) */
+STIN void mdct_butterfly_first(DATA_TYPE *T,
+ DATA_TYPE *x,
+ int points){
+
+ DATA_TYPE *x1 = x + points - 8;
+ DATA_TYPE *x2 = x + (points>>1) - 8;
+ REG_TYPE r0;
+ REG_TYPE r1;
+
+ do{
+
+ r0 = x1[6] - x2[6];
+ r1 = x1[7] - x2[7];
+ x1[6] += x2[6];
+ x1[7] += x2[7];
+ x2[6] = MULT_NORM(r1 * T[1] + r0 * T[0]);
+ x2[7] = MULT_NORM(r1 * T[0] - r0 * T[1]);
+
+ r0 = x1[4] - x2[4];
+ r1 = x1[5] - x2[5];
+ x1[4] += x2[4];
+ x1[5] += x2[5];
+ x2[4] = MULT_NORM(r1 * T[5] + r0 * T[4]);
+ x2[5] = MULT_NORM(r1 * T[4] - r0 * T[5]);
+
+ r0 = x1[2] - x2[2];
+ r1 = x1[3] - x2[3];
+ x1[2] += x2[2];
+ x1[3] += x2[3];
+ x2[2] = MULT_NORM(r1 * T[9] + r0 * T[8]);
+ x2[3] = MULT_NORM(r1 * T[8] - r0 * T[9]);
+
+ r0 = x1[0] - x2[0];
+ r1 = x1[1] - x2[1];
+ x1[0] += x2[0];
+ x1[1] += x2[1];
+ x2[0] = MULT_NORM(r1 * T[13] + r0 * T[12]);
+ x2[1] = MULT_NORM(r1 * T[12] - r0 * T[13]);
+
+ x1-=8;
+ x2-=8;
+ T+=16;
+
+ }while(x2>=x);
+}
+
+/* N/stage point generic N stage butterfly (in place, 2 register) */
+STIN void mdct_butterfly_generic(DATA_TYPE *T,
+ DATA_TYPE *x,
+ int points,
+ int trigint){
+
+ DATA_TYPE *x1 = x + points - 8;
+ DATA_TYPE *x2 = x + (points>>1) - 8;
+ REG_TYPE r0;
+ REG_TYPE r1;
+
+ do{
+
+ r0 = x1[6] - x2[6];
+ r1 = x1[7] - x2[7];
+ x1[6] += x2[6];
+ x1[7] += x2[7];
+ x2[6] = MULT_NORM(r1 * T[1] + r0 * T[0]);
+ x2[7] = MULT_NORM(r1 * T[0] - r0 * T[1]);
+
+ T+=trigint;
+
+ r0 = x1[4] - x2[4];
+ r1 = x1[5] - x2[5];
+ x1[4] += x2[4];
+ x1[5] += x2[5];
+ x2[4] = MULT_NORM(r1 * T[1] + r0 * T[0]);
+ x2[5] = MULT_NORM(r1 * T[0] - r0 * T[1]);
+
+ T+=trigint;
+
+ r0 = x1[2] - x2[2];
+ r1 = x1[3] - x2[3];
+ x1[2] += x2[2];
+ x1[3] += x2[3];
+ x2[2] = MULT_NORM(r1 * T[1] + r0 * T[0]);
+ x2[3] = MULT_NORM(r1 * T[0] - r0 * T[1]);
+
+ T+=trigint;
+
+ r0 = x1[0] - x2[0];
+ r1 = x1[1] - x2[1];
+ x1[0] += x2[0];
+ x1[1] += x2[1];
+ x2[0] = MULT_NORM(r1 * T[1] + r0 * T[0]);
+ x2[1] = MULT_NORM(r1 * T[0] - r0 * T[1]);
+
+ T+=trigint;
+ x1-=8;
+ x2-=8;
+
+ }while(x2>=x);
+}
+
+STIN void mdct_butterflies(mdct_lookup *init,
+ DATA_TYPE *x,
+ int points){
+
+ DATA_TYPE *T=init->trig;
+ int stages=init->log2n-5;
+ int i,j;
+
+ if(--stages>0){
+ mdct_butterfly_first(T,x,points);
+ }
+
+ for(i=1;--stages>0;i++){
+ for(j=0;j<(1<<i);j++)
+ mdct_butterfly_generic(T,x+(points>>i)*j,points>>i,4<<i);
+ }
+
+ for(j=0;j<points;j+=32)
+ mdct_butterfly_32(x+j);
+
+}
+
+void mdct_clear(mdct_lookup *l){
+ if(l){
+ if(l->trig)_ogg_free(l->trig);
+ if(l->bitrev)_ogg_free(l->bitrev);
+ memset(l,0,sizeof(*l));
+ }
+}
+
+STIN void mdct_bitreverse(mdct_lookup *init,
+ DATA_TYPE *x){
+ int n = init->n;
+ int *bit = init->bitrev;
+ DATA_TYPE *w0 = x;
+ DATA_TYPE *w1 = x = w0+(n>>1);
+ DATA_TYPE *T = init->trig+n;
+
+ do{
+ DATA_TYPE *x0 = x+bit[0];
+ DATA_TYPE *x1 = x+bit[1];
+
+ REG_TYPE r0 = x0[1] - x1[1];
+ REG_TYPE r1 = x0[0] + x1[0];
+ REG_TYPE r2 = MULT_NORM(r1 * T[0] + r0 * T[1]);
+ REG_TYPE r3 = MULT_NORM(r1 * T[1] - r0 * T[0]);
+
+ w1 -= 4;
+
+ r0 = HALVE(x0[1] + x1[1]);
+ r1 = HALVE(x0[0] - x1[0]);
+
+ w0[0] = r0 + r2;
+ w1[2] = r0 - r2;
+ w0[1] = r1 + r3;
+ w1[3] = r3 - r1;
+
+ x0 = x+bit[2];
+ x1 = x+bit[3];
+
+ r0 = x0[1] - x1[1];
+ r1 = x0[0] + x1[0];
+ r2 = MULT_NORM(r1 * T[2] + r0 * T[3]);
+ r3 = MULT_NORM(r1 * T[3] - r0 * T[2]);
+
+ r0 = HALVE(x0[1] + x1[1]);
+ r1 = HALVE(x0[0] - x1[0]);
+
+ w0[2] = r0 + r2;
+ w1[0] = r0 - r2;
+ w0[3] = r1 + r3;
+ w1[1] = r3 - r1;
+
+ T += 4;
+ bit += 4;
+ w0 += 4;
+
+ }while(w0<w1);
+}
+
+void mdct_backward(mdct_lookup *init, DATA_TYPE *in, DATA_TYPE *out){
+ int n=init->n;
+ int n2=n>>1;
+ int n4=n>>2;
+
+ /* rotate */
+
+ DATA_TYPE *iX = in+n2-7;
+ DATA_TYPE *oX = out+n2+n4;
+ DATA_TYPE *T = init->trig+n4;
+
+ do{
+ oX -= 4;
+ oX[0] = MULT_NORM(-iX[2] * T[3] - iX[0] * T[2]);
+ oX[1] = MULT_NORM (iX[0] * T[3] - iX[2] * T[2]);
+ oX[2] = MULT_NORM(-iX[6] * T[1] - iX[4] * T[0]);
+ oX[3] = MULT_NORM (iX[4] * T[1] - iX[6] * T[0]);
+ iX -= 8;
+ T += 4;
+ }while(iX>=in);
+
+ iX = in+n2-8;
+ oX = out+n2+n4;
+ T = init->trig+n4;
+
+ do{
+ T -= 4;
+ oX[0] = MULT_NORM (iX[4] * T[3] + iX[6] * T[2]);
+ oX[1] = MULT_NORM (iX[4] * T[2] - iX[6] * T[3]);
+ oX[2] = MULT_NORM (iX[0] * T[1] + iX[2] * T[0]);
+ oX[3] = MULT_NORM (iX[0] * T[0] - iX[2] * T[1]);
+ iX -= 8;
+ oX += 4;
+ }while(iX>=in);
+
+ mdct_butterflies(init,out+n2,n2);
+ mdct_bitreverse(init,out);
+
+ /* roatate + window */
+
+ {
+ DATA_TYPE *oX1=out+n2+n4;
+ DATA_TYPE *oX2=out+n2+n4;
+ DATA_TYPE *iX =out;
+ T =init->trig+n2;
+
+ do{
+ oX1-=4;
+
+ oX1[3] = MULT_NORM (iX[0] * T[1] - iX[1] * T[0]);
+ oX2[0] = -MULT_NORM (iX[0] * T[0] + iX[1] * T[1]);
+
+ oX1[2] = MULT_NORM (iX[2] * T[3] - iX[3] * T[2]);
+ oX2[1] = -MULT_NORM (iX[2] * T[2] + iX[3] * T[3]);
+
+ oX1[1] = MULT_NORM (iX[4] * T[5] - iX[5] * T[4]);
+ oX2[2] = -MULT_NORM (iX[4] * T[4] + iX[5] * T[5]);
+
+ oX1[0] = MULT_NORM (iX[6] * T[7] - iX[7] * T[6]);
+ oX2[3] = -MULT_NORM (iX[6] * T[6] + iX[7] * T[7]);
+
+ oX2+=4;
+ iX += 8;
+ T += 8;
+ }while(iX<oX1);
+
+ iX=out+n2+n4;
+ oX1=out+n4;
+ oX2=oX1;
+
+ do{
+ oX1-=4;
+ iX-=4;
+
+ oX2[0] = -(oX1[3] = iX[3]);
+ oX2[1] = -(oX1[2] = iX[2]);
+ oX2[2] = -(oX1[1] = iX[1]);
+ oX2[3] = -(oX1[0] = iX[0]);
+
+ oX2+=4;
+ }while(oX2<iX);
+
+ iX=out+n2+n4;
+ oX1=out+n2+n4;
+ oX2=out+n2;
+ do{
+ oX1-=4;
+ oX1[0]= iX[3];
+ oX1[1]= iX[2];
+ oX1[2]= iX[1];
+ oX1[3]= iX[0];
+ iX+=4;
+ }while(oX1>oX2);
+ }
+}
+
+void mdct_forward(mdct_lookup *init, DATA_TYPE *in, DATA_TYPE *out){
+ int n=init->n;
+ int n2=n>>1;
+ int n4=n>>2;
+ int n8=n>>3;
+ DATA_TYPE *w=alloca(n*sizeof(*w)); /* forward needs working space */
+ DATA_TYPE *w2=w+n2;
+
+ /* rotate */
+
+ /* window + rotate + step 1 */
+
+ REG_TYPE r0;
+ REG_TYPE r1;
+ DATA_TYPE *x0=in+n2+n4;
+ DATA_TYPE *x1=x0+1;
+ DATA_TYPE *T=init->trig+n2;
+
+ int i=0;
+
+ for(i=0;i<n8;i+=2){
+ x0 -=4;
+ T-=2;
+ r0= x0[2] + x1[0];
+ r1= x0[0] + x1[2];
+ w2[i]= MULT_NORM(r1*T[1] + r0*T[0]);
+ w2[i+1]= MULT_NORM(r1*T[0] - r0*T[1]);
+ x1 +=4;
+ }
+
+ x1=in+1;
+
+ for(;i<n2-n8;i+=2){
+ T-=2;
+ x0 -=4;
+ r0= x0[2] - x1[0];
+ r1= x0[0] - x1[2];
+ w2[i]= MULT_NORM(r1*T[1] + r0*T[0]);
+ w2[i+1]= MULT_NORM(r1*T[0] - r0*T[1]);
+ x1 +=4;
+ }
+
+ x0=in+n;
+
+ for(;i<n2;i+=2){
+ T-=2;
+ x0 -=4;
+ r0= -x0[2] - x1[0];
+ r1= -x0[0] - x1[2];
+ w2[i]= MULT_NORM(r1*T[1] + r0*T[0]);
+ w2[i+1]= MULT_NORM(r1*T[0] - r0*T[1]);
+ x1 +=4;
+ }
+
+
+ mdct_butterflies(init,w+n2,n2);
+ mdct_bitreverse(init,w);
+
+ /* roatate + window */
+
+ T=init->trig+n2;
+ x0=out+n2;
+
+ for(i=0;i<n4;i++){
+ x0--;
+ out[i] =MULT_NORM((w[0]*T[0]+w[1]*T[1])*init->scale);
+ x0[0] =MULT_NORM((w[0]*T[1]-w[1]*T[0])*init->scale);
+ w+=2;
+ T+=2;
+ }
+}
+
diff --git a/libcelt/mdct.h b/libcelt/mdct.h
new file mode 100644
index 0000000..176daad
--- /dev/null
+++ b/libcelt/mdct.h
@@ -0,0 +1,83 @@
+/********************************************************************
+ * *
+ * 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 XIPHOPHORUS Company http://www.xiph.org/ *
+ * *
+ ********************************************************************
+
+ function: modified discrete cosine transform prototypes
+ last mod: $Id: mdct.h 7187 2004-07-20 07:24:27Z xiphmont $
+
+ ********************************************************************/
+
+#ifndef _OGG_mdct_H_
+#define _OGG_mdct_H_
+
+#include "vorbis/codec.h"
+
+
+
+
+
+/*#define MDCT_INTEGERIZED <- be warned there could be some hurt left here*/
+#ifdef MDCT_INTEGERIZED
+
+#define DATA_TYPE int
+#define REG_TYPE register int
+#define TRIGBITS 14
+#define cPI3_8 6270
+#define cPI2_8 11585
+#define cPI1_8 15137
+
+#define FLOAT_CONV(x) ((int)((x)*(1<<TRIGBITS)+.5))
+#define MULT_NORM(x) ((x)>>TRIGBITS)
+#define HALVE(x) ((x)>>1)
+
+#else
+
+#define DATA_TYPE float
+#define REG_TYPE float
+#define cPI3_8 .38268343236508977175F
+#define cPI2_8 .70710678118654752441F
+#define cPI1_8 .92387953251128675613F
+
+#define FLOAT_CONV(x) (x)
+#define MULT_NORM(x) (x)
+#define HALVE(x) ((x)*.5f)
+
+#endif
+
+
+typedef struct {
+ int n;
+ int log2n;
+
+ DATA_TYPE *trig;
+ int *bitrev;
+
+ DATA_TYPE scale;
+} mdct_lookup;
+
+extern void mdct_init(mdct_lookup *lookup,int n);
+extern void mdct_clear(mdct_lookup *l);
+extern void mdct_forward(mdct_lookup *init, DATA_TYPE *in, DATA_TYPE *out);
+extern void mdct_backward(mdct_lookup *init, DATA_TYPE *in, DATA_TYPE *out);
+
+#endif
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/libcelt/os_support.h b/libcelt/os_support.h
new file mode 100644
index 0000000..d2f9eb8
--- /dev/null
+++ b/libcelt/os_support.h
@@ -0,0 +1,162 @@
+/* Copyright (C) 2007 Jean-Marc Valin
+
+ File: os_support.h
+ This is the (tiny) OS abstraction layer. Aside from math.h, this is the
+ only place where system headers are allowed.
+
+ 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.
+*/
+
+#ifndef OS_SUPPORT_H
+#define OS_SUPPORT_H
+
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+/** Speex wrapper for calloc. To do your own dynamic allocation, all you need to do is replace this function, speex_realloc and speex_free
+ NOTE: speex_alloc needs to CLEAR THE MEMORY */
+#ifndef OVERRIDE_SPEEX_ALLOC
+static inline void *speex_alloc (int size)
+{
+ /* WARNING: this is not equivalent to malloc(). If you want to use malloc()
+ or your own allocator, YOU NEED TO CLEAR THE MEMORY ALLOCATED. Otherwise
+ you will experience strange bugs */
+ return calloc(size,1);
+}
+#endif
+
+/** Same as speex_alloc, except that the area is only needed inside a Speex call (might cause problem with wideband though) */
+#ifndef OVERRIDE_SPEEX_ALLOC_SCRATCH
+static inline void *speex_alloc_scratch (int size)
+{
+ /* Scratch space doesn't need to be cleared */
+ return calloc(size,1);
+}
+#endif
+
+/** Speex wrapper for realloc. To do your own dynamic allocation, all you need to do is replace this function, speex_alloc and speex_free */
+#ifndef OVERRIDE_SPEEX_REALLOC
+static inline void *speex_realloc (void *ptr, int size)
+{
+ return realloc(ptr, size);
+}
+#endif
+
+/** Speex wrapper for calloc. To do your own dynamic allocation, all you need to do is replace this function, speex_realloc and speex_alloc */
+#ifndef OVERRIDE_SPEEX_FREE
+static inline void speex_free (void *ptr)
+{
+ free(ptr);
+}
+#endif
+
+/** Same as speex_free, except that the area is only needed inside a Speex call (might cause problem with wideband though) */
+#ifndef OVERRIDE_SPEEX_FREE_SCRATCH
+static inline void speex_free_scratch (void *ptr)
+{
+ free(ptr);
+}
+#endif
+
+/** Copy n bytes of memory from src to dst. The 0* term provides compile-time type checking */
+#ifndef OVERRIDE_SPEEX_COPY
+#define SPEEX_COPY(dst, src, n) (memcpy((dst), (src), (n)*sizeof(*(dst)) + 0*((dst)-(src)) ))
+#endif
+
+/** Copy n bytes of memory from src to dst, allowing overlapping regions. The 0* term
+ provides compile-time type checking */
+#ifndef OVERRIDE_SPEEX_MOVE
+#define SPEEX_MOVE(dst, src, n) (memmove((dst), (src), (n)*sizeof(*(dst)) + 0*((dst)-(src)) ))
+#endif
+
+/** Set n bytes of memory to value of c, starting at address s */
+#ifndef OVERRIDE_SPEEX_MEMSET
+#define SPEEX_MEMSET(dst, c, n) (memset((dst), (c), (n)*sizeof(*(dst))))
+#endif
+
+
+#ifndef OVERRIDE_SPEEX_FATAL
+static inline void _speex_fatal(const char *str, const char *file, int line)
+{
+ fprintf (stderr, "Fatal (internal) error in %s, line %d: %s\n", file, line, str);
+ exit(1);
+}
+#endif
+
+#ifndef OVERRIDE_SPEEX_WARNING
+static inline void speex_warning(const char *str)
+{
+#ifndef DISABLE_WARNINGS
+ fprintf (stderr, "warning: %s\n", str);
+#endif
+}
+#endif
+
+#ifndef OVERRIDE_SPEEX_WARNING_INT
+static inline void speex_warning_int(const char *str, int val)
+{
+#ifndef DISABLE_WARNINGS
+ fprintf (stderr, "warning: %s %d\n", str, val);
+#endif
+}
+#endif
+
+#ifndef OVERRIDE_SPEEX_NOTIFY
+static inline void speex_notify(const char *str)
+{
+#ifndef DISABLE_NOTIFICATIONS
+ fprintf (stderr, "notification: %s\n", str);
+#endif
+}
+#endif
+
+#ifndef OVERRIDE_SPEEX_PUTC
+/** Speex wrapper for putc */
+static inline void _speex_putc(int ch, void *file)
+{
+ FILE *f = (FILE *)file;
+ fprintf(f, "%c", ch);
+}
+#endif
+
+#define speex_fatal(str) _speex_fatal(str, __FILE__, __LINE__);
+#define speex_assert(cond) {if (!(cond)) {speex_fatal("assertion failed: " #cond);}}
+
+#ifndef RELEASE
+static inline 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
+
+#endif
+
diff --git a/libcelt/testcelt.c b/libcelt/testcelt.c
new file mode 100644
index 0000000..5ec5601
--- /dev/null
+++ b/libcelt/testcelt.c
@@ -0,0 +1,5 @@
+int main()
+{
+ return 0;
+}
+