ref: ff96b165feadf5c0bb5c75c3013d3447bd57298a
parent: d6bf19d22db8b4f758307cbb1666426254e22201
author: Jean-Marc Valin <[email protected]>
date: Mon Mar 21 07:32:50 EDT 2011
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.
--- a/libcelt/celt.c
+++ b/libcelt/celt.c
@@ -2748,6 +2748,14 @@
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,
--- a/libcelt/celt.h
+++ b/libcelt/celt.h
@@ -108,6 +108,9 @@
#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 @@
#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.
@@ -170,9 +164,6 @@
@param mode Mode to be destroyed
*/
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 */
--- a/libcelt/header.c
+++ b/libcelt/header.c
@@ -55,7 +55,8 @@
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;
--- a/libcelt/modes.c
+++ b/libcelt/modes.c
@@ -74,25 +74,6 @@
#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 @@
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)
--- a/libcelt/testcelt.c
+++ b/libcelt/testcelt.c
@@ -78,7 +78,6 @@
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 @@
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)
{
--- a/tools/celtdec.c
+++ b/tools/celtdec.c
@@ -304,8 +304,8 @@
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);
--- a/tools/celtenc.c
+++ b/tools/celtenc.c
@@ -308,8 +308,7 @@
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 @@
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 @@
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*/