ref: fd54a99e2d36510c785a011ee1457386213c6054
parent: 94491653e0f0d0c9b1ce4c5da321b4799cccf060
author: Jean-Marc Valin <[email protected]>
date: Thu Oct 21 13:50:27 EDT 2010
Prevents a folding artefact due to "folding the folding"
--- a/libcelt/bands.c
+++ b/libcelt/bands.c
@@ -927,6 +927,7 @@
int b;
int N;
int curr_balance;
+ celt_norm *effective_lowband=NULL;
celt_norm * restrict X, * restrict Y;
int tf_change=0;
@@ -962,7 +963,7 @@
b = C*16*N<<BITRES;
if (M*eBands[i]-N >= M*eBands[start] && (update_lowband || lowband==NULL))
- lowband = norm+M*eBands[i]-N;
+ lowband = norm+M*eBands[i];
tf_change = tf_res[i];
if (i>=m->effEBands)
@@ -972,8 +973,15 @@
Y = norm;
}
+ /* This ensures we never repeat spectral content within one band */
+ if (lowband != NULL)
+ {
+ effective_lowband = lowband-N;
+ if (effective_lowband < norm+M*eBands[start])
+ effective_lowband = norm+M*eBands[start];
+ }
quant_band(encode, m, i, X, Y, N, b, fold, B, tf_change,
- lowband, resynth, ec, &remaining_bits, LM,
+ effective_lowband, resynth, ec, &remaining_bits, LM,
norm+M*eBands[i], bandE, 0, &seed, Q15ONE, lowband_scratch);
balance += pulses[i] + tell;