[xiph-commits] r13978 - in trunk/speex: libspeex src

jm at svn.xiph.org jm at svn.xiph.org
Sun Oct 14 08:42:47 PDT 2007


Author: jm
Date: 2007-10-14 08:42:47 -0700 (Sun, 14 Oct 2007)
New Revision: 13978

Modified:
   trunk/speex/libspeex/Makefile.am
   trunk/speex/libspeex/jitter.c
   trunk/speex/libspeex/math_approx.c
   trunk/speex/libspeex/math_approx.h
   trunk/speex/libspeex/misc.c
   trunk/speex/libspeex/misc.h
   trunk/speex/src/Makefile.am
Log:
splitting libspeex in tw


Modified: trunk/speex/libspeex/Makefile.am
===================================================================
--- trunk/speex/libspeex/Makefile.am	2007-10-14 13:56:10 UTC (rev 13977)
+++ trunk/speex/libspeex/Makefile.am	2007-10-14 15:42:47 UTC (rev 13978)
@@ -6,18 +6,20 @@
 
 INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/include -I$(top_builddir) @OGG_CFLAGS@
 
-lib_LTLIBRARIES = libspeex.la
+lib_LTLIBRARIES = libspeex.la libspeexvoip.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 	speex.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 	preprocess.c 	smallft.c 	lbr_48k_tables.c \
-				jitter.c 	mdf.c vorbis_psy.c fftwrap.c kiss_fft.c _kiss_fft_guts.h kiss_fft.h \
-	kiss_fftr.c kiss_fftr.h window.c filterbank.c resample.c
+				exc_10_16_table.c 	exc_20_32_table.c 	hexc_10_32_table.c 	speex_header.c \
+				speex_callbacks.c 	stereo.c window.c
 
+libspeexvoip_la_SOURCES = preprocess.c 	smallft.c 	lbr_48k_tables.c \
+				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 \
@@ -28,6 +30,7 @@
 
 
 libspeex_la_LDFLAGS = -no-undefined -version-info @SPEEX_LT_CURRENT@:@SPEEX_LT_REVISION@:@SPEEX_LT_AGE@
+libspeexvoip_la_LDFLAGS = -no-undefined -version-info @SPEEX_LT_CURRENT@:@SPEEX_LT_REVISION@:@SPEEX_LT_AGE@
 
 noinst_PROGRAMS = testenc testenc_wb testenc_uwb testdenoise testecho
 testenc_SOURCES = testenc.c
@@ -37,6 +40,6 @@
 testenc_uwb_SOURCES = testenc_uwb.c
 testenc_uwb_LDADD = libspeex.la
 testdenoise_SOURCES = testdenoise.c
-testdenoise_LDADD = libspeex.la
+testdenoise_LDADD = libspeexvoip.la
 testecho_SOURCES = testecho.c
-testecho_LDADD = libspeex.la
+testecho_LDADD = libspeexvoip.la

Modified: trunk/speex/libspeex/jitter.c
===================================================================
--- trunk/speex/libspeex/jitter.c	2007-10-14 13:56:10 UTC (rev 13977)
+++ trunk/speex/libspeex/jitter.c	2007-10-14 15:42:47 UTC (rev 13978)
@@ -544,87 +544,3 @@
    return 0;
 }
 
