ex

Fork of mbed-os-example-mbed5-blinky by mbed-os-examples

Embed: (wiki syntax)

« Back to documentation index

Speex encoder and decoder

Speex encoder and decoder

This is the Speex codec itself. More...

Data Structures

struct  SpeexMode
 Struct defining a Speex mode. More...

Typedefs

typedef void *(* encoder_init_func )(const struct SpeexMode *mode)
 Encoder state initialization function.
typedef void(* encoder_destroy_func )(void *st)
 Encoder state destruction function.
typedef int(* encode_func )(void *state, void *in, SpeexBits *bits)
 Main encoding function.
typedef int(* encoder_ctl_func )(void *state, int request, void *ptr)
 Function for controlling the encoder options.
typedef void *(* decoder_init_func )(const struct SpeexMode *mode)
 Decoder state initialization function.
typedef void(* decoder_destroy_func )(void *st)
 Decoder state destruction function.
typedef int(* decode_func )(void *state, SpeexBits *bits, void *out)
 Main decoding function.
typedef int(* decoder_ctl_func )(void *state, int request, void *ptr)
 Function for controlling the decoder options.
typedef int(* mode_query_func )(const void *mode, int request, void *ptr)
 Query function for a mode.
typedef struct SpeexMode SpeexMode
 Struct defining a Speex mode.

Functions

void * speex_encoder_init (const SpeexMode *mode)
 Returns a handle to a newly created Speex encoder state structure.
void speex_encoder_destroy (void *state)
 Frees all resources associated to an existing Speex encoder state.
int speex_encode (void *state, float *in, SpeexBits *bits)
 Uses an existing encoder state to encode one frame of speech pointed to by "in".
int speex_encode_int (void *state, spx_int16_t *in, SpeexBits *bits)
 Uses an existing encoder state to encode one frame of speech pointed to by "in".
int speex_encoder_ctl (void *state, int request, void *ptr)
 Used like the ioctl function to control the encoder parameters.
void * speex_decoder_init (const SpeexMode *mode)
 Returns a handle to a newly created decoder state structure.
void speex_decoder_destroy (void *state)
 Frees all resources associated to an existing decoder state.
int speex_decode (void *state, SpeexBits *bits, float *out)
 Uses an existing decoder state to decode one frame of speech from bit-stream bits.
int speex_decode_int (void *state, SpeexBits *bits, spx_int16_t *out)
 Uses an existing decoder state to decode one frame of speech from bit-stream bits.
int speex_decoder_ctl (void *state, int request, void *ptr)
 Used like the ioctl function to control the encoder parameters.
int speex_mode_query (const SpeexMode *mode, int request, void *ptr)
 Query function for mode information.
int speex_lib_ctl (int request, void *ptr)
 Functions for controlling the behavior of libspeex.
const SpeexModespeex_lib_get_mode (int mode)
 Obtain one of the modes available.

Variables

const SpeexMode speex_nb_mode
 Default narrowband mode.
const SpeexMode speex_wb_mode
 Default wideband mode.
const SpeexMode speex_uwb_mode
 Default "ultra-wideband" mode.
const SpeexMode speex_nb_48k_mode
 4.8 kbps narrowband mode
const SpeexMode *const speex_mode_list [SPEEX_NB_MODES]
 List of all modes available.

Detailed Description

This is the Speex codec itself.


Typedef Documentation

typedef int(* decode_func)(void *state, SpeexBits *bits, void *out)

Main decoding function.

Definition at line 244 of file speex.h.

typedef int(* decoder_ctl_func)(void *state, int request, void *ptr)

Function for controlling the decoder options.

Definition at line 247 of file speex.h.

typedef void(* decoder_destroy_func)(void *st)

Decoder state destruction function.

Definition at line 241 of file speex.h.

typedef void*(* decoder_init_func)(const struct SpeexMode *mode)

Decoder state initialization function.

Definition at line 238 of file speex.h.

typedef int(* encode_func)(void *state, void *in, SpeexBits *bits)

Main encoding function.

Definition at line 232 of file speex.h.

typedef int(* encoder_ctl_func)(void *state, int request, void *ptr)

Function for controlling the encoder options.

Definition at line 235 of file speex.h.

typedef void(* encoder_destroy_func)(void *st)

Encoder state destruction function.

Definition at line 229 of file speex.h.

typedef void*(* encoder_init_func)(const struct SpeexMode *mode)

