shithub: opus

Download patch

ref: 8b906c102b37ce74571898c8879c01b2a9088fb3
parent: 7aa593a5569a767cd12620f66fc3ed65c9379a28
author: Jean-Marc Valin <[email protected]>
date: Wed Nov 7 09:09:04 EST 2012

Changed denormalize_bands() to only work between "start" and "end"

--- a/celt/bands.c
+++ b/celt/bands.c
@@ -187,7 +187,8 @@
 #endif /* FIXED_POINT */
 
 /* De-normalise the energy to produce the synthesis from the unit-energy bands */
-void denormalise_bands(const CELTMode *m, const celt_norm * OPUS_RESTRICT X, celt_sig * OPUS_RESTRICT freq, const celt_ener *bandE, int end, int C, int M)
+void denormalise_bands(const CELTMode *m, const celt_norm * OPUS_RESTRICT X,
+      celt_sig * OPUS_RESTRICT freq, const celt_ener *bandE, int start, int end, int C, int M)
 {
    int i, c, N;
    const opus_int16 *eBands = m->eBands;
@@ -197,8 +198,10 @@
       celt_sig * OPUS_RESTRICT f;
       const celt_norm * OPUS_RESTRICT x;
       f = freq+c*N;
-      x = X+c*N;
-      for (i=0;i<end;i++)
+      x = X+c*N+M*eBands[start];
+      for (i=0;i<M*eBands[start];i++)
+         *f++ = 0;
+      for (i=start;i<end;i++)
       {
          int j, band_end;
          opus_val32 g = SHR32(bandE[i+c*m->nbEBands],1);
--- a/celt/bands.h
+++ b/celt/bands.h
@@ -58,7 +58,8 @@
  * @param X Spectrum (returned de-normalised)
  * @param bands Square root of the energy for each band
  */
-void denormalise_bands(const CELTMode *m, const celt_norm * OPUS_RESTRICT X, celt_sig * OPUS_RESTRICT freq, const celt_ener *bandE, int end, int C, int M);
+void denormalise_bands(const CELTMode *m, const celt_norm * OPUS_RESTRICT X,
+      celt_sig * OPUS_RESTRICT freq, const celt_ener *bandE, int start, int end, int C, int M);
 
 #define SPREAD_NONE       (0)
 #define SPREAD_LIGHT      (1)
--- a/celt/celt.c
+++ b/celt/celt.c
@@ -1987,21 +1987,12 @@
       }
 
       /* Synthesis */
-      denormalise_bands(mode, X, freq, bandE, effEnd, C, M);
+      denormalise_bands(mode, X, freq, bandE, st->start, effEnd, C, M);
 
       c=0; do {
          OPUS_MOVE(st->syn_mem[c], st->syn_mem[c]+N, 2*MAX_PERIOD-N+overlap);
       } while (++c<CC);
 
-      c=0; do
-         for (i=0;i<M*eBands[st->start];i++)
-            freq[c*N+i] = 0;
-      while (++c<C);
-      c=0; do
-         for (i=M*eBands[st->end];i<N;i++)
-            freq[c*N+i] = 0;
-      while (++c<C);
-
       if (CC==2&&C==1)
       {
          for (i=0;i<N;i++)
@@ -2525,8 +2516,6 @@
       seed = st->rng;
       for (c=0;c<C;c++)
       {
-         for (i=0;i<(eBands[st->start]<<LM);i++)
-            X[c*N+i] = 0;
          for (i=st->start;i<mode->effEBands;i++)
          {
             int j;
@@ -2541,12 +2530,10 @@
             }
             renormalise_vector(X+boffs, blen, Q15ONE);
          }
-         for (i=(eBands[st->end]<<LM);i<N;i++)
-            X[c*N+i] = 0;
       }
       st->rng = seed;
 
-      denormalise_bands(mode, X, freq, bandE, mode->effEBands, C, 1<<LM);
+      denormalise_bands(mode, X, freq, bandE, st->start, mode->effEBands, C, 1<<LM);
 
       c=0; do
          for (i=0;i<eBands[st->start]<<LM;i++)
@@ -2970,15 +2957,6 @@
    ALLOC(collapse_masks, C*nbEBands, unsigned char);
    ALLOC(X, C*N, celt_norm);   /**< Interleaved normalised MDCTs */
 
-   c=0; do
-      for (i=0;i<M*eBands[st->start];i++)
-         X[c*N+i] = 0;
-   while (++c<C);
-   c=0; do
-      for (i=M*eBands[effEnd];i<N;i++)
-         X[c*N+i] = 0;
-   while (++c<C);
-
    quant_all_bands(0, mode, st->start, st->end, X, C==2 ? X+N : NULL, collapse_masks,
          NULL, pulses, shortBlocks, spread_decision, dual_stereo, intensity, tf_res,
          len*(8<<BITRES)-anti_collapse_rsv, balance, dec, LM, codedBands, &st->rng);
@@ -3009,7 +2987,7 @@
    }
    ALLOC(freq, IMAX(CC,C)*N, celt_sig); /**< Interleaved signal MDCTs */
    /* Synthesis */
-   denormalise_bands(mode, X, freq, bandE, effEnd, C, M);
+   denormalise_bands(mode, X, freq, bandE, st->start, effEnd, C, M);
 
    c=0; do {
       OPUS_MOVE(decode_mem[c], decode_mem[c]+N, DECODE_BUFFER_SIZE-N+overlap);