Psychoacoustic decay coefficients can now be included in the static modes
diff --git a/libcelt/dump_modes.c b/libcelt/dump_modes.c
index 4248443..cd4d611 100644
--- a/libcelt/dump_modes.c
+++ b/libcelt/dump_modes.c
@@ -88,6 +88,15 @@
       fprintf(file, "#endif\n");
       fprintf(file, "\n");
       
+      fprintf(file, "#ifndef DEF_PSY%d\n", mode->Fs);
+      fprintf(file, "#define DEF_PSY%d\n", mode->Fs);
+      fprintf (file, "const celt_word16_t psy_decayR_%d[%d] = {\n", mode->Fs, MAX_PERIOD/2);
+      for (j=0;j<MAX_PERIOD/2;j++)
+         fprintf (file, WORD16 ", ", mode->psy.decayR[j]);
+      printf ("};\n");
+      fprintf(file, "#endif\n");
+      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);
@@ -122,7 +131,7 @@
       fprintf(file, "0,\t/* bits */\n");
       fprintf(file, "{%d, 0, 0},\t/* mdct */\n", 2*mode->mdctSize);
       fprintf(file, "window%d,\t/* window */\n", mode->overlap);
-      fprintf(file, "{0},\t/* psy */\n");
+      fprintf(file, "{psy_decayR_%d},\t/* psy */\n", mode->Fs);
       fprintf(file, "0x%x,\t/* marker */\n", 0xa110ca7e);
       fprintf(file, "};\n");
    }
diff --git a/libcelt/modes.c b/libcelt/modes.c
index 49d8fef..07ad8cf 100644
--- a/libcelt/modes.c
+++ b/libcelt/modes.c
@@ -69,6 +69,8 @@
    return CELT_OK;
 }
 
+#ifndef STATIC_MODES
+
 #define PBANDS 8
 #define MIN_BINS 4
 /* Defining 25 critical bands for the full 0-20 kHz audio bandwidth
@@ -101,7 +103,7 @@
    };
 
 
-   static int *compute_ebands(celt_int32_t Fs, int frame_size, int *nbEBands)
+static int *compute_ebands(celt_int32_t Fs, int frame_size, int *nbEBands)
 {
    int *eBands;
    int i, res, min_width, lin, low, high;
@@ -215,7 +217,7 @@
    mode->allocVectors = allocVectors;
 }
 
-
+#endif /* STATIC_MODES */
 
 CELTMode *celt_mode_create(celt_int32_t Fs, int channels, int frame_size, int lookahead, int *error)
 {
@@ -302,12 +304,13 @@
 #endif
    mode->window = window;
 
+   psydecay_init(&mode->psy, MAX_PERIOD/2, mode->Fs);
+
    mode->marker_start = MODEVALID;
    mode->marker_end = MODEVALID;
 #endif
    mdct_init(&mode->mdct, 2*mode->mdctSize);
    compute_alloc_cache(mode);
-   psydecay_init(&mode->psy, MAX_PERIOD/2, mode->Fs);
    if (error)
       *error = CELT_OK;
    return mode;
@@ -315,6 +318,7 @@
 
 void celt_mode_destroy(CELTMode *mode)
 {
+#ifndef STATIC_MODES
    int i;
    const int *prevPtr = NULL;
    for (i=0;i<mode->nbEBands;i++)
@@ -327,8 +331,6 @@
    }
    celt_free((int**)mode->bits);
    mdct_clear(&mode->mdct);
-   psydecay_clear(&mode->psy);
-#ifndef STATIC_MODES
    if (check_mode(mode) != CELT_OK)
       return;
    celt_free((int*)mode->eBands);
@@ -340,6 +342,7 @@
    mode->marker_start = MODEFREED;
    mode->marker_end = MODEFREED;
    celt_free((CELTMode *)mode);
+   psydecay_clear(&mode->psy);
 #endif
 }
 
diff --git a/libcelt/psy.c b/libcelt/psy.c
index 2ae547f..1356a13 100644
--- a/libcelt/psy.c
+++ b/libcelt/psy.c
@@ -42,7 +42,7 @@
 #define toBARK(n)   (13.1f*atan(.00074f*(n))+2.24f*atan((n)*(n)*1.85e-8f)+1e-4f*(n))
 #define fromBARK(z) (102.f*(z)-2.f*pow(z,2.f)+.4f*pow(z,3.f)+pow(1.46f,z)-1.f)
 
-
+#ifndef STATIC_MODES
 /* Psychoacoustic spreading function. The idea here is compute a first order 
    recursive filter. The filter coefficient is frequency dependent and 
    chosen such that we have a -10dB/Bark slope on the right side and a -25dB/Bark
@@ -69,6 +69,7 @@
       /*printf ("%f %f\n", decayL[i], decayR[i]);*/
    }
 }
+#endif
 
 void psydecay_clear(struct PsyDecay *decay)
 {
diff --git a/libcelt/testcelt.c b/libcelt/testcelt.c
index 4add077..6afadf1 100644
--- a/libcelt/testcelt.c
+++ b/libcelt/testcelt.c
@@ -54,7 +54,9 @@
    int bytes_per_packet;
    unsigned char data[1024];
    int rate, overlap;
+#if !(defined (FIXED_POINT) && defined(STATIC_MODES))
    double rmsd = 0;
+#endif
    int count = 0;
    int skip;
    celt_int16_t *in, *out;
@@ -129,11 +131,13 @@
       for (i=0;i<frame_size*channels;i++)
          out[i] = in[i];
 #endif
+#if !(defined (FIXED_POINT) && defined(STATIC_MODES))
       for (i=0;i<frame_size*channels;i++)
       {
          rmsd += (in[i]-out[i])*1.0*(in[i]-out[i]);
          /*out[i] -= in[i];*/
       }
+#endif
       count++;
       fwrite(out, sizeof(short), (frame_size-skip)*channels, fout);
       skip = 0;
@@ -143,6 +147,7 @@
    celt_decoder_destroy(dec);
    fclose(fin);
    fclose(fout);
+#if !(defined (FIXED_POINT) && defined(STATIC_MODES))
    if (rmsd > 0)
    {
       rmsd = sqrt(rmsd/(1.0*frame_size*channels*count));
@@ -152,6 +157,7 @@
    } else {
       fprintf (stderr, "Encoder matches decoder!!\n");
    }
+#endif
    celt_mode_destroy(mode);
    celt_free(in);
    celt_free(out);