diff --git a/libcelt/cwrs.c b/libcelt/cwrs.c index 843dcd51667196c8d5586b2bfae9bcdd59b28e15..452c4ea2f5f25d8ec50a8ae61316716c470bb2c2 100644 --- a/libcelt/cwrs.c +++ b/libcelt/cwrs.c @@ -644,7 +644,7 @@ celt_uint32 icwrs(int _n,int _k,celt_uint32 *_nc,const int *_y, 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 @@ void get_required_bits(celt_int16 *_bits,int _n,int _maxk,int _frac){ RESTORE_STACK; } } -#endif /* STATIC_MODES */ +#endif /* CUSTOM_MODES */ void encode_pulses(const int *_y,int _n,int _k,ec_enc *_enc){ celt_uint32 i; diff --git a/libcelt/kiss_fft.c b/libcelt/kiss_fft.c index 390456d5d53740439210e5b38b9cbd4ab45e20b6..ec18a69b7d2ad3b26e129edfd4d6d2fe6a91dd9f 100644 --- a/libcelt/kiss_fft.c +++ b/libcelt/kiss_fft.c @@ -495,7 +495,7 @@ static void ki_work( } -#ifndef STATIC_MODES +#ifdef CUSTOM_MODES static void compute_bitrev_table( @@ -651,7 +651,7 @@ void kiss_fft_free(const kiss_fft_state *cfg) 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) { diff --git a/libcelt/mdct.c b/libcelt/mdct.c index daa9d6bf86fff4ed2c92521baba39d4c37313583..9ca65cf9b995dff88f26630dd5354b496340846f 100644 --- 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 @@ void clt_mdct_clear(mdct_lookup *l) 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) { diff --git a/libcelt/modes.c b/libcelt/modes.c index 5f801ccc221bd21e405d64a43ae5daa74f9277b3..35985b662c333d6a0c1010d39fe8b801b15203df 100644 --- a/libcelt/modes.c +++ b/libcelt/modes.c @@ -85,13 +85,11 @@ static const unsigned char band_allocation[] = { }; #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 @@ int celt_mode_info(const CELTMode *mode, int request, celt_int32 *value) 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 @@ static void compute_allocation_table(CELTMode *mode) 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 @@ CELTMode *celt_mode_create(celt_int32 Fs, int frame_size, int *error) 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 @@ failure: 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); diff --git a/libcelt/rate.c b/libcelt/rate.c index 63cfd22ac65082340f0bf0ee8077879a1bbc8fe9..c0c4ca76536822989cea19f3f3f05846ec1b2aa9 100644 --- a/libcelt/rate.c +++ b/libcelt/rate.c @@ -52,7 +52,7 @@ static const unsigned char LOG2_FRAC_TABLE[24]={ 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 @@ void compute_pulse_cache(CELTMode *m, int LM) } } -#endif /* !STATIC_MODES */ +#endif /* !CUSTOM_MODES */ #define ALLOC_STEPS 6 diff --git a/libcelt/testcelt.c b/libcelt/testcelt.c index 187ea1a7e0dcbc5203b71ce3d01430c7568bdc57..d14272f6d7ae82b078afc797ae2a9021d94a7955 100644 --- a/libcelt/testcelt.c +++ b/libcelt/testcelt.c @@ -57,7 +57,7 @@ int main(int argc, char *argv[]) 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 @@ int main(int argc, char *argv[]) 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]);