[xiph-commits] r14021 - trunk/speex/libspeex
jm at svn.xiph.org
jm at svn.xiph.org
Sat Oct 20 07:04:02 PDT 2007
Author: jm
Date: 2007-10-20 07:04:02 -0700 (Sat, 20 Oct 2007)
New Revision: 14021
Added:
trunk/speex/libspeex/os_support.h
Modified:
trunk/speex/libspeex/Makefile.am
trunk/speex/libspeex/bits.c
trunk/speex/libspeex/cb_search.c
trunk/speex/libspeex/fftwrap.c
trunk/speex/libspeex/filterbank.c
trunk/speex/libspeex/jitter.c
trunk/speex/libspeex/kiss_fft.c
trunk/speex/libspeex/kiss_fftr.c
trunk/speex/libspeex/math_approx.h
trunk/speex/libspeex/mdf.c
trunk/speex/libspeex/misc.h
trunk/speex/libspeex/nb_celp.c
trunk/speex/libspeex/preprocess.c
trunk/speex/libspeex/resample.c
trunk/speex/libspeex/sb_celp.c
trunk/speex/libspeex/smallft.c
trunk/speex/libspeex/speex.c
trunk/speex/libspeex/speex_callbacks.c
trunk/speex/libspeex/speex_header.c
Log:
Put all the OS-dependent calls in os_support.h
Modified: trunk/speex/libspeex/Makefile.am
===================================================================
--- trunk/speex/libspeex/Makefile.am 2007-10-20 14:03:25 UTC (rev 14020)
+++ trunk/speex/libspeex/Makefile.am 2007-10-20 14:04:02 UTC (rev 14021)
@@ -20,13 +20,13 @@
jitter.c mdf.c fftwrap.c kiss_fft.c _kiss_fft_guts.h kiss_fft.h \
kiss_fftr.c kiss_fftr.h filterbank.c resample.c
-noinst_HEADERS = lsp.h nb_celp.h lpc.h lpc_bfin.h ltp.h quant_lsp.h \
- cb_search.h filters.h stack_alloc.h vq.h vq_sse.h vq_arm4.h vq_bfin.h \
- modes.h sb_celp.h vbr.h misc.h misc_bfin.h ltp_sse.h ltp_arm4.h \
- ltp_bfin.h filters_sse.h filters_arm4.h filters_bfin.h math_approx.h \
- smallft.h arch.h fixed_arm4.h fixed_arm5e.h fixed_bfin.h fixed_debug.h \
- fixed_generic.h cb_search_sse.h cb_search_arm4.h cb_search_bfin.h \
- fftwrap.h pseudofloat.h lsp_bfin.h quant_lsp_bfin.h filterbank.h
+noinst_HEADERS = arch.h cb_search_arm4.h cb_search_bfin.h cb_search_sse.h \
+ filters.h filters_arm4.h filters_bfin.h filters_sse.h fixed_arm4.h \
+ fixed_arm5e.h fixed_bfin.h fixed_debug.h lpc.h lpc_bfin.h ltp.h ltp_arm4.h \
+ ltp_sse.h math_approx.h misc.h misc_bfin.h nb_celp.h quant_lsp.h sb_celp.h \
+ stack_alloc.h vbr.h vq.h vq_arm4.h vq_bfin.h vq_sse.h cb_search.h fftwrap.h \
+ filterbank.h fixed_generic.h lsp.h lsp_bfin.h ltp_bfin.h modes.h os_support.h \
+ pseudofloat.h quant_lsp_bfin.h smallft.h vorbis_psy.h
libspeex_la_LDFLAGS = -no-undefined -version-info @SPEEX_LT_CURRENT@:@SPEEX_LT_REVISION@:@SPEEX_LT_AGE@
Modified: trunk/speex/libspeex/bits.c
===================================================================
--- trunk/speex/libspeex/bits.c 2007-10-20 14:03:25 UTC (rev 14020)
+++ trunk/speex/libspeex/bits.c 2007-10-20 14:04:02 UTC (rev 14021)
@@ -38,6 +38,7 @@
#include <speex/speex_bits.h>
#include "misc.h"
+#include "os_support.h"
/* Maximum size of the bit-stream (for fixed-size allocation) */
#ifndef MAX_CHARS_PER_FRAME
Modified: trunk/speex/libspeex/cb_search.c
===================================================================
--- trunk/speex/libspeex/cb_search.c 2007-10-20 14:03:25 UTC (rev 14020)
+++ trunk/speex/libspeex/cb_search.c 2007-10-20 14:04:02 UTC (rev 14021)
@@ -38,6 +38,8 @@
#include "stack_alloc.h"
#include "vq.h"
#include "misc.h"
+#include "math_approx.h"
+#include "os_support.h"
#ifdef _USE_SSE
#include "cb_search_sse.h"
Modified: trunk/speex/libspeex/fftwrap.c
===================================================================
--- trunk/speex/libspeex/fftwrap.c 2007-10-20 14:03:25 UTC (rev 14020)
+++ trunk/speex/libspeex/fftwrap.c 2007-10-20 14:04:02 UTC (rev 14021)
@@ -41,6 +41,7 @@
#include "misc.h"
+#include "os_support.h"
#define MAX_FFT_SIZE 2048
Modified: trunk/speex/libspeex/filterbank.c
===================================================================
--- trunk/speex/libspeex/filterbank.c 2007-10-20 14:03:25 UTC (rev 14020)
+++ trunk/speex/libspeex/filterbank.c 2007-10-20 14:04:02 UTC (rev 14021)
@@ -39,6 +39,7 @@
#include "misc.h"
#include <math.h>
#include "math_approx.h"
+#include "os_support.h"
#ifdef FIXED_POINT
Modified: trunk/speex/libspeex/jitter.c
===================================================================
--- trunk/speex/libspeex/jitter.c 2007-10-20 14:03:25 UTC (rev 14020)
+++ trunk/speex/libspeex/jitter.c 2007-10-20 14:04:02 UTC (rev 14021)
@@ -41,6 +41,7 @@
#include <speex/speex.h>
#include <speex/speex_bits.h>
#include <speex/speex_jitter.h>
+#include "os_support.h"
#ifndef NULL
#define NULL 0
Modified: trunk/speex/libspeex/kiss_fft.c
===================================================================
--- trunk/speex/libspeex/kiss_fft.c 2007-10-20 14:03:25 UTC (rev 14020)
+++ trunk/speex/libspeex/kiss_fft.c 2007-10-20 14:04:02 UTC (rev 14021)
@@ -20,6 +20,7 @@
#include "_kiss_fft_guts.h"
#include "misc.h"
+#include "os_support.h"
/* The guts header contains all the multiplication and addition macros that are defined for
fixed or floating point complex numbers. It also delares the kf_ internal functions.
Modified: trunk/speex/libspeex/kiss_fftr.c
===================================================================
--- trunk/speex/libspeex/kiss_fftr.c 2007-10-20 14:03:25 UTC (rev 14020)
+++ trunk/speex/libspeex/kiss_fftr.c 2007-10-20 14:04:02 UTC (rev 14021)
@@ -16,6 +16,7 @@
#include "config.h"
#endif
+#include "os_support.h"
#include "kiss_fftr.h"
#include "_kiss_fft_guts.h"
Modified: trunk/speex/libspeex/math_approx.h
===================================================================
--- trunk/speex/libspeex/math_approx.h 2007-10-20 14:03:25 UTC (rev 14020)
+++ trunk/speex/libspeex/math_approx.h 2007-10-20 14:04:02 UTC (rev 14021)
@@ -45,10 +45,18 @@
#define spx_cos_norm(x) (cos((.5f*M_PI)*(x)))
#define spx_atan atan
+/** Generate a pseudo-random number */
+static inline spx_word16_t speex_rand(spx_word16_t std, spx_int32_t *seed)
+{
+ spx_word32_t res;
+ *seed = 1664525 * *seed + 1013904223;
+ res = MULT16_16(EXTRACT16(SHR32(*seed,16)),std);
+ return EXTRACT16(PSHR32(SUB32(res, SHR32(res, 3)),14));
+}
+
#endif
-
static inline spx_int16_t spx_ilog2(spx_uint32_t x)
{
int r=0;
@@ -106,6 +114,19 @@
#ifdef FIXED_POINT
+/** Generate a pseudo-random number */
+static inline spx_word16_t speex_rand(spx_word16_t std, spx_int32_t *seed)
+{
+ const unsigned int jflone = 0x3f800000;
+ const unsigned int jflmsk = 0x007fffff;
+ union {int i; float f;} ran;
+ *seed = 1664525 * *seed + 1013904223;
+ ran.i = jflone | (jflmsk & *seed);
+ ran.f -= 1.5;
+ return 3.4642*std*ran.f;
+}
+
+
/* sqrt(x) ~= 0.22178 + 1.29227*x - 0.77070*x^2 + 0.25723*x^3 (for .25 < x < 1) */
/*#define C0 3634
#define C1 21173
Modified: trunk/speex/libspeex/mdf.c
===================================================================
--- trunk/speex/libspeex/mdf.c 2007-10-20 14:03:25 UTC (rev 14020)
+++ trunk/speex/libspeex/mdf.c 2007-10-20 14:04:02 UTC (rev 14021)
@@ -74,6 +74,7 @@
#include "fftwrap.h"
#include "pseudofloat.h"
#include "math_approx.h"
+#include "os_support.h"
#ifndef M_PI
#define M_PI 3.14159265358979323846
Modified: trunk/speex/libspeex/misc.h
===================================================================
--- trunk/speex/libspeex/misc.h 2007-10-20 14:03:25 UTC (rev 14020)
+++ trunk/speex/libspeex/misc.h 2007-10-20 14:04:02 UTC (rev 14021)
@@ -35,16 +35,12 @@
#ifndef MISC_H
#define MISC_H
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-
#ifndef SPEEX_VERSION
#define SPEEX_MAJOR_VERSION 1 /**< Major Speex version. */
#define SPEEX_MINOR_VERSION 1 /**< Minor Speex version. */
-#define SPEEX_MICRO_VERSION 14 /**< Micro Speex version. */
+#define SPEEX_MICRO_VERSION 15 /**< Micro Speex version. */
#define SPEEX_EXTRA_VERSION "" /**< Extra Speex version. */
-#define SPEEX_VERSION "speex-1.2beta2" /**< Speex version string. */
+#define SPEEX_VERSION "speex-1.2beta3" /**< Speex version string. */
#endif
/* A couple test to catch stupid option combinations */
@@ -90,138 +86,10 @@
#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
-
#ifdef FIXED_DEBUG
long long spx_mips=0;
#endif
-/** Speex wrapper for calloc. To do your own dynamic allocation, all you need to do is replace this function, speex_realloc and speex_free */
-#ifndef OVERRIDE_SPEEX_ALLOC
-static inline void *speex_alloc (int size)
-{
- 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)
-{
- 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
-
-/** Print warning message with integer argument to stderr */
-#ifndef OVERRIDE_SPEEX_MOVE
-static inline void *speex_move (void *dest, void *src, int n)
-{
- return memmove(dest,src,n);
-}
-#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
-
-#ifdef FIXED_POINT
-/** Generate a pseudo-random number */
-static inline spx_word16_t speex_rand(spx_word16_t std, spx_int32_t *seed)
-{
- spx_word32_t res;
- *seed = 1664525 * *seed + 1013904223;
- res = MULT16_16(EXTRACT16(SHR32(*seed,16)),std);
- return EXTRACT16(PSHR32(SUB32(res, SHR32(res, 3)),14));
-}
-#else
-/** Generate a pseudo-random number */
-static inline spx_word16_t speex_rand(spx_word16_t std, spx_int32_t *seed)
-{
- const unsigned int jflone = 0x3f800000;
- const unsigned int jflmsk = 0x007fffff;
- union {int i; float f;} ran;
- *seed = 1664525 * *seed + 1013904223;
- ran.i = jflone | (jflmsk & *seed);
- ran.f -= 1.5;
- return 3.4642*std*ran.f;
-}
-#endif
-
-#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
-
-#endif
Modified: trunk/speex/libspeex/nb_celp.c
===================================================================
--- trunk/speex/libspeex/nb_celp.c 2007-10-20 14:03:25 UTC (rev 14020)
+++ trunk/speex/libspeex/nb_celp.c 2007-10-20 14:04:02 UTC (rev 14021)
@@ -47,6 +47,7 @@
#include "vbr.h"
#include "misc.h"
#include "math_approx.h"
+#include "os_support.h"
#include <speex/speex_callbacks.h>
#ifdef VORBIS_PSYCHO
Added: trunk/speex/libspeex/os_support.h
===================================================================
--- trunk/speex/libspeex/os_support.h (rev 0)
+++ trunk/speex/libspeex/os_support.h 2007-10-20 14:04:02 UTC (rev 14021)
@@ -0,0 +1,151 @@
+/* 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.
+*/
+
+#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 */
+#ifndef OVERRIDE_SPEEX_ALLOC
+static inline void *speex_alloc (int size)
+{
+ 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)
+{
+ 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
+
+/** Print warning message with integer argument to stderr */
+#ifndef OVERRIDE_SPEEX_MOVE
+static inline void *speex_move (void *dest, void *src, int n)
+{
+ return memmove(dest,src,n);
+}
+#endif
+
+/** Print warning message with integer argument to stderr */
+#ifndef OVERRIDE_SPEEX_MOVE
+static inline void *speex_memset (void *s, int c, int n)
+{
+ return memset(s,c,n);
+}
+#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
Modified: trunk/speex/libspeex/preprocess.c
===================================================================
--- trunk/speex/libspeex/preprocess.c 2007-10-20 14:03:25 UTC (rev 14020)
+++ trunk/speex/libspeex/preprocess.c 2007-10-20 14:04:02 UTC (rev 14021)
@@ -66,6 +66,7 @@
#include "fftwrap.h"
#include "filterbank.h"
#include "math_approx.h"
+#include "os_support.h"
#ifndef M_PI
#define M_PI 3.14159263
Modified: trunk/speex/libspeex/resample.c
===================================================================
--- trunk/speex/libspeex/resample.c 2007-10-20 14:03:25 UTC (rev 14020)
+++ trunk/speex/libspeex/resample.c 2007-10-20 14:04:02 UTC (rev 14021)
@@ -71,6 +71,7 @@
#include "speex/speex_resampler.h"
#include "misc.h"
+#include "os_support.h"
#endif /* OUTSIDE_SPEEX */
#include <math.h>
Modified: trunk/speex/libspeex/sb_celp.c
===================================================================
--- trunk/speex/libspeex/sb_celp.c 2007-10-20 14:03:25 UTC (rev 14020)
+++ trunk/speex/libspeex/sb_celp.c 2007-10-20 14:04:02 UTC (rev 14021)
@@ -45,6 +45,7 @@
#include "ltp.h"
#include "misc.h"
#include "math_approx.h"
+#include "os_support.h"
#ifndef NULL
#define NULL 0
Modified: trunk/speex/libspeex/smallft.c
===================================================================
--- trunk/speex/libspeex/smallft.c 2007-10-20 14:03:25 UTC (rev 14020)
+++ trunk/speex/libspeex/smallft.c 2007-10-20 14:04:02 UTC (rev 14021)
@@ -35,6 +35,7 @@
#include <math.h>
#include "smallft.h"
#include "misc.h"
+#include "os_support.h"
static void drfti1(int n, float *wa, int *ifac){
static int ntryh[4] = { 4,2,3,5 };
Modified: trunk/speex/libspeex/speex.c
===================================================================
--- trunk/speex/libspeex/speex.c 2007-10-20 14:03:25 UTC (rev 14020)
+++ trunk/speex/libspeex/speex.c 2007-10-20 14:04:02 UTC (rev 14021)
@@ -38,6 +38,7 @@
#include "modes.h"
#include <math.h>
+#include "os_support.h"
#ifndef NULL
#define NULL 0
Modified: trunk/speex/libspeex/speex_callbacks.c
===================================================================
--- trunk/speex/libspeex/speex_callbacks.c 2007-10-20 14:03:25 UTC (rev 14020)
+++ trunk/speex/libspeex/speex_callbacks.c 2007-10-20 14:04:02 UTC (rev 14021)
@@ -38,6 +38,7 @@
#include <speex/speex_callbacks.h>
#include "misc.h"
+#include "os_support.h"
int speex_inband_handler(SpeexBits *bits, SpeexCallback *callback_list, void *state)
{
Modified: trunk/speex/libspeex/speex_header.c
===================================================================
--- trunk/speex/libspeex/speex_header.c 2007-10-20 14:03:25 UTC (rev 14020)
+++ trunk/speex/libspeex/speex_header.c 2007-10-20 14:04:02 UTC (rev 14021)
@@ -38,6 +38,7 @@
#include "misc.h"
#include <speex/speex_header.h>
#include <speex/speex.h>
+#include "os_support.h"
#ifndef NULL
#define NULL 0
More information about the commits
mailing list