-
-
-void speex_jitter_init(SpeexJitter *jitter, void *decoder, int sampling_rate)
-{
-   jitter->dec = decoder;
-   speex_decoder_ctl(decoder, SPEEX_GET_FRAME_SIZE, &jitter->frame_size);
-
-   jitter->packets = jitter_buffer_init(jitter->frame_size);
-
-   speex_bits_init(&jitter->current_packet);
-   jitter->valid_bits = 0;
-
-}
-
-void speex_jitter_destroy(SpeexJitter *jitter)
-{
-   jitter_buffer_destroy(jitter->packets);
-   speex_bits_destroy(&jitter->current_packet);
-}
-
-void speex_jitter_put(SpeexJitter *jitter, char *packet, int len, int timestamp)
-{
-   JitterBufferPacket p;
-   p.data = packet;
-   p.len = len;
-   p.timestamp = timestamp;
-   p.span = jitter->frame_size;
-   jitter_buffer_put(jitter->packets, &p);
-}
-
-void speex_jitter_get(SpeexJitter *jitter, spx_int16_t *out, int *current_timestamp)
-{
-   int i;
-   int ret;
-   spx_int32_t activity;
-   char data[2048];
-   JitterBufferPacket packet;
-   packet.data = data;
-   
-   if (jitter->valid_bits)
-   {
-      /* Try decoding last received packet */
-      ret = speex_decode_int(jitter->dec, &jitter->current_packet, out);
-      if (ret == 0)
-      {
-         jitter_buffer_tick(jitter->packets);
-         return;
-      } else {
-         jitter->valid_bits = 0;
-      }
-   }
-
-   ret = jitter_buffer_get(jitter->packets, &packet, NULL);
-   
-   if (ret != JITTER_BUFFER_OK)
-   {
-      /* No packet found */
-
-      /*fprintf (stderr, "lost/late frame\n");*/
-      /*Packet is late or lost*/
-      speex_decode_int(jitter->dec, NULL, out);
-   } else {
-      speex_bits_read_from(&jitter->current_packet, packet.data, packet.len);
-      /* Decode packet */
-      ret = speex_decode_int(jitter->dec, &jitter->current_packet, out);
-      if (ret == 0)
-      {
-         jitter->valid_bits = 1;
-      } else {
-         /* Error while decoding */
-         for (i=0;i<jitter->frame_size;i++)
-            out[i]=0;
-      }
-   }
-   speex_decoder_ctl(jitter->dec, SPEEX_GET_ACTIVITY, &activity);
-   if (activity < 30)
-      jitter_buffer_update_delay(jitter->packets, &packet, NULL);
-   jitter_buffer_tick(jitter->packets);
-}
-
-int speex_jitter_get_pointer_timestamp(SpeexJitter *jitter)
-{
-   return jitter_buffer_get_pointer_timestamp(jitter->packets);
-}

Modified: trunk/speex/libspeex/math_approx.c
===================================================================
--- trunk/speex/libspeex/math_approx.c	2007-10-14 13:56:10 UTC (rev 13977)
+++ trunk/speex/libspeex/math_approx.c	2007-10-14 15:42:47 UTC (rev 13978)
@@ -36,256 +36,3 @@
 
 #include "math_approx.h"
 #include "misc.h"
