shithub: opus

Download patch

ref: 7bf550ead4daf4ed50a9ac4b9b053d96d6bc1fe2
parent: b6f906134349949daf9eb18e465bb9c81d88e592
author: Wessel Lubberhuizen <[email protected]>
date: Mon Oct 6 06:26:13 EDT 2008

fix STATIC_MODES for stereo (with a few fixes by JMV)

--- a/libcelt/dump_modes.c
+++ b/libcelt/dump_modes.c
@@ -154,7 +154,35 @@
       fprintf(file, "#endif\n");
       fprintf(file, "\n");
 
-      
+
+      if (mode->bits_stereo)
+      {
+         fprintf(file, "#ifndef DEF_ALLOC_STEREO_CACHE%d_%d_%d\n", mode->Fs, mode->mdctSize, mode->nbChannels);
+         fprintf(file, "#define DEF_ALLOC_STEREO_CACHE%d_%d_%d\n", mode->Fs, mode->mdctSize, mode->nbChannels);
+         for (j=0;j<mode->nbEBands;j++)
+         {
+            int k;
+            if (j==0 || (mode->bits[j] != mode->bits_stereo[j-1]))
+            {
+               fprintf (file, "static const celt_int16_t allocStereoCache_band%d_%d_%d_%d[MAX_PULSES] = {\n", j, mode->Fs, mode->mdctSize, mode->nbChannels);
+               for (k=0;k<MAX_PULSES;k++)
+                  fprintf (file, "%2d, ", mode->bits_stereo[j][k]);
+               fprintf (file, "};\n");
+            } else {
+               fprintf (file, "#define allocStereoCache_band%d_%d_%d_%d allocStereoCache_band%d_%d_%d_%d\n", j, mode->Fs, mode->mdctSize, mode->nbChannels, j-1, mode->Fs, mode->mdctSize, mode->nbChannels);
+            }
+         }
+         fprintf (file, "static const celt_int16_t *allocStereoCache%d_%d_%d[%d] = {\n", mode->Fs, mode->mdctSize, mode->nbChannels, mode->nbEBands);
+         for (j=0;j<mode->nbEBands;j++)
+         {
+            fprintf (file, "allocStereoCache_band%d_%d_%d_%d, ", j, mode->Fs, mode->mdctSize, mode->nbChannels);
+         }
+         fprintf (file, "};\n");
+         fprintf(file, "#endif\n");
+         fprintf(file, "\n");
+      }
+
+
       fprintf(file, "static const CELTMode mode%d_%d_%d_%d = {\n", mode->Fs, mode->nbChannels, mode->mdctSize, mode->overlap);
       fprintf(file, "0x%x,\t/* marker */\n", 0xa110ca7e);
       fprintf(file, INT32 ",\t/* Fs */\n", mode->Fs);
@@ -170,7 +198,10 @@
       fprintf(file, "%d,\t/* nbAllocVectors */\n", mode->nbAllocVectors);
       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");
+      if (mode->bits_stereo)
+         fprintf(file, "allocStereoCache%d_%d_%d,\t/* bits_stereo */\n", mode->Fs, mode->mdctSize, mode->nbChannels);
+      else
+         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);
@@ -261,5 +292,8 @@
    file = fopen("static_modes.h", "w");
    dump_header(file, m, nb);
    fclose(file);
+   for (i=0;i<nb;i++)
+      celt_mode_destroy(m[i]);
+   free(m);
    return 0;
 }