CELT  0.8.1
Functions
Encoding and decoding

Functions

EXPORT CELTModecelt_mode_create (celt_int32 Fs, int frame_size, int *error)
EXPORT void celt_mode_destroy (CELTMode *mode)
EXPORT int celt_mode_info (const CELTMode *mode, int request, celt_int32 *value)
EXPORT CELTEncodercelt_encoder_create (const CELTMode *mode, int channels, int *error)
EXPORT void celt_encoder_destroy (CELTEncoder *st)
EXPORT int celt_encode_resynthesis_float (CELTEncoder *st, const float *pcm, float *optional_resynthesis, int frame_size, unsigned char *compressed, int nbCompressedBytes)
EXPORT int celt_encode_float (CELTEncoder *st, const float *pcm, int frame_size, unsigned char *compressed, int nbCompressedBytes)
EXPORT int celt_encode_resynthesis (CELTEncoder *st, const celt_int16 *pcm, celt_int16 *optional_resynthesis, int frame_size, unsigned char *compressed, int nbCompressedBytes)
EXPORT int celt_encode (CELTEncoder *st, const celt_int16 *pcm, int frame_size, unsigned char *compressed, int nbCompressedBytes)
EXPORT int celt_encoder_ctl (CELTEncoder *st, int request,...)
EXPORT CELTDecodercelt_decoder_create (const CELTMode *mode, int channels, int *error)
EXPORT void celt_decoder_destroy (CELTDecoder *st)
EXPORT int celt_decode_float (CELTDecoder *st, const unsigned char *data, int len, float *pcm, int frame_size)
EXPORT int celt_decode (CELTDecoder *st, const unsigned char *data, int len, celt_int16 *pcm, int frame_size)
EXPORT int celt_decoder_ctl (CELTDecoder *st, int request,...)
EXPORT const char * celt_strerror (int error)

Function Documentation

EXPORT int celt_decode ( CELTDecoder st,
const unsigned char *  data,
int  len,
celt_int16 *  pcm,
int  frame_size 
)

Decodes a frame of audio.

Parameters:
stDecoder state
dataCompressed data produced by an encoder
lenNumber of bytes to read from "data". This MUST be exactly the number of bytes returned by the encoder. Using a larger value WILL NOT WORK.
pcmOne frame (frame_size samples per channel) of decoded PCM will be returned here in 16-bit PCM format (native endian).
Returns:
Error code.
EXPORT int celt_decode_float ( CELTDecoder st,
const unsigned char *  data,
int  len,
float *  pcm,
int  frame_size 
)

Decodes a frame of audio.

Parameters:
stDecoder state
dataCompressed data produced by an encoder
lenNumber of bytes to read from "data". This MUST be exactly the number of bytes returned by the encoder. Using a larger value WILL NOT WORK.
pcmOne frame (frame_size samples per channel) of decoded PCM will be returned here in float format.
Returns:
Error code.
EXPORT CELTDecoder* celt_decoder_create ( const CELTMode mode,
int  channels,
int *  error 
)