-
-spx_int16_t spx_ilog2(spx_uint32_t x)
-{
-   int r=0;
-   if (x>=(spx_int32_t)65536)
-   {
-      x >>= 16;
-      r += 16;
-   }
-   if (x>=256)
-   {
-      x >>= 8;
-      r += 8;
-   }
-   if (x>=16)
-   {
-      x >>= 4;
-      r += 4;
-   }
-   if (x>=4)
-   {
-      x >>= 2;
-      r += 2;
-   }
-   if (x>=2)
-   {
-      r += 1;
-   }
-   return r;
-}
-
-spx_int16_t spx_ilog4(spx_uint32_t x)
-{
-   int r=0;
-   if (x>=(spx_int32_t)65536)
-   {
-      x >>= 16;
-      r += 8;
-   }
-   if (x>=256)
-   {
-      x >>= 8;
-      r += 4;
-   }
-   if (x>=16)
-   {
-      x >>= 4;
-      r += 2;
-   }
-   if (x>=4)
-   {
-      r += 1;
-   }
-   return r;
-}
-
-#ifdef FIXED_POINT
-
-/* 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
-#define C2 -12627
-#define C3 4215*/
-
-/* sqrt(x) ~= 0.22178 + 1.29227*x - 0.77070*x^2 + 0.25659*x^3 (for .25 < x < 1) */
-#define C0 3634
-#define C1 21173
-#define C2 -12627
-#define C3 4204
-
-spx_word16_t spx_sqrt(spx_word32_t x)
-{
-   int k;
-   spx_word32_t rt;
-   k = spx_ilog4(x)-6;
-   x = VSHR32(x, (k<<1));
-   rt = ADD16(C0, MULT16_16_Q14(x, ADD16(C1, MULT16_16_Q14(x, ADD16(C2, MULT16_16_Q14(x, (C3)))))));
-   rt = VSHR32(rt,7-k);
-   return rt;
-}
-
-/* log(x) ~= -2.18151 + 4.20592*x - 2.88938*x^2 + 0.86535*x^3 (for .5 < x < 1) */
-
-
-#define A1 16469
-#define A2 2242
-#define A3 1486
-
-spx_word16_t spx_acos(spx_word16_t x)
-{
-   int s=0;
-   spx_word16_t ret;
-   spx_word16_t sq;
-   if (x<0)
-   {
-      s=1;
-      x = NEG16(x);
-   }
-   x = SUB16(16384,x);
-   
-   x = x >> 1;
-   sq = MULT16_16_Q13(x, ADD16(A1, MULT16_16_Q13(x, ADD16(A2, MULT16_16_Q13(x, (A3))))));
-   ret = spx_sqrt(SHL32(EXTEND32(sq),13));
-   
-   /*ret = spx_sqrt(67108864*(-1.6129e-04 + 2.0104e+00*f + 2.7373e-01*f*f + 1.8136e-01*f*f*f));*/
-   if (s)
-      ret = SUB16(25736,ret);
-   return ret;
-}
-
-
-#define K1 8192
-#define K2 -4096
-#define K3 340
-#define K4 -10
-
-spx_word16_t spx_cos(spx_word16_t x)
-{
-   spx_word16_t x2;
-
-   if (x<12868)
-   {
-      x2 = MULT16_16_P13(x,x);
-      return ADD32(K1, MULT16_16_P13(x2, ADD32(K2, MULT16_16_P13(x2, ADD32(K3, MULT16_16_P13(K4, x2))))));
-   } else {
-      x = SUB16(25736,x);
-      x2 = MULT16_16_P13(x,x);
-      return SUB32(-K1, MULT16_16_P13(x2, ADD32(K2, MULT16_16_P13(x2, ADD32(K3, MULT16_16_P13(K4, x2))))));
-   }
-}
-
-#define L1 32767
-#define L2 -7651
-#define L3 8277
-#define L4 -626
-
-static inline spx_word16_t _spx_cos_pi_2(spx_word16_t x)
-{
-   spx_word16_t x2;
-   
-   x2 = MULT16_16_P15(x,x);
-   return ADD16(1,MIN16(32766,ADD32(SUB16(L1,x2), MULT16_16_P15(x2, ADD32(L2, MULT16_16_P15(x2, ADD32(L3, MULT16_16_P15(L4, x2))))))));
-}
-
-spx_word16_t spx_cos_norm(spx_word32_t x)
-{
-   x = x&0x0001ffff;
-   if (x>SHL32(EXTEND32(1), 16))
-      x = SUB32(SHL32(EXTEND32(1), 17),x);
-   if (x&0x00007fff)
-   {
-      if (x<SHL32(EXTEND32(1), 15))
-      {
-         return _spx_cos_pi_2(EXTRACT16(x));
-      } else {
-         return NEG32(_spx_cos_pi_2(EXTRACT16(65536-x)));
-      }
-   } else {
-      if (x&0x0000ffff)
-         return 0;
-      else if (x&0x0001ffff)
-         return -32767;
-      else
-         return 32767;
-   }
-}
-
-/*
- K0 = 1
- K1 = log(2)
- K2 = 3-4*log(2)
- K3 = 3*log(2) - 2
-*/
-#define D0 16384
-#define D1 11356
-#define D2 3726
-#define D3 1301
-/* Input in Q11 format, output in Q16 */
-static spx_word32_t spx_exp2(spx_word16_t x)
-{
-   int integer;
-   spx_word16_t frac;
-   integer = SHR16(x,11);
-   if (integer>14)
-      return 0x7fffffff;
-   else if (integer < -15)
-      return 0;
-   frac = SHL16(x-SHL16(integer,11),3);
-   frac = ADD16(D0, MULT16_16_Q14(frac, ADD16(D1, MULT16_16_Q14(frac, ADD16(D2 , MULT16_16_Q14(D3,frac))))));
-   return VSHR32(EXTEND32(frac), -integer-2);
-}
-
-/* Input in Q11 format, output in Q16 */
-spx_word32_t spx_exp(spx_word16_t x)
-{
-   if (x>21290)
-      return 0x7fffffff;
-   else if (x<-21290)
-      return 0;
-   else
-      return spx_exp2(MULT16_16_P14(23637,x));
-}
-#define M1 32767
-#define M2 -21
-#define M3 -11943
-#define M4 4936
-
-static inline spx_word16_t spx_atan01(spx_word16_t x)
-{
-   return MULT16_16_P15(x, ADD32(M1, MULT16_16_P15(x, ADD32(M2, MULT16_16_P15(x, ADD32(M3, MULT16_16_P15(M4, x)))))));
-}
-
-/* Input in Q15, output in Q14 */
-spx_word16_t spx_atan(spx_word32_t x)
-{
-   if (x <= 32767)
-   {
-      return SHR16(spx_atan01(x),1);
-   } else {
-      int e = spx_ilog2(x);
-      if (e>=29)
-         return 25736;
-      x = DIV32_16(SHL32(EXTEND32(32767),29-e), EXTRACT16(SHR32(x, e-14)));
-      return SUB16(25736, SHR16(spx_atan01(x),1));
-   }
-}
-#else
-
-#ifndef M_PI
-#define M_PI           3.14159265358979323846  /* pi */
-#endif
-
-#define C1 0.9999932946f
-#define C2 -0.4999124376f
-#define C3 0.0414877472f
-#define C4 -0.0012712095f
-
-
-#define SPX_PI_2 1.5707963268
-spx_word16_t spx_cos(spx_word16_t x)
-{
-   if (x<SPX_PI_2)
-   {
-      x *= x;
-      return C1 + x*(C2+x*(C3+C4*x));
-   } else {
-      x = M_PI-x;
-      x *= x;
-      return NEG16(C1 + x*(C2+x*(C3+C4*x)));
-   }
-}
-
-#endif

