[xiph-commits] r7405 - in branches/rel-1-0-branch/speex: .

jm at dactyl.lonelymoon.com jm
Wed Jul 28 15:30:05 PDT 2004


include/speex libspeex win32
Message-ID: <20040728223005.47A4B9AAAB at dactyl.lonelymoon.com>

Author: jm
Date: Wed Jul 28 15:30:05 2004
New Revision: 7405

Modified:
branches/rel-1-0-branch/speex/configure.in
branches/rel-1-0-branch/speex/include/speex/speex.h
branches/rel-1-0-branch/speex/libspeex/modes.c
branches/rel-1-0-branch/speex/speex.pc.in
branches/rel-1-0-branch/speex/win32/Makefile.am
Log:
backported speex_encode_int and speex_decode_int from 1.1.x


Modified: branches/rel-1-0-branch/speex/configure.in
===================================================================
--- branches/rel-1-0-branch/speex/configure.in	2004-07-28 22:26:10 UTC (rev 7404)
+++ branches/rel-1-0-branch/speex/configure.in	2004-07-28 22:30:04 UTC (rev 7405)
@@ -8,9 +8,9 @@
SPEEX_EXTRA_VERSION=
SPEEX_VERSION=$SPEEX_MAJOR_VERSION.$SPEEX_MINOR_VERSION.$SPEEX_MICRO_VERSION$SPEEX_EXTRA_VERSION

-SPEEX_LT_CURRENT=3
+SPEEX_LT_CURRENT=4
SPEEX_LT_REVISION=0
-SPEEX_LT_AGE=2
+SPEEX_LT_AGE=3

AC_SUBST(SPEEX_LT_CURRENT)
AC_SUBST(SPEEX_LT_REVISION)

Modified: branches/rel-1-0-branch/speex/include/speex/speex.h
===================================================================
--- branches/rel-1-0-branch/speex/include/speex/speex.h	2004-07-28 22:26:10 UTC (rev 7404)
+++ branches/rel-1-0-branch/speex/include/speex/speex.h	2004-07-28 22:30:04 UTC (rev 7405)
@@ -264,6 +264,14 @@
*/
int speex_encode(void *state, float *in, SpeexBits *bits);

+/** Uses an existing encoder state to encode one frame of speech pointed to by
+    "in". The encoded bit-stream is saved in "bits".
+ @param state Encoder state
+ @param in Frame that will be encoded with a +-2^16 range
+ @param bits Bit-stream where the data will be written
+ */
+int speex_encode_int(void *state, short *in, SpeexBits *bits);
+
/** Used like the ioctl function to control the encoder parameters
*
* @param state Encoder state
@@ -298,7 +306,17 @@
* @param out Where to write the decoded frame
* @return return status (0 for no error, -1 for end of stream, -2 other)
*/
+
int speex_decode(void *state, SpeexBits *bits, float *out);
+/** Uses an existing decoder state to decode one frame of speech from
+ * bit-stream bits. The output speech is saved written to out.
+ *
+ * @param state Decoder state
+ * @param bits Bit-stream from which to decode the frame (NULL if the packet was lost)
+ * @param out Where to write the decoded frame
+ * @return return status (0 for no error, -1 for end of stream, -2 other)
+ */
+int speex_decode_int(void *state, SpeexBits *bits, short *out);

/** Used like the ioctl function to control the encoder parameters
*

Modified: branches/rel-1-0-branch/speex/libspeex/modes.c
===================================================================
--- branches/rel-1-0-branch/speex/libspeex/modes.c	2004-07-28 22:26:10 UTC (rev 7404)
+++ branches/rel-1-0-branch/speex/libspeex/modes.c	2004-07-28 22:30:04 UTC (rev 7405)
@@ -45,6 +45,8 @@
#define NULL 0
#endif

+#define MAX_IN_SAMPLES 640
+
SpeexMode *speex_mode_list[SPEEX_NB_MODES] = {&speex_nb_mode, &speex_wb_mode, &speex_uwb_mode};

/* Extern declarations for all codebooks we use here */
@@ -572,6 +574,17 @@
return (*((SpeexMode**)state))->enc(state, in, bits);
}

+int speex_encode_int(void *state, short *in, SpeexBits *bits)
+{
+   int i;
+   int N;
+   float float_in[MAX_IN_SAMPLES];
+   speex_encoder_ctl(state, SPEEX_GET_FRAME_SIZE, &N);
+   for (i=0;i<N;i++)
+      float_in[i] = in[i];
+   return (*((SpeexMode**)state))->enc(state, float_in, bits);
+}
+
void speex_decoder_destroy(void *state)
{
(*((SpeexMode**)state))->dec_destroy(state);
@@ -582,6 +595,25 @@
return (*((SpeexMode**)state))->dec(state, bits, out);
}

+int speex_decode_int(void *state, SpeexBits *bits, short *out)
+{
+   int i;
+   int N;
+   float float_out[MAX_IN_SAMPLES];
+   int ret;
+   speex_decoder_ctl(state, SPEEX_GET_FRAME_SIZE, &N);
+   ret = (*((SpeexMode**)state))->dec(state, bits, float_out);
+   for (i=0;i<N;i++)
+   {
+      if (float_out[i]>32767.f)
+         out[i] = 32767;
+      else if (float_out[i]<-32768.f)
+         out[i] = -32768;
+      else
+         out[i] = (short)floor(.5+float_out[i]);
+   }
+   return ret;
+}

int speex_encoder_ctl(void *state, int request, void *ptr)
{

Modified: branches/rel-1-0-branch/speex/speex.pc.in
===================================================================
--- branches/rel-1-0-branch/speex/speex.pc.in	2004-07-28 22:26:10 UTC (rev 7404)
+++ branches/rel-1-0-branch/speex/speex.pc.in	2004-07-28 22:30:04 UTC (rev 7405)
@@ -1,4 +1,4 @@
-# libogg pkg-config source file
+# libspeex pkg-config source file

prefix=@prefix@
exec_prefix=@exec_prefix@

Modified: branches/rel-1-0-branch/speex/win32/Makefile.am
===================================================================
--- branches/rel-1-0-branch/speex/win32/Makefile.am	2004-07-28 22:26:10 UTC (rev 7404)
+++ branches/rel-1-0-branch/speex/win32/Makefile.am	2004-07-28 22:30:04 UTC (rev 7405)
@@ -3,5 +3,7 @@
# Disable automatic dependency tracking if using other tools than gcc and gmake
#AUTOMAKE_OPTIONS = no-dependencies

+EXTRA_DIST = speex.iss
+
SUBDIRS = libspeex speexenc speexdec




More information about the commits mailing list