Removes the celt_mode_info() call.

Adds a CELT_GET_LOOKAHEAD() ctl() call instead. Other uses of
celt_mode_info() should not be needed anymore.
This commit is contained in:
Jean-Marc Valin 2011-03-21 11:32:50 -04:00
parent d6bf19d22d
commit ff96b165fe
7 changed files with 23 additions and 56 deletions

View file

@ -2748,6 +2748,14 @@ int celt_decoder_ctl(CELTDecoder * restrict st, int request, ...)
st->error = 0;
}
break;
case CELT_GET_LOOKAHEAD_REQUEST:
{
int *value = va_arg(ap, int*);
if (value==NULL)
goto bad_arg;
*value = st->overlap/st->downsample;
}
break;
case CELT_RESET_STATE:
{
CELT_MEMSET((char*)&st->DECODER_RESET_START, 0,

View file

@ -108,6 +108,9 @@ extern "C" {
#define CELT_GET_AND_CLEAR_ERROR_REQUEST 15
#define CELT_GET_AND_CLEAR_ERROR(x) CELT_GET_AND_CLEAR_ERROR_REQUEST, _celt_check_int_ptr(x)
#define CELT_GET_LOOKAHEAD_REQUEST 17
#define CELT_GET_LOOKAHEAD(x) CELT_GET_LOOKAHEAD_REQUEST, _celt_check_int_ptr(x)
/* Internal */
#define CELT_SET_START_BAND_REQUEST 10000
#define CELT_SET_START_BAND(x) CELT_SET_START_BAND_REQUEST, _celt_check_int(x)
@ -121,15 +124,6 @@ extern "C" {
#define CELT_SET_SIGNALLING_REQUEST 10003
#define CELT_SET_SIGNALLING(x) CELT_SET_SIGNALLING_REQUEST, _celt_check_int(x)
/** GET the lookahead used in the current mode */
#define CELT_GET_LOOKAHEAD 1001
/** GET the sample rate used in the current mode */
#define CELT_GET_SAMPLE_RATE 1003
/** GET the bit-stream version for compatibility check */
#define CELT_GET_BITSTREAM_VERSION 2000
/** Contains the state of an encoder. One encoder state is needed
for each stream. It is initialised once at the beginning of the
stream. Do *not* re-initialise the state for every frame.
@ -171,9 +165,6 @@ EXPORT CELTMode *celt_mode_create(celt_int32 Fs, int frame_size, int *error);
*/
EXPORT void celt_mode_destroy(CELTMode *mode);
/** Query information from a mode */
EXPORT int celt_mode_info(const CELTMode *mode, int request, celt_int32 *value);
/* Encoder stuff */
EXPORT int celt_encoder_get_size(int channels);

View file

@ -55,7 +55,8 @@ int celt_header_init(CELTHeader *header, const CELTMode *m, int frame_size, int
CELT_COPY(header->codec_id, "CELT ", 8);
CELT_COPY(header->codec_version, "experimental ", 20);
celt_mode_info(m, CELT_GET_BITSTREAM_VERSION, &header->version_id);
/* FIXME: Set that to zero when we freeze */
header->version_id = 0x80001000;
header->header_size = 56;
header->sample_rate = m->Fs;
header->nb_channels = channels;

View file

@ -74,25 +74,6 @@ static const unsigned char band_allocation[] = {
#endif
int celt_mode_info(const CELTMode *mode, int request, celt_int32 *value)
{
switch (request)
{
case CELT_GET_LOOKAHEAD:
*value = mode->overlap;
break;
case CELT_GET_BITSTREAM_VERSION:
*value = CELT_BITSTREAM_VERSION;
break;
case CELT_GET_SAMPLE_RATE:
*value = mode->Fs;
break;
default:
return CELT_UNIMPLEMENTED;
}
return CELT_OK;
}
#ifdef CUSTOM_MODES
/* Defining 25 critical bands for the full 0-20 kHz audio bandwidth
@ -243,23 +224,12 @@ static void compute_allocation_table(CELTMode *mode)
CELTMode *celt_mode_create(celt_int32 Fs, int frame_size, int *error)
{
int i;
CELTMode *mode=NULL;
#ifdef CUSTOM_MODES
CELTMode *mode=NULL;
int res;
celt_word16 *window;
celt_int16 *logN;
int LM;
#endif
#ifdef STDIN_TUNING
scanf("%d ", &MIN_BINS);
scanf("%d ", &BITALLOC_SIZE);
band_allocation = celt_alloc(sizeof(int)*BARK_BANDS*BITALLOC_SIZE);
for (i=0;i<BARK_BANDS*BITALLOC_SIZE;i++)
{
scanf("%d ", band_allocation+i);
}
#endif
#ifdef CUSTOM_MODES
ALLOC_STACK;
#if !defined(VAR_ARRAYS) && !defined(USE_ALLOCA)
if (global_stack==NULL)

View file

@ -78,7 +78,6 @@ int main(int argc, char *argv[])
return 1;
}
celt_mode_info(mode, CELT_GET_LOOKAHEAD, &skip);
bytes_per_packet = atoi(argv[4]);
if (bytes_per_packet < 0 || bytes_per_packet > MAX_PACKET)
{
@ -114,6 +113,7 @@ int main(int argc, char *argv[])
fprintf(stderr, "Failed to create the decoder: %s\n", celt_strerror(err));
return 1;
}
celt_decoder_ctl(dec, CELT_GET_LOOKAHEAD(&skip));
if (argc>7)
{

View file

@ -304,8 +304,8 @@ static CELTDecoder *process_header(ogg_packet *op, celt_int32 enh_enabled, celt_
return NULL;
}
celt_mode_info(*mode, CELT_GET_BITSTREAM_VERSION, &bitstream);
/* FIXME: Set that to zero when we freeze */
bitstream = 0x80001000;
if (bitstream!=header.version_id)
fprintf(stderr, "WARNING: Input was encoded with a CELT bitstream version %d. This decoder uses %d. Output will probably be corrupted.\n",header.version_id,bitstream);

View file

@ -308,8 +308,7 @@ int main(int argc, char **argv)
celt_int32 lookahead = 0;
int bytes_per_packet=-1;
int complexity=-127;
int prediction=2;
int bitstream;
int prediction=2;
/*Process command-line options*/
@ -483,9 +482,7 @@ int main(int argc, char **argv)
if (!mode)
return 1;
celt_mode_info(mode,CELT_GET_BITSTREAM_VERSION,&bitstream);
snprintf(vendor_string, sizeof(vendor_string), "Encoded with CELT %s (bitstream: %d)\n",CELT_VERSION,bitstream);
snprintf(vendor_string, sizeof(vendor_string), "Encoded with CELT %s\n",CELT_VERSION);
comment_init(&comments, &comments_length, vendor_string);
/*celt_mode_info(mode, CELT_GET_FRAME_SIZE, &frame_size);*/
@ -499,11 +496,11 @@ int main(int argc, char **argv)
st_string="stereo";
if (!quiet)
if (with_cbr)
fprintf (stderr, "Encoding %.0f kHz %s audio in %.0fms packets at %0.3fkbit/sec (%d bytes per packet, CBR) with bitstream version %d\n",
header.sample_rate/1000., st_string, frame_size/(float)header.sample_rate*1000., bitrate, bytes_per_packet,bitstream);
fprintf (stderr, "Encoding %.0f kHz %s audio in %.0fms packets at %0.3fkbit/sec (%d bytes per packet, CBR)\n",
header.sample_rate/1000., st_string, frame_size/(float)header.sample_rate*1000., bitrate, bytes_per_packet);
else
fprintf (stderr, "Encoding %.0f kHz %s audio in %.0fms packets at %0.3fkbit/sec (%d bytes per packet maximum) with bitstream version %d\n",
header.sample_rate/1000., st_string, frame_size/(float)header.sample_rate*1000., bitrate, bytes_per_packet,bitstream);
fprintf (stderr, "Encoding %.0f kHz %s audio in %.0fms packets at %0.3fkbit/sec (%d bytes per packet maximum)\n",
header.sample_rate/1000., st_string, frame_size/(float)header.sample_rate*1000., bitrate, bytes_per_packet);
}
/*Initialize CELT encoder*/