shithub: opus

Download patch

ref: 25ec9ac39aee6544e8347aec342443cb96fc37c9
parent: 2b08d7a210f0d280fad9810f5b7f1fdbde1fe265
author: Jean-Marc Valin <[email protected]>
date: Sat Oct 4 18:37:11 EDT 2008

Fixed support for STATIC_MODES

--- a/libcelt/dump_modes.c
+++ b/libcelt/dump_modes.c
@@ -102,9 +102,9 @@
       fprintf(file, "\n");
 
       
-      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_t allocVectors%d_%d[%d] = {\n", mode->Fs, mode->mdctSize, mode->nbEBands*mode->nbAllocVectors);
+      fprintf(file, "#ifndef DEF_ALLOC_VECTORS%d_%d_%d\n", mode->Fs, mode->mdctSize, mode->nbChannels);
+      fprintf(file, "#define DEF_ALLOC_VECTORS%d_%d_%d\n", mode->Fs, mode->mdctSize, mode->nbChannels);
+      fprintf (file, "static const celt_int16_t allocVectors%d_%d_%d[%d] = {\n", mode->Fs, mode->mdctSize, mode->nbChannels, mode->nbEBands*mode->nbAllocVectors);
       for (j=0;j<mode->nbAllocVectors;j++)
       {
          int k;
@@ -115,7 +115,21 @@
       fprintf (file, "};\n");
       fprintf(file, "#endif\n");
       fprintf(file, "\n");
-      
+
+      fprintf(file, "#ifndef DEF_ALLOC_ENERGY%d_%d_%d\n", mode->Fs, mode->mdctSize, mode->nbChannels);
+      fprintf(file, "#define DEF_ALLOC_ENERGY%d_%d_%d\n", mode->Fs, mode->mdctSize, mode->nbChannels);
+      fprintf (file, "static const celt_int16_t allocEnergy%d_%d_%d[%d] = {\n", mode->Fs, mode->mdctSize, mode->nbChannels, mode->nbEBands*mode->nbAllocVectors);
+      for (j=0;j<mode->nbAllocVectors;j++)
+      {
+         int k;
+         for (k=0;k<mode->nbEBands;k++)
+            fprintf (file, "%2d, ", mode->energy_alloc[j*mode->nbEBands+k]);
+         fprintf (file, "\n");
+      }
+      fprintf (file, "};\n");
+      fprintf(file, "#endif\n");
+      fprintf(file, "\n");
+
       fprintf(file, "#ifndef DEF_ALLOC_CACHE%d_%d_%d\n", mode->Fs, mode->mdctSize, mode->nbChannels);
       fprintf(file, "#define DEF_ALLOC_CACHE%d_%d_%d\n", mode->Fs, mode->mdctSize, mode->nbChannels);
       for (j=0;j<mode->nbEBands;j++)
@@ -154,15 +168,19 @@
       fprintf(file, "pBands%d_%d,\t/* pBands */\n", mode->Fs, mode->mdctSize);
       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, "allocVectors%d_%d_%d,\t/* allocVectors */\n", mode->Fs, mode->mdctSize, mode->nbChannels);
       fprintf(file, "allocCache%d_%d_%d,\t/* bits */\n", mode->Fs, mode->mdctSize, mode->nbChannels);
       fprintf(file, "0,\t/* bits_stereo */\n");
       fprintf(file, "{%d, 0, 0},\t/* mdct */\n", 2*mode->mdctSize);
       fprintf(file, "0,\t/* fft */\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, "window%d,\t/* shortWindow */\n", mode->overlap);
       fprintf(file, "{psy_decayR_%d},\t/* psy */\n", mode->Fs);
       fprintf(file, "0,\t/* prob */\n");
-      fprintf(file, "0,\t/* energy_alloc */\n");
+      fprintf(file, "allocEnergy%d_%d_%d,\t/* energy_alloc */\n", mode->Fs, mode->mdctSize, mode->nbChannels);
       fprintf(file, "0x%x,\t/* marker */\n", 0xa110ca7e);
       fprintf(file, "};\n");
    }
@@ -222,12 +240,12 @@
    int i, nb;
    FILE *file;
    CELTMode **m;
-   if (argc%4 != 1)
+   if (argc%3 != 1)
    {
       fprintf (stderr, "must have a multiple of 4 arguments\n");
       return 1;
    }
-   nb = (argc-1)/4;
+   nb = (argc-1)/3;
    m = malloc(nb*sizeof(CELTMode*));
    for (i=0;i<nb;i++)
    {
--- a/libcelt/modes.c
+++ b/libcelt/modes.c
@@ -446,7 +446,8 @@
    celt_free((int*)mode->eBands);
    celt_free((int*)mode->pBands);
    celt_free((int*)mode->allocVectors);
-   
+   celt_free((celt_int16_t *)mode->energy_alloc);
+
    celt_free((celt_word16_t*)mode->window);
 
    mode->marker_start = MODEFREED;
@@ -459,7 +460,6 @@
    mdct_clear(&mode->shortMdct);
    pitch_state_free(mode->fft);
    quant_prob_free(mode->prob);
-   celt_free((celt_int16_t *)mode->energy_alloc);
    celt_free((CELTMode *)mode);
 }