Modified: trunk/speex/libspeex/math_approx.h
===================================================================
--- trunk/speex/libspeex/math_approx.h	2007-10-14 13:56:10 UTC (rev 13977)
+++ trunk/speex/libspeex/math_approx.h	2007-10-14 15:42:47 UTC (rev 13978)
@@ -37,20 +37,8 @@
 
 #include "misc.h"
 
-spx_word16_t spx_cos(spx_word16_t x);
-spx_int16_t spx_ilog2(spx_uint32_t x);
-spx_int16_t spx_ilog4(spx_uint32_t x);
-#ifdef FIXED_POINT
-spx_word16_t spx_sqrt(spx_word32_t x);
-spx_word16_t spx_acos(spx_word16_t x);
-spx_word32_t spx_exp(spx_word16_t x);
-spx_word16_t spx_cos_norm(spx_word32_t x);
+#ifndef FIXED_POINT
 
-/* Input in Q15, output in Q14 */
-spx_word16_t spx_atan(spx_word32_t x);
-
-#else
-
 #define spx_sqrt sqrt
 #define spx_acos acos
 #define spx_exp exp
@@ -59,4 +47,265 @@
 
 #endif
 
+
+
+static inline spx_int16_t spx_ilog2(spx_uint32_t x)
+{
+   int r=0;
+   if (x>=(spx_int32_t)65536)
+   {
+      x >>= 16;
+      r += 16;
+   }
+   if (x>=256)
+   {
+      x >>= 8;
+      r += 8;
+   }
+   if (x>=16)
+   {
+      x >>= 4;
+      r += 4;
+   }
+   if (x>=4)
+   {
+      x >>= 2;
+      r += 2;
+   }
+   if (x>=2)
+   {
+      r += 1;
+   }
+   return r;
+}
+
+static inline spx_int16_t spx_ilog4(spx_uint32_t x)
+{
+   int r=0;
+   if (x>=(spx_int32_t)65536)
+   {
+      x >>= 16;
+      r += 8;
+   }
+   if (x>=256)
+   {
+      x >>= 8;
+      r += 4;
+   }
+   if (x>=16)
+   {
+      x >>= 4;
+      r += 2;
+   }
+   if (x>=4)
+   {
+      r += 1;
+   }
+   return r;
+}
+
+#ifdef FIXED_POINT
+
+/* 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
+#define C2 -12627
+#define C3 4215*/
+
+/* sqrt(x) ~= 0.22178 + 1.29227*x - 0.77070*x^2 + 0.25659*x^3 (for .25 < x < 1) */
+#define C0 3634
+#define C1 21173
+#define C2 -12627
+#define C3 4204
+
+static inline spx_word16_t spx_sqrt(spx_word32_t x)
+{
+   int k;
+   spx_word32_t rt;
+   k = spx_ilog4(x)-6;
+   x = VSHR32(x, (k<<1));
+   rt = ADD16(C0, MULT16_16_Q14(x, ADD16(C1, MULT16_16_Q14(x, ADD16(C2, MULT16_16_Q14(x, (C3)))))));
+   rt = VSHR32(rt,7-k);
+   return rt;
+}
+
+/* log(x) ~= -2.18151 + 4.20592*x - 2.88938*x^2 + 0.86535*x^3 (for .5 < x < 1) */
+
+
+#define A1 16469
+#define A2 2242
+#define A3 1486
+
+static inline spx_word16_t spx_acos(spx_word16_t x)
+{
+   int s=0;
+   spx_word16_t ret;
+   spx_word16_t sq;
+   if (x<0)
+   {
+      s=1;
+      x = NEG16(x);
+   }
+   x = SUB16(16384,x);
+   
+   x = x >> 1;
+   sq = MULT16_16_Q13(x, ADD16(A1, MULT16_16_Q13(x, ADD16(A2, MULT16_16_Q13(x, (A3))))));
+   ret = spx_sqrt(SHL32(EXTEND32(sq),13));
+   
+   /*ret = spx_sqrt(67108864*(-1.6129e-04 + 2.0104e+00*f + 2.7373e-01*f*f + 1.8136e-01*f*f*f));*/
+   if (s)
+      ret = SUB16(25736,ret);
+   return ret;
+}
+
+
+#define K1 8192
+#define K2 -4096
+#define K3 340
+#define K4 -10
+
+static inline spx_word16_t spx_cos(spx_word16_t x)
+{
+   spx_word16_t x2;
+
+   if (x<12868)
+   {
+      x2 = MULT16_16_P13(x,x);
+      return ADD32(K1, MULT16_16_P13(x2, ADD32(K2, MULT16_16_P13(x2, ADD32(K3, MULT16_16_P13(K4, x2))))));
+   } else {
+      x = SUB16(25736,x);
+      x2 = MULT16_16_P13(x,x);
+      return SUB32(-K1, MULT16_16_P13(x2, ADD32(K2, MULT16_16_P13(x2, ADD32(K3, MULT16_16_P13(K4, x2))))));
+   }
+}
+
+#define L1 32767
+#define L2 -7651
+#define L3 8277
+#define L4 -626
+
+static inline spx_word16_t _spx_cos_pi_2(spx_word16_t x)
+{
+   spx_word16_t x2;
+   
+   x2 = MULT16_16_P15(x,x);
+   return ADD16(1,MIN16(32766,ADD32(SUB16(L1,x2), MULT16_16_P15(x2, ADD32(L2, MULT16_16_P15(x2, ADD32(L3, MULT16_16_P15(L4, x2))))))));
+}
+
+static inline spx_word16_t spx_cos_norm(spx_word32_t x)
+{
+   x = x&0x0001ffff;
+   if (x>SHL32(EXTEND32(1), 16))
+      x = SUB32(SHL32(EXTEND32(1), 17),x);
+   if (x&0x00007fff)
+   {
+      if (x<SHL32(EXTEND32(1), 15))
+      {
+         return _spx_cos_pi_2(EXTRACT16(x));
+      } else {
+         return NEG32(_spx_cos_pi_2(EXTRACT16(65536-x)));
+      }
+   } else {
+      if (x&0x0000ffff)
+         return 0;
+      else if (x&0x0001ffff)
+         return -32767;
+      else
+         return 32767;
+   }
+}
+
+/*
+ K0 = 1
+ K1 = log(2)
+ K2 = 3-4*log(2)
+ K3 = 3*log(2) - 2
+*/
+#define D0 16384
+#define D1 11356
+#define D2 3726
+#define D3 1301
+/* Input in Q11 format, output in Q16 */
+static inline spx_word32_t spx_exp2(spx_word16_t x)
+{
+   int integer;
+   spx_word16_t frac;
+   integer = SHR16(x,11);
+   if (integer>14)
+      return 0x7fffffff;
+   else if (integer < -15)
+      return 0;
+   frac = SHL16(x-SHL16(integer,11),3);
+   frac = ADD16(D0, MULT16_16_Q14(frac, ADD16(D1, MULT16_16_Q14(frac, ADD16(D2 , MULT16_16_Q14(D3,frac))))));
+   return VSHR32(EXTEND32(frac), -integer-2);
+}
+
+/* Input in Q11 format, output in Q16 */
+static inline spx_word32_t spx_exp(spx_word16_t x)
+{
+   if (x>21290)
+      return 0x7fffffff;
+   else if (x<-21290)
+      return 0;
+   else
+      return spx_exp2(MULT16_16_P14(23637,x));
+}
+#define M1 32767
+#define M2 -21
+#define M3 -11943
+#define M4 4936
+
+static inline spx_word16_t spx_atan01(spx_word16_t x)
+{
+   return MULT16_16_P15(x, ADD32(M1, MULT16_16_P15(x, ADD32(M2, MULT16_16_P15(x, ADD32(M3, MULT16_16_P15(M4, x)))))));
+}
+
+#undef M1
+#undef M2
+#undef M3
+#undef M4
+
+/* Input in Q15, output in Q14 */
+static inline spx_word16_t spx_atan(spx_word32_t x)
+{
+   if (x <= 32767)
+   {
+      return SHR16(spx_atan01(x),1);
+   } else {
+      int e = spx_ilog2(x);
+      if (e>=29)
+         return 25736;
+      x = DIV32_16(SHL32(EXTEND32(32767),29-e), EXTRACT16(SHR32(x, e-14)));
+      return SUB16(25736, SHR16(spx_atan01(x),1));
+   }
+}
+#else
+
+#ifndef M_PI
+#define M_PI           3.14159265358979323846  /* pi */
 #endif
