speex.h | speex.h | |||
---|---|---|---|---|
skipping to change at line 25 | skipping to change at line 25 | |||
You should have received a copy of the GNU Lesser General Public | You should have received a copy of the GNU Lesser General Public | |||
License along with this library; if not, write to the Free Software | License along with this library; if not, write to the Free Software | |||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 US A | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 US A | |||
*/ | */ | |||
#ifndef SPEEX_MODES_H | #ifndef SPEEX_MODES_H | |||
#define SPEEX_MODES_H | #define SPEEX_MODES_H | |||
#include "speex_bits.h" | ||||
#ifdef __cplusplus | #ifdef __cplusplus | |||
extern "C" { | extern "C" { | |||
#endif | #endif | |||
#include "speex_bits.h" | ||||
struct SpeexMode; | struct SpeexMode; | |||
typedef void *(*encoder_init_func)(struct SpeexMode *mode); | typedef void *(*encoder_init_func)(struct SpeexMode *mode); | |||
typedef void (*encoder_destroy_func)(void *st); | typedef void (*encoder_destroy_func)(void *st); | |||
typedef void (*encode_func)(void *state, float *in, FrameBits *bits); | typedef void (*encode_func)(void *state, float *in, SpeexBits *bits); | |||
typedef void *(*decoder_init_func)(struct SpeexMode *mode); | typedef void *(*decoder_init_func)(struct SpeexMode *mode); | |||
typedef void (*decoder_destroy_func)(void *st); | typedef void (*decoder_destroy_func)(void *st); | |||
typedef void (*decode_func)(void *state, FrameBits *bits, float *out); | typedef void (*decode_func)(void *state, SpeexBits *bits, float *out, int l ost); | |||
/** Struct defining a Speex mode */ | /** Struct defining a Speex mode */ | |||
typedef struct SpeexMode { | typedef struct SpeexMode { | |||
/** Pointer to the low-level mode data */ | ||||
void *mode; | void *mode; | |||
/** Pointer to encoder initialization function */ | ||||
encoder_init_func enc_init; | encoder_init_func enc_init; | |||
/** Pointer to encoder destruction function */ | ||||
encoder_destroy_func enc_destroy; | encoder_destroy_func enc_destroy; | |||
/** Pointer to frame encoding function */ | ||||
encode_func enc; | encode_func enc; | |||
/** Pointer to decoder initialization function */ | ||||
decoder_init_func dec_init; | decoder_init_func dec_init; | |||
/** Pointer to decoder destruction function */ | ||||
decoder_destroy_func dec_destroy; | decoder_destroy_func dec_destroy; | |||
/** Pointer to frame decoding function */ | ||||
decode_func dec; | decode_func dec; | |||
/** Frame size used for the current mode */ | ||||
int frameSize; | int frameSize; | |||
} SpeexMode; | } SpeexMode; | |||
/** Creates an encoder state ("object") from a mode */ | /**Returns a handle to a newly created Speex encoder state structure. For n | |||
void *encoder_init(SpeexMode *mode); | ow, the | |||
"mode" arguent can be &nb_mode or &wb_mode . In the future, more modes m | ||||
ay be | ||||
added. Note that for now if you have more than one channels to encode, y | ||||
ou need | ||||
one state per channel.*/ | ||||
void *speex_encoder_init(SpeexMode *mode); | ||||
/** Destroy a Speex encoder state */ | /** Frees all resources associated to an existing Speex encoder state. */ | |||
void encoder_destroy(void *state); | void speex_encoder_destroy(void *state); | |||
/** Encode a frame */ | /** Uses an existing encoder state to encode one frame of speech pointed to | |||
void encode(void *state, float *in, FrameBits *bits); | by | |||
"in". The encoded bit-stream is saved in "bits".*/ | ||||
void speex_encode(void *state, float *in, SpeexBits *bits); | ||||
/** Creates a decoder state ("object") from a mode */ | /** Returns a handle to a newly created decoder state structure. For now, t | |||
void *decoder_init(SpeexMode *mode); | he mode | |||
arguent can be &nb_mode or &wb_mode . In the future, more modes may be | ||||
added. | ||||
Note that for now if you have more than one channels to decode, you nee | ||||
d one | ||||
state per channel. */ | ||||
void *speex_decoder_init(SpeexMode *mode); | ||||
/** Destroy a Speex decoder state */ | /** Frees all resources associated to an existing decoder state. */ | |||
void decoder_destroy(void *state); | void speex_decoder_destroy(void *state); | |||
/** Decode a frame */ | /** Uses an existing decoder state to decode one frame of speech from bit-s | |||
void decode(void *state, FrameBits *bits, float *out); | tream | |||
bits. The output speech is saved written to out. */ | ||||
void speex_decode(void *state, SpeexBits *bits, float *out, int lost); | ||||
/** Default narrowband mode */ | /** Default narrowband mode */ | |||
extern SpeexMode speex_nb_mode; | extern SpeexMode speex_nb_mode; | |||
/** Default wideband mode */ | /** Default wideband mode */ | |||
extern SpeexMode speex_wb_mode; | extern SpeexMode speex_wb_mode; | |||
#ifdef __cplusplus | #ifdef __cplusplus | |||
} | } | |||
#endif | #endif | |||
#endif | #endif | |||
End of changes. 21 change blocks. | ||||
18 lines changed or deleted | 50 lines changed or added | |||
speex_bits.h | speex_bits.h | |||
---|---|---|---|---|
skipping to change at line 25 | skipping to change at line 25 | |||
You should have received a copy of the GNU Lesser General Public | You should have received a copy of the GNU Lesser General Public | |||
License along with this library; if not, write to the Free Software | License along with this library; if not, write to the Free Software | |||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 US A | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 US A | |||
*/ | */ | |||
#ifndef BITS_H | #ifndef BITS_H | |||
#define BITS_H | #define BITS_H | |||
#ifdef __cplusplus | ||||
extern "C" { | ||||
#endif | ||||
#define MAX_BYTES_PER_FRAME 1000 | #define MAX_BYTES_PER_FRAME 1000 | |||
typedef struct FrameBits { | /** Bit-packing data structure representing (part of) a bit-stream. */ | |||
typedef struct SpeexBits { | ||||
char bytes[MAX_BYTES_PER_FRAME]; | char bytes[MAX_BYTES_PER_FRAME]; | |||
int nbBits; | int nbBits; | |||
int bytePtr; | int bytePtr; | |||
int bitPtr; | int bitPtr; | |||
} FrameBits; | } SpeexBits; | |||
void speex_bits_init(FrameBits *bits); | /** Initializes and allocates resources for a SpeexBits struct */ | |||
void speex_bits_init(SpeexBits *bits); | ||||
void speex_bits_destroy(FrameBits *bits); | /** Frees all resources assiociated to a SpeexBits struct. Right now this d | |||
oes nothing since no resources are allocated, but this could change in the | ||||
future.*/ | ||||
void speex_bits_destroy(SpeexBits *bits); | ||||
void speex_bits_reset(FrameBits *bits); | /** Resets bits to initial value (just after initialization, erasing conten | |||
t)*/ | ||||
void speex_bits_reset(SpeexBits *bits); | ||||
void speex_bits_rewind(FrameBits *bits); | /** Rewind the bit-stream to beginning (ready for read) without erasing con | |||
tent*/ | ||||
void speex_bits_rewind(SpeexBits *bits); | ||||
void speex_bits_init_from(FrameBits *bits, char *bytes, int len); | /** 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_whole_bytes(FrameBits *bits, char *bytes, int len); | void speex_bits_read_whole_bytes(SpeexBits *bits, char *bytes, int len); | |||
int speex_bits_write(FrameBits *bits, char *bytes, int max_len); | /** Write the content of a bit-stream to an area of memory */ | |||
int speex_bits_write(SpeexBits *bits, char *bytes, int max_len); | ||||
int speex_bits_write_whole_bytes(FrameBits *bits, char *bytes, int max_len) ; | int speex_bits_write_whole_bytes(SpeexBits *bits, char *bytes, int max_len) ; | |||
void speex_bits_pack(FrameBits *bits, int data, int nbBits); | void speex_bits_pack(SpeexBits *bits, int data, int nbBits); | |||
int speex_bits_unpack_signed(FrameBits *bits, int nbBits); | int speex_bits_unpack_signed(SpeexBits *bits, int nbBits); | |||
unsigned int speex_bits_unpack_unsigned(FrameBits *bits, int nbBits); | unsigned int speex_bits_unpack_unsigned(SpeexBits *bits, int nbBits); | |||
#ifdef __cplusplus | ||||
} | ||||
#endif | ||||
#endif | #endif | |||
End of changes. 14 change blocks. | ||||
13 lines changed or deleted | 32 lines changed or added | |||