[xiph-commits] r9178 - in trunk/speex: . include/speex libspeex src
jm at motherfish-iii.xiph.org
jm at motherfish-iii.xiph.org
Sun Apr 24 23:17:04 PDT 2005
Author: jm
Date: 2005-04-24 23:16:58 -0700 (Sun, 24 Apr 2005)
New Revision: 9178
Added:
trunk/speex/include/speex/speex_types.h.in
Modified:
trunk/speex/configure.ac
trunk/speex/include/speex/speex.h
trunk/speex/include/speex/speex_header.h
trunk/speex/include/speex/speex_preprocess.h
trunk/speex/include/speex/speex_stereo.h
trunk/speex/libspeex/arch.h
trunk/speex/libspeex/fixed_debug.h
trunk/speex/libspeex/ltp.c
trunk/speex/libspeex/misc.c
trunk/speex/libspeex/misc.h
trunk/speex/libspeex/preprocess.c
trunk/speex/libspeex/speex.c
trunk/speex/libspeex/stereo.c
trunk/speex/src/wav_io.c
trunk/speex/src/wav_io.h
Log:
Now autodetects (and handles) size of integer types.
Modified: trunk/speex/configure.ac
===================================================================
--- trunk/speex/configure.ac 2005-04-25 01:22:27 UTC (rev 9177)
+++ trunk/speex/configure.ac 2005-04-25 06:16:58 UTC (rev 9178)
@@ -34,7 +34,43 @@
AC_C_BIGENDIAN
AC_C_CONST
AC_C_INLINE
+AC_C_RESTRICT
+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_CHECK_HEADERS(sys/soundcard.h sys/audioio.h)
XIPH_PATH_OGG([src="src"], [src=""])
@@ -110,9 +146,10 @@
AC_OUTPUT([Makefile libspeex/Makefile src/Makefile doc/Makefile Speex.spec
include/Makefile include/speex/Makefile speex.pc
win32/Makefile win32/libspeex/Makefile win32/speexenc/Makefile
- win32/speexdec/Makefile ])
+ win32/speexdec/Makefile include/speex/speex_types.h ])
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 Speex library (libspeex) will be built (no encoder/decoder executable)"
echo "You can download libogg from http://www.vorbis.com/download.psp"
fi
Modified: trunk/speex/include/speex/speex.h
===================================================================
--- trunk/speex/include/speex/speex.h 2005-04-25 01:22:27 UTC (rev 9177)
+++ trunk/speex/include/speex/speex.h 2005-04-25 06:16:58 UTC (rev 9178)
@@ -36,7 +36,8 @@
#ifndef SPEEX_H
#define SPEEX_H
-#include "speex_bits.h"
+#include "speex/speex_bits.h"
+#include "speex/speex_types.h"
#ifdef __cplusplus
extern "C" {
@@ -305,7 +306,7 @@
@param in Frame that will be encoded with a +-2^15 range
@param bits Bit-stream where the data will be written
*/
-int speex_encode_int(void *state, short *in, SpeexBits *bits);
+int speex_encode_int(void *state, spx_int16_t *in, SpeexBits *bits);
/** Used like the ioctl function to control the encoder parameters
*
@@ -351,7 +352,7 @@
* @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_int(void *state, SpeexBits *bits, short *out);
+int speex_decode_int(void *state, SpeexBits *bits, spx_int16_t *out);
/** Used like the ioctl function to control the encoder parameters
*
Modified: trunk/speex/include/speex/speex_header.h
===================================================================
--- trunk/speex/include/speex/speex_header.h 2005-04-25 01:22:27 UTC (rev 9177)
+++ trunk/speex/include/speex/speex_header.h 2005-04-25 06:16:58 UTC (rev 9178)
@@ -37,14 +37,14 @@
#ifndef SPEEX_HEADER_H
#define SPEEX_HEADER_H
+#include "speex/speex_types.h"
+
#ifdef __cplusplus
extern "C" {
#endif
struct SpeexMode;
-typedef signed long spx_int32_t;
-
#define SPEEX_HEADER_STRING_LENGTH 8
/** Maximum number of characters for encoding the Speex version number in the header */
Modified: trunk/speex/include/speex/speex_preprocess.h
===================================================================
--- trunk/speex/include/speex/speex_preprocess.h 2005-04-25 01:22:27 UTC (rev 9177)
+++ trunk/speex/include/speex/speex_preprocess.h 2005-04-25 06:16:58 UTC (rev 9178)
@@ -34,6 +34,8 @@
#ifndef SPEEX_PREPROCESS_H
#define SPEEX_PREPROCESS_H
+#include "speex/speex_types.h"
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -107,10 +109,10 @@
void speex_preprocess_state_destroy(SpeexPreprocessState *st);
/** Preprocess a frame */
-int speex_preprocess(SpeexPreprocessState *st, short *x, int *echo);
+int speex_preprocess(SpeexPreprocessState *st, spx_int16_t *x, int *echo);
/** Preprocess a frame */
-void speex_preprocess_estimate_update(SpeexPreprocessState *st, short *x, int *echo);
+void speex_preprocess_estimate_update(SpeexPreprocessState *st, spx_int16_t *x, int *echo);
/** Used like the ioctl function to control the preprocessor parameters */
int speex_preprocess_ctl(SpeexPreprocessState *st, int request, void *ptr);
Modified: trunk/speex/include/speex/speex_stereo.h
===================================================================
--- trunk/speex/include/speex/speex_stereo.h 2005-04-25 01:22:27 UTC (rev 9177)
+++ trunk/speex/include/speex/speex_stereo.h 2005-04-25 06:16:58 UTC (rev 9178)
@@ -35,7 +35,8 @@
#ifndef STEREO_H
#define STEREO_H
-#include "speex_bits.h"
+#include "speex/speex_types.h"
+#include "speex/speex_bits.h"
#ifdef __cplusplus
extern "C" {
@@ -58,13 +59,13 @@
void speex_encode_stereo(float *data, int frame_size, SpeexBits *bits);
/** Transforms a stereo frame into a mono frame and stores intensity stereo info in 'bits' */
-void speex_encode_stereo_int(short *data, int frame_size, SpeexBits *bits);
+void speex_encode_stereo_int(spx_int16_t *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);
/** Transforms a mono frame into a stereo frame using intensity stereo info */
-void speex_decode_stereo_int(short *data, int frame_size, SpeexStereoState *stereo);
+void speex_decode_stereo_int(spx_int16_t *data, int frame_size, SpeexStereoState *stereo);
/** Callback handler for intensity stereo info */
int speex_std_stereo_request_handler(SpeexBits *bits, void *state, void *data);
Added: trunk/speex/include/speex/speex_types.h.in
===================================================================
--- trunk/speex/include/speex/speex_types.h.in 2005-04-25 01:22:27 UTC (rev 9177)
+++ trunk/speex/include/speex/speex_types.h.in 2005-04-25 06:16:58 UTC (rev 9178)
@@ -0,0 +1,10 @@
+#ifndef __SPEEX_TYPES_H__
+#define __SPEEX_TYPES_H__
+
+/* these are filled in by configure */
+typedef @SIZE16@ spx_int16_t;
+typedef @SIZE32@ spx_int32_t;
+typedef unsigned @SIZE32@ spx_uint32_t;
+
+#endif
+
Modified: trunk/speex/libspeex/arch.h
===================================================================
--- trunk/speex/libspeex/arch.h 2005-04-25 01:22:27 UTC (rev 9177)
+++ trunk/speex/libspeex/arch.h 2005-04-25 06:16:58 UTC (rev 9178)
@@ -35,16 +35,14 @@
#ifndef ARCH_H
#define ARCH_H
+#include "speex/speex_types.h"
+
#define ABS(x) ((x) < 0 ? (-(x)) : (x))
-/* FIXME: Should provide better detection */
-/*typedef signed long spx_int32_t;*/
-typedef unsigned long spx_uint32_t;
-
#ifdef FIXED_POINT
-typedef signed short spx_word16_t;
-typedef signed int spx_word32_t;
+typedef spx_int16_t spx_word16_t;
+typedef spx_int32_t spx_word32_t;
#ifdef _MSC_VER
typedef __int64 spx_word64_t;
#else
Modified: trunk/speex/libspeex/fixed_debug.h
===================================================================
--- trunk/speex/libspeex/fixed_debug.h 2005-04-25 01:22:27 UTC (rev 9177)
+++ trunk/speex/libspeex/fixed_debug.h 2005-04-25 06:16:58 UTC (rev 9178)
@@ -48,11 +48,11 @@
int res;
if (!VERIFY_SHORT(x))
{
- fprintf (stderr, "NEG16: input is not short: %d\n", x);
+ fprintf (stderr, "NEG16: input is not short: %d\n", (int)x);
}
res = -x;
if (!VERIFY_SHORT(res))
- fprintf (stderr, "NEG16: output is not short: %d\n", res);
+ fprintf (stderr, "NEG16: output is not short: %d\n", (int)res);
spx_mips++;
return res;
}
@@ -61,11 +61,11 @@
long long res;
if (!VERIFY_INT(x))
{
- fprintf (stderr, "NEG16: input is not int: %d\n", x);
+ fprintf (stderr, "NEG16: input is not int: %d\n", (int)x);
}
res = -x;
if (!VERIFY_INT(res))
- fprintf (stderr, "NEG16: output is not int: %d\n", res);
+ fprintf (stderr, "NEG16: output is not int: %d\n", (int)res);
spx_mips++;
return res;
}
@@ -126,11 +126,11 @@
long long res;
if (!VERIFY_INT(a) || !VERIFY_SHORT(shift))
{
- fprintf (stderr, "SHR32: inputs are not int: %d %d\n", a, shift);
+ fprintf (stderr, "SHR32: inputs are not int: %d %d\n", (int)a, shift);
}
res = a>>shift;
if (!VERIFY_INT(res))
- fprintf (stderr, "SHR32: output is not int: %d\n", res);
+ fprintf (stderr, "SHR32: output is not int: %d\n", (int)res);
spx_mips++;
return res;
}
@@ -139,11 +139,11 @@
long long res;
if (!VERIFY_INT(a) || !VERIFY_SHORT(shift))
{
- fprintf (stderr, "SHR32: inputs are not int: %d %d\n", a, shift);
+ fprintf (stderr, "SHR32: inputs are not int: %d %d\n", (int)a, shift);
}
res = a<<shift;
if (!VERIFY_INT(res))
- fprintf (stderr, "SHR32: output is not int: %d\n", res);
+ fprintf (stderr, "SHR32: output is not int: %d\n", (int)res);
spx_mips++;
return res;
}
@@ -254,11 +254,11 @@
long long res;
if (!VERIFY_SHORT(a) || !VERIFY_INT(b))
{
- fprintf (stderr, "MULT16_32_Q%d: inputs are not short+int: %d %d\n", Q, a, b);
+ fprintf (stderr, "MULT16_32_Q%d: inputs are not short+int: %d %d\n", Q, (int)a, (int)b);
}
res = (((long long)a)*(long long)b) >> Q;
if (!VERIFY_INT(res))
- fprintf (stderr, "MULT16_32_Q%d: output is not int: %d*%d=%d\n", Q, a, b,(int)res);
+ fprintf (stderr, "MULT16_32_Q%d: output is not int: %d*%d=%d\n", Q, (int)a, (int)b,(int)res);
spx_mips+=5;
return res;
}
Modified: trunk/speex/libspeex/ltp.c
===================================================================
--- trunk/speex/libspeex/ltp.c 2005-04-25 01:22:27 UTC (rev 9177)
+++ trunk/speex/libspeex/ltp.c 2005-04-25 06:16:58 UTC (rev 9178)
@@ -54,7 +54,6 @@
static spx_word32_t inner_prod(const spx_word16_t *x, const spx_word16_t *y, int len)
{
- int i=0;
spx_word32_t sum=0;
len >>= 2;
while(len--)
Modified: trunk/speex/libspeex/misc.c
===================================================================
--- trunk/speex/libspeex/misc.c 2005-04-25 01:22:27 UTC (rev 9177)
+++ trunk/speex/libspeex/misc.c 2005-04-25 06:16:58 UTC (rev 9178)
@@ -79,26 +79,6 @@
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;
-}
-
#if BYTES_PER_CHAR == 2
void speex_memcpy_bytes(char *dst, char *src, int nbytes)
{
@@ -119,7 +99,7 @@
void speex_memset_bytes(char *dst, char c, int nbytes)
{
int i;
- short cc = ((c << 8) | c);
+ spx_int16_t cc = ((c << 8) | c);
int nchars = nbytes/BYTES_PER_CHAR;
for (i=0;i<nchars;i++)
dst[i]=cc;
Modified: trunk/speex/libspeex/misc.h
===================================================================
--- trunk/speex/libspeex/misc.h 2005-04-25 01:22:27 UTC (rev 9177)
+++ trunk/speex/libspeex/misc.h 2005-04-25 06:16:58 UTC (rev 9178)
@@ -52,10 +52,6 @@
spx_uint32_t be_int(spx_uint32_t i);
spx_uint32_t le_int(spx_uint32_t 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);
Modified: trunk/speex/libspeex/preprocess.c
===================================================================
--- trunk/speex/libspeex/preprocess.c 2005-04-25 01:22:27 UTC (rev 9177)
+++ trunk/speex/libspeex/preprocess.c 2005-04-25 06:16:58 UTC (rev 9178)
@@ -547,7 +547,7 @@
}
-static void preprocess_analysis(SpeexPreprocessState *st, short *x)
+static void preprocess_analysis(SpeexPreprocessState *st, spx_int16_t *x)
{
int i;
int N = st->ps_size;
@@ -620,7 +620,7 @@
#define NOISE_OVERCOMPENS 1.4
-int speex_preprocess(SpeexPreprocessState *st, short *x, int *echo)
+int speex_preprocess(SpeexPreprocessState *st, spx_int16_t *x, int *echo)
{
int i;
int is_speech=1;
@@ -937,7 +937,7 @@
return is_speech;
}
-void speex_preprocess_estimate_update(SpeexPreprocessState *st, short *x, int *echo)
+void speex_preprocess_estimate_update(SpeexPreprocessState *st, spx_int16_t *x, int *echo)
{
int i;
int N = st->ps_size;
Modified: trunk/speex/libspeex/speex.c
===================================================================
--- trunk/speex/libspeex/speex.c 2005-04-25 01:22:27 UTC (rev 9177)
+++ trunk/speex/libspeex/speex.c 2005-04-25 06:16:58 UTC (rev 9178)
@@ -87,7 +87,7 @@
{
int i;
int N;
- short short_in[MAX_IN_SAMPLES];
+ spx_int16_t short_in[MAX_IN_SAMPLES];
speex_encoder_ctl(state, SPEEX_GET_FRAME_SIZE, &N);
for (i=0;i<N;i++)
{
@@ -96,12 +96,12 @@
else if (in[i]<-32768.f)
short_in[i] = -32768;
else
- short_in[i] = (short)floor(.5+in[i]);
+ short_in[i] = (spx_int16_t)floor(.5+in[i]);
}
return (*((SpeexMode**)state))->enc(state, short_in, bits);
}
-int speex_encode_int(void *state, short *in, SpeexBits *bits)
+int speex_encode_int(void *state, spx_int16_t *in, SpeexBits *bits)
{
SpeexMode *mode;
mode = *(SpeexMode**)state;
@@ -120,7 +120,7 @@
return ret;
}
-int speex_decode_int(void *state, SpeexBits *bits, short *out)
+int speex_decode_int(void *state, SpeexBits *bits, spx_int16_t *out)
{
SpeexMode *mode = *(SpeexMode**)state;
return (mode)->dec(state, bits, out);
@@ -133,7 +133,7 @@
return (*((SpeexMode**)state))->enc(state, in, bits);
}
-int speex_encode_int(void *state, short *in, SpeexBits *bits)
+int speex_encode_int(void *state, spx_int16_t *in, SpeexBits *bits)
{
int i;
int N;
@@ -149,7 +149,7 @@
return (*((SpeexMode**)state))->dec(state, bits, out);
}
-int speex_decode_int(void *state, SpeexBits *bits, short *out)
+int speex_decode_int(void *state, SpeexBits *bits, spx_int16_t *out)
{
int i;
int N;
@@ -164,7 +164,7 @@
else if (float_out[i]<-32768.f)
out[i] = -32768;
else
- out[i] = (short)floor(.5+float_out[i]);
+ out[i] = (spx_int16_t)floor(.5+float_out[i]);
}
return ret;
}
Modified: trunk/speex/libspeex/stereo.c
===================================================================
--- trunk/speex/libspeex/stereo.c 2005-04-25 01:22:27 UTC (rev 9177)
+++ trunk/speex/libspeex/stereo.c 2005-04-25 06:16:58 UTC (rev 9178)
@@ -78,7 +78,7 @@
speex_bits_pack(bits, tmp, 2);
}
-void speex_encode_stereo_int(short *data, int frame_size, SpeexBits *bits)
+void speex_encode_stereo_int(spx_int16_t *data, int frame_size, SpeexBits *bits)
{
int i, tmp;
float e_left=0, e_right=0, e_tot=0;
@@ -144,7 +144,7 @@
}
}
-void speex_decode_stereo_int(short *data, int frame_size, SpeexStereoState *stereo)
+void speex_decode_stereo_int(spx_int16_t *data, int frame_size, SpeexStereoState *stereo)
{
float balance, e_ratio;
int i;
Modified: trunk/speex/src/wav_io.c
===================================================================
--- trunk/speex/src/wav_io.c 2005-04-25 01:22:27 UTC (rev 9177)
+++ trunk/speex/src/wav_io.c 2005-04-25 06:16:58 UTC (rev 9178)
@@ -36,8 +36,41 @@
#include <stdio.h>
#include <string.h>
-#include "misc.h"
+#include "speex/speex_types.h"
+static spx_uint32_t le_int(spx_uint32_t i)
+{
+ spx_uint32_t 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;
+}
+
+
int read_wav_header(FILE *file, int *rate, int *channels, int *format, int *size)
{
char ch[5];
Modified: trunk/speex/src/wav_io.h
===================================================================
--- trunk/speex/src/wav_io.h 2005-04-25 01:22:27 UTC (rev 9177)
+++ trunk/speex/src/wav_io.h 2005-04-25 06:16:58 UTC (rev 9178)
@@ -33,6 +33,9 @@
#include <stdio.h>
+unsigned short be_short(unsigned short s);
+unsigned short le_short(unsigned short s);
+
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);
More information about the commits
mailing list