summaryrefslogtreecommitdiff
path: root/apps/codecs/libspeex/speex
diff options
context:
space:
mode:
authorDan Everton <dan@iocaine.org>2007-03-12 11:54:07 +0000
committerDan Everton <dan@iocaine.org>2007-03-12 11:54:07 +0000
commit879070f89e004be03cef53ad7f61610e02e7aa00 (patch)
treeeccbcce2722da50eb473c78cf9ce16fad6602c00 /apps/codecs/libspeex/speex
parent19bba742e789e669d4cfc15ed3a5cef4aa64199d (diff)
downloadrockbox-879070f89e004be03cef53ad7f61610e02e7aa00.zip
rockbox-879070f89e004be03cef53ad7f61610e02e7aa00.tar.gz
rockbox-879070f89e004be03cef53ad7f61610e02e7aa00.tar.bz2
rockbox-879070f89e004be03cef53ad7f61610e02e7aa00.tar.xz
* Clean up speex.c a little.
* Sync to Speex SVN 12735 which includes some of our warnings fixes. * Move decoder output to IRAM. Not much perfomance gain though. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12735 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/codecs/libspeex/speex')
-rw-r--r--apps/codecs/libspeex/speex/speex.h18
-rw-r--r--apps/codecs/libspeex/speex/speex_jitter.h8
-rw-r--r--apps/codecs/libspeex/speex/speex_noglobals.h60
-rw-r--r--apps/codecs/libspeex/speex/speex_resampler.h221
4 files changed, 200 insertions, 107 deletions
diff --git a/apps/codecs/libspeex/speex/speex.h b/apps/codecs/libspeex/speex/speex.h
index 95facf4..0ae1aba 100644
--- a/apps/codecs/libspeex/speex/speex.h
+++ b/apps/codecs/libspeex/speex/speex.h
@@ -155,20 +155,6 @@ extern "C" {
/** Get status of input/output high-pass filtering */
#define SPEEX_GET_HIGHPASS 45
-/* Used internally, NOT TO BE USED in applications */
-/** Used internally*/
-#define SPEEX_GET_PI_GAIN 100
-/** Used internally*/
-#define SPEEX_GET_EXC 101
-/** Used internally*/
-#define SPEEX_GET_INNOV 102
-/** Used internally*/
-#define SPEEX_GET_DTX_STATUS 103
-/** Used internally*/
-#define SPEEX_SET_INNOVATION_SAVE 104
-/** Used internally*/
-#define SPEEX_SET_WIDEBAND 105
-
/* Preserving compatibility:*/
/** Equivalent to SPEEX_SET_ENH */
@@ -322,7 +308,9 @@ void speex_encoder_destroy(void *state);
/** 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^15 range
+ @param in Frame that will be encoded with a +-2^15 range. This data MAY be
+ overwritten by the encoder and should be considered uninitialised
+ after the call.
@param bits Bit-stream where the data will be written
@return 0 if frame needs not be transmitted (DTX only), 1 otherwise
*/
diff --git a/apps/codecs/libspeex/speex/speex_jitter.h b/apps/codecs/libspeex/speex/speex_jitter.h
index b998a02..a5314d6 100644
--- a/apps/codecs/libspeex/speex/speex_jitter.h
+++ b/apps/codecs/libspeex/speex/speex_jitter.h
@@ -81,7 +81,13 @@ struct _JitterBufferPacket {
#define JITTER_BUFFER_SET_MARGIN 0
/** Get minimum amount of extra buffering required (margin) */
#define JITTER_BUFFER_GET_MARGIN 1
+/* JITTER_BUFFER_SET_AVALIABLE_COUNT wouldn't make sense */
+/** Get the amount of avaliable packets currently buffered */
+#define JITTER_BUFFER_GET_AVALIABLE_COUNT 3
+#define JITTER_BUFFER_ADJUST_INTERPOLATE -1
+#define JITTER_BUFFER_ADJUST_OK 0
+#define JITTER_BUFFER_ADJUST_DROP 1
/** Initialises jitter buffer
*
@@ -138,6 +144,8 @@ void jitter_buffer_tick(JitterBuffer *jitter);
*/
int jitter_buffer_ctl(JitterBuffer *jitter, int request, void *ptr);
+int jitter_buffer_update_delay(JitterBuffer *jitter, JitterBufferPacket *packet, spx_uint32_t *start_offset);
+
/* @} */
/** @defgroup SpeexJitter SpeexJitter: Adaptive jitter buffer specifically for Speex
diff --git a/apps/codecs/libspeex/speex/speex_noglobals.h b/apps/codecs/libspeex/speex/speex_noglobals.h
deleted file mode 100644
index 1d46993..0000000
--- a/apps/codecs/libspeex/speex/speex_noglobals.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/* Copyright (C) 2004 CSIRO Australia */
-/* Copyright (C) 2002 Jean-Marc Valin*/
-/**
- @file speex_noglobals.h
- @brief Dynamically allocates the different modes of the codec
-*/
-/*
- 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 SPEEX_NOGLOBALS_H
-#define SPEEX_NOGLOBALS_H
-
-/* See README.symbian in the Speex source distribution for information
- * on using this API */
-
-typedef struct SpeexMode SpeexMode;
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/** Instantiate a mode */
-const SpeexMode * speex_mode_new (int modeID);
-
-/** Destroy a mode */
-void speex_mode_destroy (const SpeexMode * mode);
-
-#ifdef __cplusplus
-}
-#endif
-
-
-#endif
diff --git a/apps/codecs/libspeex/speex/speex_resampler.h b/apps/codecs/libspeex/speex/speex_resampler.h
index 501fab8..93642ce 100644
--- a/apps/codecs/libspeex/speex/speex_resampler.h
+++ b/apps/codecs/libspeex/speex/speex_resampler.h
@@ -41,22 +41,59 @@
#ifdef OUTSIDE_SPEEX
+/********* WARNING: MENTAL SANITY ENDS HERE *************/
+
+/* If the resampler is defined outside of Speex, we change the symbol names so that
+ there won't be any clash if linking with Speex later on. */
+
+/* #define RANDOM_PREFIX your software name here */
+#ifndef RANDOM_PREFIX
+#error "Please define RANDOM_PREFIX (above) to something specific to your project to prevent symbol name clashes"
+#endif
+
+#define CAT_PREFIX2(a,b) a ## b
+#define CAT_PREFIX(a,b) CAT_PREFIX2(a, b)
+
+#define speex_resampler_init CAT_PREFIX(RANDOM_PREFIX,_resampler_init)
+#define speex_resampler_init_frac CAT_PREFIX(RANDOM_PREFIX,_resampler_init_frac)
+#define speex_resampler_destroy CAT_PREFIX(RANDOM_PREFIX,_resampler_destroy)
+#define speex_resampler_process_float CAT_PREFIX(RANDOM_PREFIX,_resampler_process_float)
+#define speex_resampler_process_int CAT_PREFIX(RANDOM_PREFIX,_resampler_process_int)
+#define speex_resampler_process_interleaved_float CAT_PREFIX(RANDOM_PREFIX,_resampler_process_interleaved_float)
+#define speex_resampler_process_interleaved_int CAT_PREFIX(RANDOM_PREFIX,_resampler_process_interleaved_int)
+#define speex_resampler_set_rate CAT_PREFIX(RANDOM_PREFIX,_resampler_set_rate)
+#define speex_resampler_get_rate CAT_PREFIX(RANDOM_PREFIX,_resampler_get_rate)
+#define speex_resampler_set_rate_frac CAT_PREFIX(RANDOM_PREFIX,_resampler_set_rate_frac)
+#define speex_resampler_get_ratio CAT_PREFIX(RANDOM_PREFIX,_resampler_get_ratio)
+#define speex_resampler_set_quality CAT_PREFIX(RANDOM_PREFIX,_resampler_set_quality)
+#define speex_resampler_get_quality CAT_PREFIX(RANDOM_PREFIX,_resampler_get_quality)
+#define speex_resampler_set_input_stride CAT_PREFIX(RANDOM_PREFIX,_resampler_set_input_stride)
+#define speex_resampler_get_input_stride CAT_PREFIX(RANDOM_PREFIX,_resampler_get_input_stride)
+#define speex_resample_set_output_stride CAT_PREFIX(RANDOM_PREFIX,_resample_set_output_stride)
+#define speex_resample_get_output_stride CAT_PREFIX(RANDOM_PREFIX,_resample_get_output_stride)
+#define speex_resampler_skip_zeros CAT_PREFIX(RANDOM_PREFIX,_resampler_skip_zeros)
+#define speex_resampler_reset_mem CAT_PREFIX(RANDOM_PREFIX,_resampler_reset_mem)
+
#define spx_int16_t short
+
#ifdef FIXED_POINT
#define spx_word16_t short
#define spx_word32_t int
-#else
+
+#else /* FIXED_POINT */
+
#define spx_word16_t float
#define spx_word32_t float
#define MULT16_16(a,b) ((a)*(b))
+#define MULT16_32_Q15(a,b) ((a)*(b))
#define PSHR32(a,b) (a)
-#endif
+#endif /* FIXED_POINT */
-#else
+#else /* OUTSIDE_SPEEX */
#include "speex_types.h"
-#endif
+#endif /* OUTSIDE_SPEEX */
#ifdef __cplusplus
extern "C" {
@@ -71,81 +108,201 @@ extern "C" {
struct SpeexResamplerState_;
typedef struct SpeexResamplerState_ SpeexResamplerState;
-/** Create a new resampler. The sampling rate ratio is an arbitrary rational number
- * with both the numerator and denominator being 32-bit integers.
+/** Create a new resampler with integer input and output rates.
+ * @param nb_channels Number of channels to be processed
+ * @param in_rate Input sampling rate (integer number of Hz).
+ * @param out_rate Output sampling rate (integer number of Hz).
+ * @param quality Resampling quality between 0 and 10, where 0 has poor quality
+ * and 10 has very high quality.
+ * @return Newly created resampler state
+ * @retval NULL Error: not enough memory
+ */
+SpeexResamplerState *speex_resampler_init(int nb_channels,
+ int in_rate,
+ int out_rate,
+ int quality);
+
+/** Create a new resampler with fractional input/output rates. The sampling
+ * rate ratio is an arbitrary rational number with both the numerator and
+ * denominator being 32-bit integers.
* @param nb_channels Number of channels to be processed
* @param ratio_num Numerator of the sampling rate ratio
* @param ratio_den Denominator of the sampling rate ratio
- * @param in_rate Nominal input sampling rate rounded to the nearest integer (in Hz). This does not need to be accurate.
- * @param out_rate Nominal output sampling rate rounded to the nearest integer (in Hz). This does not need to be accurate.
- * @param quality Resampling quality between 0 and 10, where 0 has poor quality and 10 has very high quality.
+ * @param in_rate Input sampling rate rounded to the nearest integer (in Hz).
+ * @param out_rate Output sampling rate rounded to the nearest integer (in Hz).
+ * @param quality Resampling quality between 0 and 10, where 0 has poor quality
+ * and 10 has very high quality.
* @return Newly created resampler state
+ * @retval NULL Error: not enough memory
*/
-SpeexResamplerState *speex_resampler_init(int nb_channels, int ratio_num, int ratio_den, int in_rate, int out_rate, int quality);
+SpeexResamplerState *speex_resampler_init_frac(int nb_channels,
+ int ratio_num,
+ int ratio_den,
+ int in_rate,
+ int out_rate,
+ int quality);
/** Destroy a resampler state.
* @param st Resampler state
*/
void speex_resampler_destroy(SpeexResamplerState *st);
-/** Resample a float array. The input and output may *not* alias.
+/** Resample a float array. The input and output buffers must *not* overlap.
* @param st Resampler state
- * @param channel_index Index of the channel to process for the multi-channel base (0 otherwise)
+ * @param channel_index Index of the channel to process for the multi-channel
+ * base (0 otherwise)
* @param in Input buffer
- * @param in_len Number of input samples in the input buffer. Returns the number of samples processed
+ * @param in_len Number of input samples in the input buffer. Returns the
+ * number of samples processed
* @param out Output buffer
* @param out_len Size of the output buffer. Returns the number of samples written
*/
-void speex_resampler_process_float(SpeexResamplerState *st, int channel_index, const float *in, int *in_len, float *out, int *out_len);
+void speex_resampler_process_float(SpeexResamplerState *st,
+ int channel_index,
+ const float *in,
+ int *in_len,
+ float *out,
+ int *out_len);
-/** Resample an int array. The input and output may *not* alias.
+/** Resample an int array. The input and output buffers must *not* overlap.
* @param st Resampler state
- * @param channel_index Index of the channel to process for the multi-channel base (0 otherwise)
+ * @param channel_index Index of the channel to process for the multi-channel
+ * base (0 otherwise)
* @param in Input buffer
- * @param in_len Number of input samples in the input buffer. Returns the number of samples processed
+ * @param in_len Number of input samples in the input buffer. Returns the number
+ * of samples processed
* @param out Output buffer
* @param out_len Size of the output buffer. Returns the number of samples written
*/
-void speex_resampler_process_int(SpeexResamplerState *st, int channel_index, const spx_int16_t *in, int *in_len, spx_int16_t *out, int *out_len);
+void speex_resampler_process_int(SpeexResamplerState *st,
+ int channel_index,
+ const spx_int16_t *in,
+ int *in_len,
+ spx_int16_t *out,
+ int *out_len);
+
+/** Resample an interleaved float array. The input and output buffers must *not* overlap.
+ * @param st Resampler state
+ * @param in Input buffer
+ * @param in_len Number of input samples in the input buffer. Returns the number
+ * of samples processed. This is all per-channel.
+ * @param out Output buffer
+ * @param out_len Size of the output buffer. Returns the number of samples written.
+ * This is all per-channel.
+ */
+void speex_resampler_process_interleaved_float(SpeexResamplerState *st,
+ const float *in,
+ int *in_len,
+ float *out,
+ int *out_len);
-/** Resample an interleaved float array. The input and output may *not* alias.
+/** Resample an interleaved int array. The input and output buffers must *not* overlap.
* @param st Resampler state
* @param in Input buffer
- * @param in_len Number of input samples in the input buffer. Returns the number of samples processed. This is all per-channel.
+ * @param in_len Number of input samples in the input buffer. Returns the number
+ * of samples processed. This is all per-channel.
* @param out Output buffer
- * @param out_len Size of the output buffer. Returns the number of samples written. This is all per-channel.
+ * @param out_len Size of the output buffer. Returns the number of samples written.
+ * This is all per-channel.
+ */
+void speex_resampler_process_interleaved_int(SpeexResamplerState *st,
+ const spx_int16_t *in,
+ int *in_len,
+ spx_int16_t *out,
+ int *out_len);
+
+/** Set (change) the input/output sampling rates (integer value).
+ * @param st Resampler state
+ * @param in_rate Input sampling rate (integer number of Hz).
+ * @param out_rate Output sampling rate (integer number of Hz).
+ */
+void speex_resampler_set_rate(SpeexResamplerState *st,
+ int in_rate,
+ int out_rate);
+
+/** Get the current input/output sampling rates (integer value).
+ * @param st Resampler state
+ * @param in_rate Input sampling rate (integer number of Hz) copied.
+ * @param out_rate Output sampling rate (integer number of Hz) copied.
*/
-void speex_resampler_process_interleaved_float(SpeexResamplerState *st, const float *in, int *in_len, float *out, int *out_len);
+void speex_resampler_get_rate(SpeexResamplerState *st,
+ int *in_rate,
+ int *out_rate);
-/** Set (change) the input/output sampling rates and resampling ratio.
+/** Set (change) the input/output sampling rates and resampling ratio
+ * (fractional values in Hz supported).
* @param st Resampler state
* @param ratio_num Numerator of the sampling rate ratio
* @param ratio_den Denominator of the sampling rate ratio
- * @param in_rate Nominal input sampling rate rounded to the nearest integer (in Hz). This does not need to be accurate.
- * @param out_rate Nominal output sampling rate rounded to the nearest integer (in Hz). This does not need to be accurate.
+ * @param in_rate Input sampling rate rounded to the nearest integer (in Hz).
+ * @param out_rate Output sampling rate rounded to the nearest integer (in Hz).
+ */
+void speex_resampler_set_rate_frac(SpeexResamplerState *st,
+ int ratio_num,
+ int ratio_den,
+ int in_rate,
+ int out_rate);
+
+/** Get the current resampling ratio. This will be reduced to the least
+ * common denominator.
+ * @param st Resampler state
+ * @param ratio_num Numerator of the sampling rate ratio copied
+ * @param ratio_den Denominator of the sampling rate ratio copied
*/
-void speex_resampler_set_rate(SpeexResamplerState *st, int ratio_num, int ratio_den, int in_rate, int out_rate);
+void speex_resampler_get_ratio(SpeexResamplerState *st,
+ int *ratio_num,
+ int *ratio_den);
/** Set (change) the conversion quality.
* @param st Resampler state
- * @param quality Resampling quality between 0 and 10, where 0 has poor quality and 10 has very high quality.
+ * @param quality Resampling quality between 0 and 10, where 0 has poor
+ * quality and 10 has very high quality.
*/
-void speex_resampler_set_quality(SpeexResamplerState *st, int quality);
+void speex_resampler_set_quality(SpeexResamplerState *st,
+ int quality);
+
+/** Get the conversion quality.
+ * @param st Resampler state
+ * @param quality Resampling quality between 0 and 10, where 0 has poor
+ * quality and 10 has very high quality.
+ */
+void speex_resampler_get_quality(SpeexResamplerState *st,
+ int *quality);
/** Set (change) the input stride.
* @param st Resampler state
* @param stride Input stride
*/
-void speex_resampler_set_input_stride(SpeexResamplerState *st, int stride);
+void speex_resampler_set_input_stride(SpeexResamplerState *st,
+ int stride);
+
+/** Get the input stride.
+ * @param st Resampler state
+ * @param stride Input stride copied
+ */
+void speex_resampler_get_input_stride(SpeexResamplerState *st,
+ int *stride);
/** Set (change) the output stride.
* @param st Resampler state
* @param stride Output stride
*/
-void speex_resample_set_output_stride(SpeexResamplerState *st, int stride);
+void speex_resample_set_output_stride(SpeexResamplerState *st,
+ int stride);
+
+/** Get the output stride.
+ * @param st Resampler state copied
+ * @param stride Output stride
+ */
+void speex_resample_get_output_stride(SpeexResamplerState *st,
+ int *stride);
-/** Make sure that the first samples to go out of the resamplers don't have leading zeros.
- * This is only useful before starting to use a newly created resampler.
+/** Make sure that the first samples to go out of the resamplers don't have
+ * leading zeros. This is only useful before starting to use a newly created
+ * resampler. It is recommended to use that when resampling an audio file, as
+ * it will generate a file with the same length. For real-time processing,
+ * it is probably easier not to use this call (so that the output duration
+ * is the same for the first frame).
* @param st Resampler state
*/
void speex_resampler_skip_zeros(SpeexResamplerState *st);