+
+#define C1 0.9999932946f
+#define C2 -0.4999124376f
+#define C3 0.0414877472f
+#define C4 -0.0012712095f
+
+
+#define SPX_PI_2 1.5707963268
+static inline spx_word16_t spx_cos(spx_word16_t x)
+{
+   if (x<SPX_PI_2)
+   {
+      x *= x;
+      return C1 + x*(C2+x*(C3+C4*x));
+   } else {
+      x = M_PI-x;
+      x *= x;
+      return NEG16(C1 + x*(C2+x*(C3+C4*x)));
+   }
+}
+
+#endif
+
+
+#endif

Modified: trunk/speex/libspeex/misc.c
===================================================================
--- trunk/speex/libspeex/misc.c	2007-10-14 13:56:10 UTC (rev 13977)
+++ trunk/speex/libspeex/misc.c	2007-10-14 15:42:47 UTC (rev 13978)
@@ -47,124 +47,3 @@
 #include "misc_bfin.h"
 #endif
 
-#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
-
-#ifdef FIXED_DEBUG
-long long spx_mips=0;
-#endif
-
-
-#ifndef OVERRIDE_SPEEX_ALLOC
-void *speex_alloc (int size)
-{
-   return calloc(size,1);
-}
-#endif
-
-#ifndef OVERRIDE_SPEEX_ALLOC_SCRATCH
-void *speex_alloc_scratch (int size)
-{
-   return calloc(size,1);
-}
-#endif
-
-#ifndef OVERRIDE_SPEEX_REALLOC
-void *speex_realloc (void *ptr, int size)
-{
-   return realloc(ptr, size);
-}
-#endif
-
-#ifndef OVERRIDE_SPEEX_FREE
-void speex_free (void *ptr)
-{
-   free(ptr);
-}
-#endif
-
-#ifndef OVERRIDE_SPEEX_FREE_SCRATCH
-void speex_free_scratch (void *ptr)
-{
-   free(ptr);
-}
-#endif
-
-#ifndef OVERRIDE_SPEEX_MOVE
-void *speex_move (void *dest, void *src, int n)
-{
-   return memmove(dest,src,n);
-}
-#endif
-
-#ifndef OVERRIDE_SPEEX_FATAL
-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
-void speex_warning(const char *str)
-{
-#ifndef DISABLE_WARNINGS
-   fprintf (stderr, "warning: %s\n", str);
-#endif
-}
-#endif
-
-#ifndef OVERRIDE_SPEEX_WARNING_INT
-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
-void speex_notify(const char *str)
-{
-#ifndef DISABLE_NOTIFICATIONS
-   fprintf (stderr, "notification: %s\n", str);
-#endif
-}
-#endif
-
-#ifdef FIXED_POINT
-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
-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
-void _speex_putc(int ch, void *file)
-{
-   FILE *f = (FILE *)file;
-   fprintf(f, "%c", ch);
-}
-#endif