Encoder state initialization function.

Definition at line 226 of file speex.h.

typedef int(* mode_query_func)(const void *mode, int request, void *ptr)

Query function for a mode.

Definition at line 251 of file speex.h.

typedef struct SpeexMode SpeexMode

Struct defining a Speex mode.


Function Documentation

int speex_decode ( void *  state,
SpeexBits bits,
float *  out 
)

Uses an existing decoder state to decode one frame of speech from bit-stream bits.

The output speech is saved written to out.

Parameters:
stateDecoder state
bitsBit-stream from which to decode the frame (NULL if the packet was lost)
outWhere to write the decoded frame
Returns:
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 
)

Uses an existing decoder state to decode one frame of speech from bit-stream bits.

The output speech is saved written to out.

Parameters:
stateDecoder state
bitsBit-stream from which to decode the frame (NULL if the packet was lost)
outWhere to write the decoded frame
Returns:
return status (0 for no error, -1 for end of stream, -2 corrupt stream)
int speex_decoder_ctl ( void *  state,
int  request,
void *  ptr 
)

Used like the ioctl function to control the encoder parameters.

Parameters:
stateDecoder state
requestioctl-type request (one of the SPEEX_* macros)
ptrData exchanged to-from function
Returns:
0 if no error, -1 if request in unknown, -2 for invalid parameter
void speex_decoder_destroy ( void *  state )

Frees all resources associated to an existing decoder state.

Parameters:
stateState to be destroyed
void* speex_decoder_init ( const SpeexMode mode )

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 modes may be added. Note that for now if you have more than one channels to decode, you need one state per channel.

Parameters:
modeSpeex mode (one of speex_nb_mode or speex_wb_mode)
Returns:
A newly created decoder state or NULL if state allocation fails
int speex_encode ( void *  state,
float *  in,
SpeexBits bits 
)

Uses an existing encoder state to encode one frame of speech pointed to by "in".

The encoded bit-stream is saved in "bits".

Parameters:
stateEncoder state
inFrame 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.
bitsBit-stream where the data will be written
Returns:
0 if frame needs not be transmitted (DTX only), 1 otherwise
int speex_encode_int ( void *  state,
spx_int16_t *  in,
SpeexBits bits 
)

Uses an existing encoder state to encode one frame of speech pointed to by "in".

The encoded bit-stream is saved in "bits".

Parameters:
stateEncoder state
inFrame that will be encoded with a +-2^15 range
bitsBit-stream where the data will be written
Returns:
0 if frame needs not be transmitted (DTX only), 1 otherwise
int speex_encoder_ctl ( void *  state,
int  request,
void *  ptr 
)

Used like the ioctl function to control the encoder parameters.

Parameters:
stateEncoder state
requestioctl-type request (one of the SPEEX_* macros)
ptrData exchanged to-from function
Returns:
0 if no error, -1 if request in unknown, -2 for invalid parameter
void speex_encoder_destroy ( void *  state )

Frees all resources associated to an existing Speex encoder state.

Parameters:
stateEncoder state to be destroyed
void* speex_encoder_init ( const SpeexMode mode )

Returns a handle to a newly created Speex encoder state structure.

For now, the "mode" argument 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 encode, you need one state per channel.

Parameters:
modeThe mode to use (either speex_nb_mode or speex_wb.mode)
Returns:
A newly created encoder state or NULL if state allocation fails
int speex_lib_ctl ( int  request,
void *  ptr 
)

Functions for controlling the behavior of libspeex.

Parameters:
requestioctl-type request (one of the SPEEX_LIB_* macros)
ptrData exchanged to-from function
Returns:
0 if no error, -1 if request in unknown, -2 for invalid parameter
const SpeexMode* speex_lib_get_mode ( int  mode )

Obtain one of the modes available.

int speex_mode_query ( const SpeexMode mode,
int  request,
void *  ptr 
)

Query function for mode information.

Parameters:
modeSpeex mode
requestioctl-type request (one of the SPEEX_* macros)
ptrData exchanged to-from function
Returns:
0 if no error, -1 if request in unknown, -2 for invalid parameter

Variable Documentation

const SpeexMode* const speex_mode_list[SPEEX_NB_MODES]

List of all modes available.

4.8 kbps narrowband mode

Default narrowband mode.

Default "ultra-wideband" mode.

Default wideband mode.