Skip to content

Commit

Permalink
QEXT: More precision in pre-emphasis
Browse files Browse the repository at this point in the history
  • Loading branch information
jmvalin committed Jan 20, 2025
1 parent cf6feb4 commit cdf305a
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions celt/celt_encoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -579,13 +579,24 @@ void celt_preemphasis(const opus_res * OPUS_RESTRICT pcmp, celt_sig * OPUS_RESTR
if (coef[1] != 0)
{
opus_val16 coef1 = coef[1];
#if defined(FIXED_POINT) && defined(ENABLE_QEXT)
/* If we need the extra precision, we use the fact that coef[3] is exact to do a Newton-Raphson
iteration and get us more precision on coef[2]. */
celt_assert(SIG_SHIFT == 12);
opus_val32 coef2_q30 = SHL32(coef[2], 18) + PSHR32(MULT16_16(QCONST32(1.f, 25) - MULT16_16(coef[3], coef[2]), coef[2]), 7);
#else
opus_val16 coef2 = coef[2];
#endif
for (i=0;i<N;i++)
{
celt_sig x, tmp;
x = inp[i];
/* Apply pre-emphasis */
#if defined(FIXED_POINT) && defined(ENABLE_QEXT)
tmp = SHL32(MULT32_32_Q31(coef2_q30, x), 1);
#else
tmp = SHL32(MULT16_32_Q15(coef2, x), 15-SIG_SHIFT);
#endif
inp[i] = tmp + m;
m = MULT16_32_Q15(coef1, inp[i]) - MULT16_32_Q15(coef0, tmp);
}
Expand Down

0 comments on commit cdf305a

Please sign in to comment.