Commit e0f26246 authored by Jean-Marc Valin's avatar Jean-Marc Valin
Browse files

fixed-point: adds rounding to some shifts to eliminate bias

This reduces the peak decoding error by removing small (inaudible) spikes in
the error at the frame boundaries. These were due to the frequency-domain bias
ending up as a small pulse in the middle of the IMDCT overlap. None of this
was ever audible, but fixing it is still cleaner.
parent 4a168eb3
......@@ -430,7 +430,7 @@ static void stereo_merge(celt_norm * OPUS_RESTRICT X, celt_norm * OPUS_RESTRICT
{
celt_norm r, l;
/* Apply mid scaling (side is already scaled) */
l = MULT16_16_Q15(mid, X[j]);
l = MULT16_16_P15(mid, X[j]);
r = Y[j];
X[j] = EXTRACT16(PSHR32(MULT16_16(lgain, SUB16(l,r)), kl+1));
Y[j] = EXTRACT16(PSHR32(MULT16_16(rgain, ADD16(l,r)), kr+1));
......@@ -600,8 +600,8 @@ void haar1(celt_norm *X, int N0, int stride)
opus_val32 tmp1, tmp2;
tmp1 = MULT16_16(QCONST16(.70710678f,15), X[stride*2*j+i]);
tmp2 = MULT16_16(QCONST16(.70710678f,15), X[stride*(2*j+1)+i]);
X[stride*2*j+i] = EXTRACT16(SHR32(ADD32(tmp1, tmp2), 15));
X[stride*(2*j+1)+i] = EXTRACT16(SHR32(SUB32(tmp1, tmp2), 15));
X[stride*2*j+i] = EXTRACT16(PSHR32(ADD32(tmp1, tmp2), 15));
X[stride*(2*j+1)+i] = EXTRACT16(PSHR32(SUB32(tmp1, tmp2), 15));
}
}
......
......@@ -49,8 +49,8 @@ static void exp_rotation1(celt_norm *X, int len, int stride, opus_val16 c, opus_
celt_norm x1, x2;
x1 = Xptr[0];
x2 = Xptr[stride];
Xptr[stride] = EXTRACT16(SHR32(MULT16_16(c,x2) + MULT16_16(s,x1), 15));
*Xptr++ = EXTRACT16(SHR32(MULT16_16(c,x1) - MULT16_16(s,x2), 15));
Xptr[stride] = EXTRACT16(PSHR32(MULT16_16(c,x2) + MULT16_16(s,x1), 15));
*Xptr++ = EXTRACT16(PSHR32(MULT16_16(c,x1) - MULT16_16(s,x2), 15));
}
Xptr = &X[len-2*stride-1];
for (i=len-2*stride-1;i>=0;i--)
......@@ -58,8 +58,8 @@ static void exp_rotation1(celt_norm *X, int len, int stride, opus_val16 c, opus_
celt_norm x1, x2;
x1 = Xptr[0];
x2 = Xptr[stride];
Xptr[stride] = EXTRACT16(SHR32(MULT16_16(c,x2) + MULT16_16(s,x1), 15));
*Xptr-- = EXTRACT16(SHR32(MULT16_16(c,x1) - MULT16_16(s,x2), 15));
Xptr[stride] = EXTRACT16(PSHR32(MULT16_16(c,x2) + MULT16_16(s,x1), 15));
*Xptr-- = EXTRACT16(PSHR32(MULT16_16(c,x1) - MULT16_16(s,x2), 15));
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment