diff options
author | Jean-Marc Valin <jean-marc.valin@usherbrooke.ca> | 2009-12-28 15:59:42 +0300 |
---|---|---|
committer | Jean-Marc Valin <jean-marc.valin@usherbrooke.ca> | 2009-12-28 15:59:42 +0300 |
commit | 07fed1bf76ce38099d94e58770ca9db19fd772d3 (patch) | |
tree | 4c80f7043d1e448590ca727f65d07baabf855be3 | |
parent | d69c1cb37c0b88febe74656feeaa067cc09f9add (diff) |
Adding a safeguard against unstable LPC, so now there's no way (that I can
think of) to produce NaNs in the new PLC.
-rw-r--r-- | libcelt/celt.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/libcelt/celt.c b/libcelt/celt.c index 41effc4..2e206e7 100644 --- a/libcelt/celt.c +++ b/libcelt/celt.c @@ -1347,13 +1347,20 @@ static void celt_decode_lost(CELTDecoder * restrict st, celt_word16 * restrict p iir(e, st->lpc, e, len+st->mode->overlap, LPC_ORDER, mem); { - float ratio, S2=0; + float S2=0; for (i=0;i<len+overlap;i++) S2 += e[i]*1.*e[i]; - ratio = sqrt((S1+1)/(S2+1)); - if (ratio < 1) + /* This checks for an "explosion" in the synthesis (including NaNs) */ + if (!(S1 > 0.2f*S2)) + { + for (i=0;i<len+overlap;i++) + e[i] = 0; + } else if (S1 < S2) + { + float ratio = sqrt((S1+1)/(S2+1)); for (i=0;i<len+overlap;i++) e[i] *= ratio; + } } for (i=0;i<MAX_PERIOD+st->mode->overlap-N;i++) |