Bitstream change: prevent noise injection in hybrid mode
authorJean-Marc Valin <jmvalin@jmvalin.ca>
Mon, 6 Jun 2016 17:44:01 +0000 (13:44 -0400)
committerJean-Marc Valin <jmvalin@jmvalin.ca>
Wed, 8 Jun 2016 20:11:05 +0000 (16:11 -0400)
This makes it possible to use folding rather than LCG noise in the second CELT
band (9.6 to 12 kHz) in hybrid mode.

celt/bands.c

index 22a0034..43a8b0b 100644 (file)
@@ -1445,9 +1445,17 @@ void quant_all_bands(int encode, const CELTMode *m, int start, int end,
          b = 0;
       }
 
-      if (resynth && M*eBands[i]-N >= M*eBands[start] && (update_lowband || lowband_offset==0))
+      if (resynth && (M*eBands[i]-N >= M*eBands[start] || i==start+1) && (update_lowband || lowband_offset==0))
             lowband_offset = i;
-
+      if (i == start+1)
+      {
+         int n1, n2;
+         n1 = M*(eBands[start+1]-eBands[start]);
+         n2 = M*(eBands[start+2]-eBands[start+1]);
+         /* Duplicate enough of the first band folding data to be able to fold the second band.
+            Copies no data for CELT-only mode. */
+         OPUS_COPY(&norm[n1], &norm[2*n1 - n2], n2-n1);
+      }
       tf_change = tf_res[i];
       ctx.tf_change = tf_change;
       if (i>=m->effEBands)