Skip to content
Snippets Groups Projects
Unverified Commit 68d21fb5 authored by Jean-Marc Valin's avatar Jean-Marc Valin
Browse files

Fix fixed-point overflow in pitch downsampling

Reviewed by Mark Harris
parent 78fe48ad
No related branches found
No related tags found
No related merge requests found
......@@ -161,17 +161,26 @@ void pitch_downsample(celt_sig * OPUS_RESTRICT x[], opus_val16 * OPUS_RESTRICT x
shift=0;
if (C==2)
shift++;
#endif
for (i=1;i<len>>1;i++)
x_lp[i] = SHR32(HALF32(HALF32(x[0][(2*i-1)]+x[0][(2*i+1)])+x[0][2*i]), shift);
x_lp[0] = SHR32(HALF32(HALF32(x[0][1])+x[0][0]), shift);
x_lp[i] = SHR32(x[0][(2*i-1)], shift+2) + SHR32(x[0][(2*i+1)], shift+2) + SHR32(x[0][2*i], shift+1);
x_lp[0] = SHR32(x[0][1], shift+2) + SHR32(x[0][0], shift+1);
if (C==2)
{
for (i=1;i<len>>1;i++)
x_lp[i] += SHR32(HALF32(HALF32(x[1][(2*i-1)]+x[1][(2*i+1)])+x[1][2*i]), shift);
x_lp[0] += SHR32(HALF32(HALF32(x[1][1])+x[1][0]), shift);
x_lp[i] += SHR32(x[1][(2*i-1)], shift+2) + SHR32(x[1][(2*i+1)], shift+2) + SHR32(x[1][2*i], shift+1);
x_lp[0] += SHR32(x[1][1], shift+2) + SHR32(x[1][0], shift+1);
}
#else
for (i=1;i<len>>1;i++)
x_lp[i] = .25f*x[0][(2*i-1)] + .25f*x[0][(2*i+1)] + .5f*x[0][2*i];
x_lp[0] = .25f*x[0][1] + .5f*x[0][0];
if (C==2)
{
for (i=1;i<len>>1;i++)
x_lp[i] += .25f*x[1][(2*i-1)] + .25f*x[1][(2*i+1)] + .5f*x[1][2*i];
x_lp[0] += .25f*x[1][1] + .5f*x[1][0];
}
#endif
_celt_autocorr(x_lp, ac, NULL, 0,
4, len>>1, arch);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment