saturate MDCT output
This commit is contained in:
parent
273906404c
commit
382ab797cf
2 changed files with 7 additions and 4 deletions
|
@ -101,6 +101,9 @@ typedef opus_val32 celt_ener;
|
||||||
#define Q15ONE 32767
|
#define Q15ONE 32767
|
||||||
|
|
||||||
#define SIG_SHIFT 12
|
#define SIG_SHIFT 12
|
||||||
|
/* Safe saturation value for 32-bit signals. Should be less than
|
||||||
|
2^31*(1-0.85) to avoid blowing up on DC at deemphasis.*/
|
||||||
|
#define SIG_SAT (300000000)
|
||||||
|
|
||||||
#define NORM_SCALING 16384
|
#define NORM_SCALING 16384
|
||||||
|
|
||||||
|
|
|
@ -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. */
|
/* We swap real and imag because we're using an FFT instead of an IFFT. */
|
||||||
re = yp1[1];
|
re = yp1[1];
|
||||||
im = yp1[0];
|
im = yp1[0];
|
||||||
yp0[0] = yr;
|
yp0[0] = SATURATE(yr, SIG_SAT);
|
||||||
yp1[1] = yi;
|
yp1[1] = SATURATE(yi, SIG_SAT);
|
||||||
|
|
||||||
t0 = t[(N4-i-1)];
|
t0 = t[(N4-i-1)];
|
||||||
t1 = t[(N2-i-1)];
|
t1 = t[(N2-i-1)];
|
||||||
/* We'd scale up by 2 here, but instead it's done when mixing the windows */
|
/* 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));
|
yr = ADD32_ovflw(S_MUL(re,t0), S_MUL(im,t1));
|
||||||
yi = SUB32_ovflw(S_MUL(re,t1), S_MUL(im,t0));
|
yi = SUB32_ovflw(S_MUL(re,t1), S_MUL(im,t0));
|
||||||
yp1[0] = yr;
|
yp1[0] = SATURATE(yr, SIG_SAT);
|
||||||
yp0[1] = yi;
|
yp0[1] = SATURATE(yi, SIG_SAT);
|
||||||
yp0 += 2;
|
yp0 += 2;
|
||||||
yp1 -= 2;
|
yp1 -= 2;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue