From cdf305a0122a7186413084749cd6ea2b9e39785b Mon Sep 17 00:00:00 2001 From: Jean-Marc Valin Date: Mon, 20 Jan 2025 15:48:09 -0500 Subject: [PATCH] QEXT: More precision in pre-emphasis --- celt/celt_encoder.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/celt/celt_encoder.c b/celt/celt_encoder.c index b386d0d60..8c2e91a67 100644 --- a/celt/celt_encoder.c +++ b/celt/celt_encoder.c @@ -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