ref: aadaafdfcfabc75c1cc0f138c8d470d5db76cfac
parent: a57e924f2e907af34dda301b6fcbedf14c698818
author: Jean-Marc Valin <[email protected]>
date: Sun Jun 27 05:51:20 EDT 2010
Updating static modes (not done yet)
--- a/libcelt/dump_modes.c
+++ b/libcelt/dump_modes.c
@@ -54,7 +54,7 @@
void dump_modes(FILE *file, CELTMode **modes, int nb_modes)
{
- int i, j;
+ int i, j, k;
fprintf(file, "/* The contents of this file is automatically generated and contains static\n");
fprintf(file, " definitions for some pre-defined modes */\n");
fprintf(file, "#include \"modes.h\"\n");
@@ -85,10 +85,9 @@
fprintf(file, "#ifndef DEF_ALLOC_VECTORS%d_%d\n", mode->Fs, mode->mdctSize);
fprintf(file, "#define DEF_ALLOC_VECTORS%d_%d\n", mode->Fs, mode->mdctSize);
- fprintf (file, "static const celt_int16 allocVectors%d_%d[%d] = {\n", mode->Fs, mode->mdctSize, mode->nbEBands*mode->nbAllocVectors);
+ fprintf (file, "static const unsigned char allocVectors%d_%d[%d] = {\n", mode->Fs, mode->mdctSize, mode->nbEBands*mode->nbAllocVectors);
for (j=0;j<mode->nbAllocVectors;j++)
{
- int k;
for (k=0;k<mode->nbEBands;k++)
fprintf (file, "%2d, ", mode->allocVectors[j*mode->nbEBands+k]);
fprintf (file, "\n");
@@ -97,29 +96,42 @@
fprintf(file, "#endif\n");
fprintf(file, "\n");
- fprintf(file, "#ifndef DEF_ALLOC_CACHE%d_%d\n", mode->Fs, mode->mdctSize);
- fprintf(file, "#define DEF_ALLOC_CACHE%d_%d\n", mode->Fs, mode->mdctSize);
- for (j=0;j<mode->nbEBands;j++)
+ for (k=0;(1<<k>>1)<=mode->nbShortMdcts;k++)
{
- int k;
- if (j==0 || (mode->bits[j] != mode->bits[j-1]))
+ int mdctSize = mode->shortMdctSize;
+ if (k>=1)
+ mdctSize <<= k-1;
+ else
+ mdctSize >>= 1;
+ fprintf(file, "#ifndef DEF_ALLOC_CACHE%d_%d\n", mode->Fs, mdctSize);
+ fprintf(file, "#define DEF_ALLOC_CACHE%d_%d\n", mode->Fs, mdctSize);
+ for (j=0;j<mode->nbEBands;j++)
{
- fprintf (file, "static const celt_int16 allocCache_band%d_%d_%d[MAX_PSEUDO] = {\n", j, mode->Fs, mode->mdctSize);
- for (k=0;k<MAX_PSEUDO;k++)
- fprintf (file, "%2d, ", mode->bits[j][k]);
- fprintf (file, "};\n");
- } else {
- fprintf (file, "#define allocCache_band%d_%d_%d allocCache_band%d_%d_%d\n", j, mode->Fs, mode->mdctSize, j-1, mode->Fs, mode->mdctSize);
+ int m;
+ if (mode->_bits[k][j]==NULL)
+ {
+ fprintf (file, "#define allocCache_band%d_%d_%d NULL\n", j, mode->Fs, mdctSize);
+ continue;
+ }
+ if (j==0 || (mode->_bits[k][j] != mode->_bits[k][j-1]))
+ {
+ fprintf (file, "static const celt_int16 allocCache_band%d_%d_%d[MAX_PSEUDO] = {\n", j, mode->Fs, mdctSize);
+ for (m=0;m<MAX_PSEUDO;m++)
+ fprintf (file, "%2d, ", mode->_bits[k][j][m]);
+ fprintf (file, "};\n");
+ } else {
+ fprintf (file, "#define allocCache_band%d_%d_%d allocCache_band%d_%d_%d\n", j, mode->Fs, mdctSize, j-1, mode->Fs, mdctSize);
+ }
}
+ fprintf (file, "static const celt_int16 *allocCache%d_%d[%d] = {\n", mode->Fs, mdctSize, mode->nbEBands);
+ for (j=0;j<mode->nbEBands;j++)
+ {
+ fprintf (file, "allocCache_band%d_%d_%d, ", j, mode->Fs, mdctSize);
+ }
+ fprintf (file, "};\n");
+ fprintf(file, "#endif\n");
+ fprintf(file, "\n");
}
- fprintf (file, "static const celt_int16 *allocCache%d_%d[%d] = {\n", mode->Fs, mode->mdctSize, mode->nbEBands);
- for (j=0;j<mode->nbEBands;j++)
- {
- fprintf (file, "allocCache_band%d_%d_%d, ", j, mode->Fs, mode->mdctSize);
- }
- fprintf (file, "};\n");
- fprintf(file, "#endif\n");
- fprintf(file, "\n");
fprintf(file, "#ifndef DEF_LOGN%d_%d\n", mode->Fs, mode->mdctSize);
fprintf(file, "#define DEF_LOGN%d_%d\n", mode->Fs, mode->mdctSize);
@@ -141,12 +153,28 @@
fprintf(file, WORD16 ",\t/* ePredCoef */\n", mode->ePredCoef);
fprintf(file, "%d,\t/* nbAllocVectors */\n", mode->nbAllocVectors);
fprintf(file, "allocVectors%d_%d,\t/* allocVectors */\n", mode->Fs, mode->mdctSize);
- fprintf(file, "allocCache%d_%d,\t/* bits */\n", mode->Fs, mode->mdctSize);
- fprintf(file, "{%d, 0, 0},\t/* mdct */\n", 2*mode->mdctSize);
+ fprintf(file, "NULL,\t/* bits */\n");
+ //fprintf(file, "allocCacheTop%d_%d,\t/* _bits */\n", mode->Fs, mode->mdctSize);
+ fprintf (file, "{ ");
+ for (k=0;(1<<k>>1)<=mode->nbShortMdcts;k++)
+ {
+ int mdctSize = mode->shortMdctSize;
+ if (k>=1)
+ mdctSize <<= k-1;
+ else
+ mdctSize >>= 1;
+ fprintf (file, "allocCache%d_%d, ", mode->Fs, mdctSize);
+ }
+ fprintf (file, "}, /* _bits */\n");
+
+ fprintf (file, "{ ");
+ for (k=0;(1<<k)<=mode->nbShortMdcts;k++)
+ fprintf(file, "{%d, 0, 0},\t ", 2*mode->shortMdctSize<<k);
+ fprintf (file, "}, /* mdct */\n");
+
fprintf(file, "window%d,\t/* window */\n", mode->overlap);
fprintf(file, "%d,\t/* nbShortMdcts */\n", mode->nbShortMdcts);
fprintf(file, "%d,\t/* shortMdctSize */\n", mode->shortMdctSize);
- fprintf(file, "{%d, 0, 0},\t/* shortMdct */\n", 2*mode->mdctSize);
fprintf(file, "0,\t/* prob */\n");
fprintf(file, "logN%d_%d,\t/* logN */\n", mode->Fs, mode->mdctSize);
fprintf(file, "0x%x,\t/* marker */\n", 0xa110ca7e);