diff options
| author | Dan Everton <dan@iocaine.org> | 2007-02-10 11:44:26 +0000 |
|---|---|---|
| committer | Dan Everton <dan@iocaine.org> | 2007-02-10 11:44:26 +0000 |
| commit | 7bf62e8da66ca8ff0acc2702f92ea4fe06eb94b1 (patch) | |
| tree | c9db4558a73ae3094839c4655fa0b8ebc2231c56 /apps/codecs/libspeex/speex | |
| parent | 51587512635a8b19e6a5f19a20074d0d4d1f17da (diff) | |
| download | rockbox-7bf62e8da66ca8ff0acc2702f92ea4fe06eb94b1.zip rockbox-7bf62e8da66ca8ff0acc2702f92ea4fe06eb94b1.tar.gz rockbox-7bf62e8da66ca8ff0acc2702f92ea4fe06eb94b1.tar.bz2 rockbox-7bf62e8da66ca8ff0acc2702f92ea4fe06eb94b1.tar.xz | |
* Sync Speex codec with Speex SVN revision 12449 (roughly Speex 1.2beta1).
* Redo the changes required to make Speex compile in Rockbox. Should be a bit easier to keep in sync with Speex SVN now.
* Fix name of Speex library in codecs Makefile.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12254 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/codecs/libspeex/speex')
| -rw-r--r-- | apps/codecs/libspeex/speex/ogg.h | 2 | ||||
| -rw-r--r-- | apps/codecs/libspeex/speex/speex.h | 6 | ||||
| -rw-r--r-- | apps/codecs/libspeex/speex/speex_bits.h | 24 | ||||
| -rw-r--r-- | apps/codecs/libspeex/speex/speex_callbacks.h | 10 | ||||
| -rw-r--r-- | apps/codecs/libspeex/speex/speex_config_types.h | 12 | ||||
| -rw-r--r-- | apps/codecs/libspeex/speex/speex_echo.h | 59 | ||||
| -rw-r--r-- | apps/codecs/libspeex/speex/speex_header.h | 7 | ||||
| -rw-r--r-- | apps/codecs/libspeex/speex/speex_jitter.h | 107 | ||||
| -rw-r--r-- | apps/codecs/libspeex/speex/speex_preprocess.h | 161 | ||||
| -rw-r--r-- | apps/codecs/libspeex/speex/speex_resampler.h | 162 | ||||
| -rw-r--r-- | apps/codecs/libspeex/speex/speex_stereo.h | 6 | ||||
| -rw-r--r-- | apps/codecs/libspeex/speex/speex_types.h | 109 |
12 files changed, 541 insertions, 124 deletions
diff --git a/apps/codecs/libspeex/speex/ogg.h b/apps/codecs/libspeex/speex/ogg.h index bd0a118..b4e10d7 100644 --- a/apps/codecs/libspeex/speex/ogg.h +++ b/apps/codecs/libspeex/speex/ogg.h @@ -21,6 +21,8 @@ extern "C" { #endif +#include "../../codec.h" + typedef short spx_ogg_int16_t; typedef unsigned short spx_ogg_uint16_t; typedef int spx_ogg_int32_t; diff --git a/apps/codecs/libspeex/speex/speex.h b/apps/codecs/libspeex/speex/speex.h index 7c63cfa..95facf4 100644 --- a/apps/codecs/libspeex/speex/speex.h +++ b/apps/codecs/libspeex/speex/speex.h @@ -35,6 +35,10 @@ #ifndef SPEEX_H #define SPEEX_H +/** @defgroup Codec Speex encoder and decoder + * This is the Speex codec itself. + * @{ + */ #include "speex_bits.h" #include "speex_types.h" @@ -427,5 +431,5 @@ const SpeexMode * speex_lib_get_mode (int mode); } #endif - +/** @}*/ #endif diff --git a/apps/codecs/libspeex/speex/speex_bits.h b/apps/codecs/libspeex/speex/speex_bits.h index b77202f..88334c4 100644 --- a/apps/codecs/libspeex/speex/speex_bits.h +++ b/apps/codecs/libspeex/speex/speex_bits.h @@ -35,6 +35,11 @@ #ifndef BITS_H #define BITS_H +/** @defgroup SpeexBits SpeexBits: Bit-stream manipulations + * This is the structure that holds the bit-stream when encoding or decoding + * with Speex. It allows some manipulations as well. + * @{ + */ #ifdef __cplusplus extern "C" { @@ -72,13 +77,20 @@ void speex_bits_rewind(SpeexBits *bits); void speex_bits_read_from(SpeexBits *bits, char *bytes, int len); /** Append bytes to the bit-stream + * * @param bits Bit-stream to operate on * @param bytes pointer to the bytes what will be appended * @param len Number of bytes of append */ void speex_bits_read_whole_bytes(SpeexBits *bits, char *bytes, int len); -/** Write the content of a bit-stream to an area of memory */ +/** Write the content of a bit-stream to an area of memory + * + * @param bits Bit-stream to operate on + * @param bytes Memory location where to write the bits + * @param max_len Maximum number of bytes to write (i.e. size of the "bytes" buffer) + * @return Number of bytes written to the "bytes" buffer +*/ int speex_bits_write(SpeexBits *bits, char *bytes, int max_len); /** Like speex_bits_write, but writes only the complete bytes in the stream. Also removes the written bytes from the stream */ @@ -114,13 +126,19 @@ unsigned int speex_bits_unpack_unsigned(SpeexBits *bits, int nbBits); */ int speex_bits_nbytes(SpeexBits *bits); -/** Same as speex_bits_unpack_unsigned, but without modifying the cursor position */ +/** Same as speex_bits_unpack_unsigned, but without modifying the cursor position + * + * @param bits Bit-stream to operate on + * @param nbBits Number of bits to look for + * @return Value of the bits peeked, interpreted as unsigned + */ unsigned int speex_bits_peek_unsigned(SpeexBits *bits, int nbBits); /** Get the value of the next bit in the stream, without modifying the * "cursor" position * * @param bits Bit-stream to operate on + * @return Value of the bit peeked (one bit only) */ int speex_bits_peek(SpeexBits *bits); @@ -134,6 +152,7 @@ void speex_bits_advance(SpeexBits *bits, int n); /** Returns the number of bits remaining to be read in a stream * * @param bits Bit-stream to operate on + * @return Number of bits that can still be read from the stream */ int speex_bits_remaining(SpeexBits *bits); @@ -148,4 +167,5 @@ void speex_bits_insert_terminator(SpeexBits *bits); } #endif +/* @} */ #endif diff --git a/apps/codecs/libspeex/speex/speex_callbacks.h b/apps/codecs/libspeex/speex/speex_callbacks.h index f6334f2..7892e2f 100644 --- a/apps/codecs/libspeex/speex/speex_callbacks.h +++ b/apps/codecs/libspeex/speex/speex_callbacks.h @@ -35,6 +35,9 @@ #ifndef SPEEX_CALLBACKS_H #define SPEEX_CALLBACKS_H +/** @defgroup SpeexCallbacks Various definitions for Speex callbacks supported by the decoder. + * @{ + */ #include "speex.h" @@ -110,13 +113,16 @@ int speex_default_user_handler(SpeexBits *bits, void *state, void *data); - +/** Standard handler for low mode request (change low mode, no questions asked) */ int speex_std_low_mode_request_handler(SpeexBits *bits, void *state, void *data); +/** Standard handler for VBR request (Set VBR, no questions asked) */ int speex_std_vbr_request_handler(SpeexBits *bits, void *state, void *data); +/** Standard handler for enhancer request (Turn ehnancer on/off, no questions asked) */ int speex_std_enh_request_handler(SpeexBits *bits, void *state, void *data); +/** Standard handler for VBR quality request (Set VBR quality, no questions asked) */ int speex_std_vbr_quality_request_handler(SpeexBits *bits, void *state, void *data); @@ -124,5 +130,5 @@ int speex_std_vbr_quality_request_handler(SpeexBits *bits, void *state, void *da } #endif - +/** @} */ #endif diff --git a/apps/codecs/libspeex/speex/speex_config_types.h b/apps/codecs/libspeex/speex/speex_config_types.h index bd54854..ef328d4 100644 --- a/apps/codecs/libspeex/speex/speex_config_types.h +++ b/apps/codecs/libspeex/speex/speex_config_types.h @@ -1,11 +1,13 @@ #ifndef __SPEEX_TYPES_H__ #define __SPEEX_TYPES_H__ -/* these are filled in by configure */ -typedef short spx_int16_t; -typedef unsigned short spx_uint16_t; -typedef int spx_int32_t; -typedef unsigned int spx_uint32_t; +#include "inttypes.h" +#define spx_int16_t int16_t +#define spx_uint16_t uint16_t +#define spx_int32_t int32_t +#define spx_uint32_t uint32_t +#define spx_int64_t int64_t +#define spx_uint64_t uint64_t #endif diff --git a/apps/codecs/libspeex/speex/speex_echo.h b/apps/codecs/libspeex/speex/speex_echo.h index 4813b5a..5b5eccd 100644 --- a/apps/codecs/libspeex/speex/speex_echo.h +++ b/apps/codecs/libspeex/speex/speex_echo.h @@ -33,8 +33,11 @@ #ifndef SPEEX_ECHO_H #define SPEEX_ECHO_H - -#include "speex/speex_types.h" +/** @defgroup SpeexEchoState SpeexEchoState: Acoustic echo canceller + * This is the acoustic echo canceller module. + * @{ + */ +#include "speex_types.h" #ifdef __cplusplus extern "C" { @@ -48,33 +51,63 @@ extern "C" { /** Get sampling rate */ #define SPEEX_ECHO_GET_SAMPLING_RATE 25 - -/*struct drft_lookup;*/ +/** Internal echo canceller state. Should never be accessed directly. */ struct SpeexEchoState_; +/** @class SpeexEchoState + * This holds the state of the echo canceller. You need one per channel. +*/ + +/** Internal echo canceller state. Should never be accessed directly. */ typedef struct SpeexEchoState_ SpeexEchoState; -/** Creates a new echo canceller state */ +/** Creates a new echo canceller state + * @param frame_size Number of samples to process at one time (should correspond to 10-20 ms) + * @param filter_length Number of samples of echo to cancel (should generally correspond to 100-500 ms) + * @return Newly-created echo canceller state + */ SpeexEchoState *speex_echo_state_init(int frame_size, int filter_length); -/** Destroys an echo canceller state */ +/** Destroys an echo canceller state + * @param st Echo canceller state +*/ void speex_echo_state_destroy(SpeexEchoState *st); -/** Performs echo cancellation a frame */ +/** Performs echo cancellation a frame, based on the audio sent to the speaker (no delay is added + * to playback ni this form) + * + * @param st Echo canceller state + * @param rec signal from the microphone (near end + far end echo) + * @param play Signal played to the speaker (received from far end) + * @param out Returns near-end signal with echo removed + */ +void speex_echo_cancellation(SpeexEchoState *st, const spx_int16_t *rec, const spx_int16_t *play, spx_int16_t *out); + +/** Performs echo cancellation a frame (deprecated) */ void speex_echo_cancel(SpeexEchoState *st, const spx_int16_t *rec, const spx_int16_t *play, spx_int16_t *out, spx_int32_t *Yout); -/** Perform echo cancellation using internal playback buffer */ -void speex_echo_capture(SpeexEchoState *st, const spx_int16_t *rec, spx_int16_t *out, spx_int32_t *Yout); +/** Perform echo cancellation using internal playback buffer, which is delayed by two frames + * to account for the delay introduced by most soundcards (but it could be off!) + * @param st Echo canceller state + * @param rec signal from the microphone (near end + far end echo) + * @param out Returns near-end signal with echo removed +*/ +void speex_echo_capture(SpeexEchoState *st, const spx_int16_t *rec, spx_int16_t *out); -/** Let the echo canceller know that a frame was just played */ +/** Let the echo canceller know that a frame was just queued to the soundcard + * @param st Echo canceller state + * @param play Signal played to the speaker (received from far end) +*/ void speex_echo_playback(SpeexEchoState *st, const spx_int16_t *play); -/** Reset the echo canceller state */ +/** Reset the echo canceller to its original state + * @param st Echo canceller state + */ void speex_echo_state_reset(SpeexEchoState *st); /** Used like the ioctl function to control the echo canceller parameters * - * @param state Encoder state + * @param st Echo canceller state * @param request ioctl-type request (one of the SPEEX_ECHO_* macros) * @param ptr Data exchanged to-from function * @return 0 if no error, -1 if request in unknown @@ -85,4 +118,6 @@ int speex_echo_ctl(SpeexEchoState *st, int request, void *ptr); } #endif + +/** @}*/ #endif diff --git a/apps/codecs/libspeex/speex/speex_header.h b/apps/codecs/libspeex/speex/speex_header.h index ba56b73..2b60003 100644 --- a/apps/codecs/libspeex/speex/speex_header.h +++ b/apps/codecs/libspeex/speex/speex_header.h @@ -36,6 +36,10 @@ #ifndef SPEEX_HEADER_H #define SPEEX_HEADER_H +/** @defgroup SpeexHeader SpeexHeader: Makes it easy to write/parse an Ogg/Speex header + * This is the Speex header for the Ogg encapsulation. You don't need that if you just use RTP. + * @{ + */ #include "speex_types.h" @@ -45,6 +49,7 @@ extern "C" { struct SpeexMode; +/** Length of the Speex header identifier */ #define SPEEX_HEADER_STRING_LENGTH 8 /** Maximum number of characters for encoding the Speex version number in the header */ @@ -82,5 +87,5 @@ SpeexHeader *speex_packet_to_header(char *packet, int size); } #endif - +/** @} */ #endif diff --git a/apps/codecs/libspeex/speex/speex_jitter.h b/apps/codecs/libspeex/speex/speex_jitter.h index 34043b3..b998a02 100644 --- a/apps/codecs/libspeex/speex/speex_jitter.h +++ b/apps/codecs/libspeex/speex/speex_jitter.h @@ -35,6 +35,11 @@ #ifndef SPEEX_JITTER_H #define SPEEX_JITTER_H +/** @defgroup JitterBuffer JitterBuffer: Adaptive jitter buffer + * This is the jitter buffer that reorders UDP/RTP packets and adjusts the buffer size + * to maintain good quality and low latency. + * @{ + */ #include "speex.h" #include "speex_bits.h" @@ -43,58 +48,120 @@ extern "C" { #endif +/** Generic adaptive jitter buffer state */ struct JitterBuffer_; +/** Generic adaptive jitter buffer state */ typedef struct JitterBuffer_ JitterBuffer; +/** Definition of an incoming packet */ typedef struct _JitterBufferPacket JitterBufferPacket; +/** Definition of an incoming packet */ struct _JitterBufferPacket { - char *data; - spx_uint32_t len; - spx_uint32_t timestamp; - spx_uint32_t span; + char *data; /**< Data bytes contained in the packet */ + spx_uint32_t len; /**< Length of the packet in bytes */ + spx_uint32_t timestamp; /**< Timestamp for the packet */ + spx_uint32_t span; /**< Time covered by the packet (same units as timestamp) */ }; - +/** Packet has been retrieved */ #define JITTER_BUFFER_OK 0 +/** Packet is missing */ #define JITTER_BUFFER_MISSING 1 +/** Packet is incomplete (does not cover the entive tick */ #define JITTER_BUFFER_INCOMPLETE 2 +/** There was an error in the jitter buffer */ #define JITTER_BUFFER_INTERNAL_ERROR -1 +/** Invalid argument */ #define JITTER_BUFFER_BAD_ARGUMENT -2 -/** Initialise jitter buffer */ + +/** Set minimum amount of extra buffering required (margin) */ +#define JITTER_BUFFER_SET_MARGIN 0 +/** Get minimum amount of extra buffering required (margin) */ +#define JITTER_BUFFER_GET_MARGIN 1 + + +/** Initialises jitter buffer + * + * @param tick Number of samples per "tick", i.e. the time period of the elements that will be retrieved + * @return Newly created jitter buffer state + */ JitterBuffer *jitter_buffer_init(int tick); -/** Reset jitter buffer */ +/** Restores jitter buffer to its original state + * + * @param jitter Jitter buffer state + */ void jitter_buffer_reset(JitterBuffer *jitter); -/** Destroy jitter buffer */ +/** Destroys jitter buffer + * + * @param jitter Jitter buffer state + */ void jitter_buffer_destroy(JitterBuffer *jitter); -/** Put one packet into the jitter buffer */ +/** Put one packet into the jitter buffer + * + * @param jitter Jitter buffer state + * @param packet Incoming packet +*/ void jitter_buffer_put(JitterBuffer *jitter, const JitterBufferPacket *packet); -/** Get one packet from the jitter buffer */ +/** Get one packet from the jitter buffer + * + * @param jitter Jitter buffer state + * @param packet Returned packet + * @param current_timestamp Timestamp for the returned packet +*/ int jitter_buffer_get(JitterBuffer *jitter, JitterBufferPacket *packet, spx_uint32_t *current_timestamp); -/** Get pointer timestamp of jitter buffer */ +/** Get pointer timestamp of jitter buffer + * + * @param jitter Jitter buffer state +*/ int jitter_buffer_get_pointer_timestamp(JitterBuffer *jitter); -/** Advance by one tick */ +/** Advance by one tick + * + * @param jitter Jitter buffer state +*/ void jitter_buffer_tick(JitterBuffer *jitter); +/** Used like the ioctl function to control the jitter buffer parameters + * + * @param jitter Jitter buffer state + * @param request ioctl-type request (one of the JITTER_BUFFER_* macros) + * @param ptr Data exchanged to-from function + * @return 0 if no error, -1 if request in unknown +*/ +int jitter_buffer_ctl(JitterBuffer *jitter, int request, void *ptr); + +/* @} */ -/** Speex jitter-buffer state. */ +/** @defgroup SpeexJitter SpeexJitter: Adaptive jitter buffer specifically for Speex + * This is the jitter buffer that reorders UDP/RTP packets and adjusts the buffer size + * to maintain good quality and low latency. This is a simplified version that works only + * with Speex, but is much easier to use. + * @{ +*/ + +/** Speex jitter-buffer state. Never use it directly! */ typedef struct SpeexJitter { - SpeexBits current_packet; /**< Current Speex packet */ - int valid_bits; /**< True if Speex bits are valid */ - JitterBuffer *packets; - void *dec; /**< Pointer to Speex decoder */ - int frame_size; /**< Frame size of Speex decoder */ + SpeexBits current_packet; /**< Current Speex packet */ + int valid_bits; /**< True if Speex bits are valid */ + JitterBuffer *packets; /**< Generic jitter buffer state */ + void *dec; /**< Pointer to Speex decoder */ + spx_int32_t frame_size; /**< Frame size of Speex decoder */ } SpeexJitter; -/** Initialise jitter buffer */ +/** Initialise jitter buffer + * + * @param jitter State of the Speex jitter buffer + * @param decoder Speex decoder to call + * @param sampling_rate Sampling rate used by the decoder +*/ void speex_jitter_init(SpeexJitter *jitter, void *decoder, int sampling_rate); /** Destroy jitter buffer */ @@ -113,5 +180,5 @@ int speex_jitter_get_pointer_timestamp(SpeexJitter *jitter); } #endif - +/* @} */ #endif diff --git a/apps/codecs/libspeex/speex/speex_preprocess.h b/apps/codecs/libspeex/speex/speex_preprocess.h index 5bb3a2c..863b83f 100644 --- a/apps/codecs/libspeex/speex/speex_preprocess.h +++ b/apps/codecs/libspeex/speex/speex_preprocess.h @@ -1,8 +1,10 @@ /* Copyright (C) 2003 Epic Games Written by Jean-Marc Valin */ /** - @file speex_preprocess.h - @brief Speex preprocessor + * @file speex_preprocess.h + * @brief Speex preprocessor. The preprocess can do noise suppression, + * residual echo suppression (after using the echo canceller), automatic + * gain control (AGC) and voice activity detection (VAD). */ /* Redistribution and use in source and binary forms, with or without @@ -34,91 +36,61 @@ #ifndef SPEEX_PREPROCESS_H #define SPEEX_PREPROCESS_H +/** @defgroup SpeexPreprocessState SpeexPreprocessState: The Speex preprocessor + * This is the Speex preprocessor. The preprocess can do noise suppression, + * residual echo suppression (after using the echo canceller), automatic + * gain control (AGC) and voice activity detection (VAD). + * @{ + */ -#include "speex/speex_types.h" +#include "speex_types.h" #ifdef __cplusplus extern "C" { #endif + +/** State of the preprocessor (one per channel). Should never be accessed directly. */ +struct SpeexPreprocessState_; -struct drft_lookup; +/** State of the preprocessor (one per channel). Should never be accessed directly. */ +typedef struct SpeexPreprocessState_ SpeexPreprocessState; -/** Speex pre-processor state. */ -typedef struct SpeexPreprocessState { - int frame_size; /**< Number of samples processed each time */ - int ps_size; /**< Number of points in the power spectrum */ - int sampling_rate; /**< Sampling rate of the input/output */ - - /* parameters */ - int denoise_enabled; - int agc_enabled; - float agc_level; - int vad_enabled; - int dereverb_enabled; - float reverb_decay; - float reverb_level; - float speech_prob_start; - float speech_prob_continue; - - float *frame; /**< Processing frame (2*ps_size) */ - float *ps; /**< Current power spectrum */ - float *gain2; /**< Adjusted gains */ - float *window; /**< Analysis/Synthesis window */ - float *noise; /**< Noise estimate */ - float *reverb_estimate; /**< Estimate of reverb energy */ - float *old_ps; /**< Power spectrum for last frame */ - float *gain; /**< Ephraim Malah gain */ - float *prior; /**< A-priori SNR */ - float *post; /**< A-posteriori SNR */ - - float *S; /**< Smoothed power spectrum */ - float *Smin; /**< See Cohen paper */ - float *Stmp; /**< See Cohen paper */ - float *update_prob; /**< Propability of speech presence for noise update */ - - float *zeta; /**< Smoothed a priori SNR */ - float Zpeak; - float Zlast; - - float *loudness_weight; /**< Perceptual loudness curve */ - - float *echo_noise; - - float *noise_bands; - float *noise_bands2; - int noise_bandsN; - float *speech_bands; - float *speech_bands2; - int speech_bandsN; - - float *inbuf; /**< Input buffer (overlapped analysis) */ - float *outbuf; /**< Output buffer (for overlap and add) */ - - float speech_prob; - int last_speech; - float loudness; /**< loudness estimate */ - float loudness2; /**< loudness estimate */ - int nb_adapt; /**< Number of frames used for adaptation so far */ - int nb_loudness_adapt; /**< Number of frames used for loudness adaptation so far */ - int consec_noise; /**< Number of consecutive noise frames */ - int nb_preprocess; /**< Number of frames processed so far */ - struct drft_lookup *fft_lookup; /**< Lookup table for the FFT */ - -} SpeexPreprocessState; - -/** Creates a new preprocessing state */ + +/** Creates a new preprocessing state. You MUST create one state per channel processed. + * @param frame_size Number of samples to process at one time (should correspond to 10-20 ms). Must be + * the same value as that used for the echo canceller for residual echo cancellation to work. + * @param sampling_rate Sampling rate used for the input. + * @return Newly created preprocessor state +*/ SpeexPreprocessState *speex_preprocess_state_init(int frame_size, int sampling_rate); -/** Destroys a denoising state */ +/** Destroys a preprocessor state + * @param st Preprocessor state to destroy +*/ void speex_preprocess_state_destroy(SpeexPreprocessState *st); -/** Preprocess a frame */ +/** Preprocess a frame + * @param st Preprocessor state + * @param x Audio sample vector (in and out). Must be same size as specified in speex_preprocess_state_init(). + * @return Bool value for voice activity (1 for speech, 0 for noise/silence), ONLY if VAD turned on. +*/ +int speex_preprocess_run(SpeexPreprocessState *st, spx_int16_t *x); + +/** Preprocess a frame (deprecated, use speex_preprocess_run() instead)*/ int speex_preprocess(SpeexPreprocessState *st, spx_int16_t *x, spx_int32_t *echo); -/** Preprocess a frame */ -void speex_preprocess_estimate_update(SpeexPreprocessState *st, spx_int16_t *x, spx_int32_t *echo); +/** Update preprocessor state, but do not compute the output + * @param st Preprocessor state + * @param x Audio sample vector (in only). Must be same size as specified in speex_preprocess_state_init(). +*/ +void speex_preprocess_estimate_update(SpeexPreprocessState *st, spx_int16_t *x); -/** Used like the ioctl function to control the preprocessor parameters */ +/** Used like the ioctl function to control the preprocessor parameters + * @param st Preprocessor state + * @param request ioctl-type request (one of the SPEEX_PREPROCESS_* macros) + * @param ptr Data exchanged to-from function + * @return 0 if no error, -1 if request in unknown +*/ int speex_preprocess_ctl(SpeexPreprocessState *st, int request, void *ptr); @@ -158,14 +130,57 @@ int speex_preprocess_ctl(SpeexPreprocessState *st, int request, void *ptr); /** Get preprocessor dereverb decay */ #define SPEEX_PREPROCESS_GET_DEREVERB_DECAY 13 +/** Set probability required for the VAD to go from silence to voice */ #define SPEEX_PREPROCESS_SET_PROB_START 14 +/** Get probability required for the VAD to go from silence to voice */ #define SPEEX_PREPROCESS_GET_PROB_START 15 +/** Set probability required for the VAD to stay in the voice state (integer percent) */ #define SPEEX_PREPROCESS_SET_PROB_CONTINUE 16 +/** Get probability required for the VAD to stay in the voice state (integer percent) */ #define SPEEX_PREPROCESS_GET_PROB_CONTINUE 17 +/** Set maximum attenuation of the noise in dB (negative number) */ +#define SPEEX_PREPROCESS_SET_NOISE_SUPPRESS 18 +/** Get maximum attenuation of the noise in dB (negative number) */ +#define SPEEX_PREPROCESS_GET_NOISE_SUPPRESS 19 + +/** Set maximum attenuation of the residual echo in dB (negative number) */ +#define SPEEX_PREPROCESS_SET_ECHO_SUPPRESS 20 +/** Get maximum attenuation of the residual echo in dB (negative number) */ +#define SPEEX_PREPROCESS_GET_ECHO_SUPPRESS 21 + +/** Set maximum attenuation of the residual echo in dB when near end is active (negative number) */ +#define SPEEX_PREPROCESS_SET_ECHO_SUPPRESS_ACTIVE 22 +/** Get maximum attenuation of the residual echo in dB when near end is active (negative number) */ +#define SPEEX_PREPROCESS_GET_ECHO_SUPPRESS_ACTIVE 23 + +/** Set the corresponding echo canceller state so that residual echo suppression can be performed (NULL for no residual echo suppression) */ +#define SPEEX_PREPROCESS_SET_ECHO_STATE 24 +/** Get the corresponding echo canceller state */ +#define SPEEX_PREPROCESS_GET_ECHO_STATE 25 + +/** Set maximal gain increase in dB/second (int32) */ +#define SPEEX_PREPROCESS_SET_AGC_INCREMENT 26 + +/** Get maximal gain increase in dB/second (int32) */ +#define SPEEX_PREPROCESS_GET_AGC_INCREMENT 27 + +/** Set maximal gain decrease in dB/second (int32) */ +#define SPEEX_PREPROCESS_SET_AGC_DECREMENT 28 + +/** Get maximal gain decrease in dB/second (int32) */ +#define SPEEX_PREPROCESS_GET_AGC_DECREMENT 29 + +/** Set maximal gain in dB (int32) */ +#define SPEEX_PREPROCESS_SET_AGC_MAX_GAIN 30 + +/** Get maximal gain in dB (int32) */ +#define SPEEX_PREPROCESS_GET_AGC_MAX_GAIN 31 + #ifdef __cplusplus } #endif +/** @}*/ #endif diff --git a/apps/codecs/libspeex/speex/speex_resampler.h b/apps/codecs/libspeex/speex/speex_resampler.h new file mode 100644 index 0000000..501fab8 --- /dev/null +++ b/apps/codecs/libspeex/speex/speex_resampler.h @@ -0,0 +1,162 @@ +/* Copyright (C) 2007 Jean-Marc Valin + + File: speex_resampler.h + Resampling code + + The design goals of this code are: + - Very fast algorithm + - Low memory requirement + - Good *perceptual* quality (and not best SNR) + + 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. +*/ + + +#ifndef SPEEX_RESAMPLER_H +#define SPEEX_RESAMPLER_H + +#ifdef OUTSIDE_SPEEX + +#define spx_int16_t short +#ifdef FIXED_POINT +#define spx_word16_t short +#define spx_word32_t int +#else +#define spx_word16_t float +#define spx_word32_t float +#define MULT16_16(a,b) ((a)*(b)) +#define PSHR32(a,b) (a) +#endif + +#else + +#include "speex_types.h" + +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#define SPEEX_RESAMPLER_QUALITY_MAX 10 +#define SPEEX_RESAMPLER_QUALITY_MIN 0 +#define SPEEX_RESAMPLER_QUALITY_DEFAULT 4 +#define SPEEX_RESAMPLER_QUALITY_VOIP 3 +#define SPEEX_RESAMPLER_QUALITY_DESKTOP 5 + +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. + * @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. + * @return Newly created resampler state + */ +SpeexResamplerState *speex_resampler_init(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. + * @param st Resampler state + * @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 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); + +/** Resample an int array. The input and output may *not* alias. + * @param st Resampler state + * @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 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); + +/** Resample an interleaved float array. The input and output may *not* alias. + * @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); + +/** Set (change) the input/output sampling rates and resampling ratio. + * @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. + */ +void speex_resampler_set_rate(SpeexResamplerState *st, int ratio_num, int ratio_den, int in_rate, int out_rate); + +/** 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. + */ +void speex_resampler_set_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); + +/** Set (change) the output stride. + * @param st Resampler state + * @param stride Output stride + */ +void speex_resample_set_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. + * @param st Resampler state + */ +void speex_resampler_skip_zeros(SpeexResamplerState *st); + +/** Reset a resampler so a new (unrelated) stream can be processed. + * @param st Resampler state + */ +void speex_resampler_reset_mem(SpeexResamplerState *st); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/apps/codecs/libspeex/speex/speex_stereo.h b/apps/codecs/libspeex/speex/speex_stereo.h index 60021c8..ea2f976 100644 --- a/apps/codecs/libspeex/speex/speex_stereo.h +++ b/apps/codecs/libspeex/speex/speex_stereo.h @@ -34,6 +34,10 @@ #ifndef STEREO_H #define STEREO_H +/** @defgroup SpeexStereoState SpeexStereoState: Handling Speex stereo files + * This describes the Speex intensity stereo encoding/decoding + * @{ + */ #include "speex_types.h" #include "speex_bits.h" @@ -74,5 +78,5 @@ int speex_std_stereo_request_handler(SpeexBits *bits, void *state, void *data); } #endif - +/** @} */ #endif diff --git a/apps/codecs/libspeex/speex/speex_types.h b/apps/codecs/libspeex/speex/speex_types.h index 61a9788..12a0351 100644 --- a/apps/codecs/libspeex/speex/speex_types.h +++ b/apps/codecs/libspeex/speex/speex_types.h @@ -21,11 +21,106 @@ */ #ifndef _SPEEX_TYPES_H #define _SPEEX_TYPES_H -#include "inttypes.h" -#define spx_int16_t int16_t -#define spx_uint16_t uint16_t -#define spx_int32_t int32_t -#define spx_uint32_t uint32_t -#define spx_int64_t int64_t -#define spx_uint64_t uint64_t + +#if defined(_WIN32) + +# if defined(__CYGWIN__) +# include <_G_config.h> + typedef _G_int32_t spx_int32_t; + typedef _G_uint32_t spx_uint32_t; + typedef _G_int16_t spx_int16_t; + typedef _G_uint16_t spx_uint16_t; +# elif defined(__MINGW32__) + typedef short spx_int16_t; + typedef unsigned short spx_uint16_t; + typedef int spx_int32_t; + typedef unsigned int spx_uint32_t; +# elif defined(__MWERKS__) + typedef int spx_int32_t; + typedef unsigned int spx_uint32_t; + typedef short spx_int16_t; + typedef unsigned short spx_uint16_t; +# else + /* MSVC/Borland */ + typedef __int32 spx_int32_t; + typedef unsigned __int32 spx_uint32_t; + typedef __int16 spx_int16_t; + typedef unsigned __int16 spx_uint16_t; +# endif + +#elif defined(__MACOS__) + +# include <sys/types.h> + typedef SInt16 spx_int16_t; + typedef UInt16 spx_uint16_t; + typedef SInt32 spx_int32_t; + typedef UInt32 spx_uint32_t; + +#elif defined(__MACOSX__) /* MacOS X Framework build */ + +# include <sys/types.h> + typedef int16_t spx_int16_t; + typedef u_int16_t spx_uint16_t; + typedef int32_t spx_int32_t; + typedef u_int32_t spx_uint32_t; + +#elif defined(__BEOS__) + + /* Be */ +# include <inttypes.h> + typedef int16_t spx_int16_t; + typedef u_int16_t spx_uint16_t; + typedef int32_t spx_int32_t; + typedef u_int32_t spx_uint32_t; + +#elif defined (__EMX__) + + /* OS/2 GCC */ + typedef short spx_int16_t; + typedef unsigned short spx_uint16_t; + typedef int spx_int32_t; + typedef unsigned int spx_uint32_t; + +#elif defined (DJGPP) + + /* DJGPP */ + typedef short spx_int16_t; + typedef int spx_int32_t; + typedef unsigned int spx_uint32_t; + +#elif defined(R5900) + + /* PS2 EE */ + typedef int spx_int32_t; + typedef unsigned spx_uint32_t; + typedef short spx_int16_t; + +#elif defined(__SYMBIAN32__) + + /* Symbian GCC */ + typedef signed short spx_int16_t; + typedef unsigned short spx_uint16_t; + typedef signed int spx_int32_t; + typedef unsigned int spx_uint32_t; + +#elif defined(CONFIG_TI_C54X) || defined (CONFIG_TI_C55X) + + typedef short spx_int16_t; + typedef unsigned short spx_uint16_t; + typedef long spx_int32_t; + typedef unsigned long spx_uint32_t; + +#elif defined(CONFIG_TI_C6X) + + typedef short spx_int16_t; + typedef unsigned short spx_uint16_t; + typedef int spx_int32_t; + typedef unsigned int spx_uint32_t; + +#else + +# include "speex_config_types.h" + +#endif + #endif /* _SPEEX_TYPES_H */ |