CELTEncoder *celt_encoder_create(const CELTMode *mode, int channels, int *error)
{
- CELTEncoder *st;
+ return celt_encoder_init(
+ (CELTEncoder *)celt_alloc(celt_encoder_get_size(mode, channels)),
+ mode, channels, error);
+}
+CELTEncoder *celt_encoder_init(CELTEncoder *st, const CELTMode *mode, int channels, int *error)
+{
if (channels < 0 || channels > 2)
{
celt_warning("Only mono and stereo supported");
return NULL;
}
- st = celt_alloc(celt_encoder_get_size(mode, channels));
+ CELT_MEMSET((char*)st, 0, celt_encoder_get_size(mode, channels));
if (st==NULL)
{
CELTDecoder *celt_decoder_create(const CELTMode *mode, int channels, int *error)
{
- int C;
- CELTDecoder *st;
+ return celt_decoder_init(
+ (CELTDecoder *)celt_alloc(celt_decoder_get_size(mode, channels)),
+ mode, channels, error);
+}
+CELTDecoder *celt_decoder_init(CELTDecoder *st, const CELTMode *mode, int channels, int *error)
+{
if (channels < 0 || channels > 2)
{
celt_warning("Only mono and stereo supported");
return NULL;
}
- C = CHANNELS(channels);
- st = celt_alloc(celt_decoder_get_size(mode, channels));
+ CELT_MEMSET((char*)st, 0, celt_decoder_get_size(mode, channels));
if (st==NULL)
{
/* Encoder stuff */
+EXPORT int celt_encoder_get_size(const CELTMode *mode, int channels);
/** Creates a new encoder state. Each stream needs its own encoder
state (can't be shared across simultaneous streams).
*/
EXPORT CELTEncoder *celt_encoder_create(const CELTMode *mode, int channels, int *error);
+EXPORT CELTEncoder *celt_encoder_init(CELTEncoder *st, const CELTMode *mode, int channels, int *error);
+
/** Destroys a an encoder state.
@param st Encoder state to be destroyed
*/
/* Decoder stuff */
+EXPORT int celt_decoder_get_size(const CELTMode *mode, int channels);
/** Creates a new decoder state. Each stream needs its own decoder state (can't
be shared across simultaneous streams).
*/
EXPORT CELTDecoder *celt_decoder_create(const CELTMode *mode, int channels, int *error);
+EXPORT CELTDecoder *celt_decoder_init(CELTDecoder *st, const CELTMode *mode, int channels, int *error);
+
/** Destroys a a decoder state.
@param st Decoder state to be destroyed
*/