Code simplifications for log->amplitude conversion
diff --git a/libcelt/celt.c b/libcelt/celt.c
index ad400d8..824b2aa 100644
--- a/libcelt/celt.c
+++ b/libcelt/celt.c
@@ -1061,13 +1061,15 @@
 
    quant_energy_finalise(st->mode, st->start, st->end, bandE, st->oldBandE, error, fine_quant, fine_priority, nbCompressedBytes*8-ec_enc_tell(enc, 0), enc, C);
 
-#ifdef MEASURE_NORM_MSE
-   measure_norm_mse(st->mode, X, X0, bandE, bandE0, M, N, C);
-#endif
-
    /* Re-synthesis of the coded audio if required */
    if (resynth)
    {
+      log2Amp(st->mode, st->start, st->end, bandE, st->oldBandE, C);
+
+#ifdef MEASURE_NORM_MSE
+      measure_norm_mse(st->mode, X, X0, bandE, bandE0, M, N, C);
+#endif
+
       if (st->pitch_available>0 && st->pitch_available<MAX_PERIOD)
         st->pitch_available+=N;
 
@@ -1828,6 +1830,8 @@
 
    unquant_energy_finalise(st->mode, st->start, st->end, bandE, st->oldBandE, fine_quant, fine_priority, len*8-ec_dec_tell(dec, 0), dec, C);
 
+   log2Amp(st->mode, st->start, st->end, bandE, st->oldBandE, C);
+
    if (mdct_weight_shift)
    {
       mdct_shape(st->mode, X, 0, mdct_weight_pos+1, N, mdct_weight_shift, effEnd, C, 1, M);
diff --git a/libcelt/quant_bands.c b/libcelt/quant_bands.c
index 52f6410..92d5a8c 100644
--- a/libcelt/quant_bands.c
+++ b/libcelt/quant_bands.c
@@ -227,15 +227,6 @@
          } while (++c < C);
       }
    }
-   c=0;
-   do {
-      for (i=start;i<m->nbEBands;i++)
-      {
-         eBands[i+c*m->nbEBands] = log2Amp(oldEBands[i+c*m->nbEBands]);
-         if (oldEBands[i+c*m->nbEBands] < -QCONST16(7.f,DB_SHIFT))
-            oldEBands[i+c*m->nbEBands] = -QCONST16(7.f,DB_SHIFT);
-      }
-   } while (++c < C);
 }
 
 void unquant_coarse_energy(const CELTMode *m, int start, int end, celt_ener *eBands, celt_word16 *oldEBands, int intra, int *prob, ec_dec *dec, int _C, int LM)
@@ -324,13 +315,22 @@
          } while (++c < C);
       }
    }
+}
+
+void log2Amp(const CELTMode *m, int start, int end,
+      celt_ener *eBands, celt_word16 *oldEBands, int _C)
+{
+   int c, i;
+   const int C = CHANNELS(_C);
    c=0;
    do {
       for (i=start;i<m->nbEBands;i++)
       {
-         eBands[i+c*m->nbEBands] = log2Amp(oldEBands[i+c*m->nbEBands]);
+         celt_word16 lg = oldEBands[i+c*m->nbEBands];
+         eBands[i+c*m->nbEBands] = PSHR32(celt_exp2(SHL16(lg,11-DB_SHIFT)),4);
          if (oldEBands[i+c*m->nbEBands] < -QCONST16(7.f,DB_SHIFT))
             oldEBands[i+c*m->nbEBands] = -QCONST16(7.f,DB_SHIFT);
       }
    } while (++c < C);
 }
+
diff --git a/libcelt/quant_bands.h b/libcelt/quant_bands.h
index a90ec4f..76b0bcf 100644
--- a/libcelt/quant_bands.h
+++ b/libcelt/quant_bands.h
@@ -44,16 +44,12 @@
 	return celt_log2(MAX32(QCONST32(.001f,14),SHL32(amp,2)));
 }
 
-static inline celt_word32 log2Amp(celt_word16 lg)
-{
-	return PSHR32(celt_exp2(SHL16(lg,11-DB_SHIFT)),4);
-}
+void log2Amp(const CELTMode *m, int start, int end,
+      celt_ener *eBands, celt_word16 *oldEBands, int _C);
 
 int *quant_prob_alloc(const CELTMode *m);
 void quant_prob_free(int *freq);
 
-void compute_fine_allocation(const CELTMode *m, int *bits, int budget);
-
 int intra_decision(celt_word16 *eBands, celt_word16 *oldEBands, int start, int end, int len, int C);
 
 void quant_coarse_energy(const CELTMode *m, int start, int end, const celt_word16 *eBands, celt_word16 *oldEBands, int budget, int intra, int *prob, celt_word16 *error, ec_enc *enc, int _C, int LM, celt_word16 max_decay);