Creates a new decoder state. Each stream needs its own decoder state (can't be shared across simultaneous streams).

Parameters:
modeContains all the information about the characteristics of the stream (must be the same characteristics as used for the encoder)
channelsNumber of channels
errorReturns an error code
Returns:
Newly created decoder state.
EXPORT int celt_decoder_ctl ( CELTDecoder st,
int  request,
  ... 
)

Query and set decoder parameters

Parameters:
stDecoder state
requestParameter to change or query
valuePointer to a 32-bit int value
Returns:
Error code
EXPORT void celt_decoder_destroy ( CELTDecoder st)

Destroys a a decoder state.

Parameters:
stDecoder state to be destroyed
EXPORT int celt_encode ( CELTEncoder st,
const celt_int16 *  pcm,
int  frame_size,
unsigned char *  compressed,
int  nbCompressedBytes 
)

Encodes a frame of audio.

Parameters:
stEncoder state
pcmPCM audio in signed 16-bit format (native endian). There must be exactly frame_size samples per channel.
compressedThe compressed data is written here. This may not alias pcm or optional_synthesis.
nbCompressedBytesMaximum number of bytes to use for compressing the frame (can change from one frame to another)
Returns:
Number of bytes written to "compressed". Will be the same as "nbCompressedBytes" unless the stream is VBR and will never be larger. If negative, an error has occurred (see error codes). It is IMPORTANT that the length returned be somehow transmitted to the decoder. Otherwise, no decoding is possible.
EXPORT int celt_encode_float ( CELTEncoder st,
const float *  pcm,
int  frame_size,
unsigned char *  compressed,
int  nbCompressedBytes 
)

Encodes a frame of audio.

Parameters:
stEncoder state
pcmPCM audio in float format, with a normal range of ±1.0. Samples with a range beyond ±1.0 are supported but will be clipped by decoders using the integer API and should only be used if it is known that the far end supports extended dynmaic range. There must be exactly frame_size samples per channel.
compressedThe compressed data is written here. This may not alias pcm or optional_synthesis.
nbCompressedBytesMaximum number of bytes to use for compressing the frame (can change from one frame to another)
Returns:
Number of bytes written to "compressed". Will be the same as "nbCompressedBytes" unless the stream is VBR and will never be larger. If negative, an error has occurred (see error codes). It is IMPORTANT that the length returned be somehow transmitted to the decoder. Otherwise, no decoding is possible.
EXPORT int celt_encode_resynthesis ( CELTEncoder st,
const celt_int16 *  pcm,
celt_int16 *  optional_resynthesis,
int  frame_size,
unsigned char *  compressed,
int  nbCompressedBytes 
)

Encodes a frame of audio.

Parameters:
stEncoder state
pcmPCM audio in signed 16-bit format (native endian). There must be exactly frame_size samples per channel.
optional_resynthesisIf not NULL, the encoder copies the audio signal that the decoder would decode. It is the same as calling the decoder on the compressed data, just faster. This may alias pcm.
compressedThe compressed data is written here. This may not alias pcm or optional_synthesis.
nbCompressedBytesMaximum number of bytes to use for compressing the frame (can change from one frame to another)
Returns:
Number of bytes written to "compressed". Will be the same as "nbCompressedBytes" unless the stream is VBR and will never be larger. If negative, an error has occurred (see error codes). It is IMPORTANT that the length returned be somehow transmitted to the decoder. Otherwise, no decoding is possible.
EXPORT int celt_encode_resynthesis_float ( CELTEncoder st,
const float *  pcm,
float *  optional_resynthesis,
int  frame_size,
unsigned char *  compressed,
int  nbCompressedBytes 
)

Encodes a frame of audio.

Parameters:
stEncoder state
pcmPCM audio in float format, with a normal range of ±1.0. Samples with a range beyond ±1.0 are supported but will be clipped by decoders using the integer API and should only be used if it is known that the far end supports extended dynmaic range. There must be exactly frame_size samples per channel.
optional_resynthesisIf not NULL, the encoder copies the audio signal that the decoder would decode. It is the same as calling the decoder on the compressed data, just faster. This may alias pcm.
compressedThe compressed data is written here. This may not alias pcm or optional_synthesis.
nbCompressedBytesMaximum number of bytes to use for compressing the frame (can change from one frame to another)
Returns:
Number of bytes written to "compressed". Will be the same as "nbCompressedBytes" unless the stream is VBR and will never be larger. If negative, an error has occurred (see error codes). It is IMPORTANT that the length returned be somehow transmitted to the decoder. Otherwise, no decoding is possible.
EXPORT CELTEncoder* celt_encoder_create ( const CELTMode mode,
int  channels,
int *  error 
)

Creates a new encoder state. Each stream needs its own encoder state (can't be shared across simultaneous streams).

Parameters:
modeContains all the information about the characteristics of the stream (must be the same characteristics as used for the decoder)
channelsNumber of channels
errorReturns an error code
Returns:
Newly created encoder state.
EXPORT int celt_encoder_ctl ( CELTEncoder st,
int  request,
  ... 
)

Query and set encoder parameters

Parameters:
stEncoder state
requestParameter to change or query
valuePointer to a 32-bit int value
Returns:
Error code
EXPORT void celt_encoder_destroy ( CELTEncoder st)

Destroys a an encoder state.

Parameters:
stEncoder state to be destroyed
EXPORT CELTMode* celt_mode_create ( celt_int32  Fs,
int  frame_size,
int *  error 
)

Creates a new mode struct. This will be passed to an encoder or decoder. The mode MUST NOT BE DESTROYED until the encoders and decoders that use it are destroyed as well.

Parameters:
FsSampling rate (32000 to 96000 Hz)
frame_sizeNumber of samples (per channel) to encode in each packet (even values; 64 - 512)
errorReturned error code (if NULL, no error will be returned)
Returns:
A newly created mode
EXPORT void celt_mode_destroy ( CELTMode mode)

Destroys a mode struct. Only call this after all encoders and decoders using this mode are destroyed as well.

Parameters:
modeMode to be destroyed
EXPORT int celt_mode_info ( const CELTMode mode,
int  request,
celt_int32 *  value 
)

Query information from a mode

EXPORT const char* celt_strerror ( int  error)

Returns the English string that corresponds to an error code

Parameters:
errorError code (negative for an error, 0 for success
Returns:
Constant string (must NOT be freed)