Modified: trunk/speex/libspeex/misc.h
===================================================================
--- trunk/speex/libspeex/misc.h	2007-10-14 13:56:10 UTC (rev 13977)
+++ trunk/speex/libspeex/misc.h	2007-10-14 15:42:47 UTC (rev 13978)
@@ -35,6 +35,10 @@
 #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. */
@@ -70,11 +74,6 @@
 
 #include "arch.h"
 
-#ifndef RELEASE
-/** Print a named vector to stdout */
-void print_vec(float *vec, int len, char *name);
-#endif
-
 /** Convert little endian */
 static inline spx_int32_t le_int(spx_int32_t i)
 {
@@ -94,40 +93,135 @@
 #define speex_fatal(str) _speex_fatal(str, __FILE__, __LINE__);
 #define speex_assert(cond) {if (!(cond)) {speex_fatal("assertion failed: " #cond);}}
 
+#ifndef RELEASE
+static 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 */
-void *speex_alloc (int size);
+#ifndef OVERRIDE_SPEEX_ALLOC
+static 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) */
-void *speex_alloc_scratch (int size);
+#ifndef OVERRIDE_SPEEX_ALLOC_SCRATCH
+static 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 */
-void *speex_realloc (void *ptr, int size);
+#ifndef OVERRIDE_SPEEX_REALLOC
+static 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 */
-void speex_free (void *ptr);
+#ifndef OVERRIDE_SPEEX_FREE
+static void speex_free (void *ptr)
+{
+   free(ptr);
+}
+#endif
 
