Removing check_decoder()

This commit is contained in:
Jean-Marc Valin 2010-08-27 16:02:30 -04:00
parent 02a3527aa4
commit 0410e9ca81

View file

@ -925,9 +925,6 @@ int celt_encode_with_ec_float(CELTEncoder * restrict st, const float * pcm, floa
VARDECL(celt_int16, in); VARDECL(celt_int16, in);
SAVE_STACK; SAVE_STACK;
if (check_encoder(st) != CELT_OK)
return CELT_INVALID_STATE;
if (check_mode(st->mode) != CELT_OK) if (check_mode(st->mode) != CELT_OK)
return CELT_INVALID_MODE; return CELT_INVALID_MODE;
@ -1151,7 +1148,6 @@ bad_request:
@brief Decoder state @brief Decoder state
*/ */
struct CELTDecoder { struct CELTDecoder {
celt_uint32 marker;
const CELTMode *mode; const CELTMode *mode;
int overlap; int overlap;
int channels; int channels;
@ -1165,22 +1161,6 @@ struct CELTDecoder {
celt_sig _decode_mem[1]; celt_sig _decode_mem[1];
}; };
int check_decoder(const CELTDecoder *st)
{
if (st==NULL)
{
celt_warning("NULL passed a decoder structure");
return CELT_INVALID_STATE;
}
if (st->marker == DECODERVALID)
return CELT_OK;
if (st->marker == DECODERFREED)
celt_warning("Referencing a decoder that has already been freed");
else
celt_warning("This is not a valid CELT decoder structure");
return CELT_INVALID_STATE;
}
int celt_decoder_get_size(const CELTMode *mode, int channels) int celt_decoder_get_size(const CELTMode *mode, int channels)
{ {
int size = sizeof(struct CELTDecoder) int size = sizeof(struct CELTDecoder)
@ -1231,14 +1211,7 @@ CELTDecoder *celt_decoder_create(const CELTMode *mode, int channels, int *error)
if (error) if (error)
*error = CELT_OK; *error = CELT_OK;
st->marker = DECODERVALID;
return st; return st;
/* If the setup fails for some reason deallocate it. */
celt_decoder_destroy(st);
if (error)
*error = CELT_ALLOC_FAIL;
return NULL;
} }
void celt_decoder_destroy(CELTDecoder *st) void celt_decoder_destroy(CELTDecoder *st)
@ -1461,9 +1434,6 @@ int celt_decode_with_ec_float(CELTDecoder * restrict st, const unsigned char *da
int effEnd; int effEnd;
SAVE_STACK; SAVE_STACK;
if (check_decoder(st) != CELT_OK)
return CELT_INVALID_STATE;
if (check_mode(st->mode) != CELT_OK) if (check_mode(st->mode) != CELT_OK)
return CELT_INVALID_MODE; return CELT_INVALID_MODE;
@ -1631,9 +1601,6 @@ int celt_decode_with_ec_float(CELTDecoder * restrict st, const unsigned char *da
VARDECL(celt_int16, out); VARDECL(celt_int16, out);
SAVE_STACK; SAVE_STACK;
if (check_decoder(st) != CELT_OK)
return CELT_INVALID_STATE;
if (check_mode(st->mode) != CELT_OK) if (check_mode(st->mode) != CELT_OK)
return CELT_INVALID_MODE; return CELT_INVALID_MODE;
@ -1667,9 +1634,6 @@ int celt_decode_with_ec(CELTDecoder * restrict st, const unsigned char *data, in
VARDECL(celt_sig, out); VARDECL(celt_sig, out);
SAVE_STACK; SAVE_STACK;
if (check_decoder(st) != CELT_OK)
return CELT_INVALID_STATE;
if (check_mode(st->mode) != CELT_OK) if (check_mode(st->mode) != CELT_OK)
return CELT_INVALID_MODE; return CELT_INVALID_MODE;
@ -1714,9 +1678,6 @@ int celt_decoder_ctl(CELTDecoder * restrict st, int request, ...)
{ {
va_list ap; va_list ap;
if (check_decoder(st) != CELT_OK)
return CELT_INVALID_STATE;
va_start(ap, request); va_start(ap, request);
if ((request!=CELT_GET_MODE_REQUEST) && (check_mode(st->mode) != CELT_OK)) if ((request!=CELT_GET_MODE_REQUEST) && (check_mode(st->mode) != CELT_OK))
goto bad_mode; goto bad_mode;