Merge branch 'exp_api_change'

This commit is contained in:
Jean-Marc Valin 2011-01-30 12:15:12 -05:00
commit 665da0ba4d
17 changed files with 512 additions and 77 deletions

View file

@ -85,13 +85,13 @@ 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 CUSTOM_MODES_ONLY
#ifdef FIXED_POINT
#include "static_modes_fixed.c"
#else
#include "static_modes_float.c"
#endif
#endif /* CUSTOM_MODES_ONLY */
#ifndef M_PI
#define M_PI 3.141592653
@ -117,7 +117,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 +253,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 +278,29 @@ CELTMode *celt_mode_create(celt_int32 Fs, int frame_size, int *error)
goto failure;
#endif
#ifndef CUSTOM_MODES_ONLY
for (i=0;i<TOTAL_MODES;i++)
{
int j;
for (j=0;j<4;j++)
{
if (Fs == static_mode_list[i]->Fs &&
(frame_size<<j) == static_mode_list[i]->shortMdctSize*static_mode_list[i]->nbShortMdcts)
{
if (error)
*error = CELT_OK;
return (CELTMode*)static_mode_list[i];
}
}
}
#endif /* CUSTOM_MODES_ONLY */
#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,15 +425,24 @@ 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;
#ifndef CUSTOM_MODES_ONLY
for (i=0;i<TOTAL_MODES;i++)
{
if (mode == static_mode_list[i])
{
return;
}
}
#endif /* CUSTOM_MODES_ONLY */
celt_free((celt_int16*)mode->eBands);
celt_free((celt_int16*)mode->allocVectors);