diff --git a/libcelt/celt.c b/libcelt/celt.c index a6ca4eeba136ad3a97663eff06c431e9ca34e461..411ba45849e7336494d7c9686c7b7d7c55e2d276 100644 --- a/libcelt/celt.c +++ b/libcelt/celt.c @@ -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, diff --git a/libcelt/celt.h b/libcelt/celt.h index 91dcc5e383ca98e5e21570bd0223ff5bc310c25f..b6f2e26d07a9f68b0df5d59181d5c3a02fb58e12 100644 --- a/libcelt/celt.h +++ b/libcelt/celt.h @@ -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); diff --git a/libcelt/header.c b/libcelt/header.c index b31a5b75aa6a786d690e47cb88ad7d4f423c0955..37b11bf5c9b0a717a18ac665fe386c856081aefa 100644 --- a/libcelt/header.c +++ b/libcelt/header.c @@ -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; diff --git a/libcelt/modes.c b/libcelt/modes.c index 7aa6ebabf5858a22aa429da3518c201d2dba77ad..968bc2ff3b36c176f90e510d3e0e0382e3d871b0 100644 --- a/libcelt/modes.c +++ b/libcelt/modes.c @@ -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) diff --git a/libcelt/testcelt.c b/libcelt/testcelt.c index 72b70ba1dc36f53435f8adb6bb2732f6b58a3c73..d889a5b28db122c1842fdf6510d165c6b0eb810c 100644 --- a/libcelt/testcelt.c +++ b/libcelt/testcelt.c @@ -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) { diff --git a/tools/celtdec.c b/tools/celtdec.c index 5edbd4809aa9133b6bc5a363ea03ff1245b0c79a..30cc87d90169eaa7aea552e5e39501a3f976b3aa 100644 --- a/tools/celtdec.c +++ b/tools/celtdec.c @@ -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); diff --git a/tools/celtenc.c b/tools/celtenc.c index 1f92607da3da29aa58cd9310e0ba085c24206925..685c62ccf1acc6646acfe3687ce4ab19b73cd436 100644 --- a/tools/celtenc.c +++ b/tools/celtenc.c @@ -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*/