ref: 5ad35bf3bf9eb64f8fc2d0d4a4799f4c21d013b8
parent: d9e4b1d72c3cf5e6d3886b09b4a0387f3abf8ffe
author: Jean-Marc Valin <[email protected]>
date: Fri Jan 28 17:42:09 EST 2011
Enabling the standard static mode by default
--- a/libcelt/cwrs.c
+++ b/libcelt/cwrs.c
@@ -644,7 +644,7 @@
return i;
}
-#ifndef STATIC_MODES
+#ifdef CUSTOM_MODES
void get_required_bits(celt_int16 *_bits,int _n,int _maxk,int _frac){
int k;
/*_maxk==0 => there's nothing to do.*/
@@ -665,7 +665,7 @@
RESTORE_STACK;
}
}
-#endif /* STATIC_MODES */
+#endif /* CUSTOM_MODES */
void encode_pulses(const int *_y,int _n,int _k,ec_enc *_enc){
celt_uint32 i;
--- a/libcelt/kiss_fft.c
+++ b/libcelt/kiss_fft.c
@@ -495,7 +495,7 @@
}
-#ifndef STATIC_MODES
+#ifdef CUSTOM_MODES
static
void compute_bitrev_table(
@@ -651,7 +651,7 @@
celt_free((kiss_fft_state*)cfg);
}
-#endif /* STATIC_MODES */
+#endif /* CUSTOM_MODES */
static void kiss_fft_stride(const kiss_fft_state *st,const kiss_fft_cpx *fin,kiss_fft_cpx *fout,int in_stride)
{
--- a/libcelt/mdct.c
+++ b/libcelt/mdct.c
@@ -61,7 +61,7 @@
#define M_PI 3.141592653
#endif
-#ifndef STATIC_MODES
+#ifdef CUSTOM_MODES
void clt_mdct_init(mdct_lookup *l,int N, int maxshift)
{
@@ -104,7 +104,7 @@
celt_free((kiss_twiddle_scalar*)l->trig);
}
-#endif /* STATIC_MODES */
+#endif /* CUSTOM_MODES */
void clt_mdct_forward(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scalar * restrict out, const celt_word16 *window, int overlap, int shift)
{
--- a/libcelt/modes.c
+++ b/libcelt/modes.c
@@ -85,13 +85,11 @@
};
#endif
-#ifdef STATIC_MODES
#ifdef FIXED_POINT
#include "static_modes_fixed.c"
#else
#include "static_modes_float.c"
#endif
-#endif
#ifndef M_PI
#define M_PI 3.141592653
@@ -117,7 +115,7 @@
return CELT_OK;
}
-#ifndef STATIC_MODES
+#ifdef CUSTOM_MODES
/* Defining 25 critical bands for the full 0-20 kHz audio bandwidth
Taken from http://ccrma.stanford.edu/~jos/bbt/Bark_Frequency_Scale.html */
@@ -253,24 +251,11 @@
mode->allocVectors = allocVectors;
}
-#endif /* STATIC_MODES */
+#endif /* CUSTOM_MODES */
CELTMode *celt_mode_create(celt_int32 Fs, int frame_size, int *error)
{
int i;
-#ifdef STATIC_MODES
- for (i=0;i<TOTAL_MODES;i++)
- {
- if (Fs == static_mode_list[i]->Fs &&
- frame_size == static_mode_list[i]->shortMdctSize*static_mode_list[i]->nbShortMdcts)
- {
- return (CELTMode*)static_mode_list[i];
- }
- }
- if (error)
- *error = CELT_BAD_ARG;
- return NULL;
-#else
int res;
CELTMode *mode=NULL;
celt_word16 *window;
@@ -291,6 +276,20 @@
goto failure;
#endif
+ for (i=0;i<TOTAL_MODES;i++)
+ {
+ if (Fs == static_mode_list[i]->Fs &&
+ frame_size == static_mode_list[i]->shortMdctSize*static_mode_list[i]->nbShortMdcts)
+ {
+ return (CELTMode*)static_mode_list[i];
+ }
+ }
+#ifndef CUSTOM_MODES
+ if (error)
+ *error = CELT_BAD_ARG;
+ return NULL;
+#else
+
/* The good thing here is that permutation of the arguments will automatically be invalid */
if (Fs < 8000 || Fs > 96000)
@@ -415,14 +414,22 @@
if (mode!=NULL)
celt_mode_destroy(mode);
return NULL;
-#endif /* !STATIC_MODES */
+#endif /* !CUSTOM_MODES */
}
void celt_mode_destroy(CELTMode *mode)
{
-#ifndef STATIC_MODES
+#ifdef CUSTOM_MODES
+ int i;
if (mode == NULL)
return;
+ for (i=0;i<TOTAL_MODES;i++)
+ {
+ if (mode == static_mode_list[i])
+ {
+ return;
+ }
+ }
celt_free((celt_int16*)mode->eBands);
celt_free((celt_int16*)mode->allocVectors);
--- a/libcelt/rate.c
+++ b/libcelt/rate.c
@@ -52,7 +52,7 @@
32,33,34,34,35,36,36,37,37
};
-#ifndef STATIC_MODES
+#ifdef CUSTOM_MODES
/*Determines if V(N,K) fits in a 32-bit unsigned integer.
N and K are themselves limited to 15 bits.*/
@@ -143,7 +143,7 @@
}
}
-#endif /* !STATIC_MODES */
+#endif /* !CUSTOM_MODES */
#define ALLOC_STEPS 6
--- a/libcelt/testcelt.c
+++ b/libcelt/testcelt.c
@@ -57,7 +57,7 @@
unsigned char data[MAX_PACKET];
int rate;
int complexity;
-#if !(defined (FIXED_POINT) && defined(STATIC_MODES))
+#if !(defined (FIXED_POINT) && !defined(CUSTOM_MODES))
int i;
double rmsd = 0;
#endif
@@ -174,7 +174,7 @@
for (i=0;i<frame_size*channels;i++)
out[i] = in[i];
#endif
-#if !(defined (FIXED_POINT) && defined(STATIC_MODES))
+#if !(defined (FIXED_POINT) && !defined(CUSTOM_MODES))
for (i=0;i<frame_size*channels;i++)
{
rmsd += (in[i]-out[i])*1.0*(in[i]-out[i]);