summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Marc Valin <jmvalin@jmvalin.ca>2016-07-24 17:40:44 -0400
committerJean-Marc Valin <jmvalin@jmvalin.ca>2016-07-24 17:40:44 -0400
commit6031482d715fa128c67c6903b8c01f566e228638 (patch)
tree3e283300661e4a1b70791c9cc88c134502b18d26
parent2d3ff4239cb7f2c63bb20714f61f69c3635e6fdc (diff)
downloadopus-6031482d715fa128c67c6903b8c01f566e228638.tar.gz
Saturate MDCT output post-TDAC rather than pre-
Gives us a tighter bound on the pitch postfilter input to avoid overflows
-rw-r--r--celt/celt_decoder.c6
-rw-r--r--celt/mdct.c8
2 files changed, 10 insertions, 4 deletions
diff --git a/celt/celt_decoder.c b/celt/celt_decoder.c
index 6f7b34d3..0d9364d8 100644
--- a/celt/celt_decoder.c
+++ b/celt/celt_decoder.c
@@ -345,6 +345,12 @@ void celt_synthesis(const CELTMode *mode, celt_norm *X, celt_sig * out_syn[],
clt_mdct_backward(&mode->mdct, &freq[b], out_syn[c]+NB*b, mode->window, overlap, shift, B, arch);
} while (++c<CC);
}
+ /* Saturate IMDCT output so that we can't overflow in the pitch postfilter
+ or in the */
+ c=0; do {
+ for (i=0;i<N;i++)
+ out_syn[c][i] = SATURATE(out_syn[c][i], SIG_SAT);
+ } while (++c<CC);
RESTORE_STACK;
}
diff --git a/celt/mdct.c b/celt/mdct.c
index a8497c66..5c6dab5b 100644
--- a/celt/mdct.c
+++ b/celt/mdct.c
@@ -306,16 +306,16 @@ void clt_mdct_backward_c(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_sca
/* We swap real and imag because we're using an FFT instead of an IFFT. */
re = yp1[1];
im = yp1[0];
- yp0[0] = SATURATE(yr, SIG_SAT);
- yp1[1] = SATURATE(yi, SIG_SAT);
+ yp0[0] = yr;
+ yp1[1] = yi;
t0 = t[(N4-i-1)];
t1 = t[(N2-i-1)];
/* We'd scale up by 2 here, but instead it's done when mixing the windows */
yr = ADD32_ovflw(S_MUL(re,t0), S_MUL(im,t1));
yi = SUB32_ovflw(S_MUL(re,t1), S_MUL(im,t0));
- yp1[0] = SATURATE(yr, SIG_SAT);
- yp0[1] = SATURATE(yi, SIG_SAT);
+ yp1[0] = yr;
+ yp0[1] = yi;
yp0 += 2;
yp1 -= 2;
}