New pulse cache
diff --git a/libcelt/modes.c b/libcelt/modes.c
index b8e7258..dc78cc3 100644
--- a/libcelt/modes.c
+++ b/libcelt/modes.c
@@ -413,17 +413,6 @@
#endif
mode->window = window;
- mode->bits = mode->_bits+1;
- for (i=0;(1<<i)<=mode->nbShortMdcts;i++)
- {
- mode->bits[i] = (const celt_int16 **)compute_alloc_cache(mode, 1<<i);
- if (mode->bits[i]==NULL)
- goto failure;
- }
- mode->bits[-1] = (const celt_int16 **)compute_alloc_cache(mode, 0);
- if (mode->bits[-1]==NULL)
- goto failure;
-
logN = (celt_int16*)celt_alloc(mode->nbEBands*sizeof(celt_int16));
if (logN==NULL)
goto failure;
@@ -431,6 +420,8 @@
for (i=0;i<mode->nbEBands;i++)
logN[i] = log2_frac(mode->eBands[i+1]-mode->eBands[i], BITRES);
mode->logN = logN;
+
+ compute_pulse_cache(mode, mode->maxLM);
#endif /* !STATIC_MODES */
clt_mdct_init(&mode->mdct, 2*mode->shortMdctSize*mode->nbShortMdcts, LM);
@@ -460,8 +451,6 @@
void celt_mode_destroy(CELTMode *mode)
{
- int i, m;
- const celt_int16 *prevPtr = NULL;
if (mode == NULL)
{
celt_warning("NULL passed to celt_mode_destroy");
@@ -481,40 +470,14 @@
}
mode->marker_start = MODEFREED;
#ifndef STATIC_MODES
- for (m=0;(1<<m)<=mode->nbShortMdcts;m++)
- {
- if (mode->bits[m]!=NULL)
- {
- for (i=0;i<mode->nbEBands;i++)
- {
- if (mode->bits[m][i] != prevPtr)
- {
- prevPtr = mode->bits[m][i];
- celt_free((int*)mode->bits[m][i]);
- }
- }
- }
- celt_free((celt_int16**)mode->bits[m]);
- }
- if (mode->bits[-1]!=NULL)
- {
- for (i=0;i<mode->nbEBands;i++)
- {
- if (mode->bits[-1][i] != prevPtr)
- {
- prevPtr = mode->bits[-1][i];
- celt_free((int*)mode->bits[-1][i]);
- }
- }
- }
- celt_free((celt_int16**)mode->bits[-1]);
-
celt_free((celt_int16*)mode->eBands);
celt_free((celt_int16*)mode->allocVectors);
celt_free((celt_word16*)mode->window);
celt_free((celt_int16*)mode->logN);
+ celt_free(mode->cache.index);
+ celt_free(mode->cache.bits);
#endif
clt_mdct_clear(&mode->mdct);