| speex.h | | speex.h | |
|
| /* Copyright (C) 2002 Jean-Marc Valin*/ | | /* Copyright (C) 2002-2006 Jean-Marc Valin*/ | |
| /** | | /** | |
| @file speex.h | | @file speex.h | |
| @brief Describes the different modes of the codec | | @brief Describes the different modes of the codec | |
| */ | | */ | |
| /* | | /* | |
| Redistribution and use in source and binary forms, with or without | | Redistribution and use in source and binary forms, with or without | |
| modification, are permitted provided that the following conditions | | modification, are permitted provided that the following conditions | |
| are met: | | are met: | |
| | | | |
| - Redistributions of source code must retain the above copyright | | - Redistributions of source code must retain the above copyright | |
| | | | |
| skipping to change at line 38 | | skipping to change at line 38 | |
| PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | |
| PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | |
| LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | |
| NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | |
| SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| | | | |
| */ | | */ | |
| | | | |
| #ifndef SPEEX_H | | #ifndef SPEEX_H | |
| #define SPEEX_H | | #define SPEEX_H | |
|
| | | /** @defgroup Codec Speex encoder and decoder | |
| | | * This is the Speex codec itself. | |
| | | * @{ | |
| | | */ | |
| | | | |
|
| #include "speex/speex_bits.h" | | #include "speex_types.h" | |
| #include "speex/speex_types.h" | | #include "speex_bits.h" | |
| | | | |
| #ifdef __cplusplus | | #ifdef __cplusplus | |
| extern "C" { | | extern "C" { | |
| #endif | | #endif | |
| | | | |
| /* Values allowed for *ctl() requests */ | | /* Values allowed for *ctl() requests */ | |
| | | | |
| /** Set enhancement on/off (decoder only) */ | | /** Set enhancement on/off (decoder only) */ | |
| #define SPEEX_SET_ENH 0 | | #define SPEEX_SET_ENH 0 | |
| /** Get enhancement state (decoder only) */ | | /** Get enhancement state (decoder only) */ | |
| | | | |
| skipping to change at line 136 | | skipping to change at line 140 | |
| #define SPEEX_SET_DTX 34 | | #define SPEEX_SET_DTX 34 | |
| /** Get DTX status (1 for on, 0 for off) */ | | /** Get DTX status (1 for on, 0 for off) */ | |
| #define SPEEX_GET_DTX 35 | | #define SPEEX_GET_DTX 35 | |
| | | | |
| /** Set submode encoding in each frame (1 for yes, 0 for no, setting to no
breaks the standard) */ | | /** Set submode encoding in each frame (1 for yes, 0 for no, setting to no
breaks the standard) */ | |
| #define SPEEX_SET_SUBMODE_ENCODING 36 | | #define SPEEX_SET_SUBMODE_ENCODING 36 | |
| /** Get submode encoding in each frame */ | | /** Get submode encoding in each frame */ | |
| #define SPEEX_GET_SUBMODE_ENCODING 37 | | #define SPEEX_GET_SUBMODE_ENCODING 37 | |
| | | | |
| /*#define SPEEX_SET_LOOKAHEAD 38*/ | | /*#define SPEEX_SET_LOOKAHEAD 38*/ | |
|
| /** Returns the lookahead used by Speex */ | | /** Returns the lookahead used by Speex separately for an encoder and a dec | |
| | | oder. | |
| | | * Sum encoder and decoder lookahead values to get the total codec lookahe | |
| | | ad. */ | |
| #define SPEEX_GET_LOOKAHEAD 39 | | #define SPEEX_GET_LOOKAHEAD 39 | |
| | | | |
| /** Sets tuning for packet-loss concealment (expected loss rate) */ | | /** Sets tuning for packet-loss concealment (expected loss rate) */ | |
| #define SPEEX_SET_PLC_TUNING 40 | | #define SPEEX_SET_PLC_TUNING 40 | |
| /** Gets tuning for PLC */ | | /** Gets tuning for PLC */ | |
| #define SPEEX_GET_PLC_TUNING 41 | | #define SPEEX_GET_PLC_TUNING 41 | |
| | | | |
|
| /* Used internally, not to be used in applications */ | | /** Sets the max bit-rate allowed in VBR mode */ | |
| /** Used internally*/ | | #define SPEEX_SET_VBR_MAX_BITRATE 42 | |
| #define SPEEX_GET_PI_GAIN 100 | | /** Gets the max bit-rate allowed in VBR mode */ | |
| /** Used internally*/ | | #define SPEEX_GET_VBR_MAX_BITRATE 43 | |
| #define SPEEX_GET_EXC 101 | | | |
| /** Used internally*/ | | /** Turn on/off input/output high-pass filtering */ | |
| #define SPEEX_GET_INNOV 102 | | #define SPEEX_SET_HIGHPASS 44 | |
| /** Used internally*/ | | /** Get status of input/output high-pass filtering */ | |
| #define SPEEX_GET_DTX_STATUS 103 | | #define SPEEX_GET_HIGHPASS 45 | |
| | | | |
| | | /** Get "activity level" of the last decoded frame, i.e. | |
| | | how much damage we cause if we remove the frame */ | |
| | | #define SPEEX_GET_ACTIVITY 47 | |
| | | | |
| /* Preserving compatibility:*/ | | /* Preserving compatibility:*/ | |
| /** Equivalent to SPEEX_SET_ENH */ | | /** Equivalent to SPEEX_SET_ENH */ | |
| #define SPEEX_SET_PF 0 | | #define SPEEX_SET_PF 0 | |
| /** Equivalent to SPEEX_GET_ENH */ | | /** Equivalent to SPEEX_GET_ENH */ | |
| #define SPEEX_GET_PF 1 | | #define SPEEX_GET_PF 1 | |
| | | | |
| /* Values allowed for mode queries */ | | /* Values allowed for mode queries */ | |
| /** Query the frame size of a mode */ | | /** Query the frame size of a mode */ | |
| #define SPEEX_MODE_FRAME_SIZE 0 | | #define SPEEX_MODE_FRAME_SIZE 0 | |
| | | | |
| skipping to change at line 201 | | skipping to change at line 210 | |
| | | | |
| /** modeID for the defined narrowband mode */ | | /** modeID for the defined narrowband mode */ | |
| #define SPEEX_MODEID_NB 0 | | #define SPEEX_MODEID_NB 0 | |
| | | | |
| /** modeID for the defined wideband mode */ | | /** modeID for the defined wideband mode */ | |
| #define SPEEX_MODEID_WB 1 | | #define SPEEX_MODEID_WB 1 | |
| | | | |
| /** modeID for the defined ultra-wideband mode */ | | /** modeID for the defined ultra-wideband mode */ | |
| #define SPEEX_MODEID_UWB 2 | | #define SPEEX_MODEID_UWB 2 | |
| | | | |
|
| #ifdef EPIC_48K | | | |
| /** modeID for the Epic 48K mode */ | | | |
| #define SPEEX_MODEID_NB_48K 1000 | | | |
| #endif | | | |
| | | | |
| struct SpeexMode; | | struct SpeexMode; | |
| | | | |
| /* Prototypes for mode function pointers */ | | /* Prototypes for mode function pointers */ | |
| | | | |
| /** Encoder state initialization function */ | | /** Encoder state initialization function */ | |
| typedef void *(*encoder_init_func)(const struct SpeexMode *mode); | | typedef void *(*encoder_init_func)(const struct SpeexMode *mode); | |
| | | | |
| /** Encoder state destruction function */ | | /** Encoder state destruction function */ | |
| typedef void (*encoder_destroy_func)(void *st); | | typedef void (*encoder_destroy_func)(void *st); | |
| | | | |
| | | | |
| skipping to change at line 288 | | skipping to change at line 292 | |
| | | | |
| } SpeexMode; | | } SpeexMode; | |
| | | | |
| /** | | /** | |
| * Returns a handle to a newly created Speex encoder state structure. For n
ow, | | * Returns a handle to a newly created Speex encoder state structure. For n
ow, | |
| * the "mode" argument can be &nb_mode or &wb_mode . In the future, more mo
des | | * the "mode" argument can be &nb_mode or &wb_mode . In the future, more mo
des | |
| * may be added. Note that for now if you have more than one channels to | | * may be added. Note that for now if you have more than one channels to | |
| * encode, you need one state per channel. | | * encode, you need one state per channel. | |
| * | | * | |
| * @param mode The mode to use (either speex_nb_mode or speex_wb.mode) | | * @param mode The mode to use (either speex_nb_mode or speex_wb.mode) | |
|
| * @return A newly created encoder | | * @return A newly created encoder state or NULL if state allocation fails | |
| */ | | */ | |
| void *speex_encoder_init(const SpeexMode *mode); | | void *speex_encoder_init(const SpeexMode *mode); | |
| | | | |
| /** Frees all resources associated to an existing Speex encoder state. | | /** Frees all resources associated to an existing Speex encoder state. | |
| * @param state Encoder state to be destroyed */ | | * @param state Encoder state to be destroyed */ | |
| void speex_encoder_destroy(void *state); | | void speex_encoder_destroy(void *state); | |
| | | | |
| /** Uses an existing encoder state to encode one frame of speech pointed to
by | | /** Uses an existing encoder state to encode one frame of speech pointed to
by | |
| "in". The encoded bit-stream is saved in "bits". | | "in". The encoded bit-stream is saved in "bits". | |
| @param state Encoder state | | @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 | | @param bits Bit-stream where the data will be written | |
| @return 0 if frame needs not be transmitted (DTX only), 1 otherwise | | @return 0 if frame needs not be transmitted (DTX only), 1 otherwise | |
| */ | | */ | |
| int speex_encode(void *state, float *in, SpeexBits *bits); | | int speex_encode(void *state, float *in, SpeexBits *bits); | |
| | | | |
| /** Uses an existing encoder state to encode one frame of speech pointed to
by | | /** Uses an existing encoder state to encode one frame of speech pointed to
by | |
| "in". The encoded bit-stream is saved in "bits". | | "in". The encoded bit-stream is saved in "bits". | |
| @param state Encoder state | | @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 | |
| @param bits Bit-stream where the data will be written | | @param bits Bit-stream where the data will be written | |
| @return 0 if frame needs not be transmitted (DTX only), 1 otherwise | | @return 0 if frame needs not be transmitted (DTX only), 1 otherwise | |
| */ | | */ | |
| int speex_encode_int(void *state, spx_int16_t *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 | | /** Used like the ioctl function to control the encoder parameters | |
| * | | * | |
| * @param state Encoder state | | * @param state Encoder state | |
| * @param request ioctl-type request (one of the SPEEX_* macros) | | * @param request ioctl-type request (one of the SPEEX_* macros) | |
| * @param ptr Data exchanged to-from function | | * @param ptr Data exchanged to-from function | |
|
| * @return 0 if no error, -1 if request in unknown | | * @return 0 if no error, -1 if request in unknown, -2 for invalid paramete
r | |
| */ | | */ | |
| int speex_encoder_ctl(void *state, int request, void *ptr); | | int speex_encoder_ctl(void *state, int request, void *ptr); | |
| | | | |
| /** Returns a handle to a newly created decoder state structure. For now, | | /** Returns a handle to a newly created decoder state structure. For now, | |
| * the mode argument can be &nb_mode or &wb_mode . In the future, more mode
s | | * the mode argument can be &nb_mode or &wb_mode . In the future, more mode
s | |
| * may be added. Note that for now if you have more than one channels to | | * may be added. Note that for now if you have more than one channels to | |
| * decode, you need one state per channel. | | * decode, you need one state per channel. | |
| * | | * | |
| * @param mode Speex mode (one of speex_nb_mode or speex_wb_mode) | | * @param mode Speex mode (one of speex_nb_mode or speex_wb_mode) | |
|
| * @return A newly created decoder state | | * @return A newly created decoder state or NULL if state allocation fails | |
| */ | | */ | |
| void *speex_decoder_init(const SpeexMode *mode); | | void *speex_decoder_init(const SpeexMode *mode); | |
| | | | |
| /** Frees all resources associated to an existing decoder state. | | /** Frees all resources associated to an existing decoder state. | |
| * | | * | |
| * @param state State to be destroyed | | * @param state State to be destroyed | |
| */ | | */ | |
| void speex_decoder_destroy(void *state); | | void speex_decoder_destroy(void *state); | |
| | | | |
| /** Uses an existing decoder state to decode one frame of speech from | | /** Uses an existing decoder state to decode one frame of speech from | |
| | | | |
| skipping to change at line 364 | | skipping to change at line 370 | |
| * @param out Where to write the decoded frame | | * @param out Where to write the decoded frame | |
| * @return return status (0 for no error, -1 for end of stream, -2 corrupt
stream) | | * @return return status (0 for no error, -1 for end of stream, -2 corrupt
stream) | |
| */ | | */ | |
| int speex_decode_int(void *state, SpeexBits *bits, spx_int16_t *out); | | int speex_decode_int(void *state, SpeexBits *bits, spx_int16_t *out); | |
| | | | |
| /** Used like the ioctl function to control the encoder parameters | | /** Used like the ioctl function to control the encoder parameters | |
| * | | * | |
| * @param state Decoder state | | * @param state Decoder state | |
| * @param request ioctl-type request (one of the SPEEX_* macros) | | * @param request ioctl-type request (one of the SPEEX_* macros) | |
| * @param ptr Data exchanged to-from function | | * @param ptr Data exchanged to-from function | |
|
| * @return 0 if no error, -1 if request in unknown | | * @return 0 if no error, -1 if request in unknown, -2 for invalid paramete
r | |
| */ | | */ | |
| int speex_decoder_ctl(void *state, int request, void *ptr); | | int speex_decoder_ctl(void *state, int request, void *ptr); | |
| | | | |
| /** Query function for mode information | | /** Query function for mode information | |
| * | | * | |
| * @param mode Speex mode | | * @param mode Speex mode | |
| * @param request ioctl-type request (one of the SPEEX_* macros) | | * @param request ioctl-type request (one of the SPEEX_* macros) | |
| * @param ptr Data exchanged to-from function | | * @param ptr Data exchanged to-from function | |
|
| | | * @return 0 if no error, -1 if request in unknown, -2 for invalid paramete
r | |
| */ | | */ | |
| int speex_mode_query(const SpeexMode *mode, int request, void *ptr); | | int speex_mode_query(const SpeexMode *mode, int request, void *ptr); | |
| | | | |
| /** Functions for controlling the behavior of libspeex | | /** Functions for controlling the behavior of libspeex | |
| * @param request ioctl-type request (one of the SPEEX_LIB_* macros) | | * @param request ioctl-type request (one of the SPEEX_LIB_* macros) | |
| * @param ptr Data exchanged to-from function | | * @param ptr Data exchanged to-from function | |
|
| | | * @return 0 if no error, -1 if request in unknown, -2 for invalid paramete
r | |
| */ | | */ | |
| int speex_lib_ctl(int request, void *ptr); | | int speex_lib_ctl(int request, void *ptr); | |
| | | | |
| /** Default narrowband mode */ | | /** Default narrowband mode */ | |
| extern const SpeexMode speex_nb_mode; | | extern const SpeexMode speex_nb_mode; | |
| | | | |
| /** Default wideband mode */ | | /** Default wideband mode */ | |
| extern const SpeexMode speex_wb_mode; | | extern const SpeexMode speex_wb_mode; | |
| | | | |
| /** Default "ultra-wideband" mode */ | | /** Default "ultra-wideband" mode */ | |
| extern const SpeexMode speex_uwb_mode; | | extern const SpeexMode speex_uwb_mode; | |
| | | | |
|
| #ifdef EPIC_48K | | | |
| /** 4.8 kbps narrowband mode */ | | | |
| extern const SpeexMode speex_nb_48k_mode; | | | |
| #endif | | | |
| | | | |
| /** List of all modes available */ | | /** List of all modes available */ | |
| extern const SpeexMode * const speex_mode_list[SPEEX_NB_MODES]; | | extern const SpeexMode * const speex_mode_list[SPEEX_NB_MODES]; | |
| | | | |
| /** Obtain one of the modes available */ | | /** Obtain one of the modes available */ | |
| const SpeexMode * speex_lib_get_mode (int mode); | | const SpeexMode * speex_lib_get_mode (int mode); | |
| | | | |
|
| | | #ifndef WIN32 | |
| | | /* We actually override the function in the narrowband case so that we can | |
| | | avoid linking in the wideband stuff */ | |
| | | #define speex_lib_get_mode(mode) ((mode)==SPEEX_MODEID_NB ? &speex_nb_mode | |
| | | : speex_lib_get_mode (mode)) | |
| | | #endif | |
| | | | |
| #ifdef __cplusplus | | #ifdef __cplusplus | |
| } | | } | |
| #endif | | #endif | |
| | | | |
|
| | | /** @}*/ | |
| #endif | | #endif | |
| | | | |
End of changes. 16 change blocks. |
| 28 lines changed or deleted | | 41 lines changed or added | |
|
| speex_bits.h | | speex_bits.h | |
| | | | |
| skipping to change at line 38 | | skipping to change at line 38 | |
| PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | |
| PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | |
| LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | |
| NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | |
| SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| | | | |
| */ | | */ | |
| | | | |
| #ifndef BITS_H | | #ifndef BITS_H | |
| #define BITS_H | | #define BITS_H | |
|
| | | /** @defgroup SpeexBits SpeexBits: Bit-stream manipulations | |
| | | * This is the structure that holds the bit-stream when encoding or decodi | |
| | | ng | |
| | | * with Speex. It allows some manipulations as well. | |
| | | * @{ | |
| | | */ | |
| | | | |
| #ifdef __cplusplus | | #ifdef __cplusplus | |
| extern "C" { | | extern "C" { | |
| #endif | | #endif | |
| | | | |
| /** Bit-packing data structure representing (part of) a bit-stream. */ | | /** Bit-packing data structure representing (part of) a bit-stream. */ | |
| typedef struct SpeexBits { | | typedef struct SpeexBits { | |
| char *chars; /**< "raw" data */ | | char *chars; /**< "raw" data */ | |
| int nbBits; /**< Total number of bits stored in the stream*/ | | int nbBits; /**< Total number of bits stored in the stream*/ | |
| int charPtr; /**< Position of the byte "cursor" */ | | int charPtr; /**< Position of the byte "cursor" */ | |
| | | | |
| skipping to change at line 62 | | skipping to change at line 67 | |
| int reserved1; /**< Reserved for future use */ | | int reserved1; /**< Reserved for future use */ | |
| void *reserved2; /**< Reserved for future use */ | | void *reserved2; /**< Reserved for future use */ | |
| } SpeexBits; | | } SpeexBits; | |
| | | | |
| /** Initializes and allocates resources for a SpeexBits struct */ | | /** Initializes and allocates resources for a SpeexBits struct */ | |
| void speex_bits_init(SpeexBits *bits); | | void speex_bits_init(SpeexBits *bits); | |
| | | | |
| /** Initializes SpeexBits struct using a pre-allocated buffer*/ | | /** Initializes SpeexBits struct using a pre-allocated buffer*/ | |
| void speex_bits_init_buffer(SpeexBits *bits, void *buff, int buf_size); | | void speex_bits_init_buffer(SpeexBits *bits, void *buff, int buf_size); | |
| | | | |
|
| | | /** Sets the bits in a SpeexBits struct to use data from an existing buffer | |
| | | (for decoding without copying data) */ | |
| | | void speex_bits_set_bit_buffer(SpeexBits *bits, void *buff, int buf_size); | |
| | | | |
| /** Frees all resources associated to a SpeexBits struct. Right now this do
es nothing since no resources are allocated, but this could change in the f
uture.*/ | | /** Frees all resources associated to a SpeexBits struct. Right now this do
es nothing since no resources are allocated, but this could change in the f
uture.*/ | |
| void speex_bits_destroy(SpeexBits *bits); | | void speex_bits_destroy(SpeexBits *bits); | |
| | | | |
| /** Resets bits to initial value (just after initialization, erasing conten
t)*/ | | /** Resets bits to initial value (just after initialization, erasing conten
t)*/ | |
| void speex_bits_reset(SpeexBits *bits); | | void speex_bits_reset(SpeexBits *bits); | |
| | | | |
| /** Rewind the bit-stream to the beginning (ready for read) without erasing
the content */ | | /** Rewind the bit-stream to the beginning (ready for read) without erasing
the content */ | |
| void speex_bits_rewind(SpeexBits *bits); | | void speex_bits_rewind(SpeexBits *bits); | |
| | | | |
| /** Initializes the bit-stream from the data in an area of memory */ | | /** Initializes the bit-stream from the data in an area of memory */ | |
|
| void speex_bits_read_from(SpeexBits *bits, char *bytes, int len); | | void speex_bits_read_from(SpeexBits *bits, const char *bytes, int len); | |
| | | | |
| /** Append bytes to the bit-stream | | /** Append bytes to the bit-stream | |
|
| | | * | |
| * @param bits Bit-stream to operate on | | * @param bits Bit-stream to operate on | |
| * @param bytes pointer to the bytes what will be appended | | * @param bytes pointer to the bytes what will be appended | |
| * @param len Number of bytes of append | | * @param len Number of bytes of append | |
| */ | | */ | |
|
| void speex_bits_read_whole_bytes(SpeexBits *bits, char *bytes, int len); | | void speex_bits_read_whole_bytes(SpeexBits *bits, const char *bytes, int le
n); | |
| | | | |
|
| /** 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); | | 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 */ | | /** Like speex_bits_write, but writes only the complete bytes in the stream
. Also removes the written bytes from the stream */ | |
| int speex_bits_write_whole_bytes(SpeexBits *bits, char *bytes, int max_len)
; | | int speex_bits_write_whole_bytes(SpeexBits *bits, char *bytes, int max_len)
; | |
| | | | |
| /** Append bits to the bit-stream | | /** Append bits to the bit-stream | |
| * @param bits Bit-stream to operate on | | * @param bits Bit-stream to operate on | |
| * @param data Value to append as integer | | * @param data Value to append as integer | |
| * @param nbBits number of bits to consider in "data" | | * @param nbBits number of bits to consider in "data" | |
| */ | | */ | |
| | | | |
| skipping to change at line 117 | | skipping to change at line 132 | |
| */ | | */ | |
| unsigned int speex_bits_unpack_unsigned(SpeexBits *bits, int nbBits); | | unsigned int speex_bits_unpack_unsigned(SpeexBits *bits, int nbBits); | |
| | | | |
| /** Returns the number of bytes in the bit-stream, including the last one e
ven if it is not "full" | | /** Returns the number of bytes in the bit-stream, including the last one e
ven if it is not "full" | |
| * | | * | |
| * @param bits Bit-stream to operate on | | * @param bits Bit-stream to operate on | |
| * @return Number of bytes in the stream | | * @return Number of bytes in the stream | |
| */ | | */ | |
| int speex_bits_nbytes(SpeexBits *bits); | | int speex_bits_nbytes(SpeexBits *bits); | |
| | | | |
|
| /** Same as speex_bits_unpack_unsigned, but without modifying the cursor po | | /** Same as speex_bits_unpack_unsigned, but without modifying the cursor po | |
| sition */ | | sition | |
| | | * | |
| | | * @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); | | unsigned int speex_bits_peek_unsigned(SpeexBits *bits, int nbBits); | |
| | | | |
| /** Get the value of the next bit in the stream, without modifying the | | /** Get the value of the next bit in the stream, without modifying the | |
| * "cursor" position | | * "cursor" position | |
| * | | * | |
| * @param bits Bit-stream to operate on | | * @param bits Bit-stream to operate on | |
|
| | | * @return Value of the bit peeked (one bit only) | |
| */ | | */ | |
| int speex_bits_peek(SpeexBits *bits); | | int speex_bits_peek(SpeexBits *bits); | |
| | | | |
| /** Advances the position of the "bit cursor" in the stream | | /** Advances the position of the "bit cursor" in the stream | |
| * | | * | |
| * @param bits Bit-stream to operate on | | * @param bits Bit-stream to operate on | |
| * @param n Number of bits to advance | | * @param n Number of bits to advance | |
| */ | | */ | |
| void speex_bits_advance(SpeexBits *bits, int n); | | void speex_bits_advance(SpeexBits *bits, int n); | |
| | | | |
| /** Returns the number of bits remaining to be read in a stream | | /** Returns the number of bits remaining to be read in a stream | |
| * | | * | |
| * @param bits Bit-stream to operate on | | * @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); | | int speex_bits_remaining(SpeexBits *bits); | |
| | | | |
| /** Insert a terminator so that the data can be sent as a packet while auto
-detecting | | /** Insert a terminator so that the data can be sent as a packet while auto
-detecting | |
| * the number of frames in each packet | | * the number of frames in each packet | |
| * | | * | |
| * @param bits Bit-stream to operate on | | * @param bits Bit-stream to operate on | |
| */ | | */ | |
| void speex_bits_insert_terminator(SpeexBits *bits); | | void speex_bits_insert_terminator(SpeexBits *bits); | |
| | | | |
| #ifdef __cplusplus | | #ifdef __cplusplus | |
| } | | } | |
| #endif | | #endif | |
| | | | |
|
| | | /* @} */ | |
| #endif | | #endif | |
| | | | |
End of changes. 10 change blocks. |
| 5 lines changed or deleted | | 31 lines changed or added | |
|
| speex_callbacks.h | | speex_callbacks.h | |
| | | | |
| skipping to change at line 38 | | skipping to change at line 38 | |
| PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | |
| PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | |
| LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | |
| NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | |
| SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| | | | |
| */ | | */ | |
| | | | |
| #ifndef SPEEX_CALLBACKS_H | | #ifndef SPEEX_CALLBACKS_H | |
| #define SPEEX_CALLBACKS_H | | #define SPEEX_CALLBACKS_H | |
|
| | | /** @defgroup SpeexCallbacks Various definitions for Speex callbacks suppor | |
| | | ted by the decoder. | |
| | | * @{ | |
| | | */ | |
| | | | |
| #include "speex.h" | | #include "speex.h" | |
| | | | |
| #ifdef __cplusplus | | #ifdef __cplusplus | |
| extern "C" { | | extern "C" { | |
| #endif | | #endif | |
| | | | |
| /** Total number of callbacks */ | | /** Total number of callbacks */ | |
| #define SPEEX_MAX_CALLBACKS 16 | | #define SPEEX_MAX_CALLBACKS 16 | |
| | | | |
| | | | |
| skipping to change at line 111 | | skipping to change at line 114 | |
| | | | |
| /** Standard handler for high mode request (change high mode, no questions
asked) */ | | /** Standard handler for high mode request (change high mode, no questions
asked) */ | |
| int speex_std_high_mode_request_handler(SpeexBits *bits, void *state, void
*data); | | int speex_std_high_mode_request_handler(SpeexBits *bits, void *state, void
*data); | |
| | | | |
| /** Standard handler for in-band characters (write to stderr) */ | | /** Standard handler for in-band characters (write to stderr) */ | |
| int speex_std_char_handler(SpeexBits *bits, void *state, void *data); | | int speex_std_char_handler(SpeexBits *bits, void *state, void *data); | |
| | | | |
| /** Default handler for user-defined requests: in this case, just ignore */ | | /** Default handler for user-defined requests: in this case, just ignore */ | |
| int speex_default_user_handler(SpeexBits *bits, void *state, void *data); | | int speex_default_user_handler(SpeexBits *bits, void *state, void *data); | |
| | | | |
|
| | | /** Standard handler for low mode request (change low mode, no questions as
ked) */ | |
| int speex_std_low_mode_request_handler(SpeexBits *bits, void *state, void *
data); | | 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)
; | | int speex_std_vbr_request_handler(SpeexBits *bits, void *state, void *data)
; | |
| | | | |
|
| | | /** Standard handler for enhancer request (Turn enhancer on/off, no questio
ns asked) */ | |
| int speex_std_enh_request_handler(SpeexBits *bits, void *state, void *data)
; | | 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, voi
d *data); | | int speex_std_vbr_quality_request_handler(SpeexBits *bits, void *state, voi
d *data); | |
| | | | |
| #ifdef __cplusplus | | #ifdef __cplusplus | |
| } | | } | |
| #endif | | #endif | |
| | | | |
|
| | | /** @} */ | |
| #endif | | #endif | |
| | | | |
End of changes. 6 change blocks. |
| 0 lines changed or deleted | | 9 lines changed or added | |
|
| speex_stereo.h | | speex_stereo.h | |
| | | | |
| skipping to change at line 37 | | skipping to change at line 37 | |
| EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | |
| PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | |
| PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | |
| LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | |
| NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | |
| SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| */ | | */ | |
| | | | |
| #ifndef STEREO_H | | #ifndef STEREO_H | |
| #define STEREO_H | | #define STEREO_H | |
|
| | | /** @defgroup SpeexStereoState SpeexStereoState: Handling Speex stereo file | |
| | | s | |
| | | * This describes the Speex intensity stereo encoding/decoding | |
| | | * @{ | |
| | | */ | |
| | | | |
|
| #include "speex/speex_types.h" | | #include "speex_types.h" | |
| #include "speex/speex_bits.h" | | #include "speex_bits.h" | |
| | | | |
| #ifdef __cplusplus | | #ifdef __cplusplus | |
| extern "C" { | | extern "C" { | |
| #endif | | #endif | |
| | | | |
|
| /** State used for decoding (intensity) stereo information */ | | /** If you access any of these fields directly, I'll personally come and bi
te you */ | |
| typedef struct SpeexStereoState { | | typedef struct SpeexStereoState { | |
| float balance; /**< Left/right balance info */ | | float balance; /**< Left/right balance info */ | |
| float e_ratio; /**< Ratio of energies: E(left+right)/[E(left)+E(rig
ht)] */ | | float e_ratio; /**< Ratio of energies: E(left+right)/[E(left)+E(rig
ht)] */ | |
| float smooth_left; /**< Smoothed left channel gain */ | | float smooth_left; /**< Smoothed left channel gain */ | |
| float smooth_right; /**< Smoothed right channel gain */ | | float smooth_right; /**< Smoothed right channel gain */ | |
| float reserved1; /**< Reserved for future use */ | | float reserved1; /**< Reserved for future use */ | |
| float reserved2; /**< Reserved for future use */ | | float reserved2; /**< Reserved for future use */ | |
| } SpeexStereoState; | | } SpeexStereoState; | |
| | | | |
|
| /** Initialization value for a stereo state */ | | /** Deprecated. Use speex_stereo_state_init() instead. */ | |
| #define SPEEX_STEREO_STATE_INIT {1,.5,1,1} | | #define SPEEX_STEREO_STATE_INIT {1,.5,1,1,0,0} | |
| | | | |
| | | /** Initialise/create a stereo stereo state */ | |
| | | SpeexStereoState *speex_stereo_state_init(); | |
| | | | |
| | | /** Reset/re-initialise an already allocated stereo state */ | |
| | | void speex_stereo_state_reset(SpeexStereoState *stereo); | |
| | | | |
| | | /** Destroy a stereo stereo state */ | |
| | | void speex_stereo_state_destroy(SpeexStereoState *stereo); | |
| | | | |
| /** Transforms a stereo frame into a mono frame and stores intensity stereo
info in 'bits' */ | | /** Transforms a stereo frame into a mono frame and stores intensity stereo
info in 'bits' */ | |
| void speex_encode_stereo(float *data, int frame_size, SpeexBits *bits); | | 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' */ | | /** Transforms a stereo frame into a mono frame and stores intensity stereo
info in 'bits' */ | |
| void speex_encode_stereo_int(spx_int16_t *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
*/ | | /** Transforms a mono frame into a stereo frame using intensity stereo info
*/ | |
| void speex_decode_stereo(float *data, int frame_size, SpeexStereoState *ste
reo); | | void speex_decode_stereo(float *data, int frame_size, SpeexStereoState *ste
reo); | |
| | | | |
| /** Transforms a mono frame into a stereo frame using intensity stereo info
*/ | | /** Transforms a mono frame into a stereo frame using intensity stereo info
*/ | |
| void speex_decode_stereo_int(spx_int16_t *data, int frame_size, SpeexStereo
State *stereo); | | void speex_decode_stereo_int(spx_int16_t *data, int frame_size, SpeexStereo
State *stereo); | |
| | | | |
| /** Callback handler for intensity stereo info */ | | /** Callback handler for intensity stereo info */ | |
| int speex_std_stereo_request_handler(SpeexBits *bits, void *state, void *da
ta); | | int speex_std_stereo_request_handler(SpeexBits *bits, void *state, void *da
ta); | |
| | | | |
| #ifdef __cplusplus | | #ifdef __cplusplus | |
| } | | } | |
| #endif | | #endif | |
| | | | |
|
| | | /** @} */ | |
| #endif | | #endif | |
| | | | |
End of changes. 5 change blocks. |
| 5 lines changed or deleted | | 20 lines changed or added | |
|
| speex_types.h | | speex_types.h | |
| | | | |
| skipping to change at line 29 | | skipping to change at line 29 | |
| @file speex_types.h | | @file speex_types.h | |
| @brief Speex types | | @brief Speex types | |
| */ | | */ | |
| #ifndef _SPEEX_TYPES_H | | #ifndef _SPEEX_TYPES_H | |
| #define _SPEEX_TYPES_H | | #define _SPEEX_TYPES_H | |
| | | | |
| #if defined(_WIN32) | | #if defined(_WIN32) | |
| | | | |
| # if defined(__CYGWIN__) | | # if defined(__CYGWIN__) | |
| # include <_G_config.h> | | # include <_G_config.h> | |
|
| typedef _G_int64_t spx_int64_t; | | | |
| typedef _G_int32_t spx_int32_t; | | typedef _G_int32_t spx_int32_t; | |
| typedef _G_uint32_t spx_uint32_t; | | typedef _G_uint32_t spx_uint32_t; | |
| typedef _G_int16_t spx_int16_t; | | typedef _G_int16_t spx_int16_t; | |
| typedef _G_uint16_t spx_uint16_t; | | typedef _G_uint16_t spx_uint16_t; | |
| # elif defined(__MINGW32__) | | # elif defined(__MINGW32__) | |
| typedef short spx_int16_t; | | typedef short spx_int16_t; | |
| typedef unsigned short spx_uint16_t; | | typedef unsigned short spx_uint16_t; | |
| typedef int spx_int32_t; | | typedef int spx_int32_t; | |
| typedef unsigned int spx_uint32_t; | | typedef unsigned int spx_uint32_t; | |
|
| typedef long long spx_int64_t; | | | |
| typedef unsigned long long spx_uint64_t; | | | |
| # elif defined(__MWERKS__) | | # elif defined(__MWERKS__) | |
|
| typedef long long spx_int64_t; | | | |
| typedef int spx_int32_t; | | typedef int spx_int32_t; | |
| typedef unsigned int spx_uint32_t; | | typedef unsigned int spx_uint32_t; | |
| typedef short spx_int16_t; | | typedef short spx_int16_t; | |
| typedef unsigned short spx_uint16_t; | | typedef unsigned short spx_uint16_t; | |
| # else | | # else | |
| /* MSVC/Borland */ | | /* MSVC/Borland */ | |
|
| typedef __int64 spx_int64_t; | | | |
| typedef __int32 spx_int32_t; | | typedef __int32 spx_int32_t; | |
| typedef unsigned __int32 spx_uint32_t; | | typedef unsigned __int32 spx_uint32_t; | |
| typedef __int16 spx_int16_t; | | typedef __int16 spx_int16_t; | |
| typedef unsigned __int16 spx_uint16_t; | | typedef unsigned __int16 spx_uint16_t; | |
| # endif | | # endif | |
| | | | |
| #elif defined(__MACOS__) | | #elif defined(__MACOS__) | |
| | | | |
| # include <sys/types.h> | | # include <sys/types.h> | |
| typedef SInt16 spx_int16_t; | | typedef SInt16 spx_int16_t; | |
| typedef UInt16 spx_uint16_t; | | typedef UInt16 spx_uint16_t; | |
| typedef SInt32 spx_int32_t; | | typedef SInt32 spx_int32_t; | |
| typedef UInt32 spx_uint32_t; | | typedef UInt32 spx_uint32_t; | |
|
| typedef SInt64 spx_int64_t; | | | |
| | | | |
|
| #elif defined(__MACOSX__) /* MacOS X Framework build */ | | #elif (defined(__APPLE__) && defined(__MACH__)) /* MacOS X Framework build
*/ | |
| | | | |
| # include <sys/types.h> | | # include <sys/types.h> | |
| typedef int16_t spx_int16_t; | | typedef int16_t spx_int16_t; | |
| typedef u_int16_t spx_uint16_t; | | typedef u_int16_t spx_uint16_t; | |
| typedef int32_t spx_int32_t; | | typedef int32_t spx_int32_t; | |
| typedef u_int32_t spx_uint32_t; | | typedef u_int32_t spx_uint32_t; | |
|
| typedef int64_t spx_int64_t; | | | |
| | | | |
| #elif defined(__BEOS__) | | #elif defined(__BEOS__) | |
| | | | |
| /* Be */ | | /* Be */ | |
| # include <inttypes.h> | | # include <inttypes.h> | |
| typedef int16_t spx_int16_t; | | typedef int16_t spx_int16_t; | |
| typedef u_int16_t spx_uint16_t; | | typedef u_int16_t spx_uint16_t; | |
| typedef int32_t spx_int32_t; | | typedef int32_t spx_int32_t; | |
| typedef u_int32_t spx_uint32_t; | | typedef u_int32_t spx_uint32_t; | |
|
| typedef int64_t spx_int64_t; | | | |
| | | | |
| #elif defined (__EMX__) | | #elif defined (__EMX__) | |
| | | | |
| /* OS/2 GCC */ | | /* OS/2 GCC */ | |
| typedef short spx_int16_t; | | typedef short spx_int16_t; | |
| typedef unsigned short spx_uint16_t; | | typedef unsigned short spx_uint16_t; | |
| typedef int spx_int32_t; | | typedef int spx_int32_t; | |
| typedef unsigned int spx_uint32_t; | | typedef unsigned int spx_uint32_t; | |
|
| typedef long long spx_int64_t; | | | |
| | | | |
| #elif defined (DJGPP) | | #elif defined (DJGPP) | |
| | | | |
| /* DJGPP */ | | /* DJGPP */ | |
| typedef short spx_int16_t; | | typedef short spx_int16_t; | |
| typedef int spx_int32_t; | | typedef int spx_int32_t; | |
| typedef unsigned int spx_uint32_t; | | typedef unsigned int spx_uint32_t; | |
|
| typedef long long spx_int64_t; | | | |
| | | | |
| #elif defined(R5900) | | #elif defined(R5900) | |
| | | | |
| /* PS2 EE */ | | /* PS2 EE */ | |
|
| typedef long spx_int64_t; | | | |
| typedef int spx_int32_t; | | typedef int spx_int32_t; | |
| typedef unsigned spx_uint32_t; | | typedef unsigned spx_uint32_t; | |
| typedef short spx_int16_t; | | typedef short spx_int16_t; | |
| | | | |
| #elif defined(__SYMBIAN32__) | | #elif defined(__SYMBIAN32__) | |
| | | | |
| /* Symbian GCC */ | | /* Symbian GCC */ | |
| typedef signed short spx_int16_t; | | typedef signed short spx_int16_t; | |
| typedef unsigned short spx_uint16_t; | | typedef unsigned short spx_uint16_t; | |
| typedef signed int spx_int32_t; | | typedef signed int spx_int32_t; | |
| typedef unsigned int spx_uint32_t; | | typedef unsigned int spx_uint32_t; | |
|
| typedef long long int spx_int64_t; | | | |
| | | | |
| #elif defined(CONFIG_TI_C54X) || defined (CONFIG_TI_C55X) | | #elif defined(CONFIG_TI_C54X) || defined (CONFIG_TI_C55X) | |
| | | | |
| typedef short spx_int16_t; | | typedef short spx_int16_t; | |
| typedef unsigned short spx_uint16_t; | | typedef unsigned short spx_uint16_t; | |
| typedef long spx_int32_t; | | typedef long spx_int32_t; | |
| typedef unsigned long spx_uint32_t; | | typedef unsigned long spx_uint32_t; | |
| | | | |
|
| #elif defined(CONFIG_TI_C5X) | | #elif defined(CONFIG_TI_C6X) | |
| | | | |
| typedef short spx_int16_t; | | typedef short spx_int16_t; | |
| typedef unsigned short spx_uint16_t; | | typedef unsigned short spx_uint16_t; | |
| typedef int spx_int32_t; | | typedef int spx_int32_t; | |
| typedef unsigned int spx_uint32_t; | | typedef unsigned int spx_uint32_t; | |
| | | | |
| #else | | #else | |
| | | | |
|
| # include <speex/speex_config_types.h> | | #include "speex_config_types.h" | |
| | | | |
| #endif | | #endif | |
| | | | |
| #endif /* _SPEEX_TYPES_H */ | | #endif /* _SPEEX_TYPES_H */ | |
| | | | |
End of changes. 14 change blocks. |
| 15 lines changed or deleted | | 3 lines changed or added | |
|