diff options
author | Jean-Marc Valin <jean-marc.valin@octasic.com> | 2011-02-10 18:50:26 +0300 |
---|---|---|
committer | Jean-Marc Valin <jean-marc.valin@octasic.com> | 2011-02-10 18:50:26 +0300 |
commit | cf89d2a60cfed1b30a377340637ef1ae1b9d83b1 (patch) | |
tree | faeea4356bfd3ff63780a88905302b912fe24049 | |
parent | 1111db3163be985d03fd048bf2761c16792445db (diff) |
Adding a tiny amount of noise when folding to prevent/reduce numerical issues
-rw-r--r-- | libcelt/bands.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/libcelt/bands.c b/libcelt/bands.c index e7997f9..1c8fe25 100644 --- a/libcelt/bands.c +++ b/libcelt/bands.c @@ -1084,7 +1084,14 @@ static unsigned quant_band(int encode, const CELTMode *m, int i, celt_norm *X, c } else { /* Folded spectrum */ for (j=0;j<N;j++) - X[j] = lowband[j]; + { + celt_word16 tmp; + *seed = lcg_rand(*seed); + /* About 48 dB below the "normal" folding level */ + tmp = QCONST16(1.0f/256, 10); + tmp = (*seed)&0x8000 ? tmp : -tmp; + X[j] = lowband[j]+tmp; + } cm = fill; } renormalise_vector(X, N, gain); |