ref: efdd314305038978062e48bdb98bc9d4832eebbf
parent: f8eb44e83aa4d61fb758dcd7c64cc14140c06021
author: Jean-Marc Valin <[email protected]>
date: Fri May 17 22:14:24 EDT 2013
Fixes fixed-point PLC issue reported in trac ticket #1954 A fixed shift factor was insufficient to properly estimate the decay factor, resulting in extreme attenuation of the PLC excitation.
--- a/celt/celt_decoder.c
+++ b/celt/celt_decoder.c
@@ -506,14 +506,17 @@
{
opus_val32 E1=1, E2=1;
int decay_length;
+#ifdef FIXED_POINT
+ int shift = IMAX(0,2*celt_zlog2(celt_maxabs16(&exc[MAX_PERIOD-exc_length], exc_length))-20);
+#endif
decay_length = exc_length>>1;
for (i=0;i<decay_length;i++)
{
opus_val16 e;
e = exc[MAX_PERIOD-decay_length+i];
- E1 += SHR32(MULT16_16(e, e), 8);
+ E1 += SHR32(MULT16_16(e, e), shift);
e = exc[MAX_PERIOD-2*decay_length+i];
- E2 += SHR32(MULT16_16(e, e), 8);
+ E2 += SHR32(MULT16_16(e, e), shift);
}
E1 = MIN32(E1, E2);
decay = celt_sqrt(frac_div32(SHR32(E1, 1), E2));