-/** Same as speex_alloc, except that the area is only needed inside a Speex call (might cause problem with wideband though) */
-void speex_free_scratch (void *ptr);
+/** 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 void speex_free_scratch (void *ptr)
+{
+   free(ptr);
+}
+#endif
 
-/** Speex wrapper for mem_move */
-void *speex_move (void *dest, void *src, int n);
+/** Print warning message with integer argument to stderr */
+#ifndef OVERRIDE_SPEEX_MOVE
+static void *speex_move (void *dest, void *src, int n)
+{
+   return memmove(dest,src,n);
+}
+#endif
 
-/** Abort with an error message to stderr (internal Speex error) */
-void _speex_fatal(const char *str, const char *file, int line);
+#ifndef OVERRIDE_SPEEX_FATAL
+static 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
 
-/** Print warning message to stderr (programming error) */
-void speex_warning(const char *str);
+#ifndef OVERRIDE_SPEEX_WARNING
+static void speex_warning(const char *str)
+{
+#ifndef DISABLE_WARNINGS
+   fprintf (stderr, "warning: %s\n", str);
+#endif
+}
+#endif
 
-/** Print warning message with integer argument to stderr */
-void speex_warning_int(const char *str, int val);
+#ifndef OVERRIDE_SPEEX_WARNING_INT
+static void speex_warning_int(const char *str, int val)
+{
+#ifndef DISABLE_WARNINGS
+   fprintf (stderr, "warning: %s %d\n", str, val);
+#endif
+}
+#endif
 
-/** Print notification message to stderr */
-void speex_notify(const char *str);
+#ifndef OVERRIDE_SPEEX_NOTIFY
+static void speex_notify(const char *str)
+{
+#ifndef DISABLE_NOTIFICATIONS
+   fprintf (stderr, "notification: %s\n", str);
+#endif
+}
+#endif
 
-/** Generate a random number */
-spx_word16_t speex_rand(spx_word16_t std, spx_int32_t *seed);
+#ifdef FIXED_POINT
+/** Generate a pseudo-random number */
+static 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 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 */
-void _speex_putc(int ch, void *file);
+static void _speex_putc(int ch, void *file)
+{
+   FILE *f = (FILE *)file;
+   fprintf(f, "%c", ch);
+}
+#endif
 
 #endif

Modified: trunk/speex/src/Makefile.am
===================================================================
--- trunk/speex/src/Makefile.am	2007-10-14 13:56:10 UTC (rev 13977)
+++ trunk/speex/src/Makefile.am	2007-10-14 15:42:47 UTC (rev 13978)
@@ -17,9 +17,9 @@
 bin_PROGRAMS = speexenc speexdec
 
 speexenc_SOURCES = speexenc.c wav_io.c skeleton.c
-speexenc_LDADD = $(top_builddir)/libspeex/libspeex.la \
+speexenc_LDADD = $(top_builddir)/libspeex/libspeex.la $(top_builddir)/libspeex/libspeexvoip.la \
 	$(OGG_LIBS)
 
 speexdec_SOURCES = speexdec.c wav_io.c
-speexdec_LDADD = $(top_builddir)/libspeex/libspeex.la \
+speexdec_LDADD = $(top_builddir)/libspeex/libspeex.la $(top_builddir)/libspeex/libspeexvoip.la \
 	$(OGG_LIBS)



More information about the commits mailing list