Always use the max of the decaying PLC energy and the background noise

Should no longer cause discontinuities in the noise after 5 packets
This commit is contained in:
Jean-Marc Valin 2015-12-03 13:32:10 -05:00
parent eda57aa386
commit 1970d5becd

View file

@ -457,10 +457,9 @@ static void celt_decode_lost(CELTDecoder * OPUS_RESTRICT st, int N, int LM)
VARDECL(celt_norm, X); VARDECL(celt_norm, X);
#endif #endif
opus_uint32 seed; opus_uint32 seed;
opus_val16 *plcLogE;
int end; int end;
int effEnd; int effEnd;
opus_val16 decay;
end = st->end; end = st->end;
effEnd = IMAX(start, IMIN(end, mode->effEBands)); effEnd = IMAX(start, IMIN(end, mode->effEBands));
@ -472,19 +471,13 @@ static void celt_decode_lost(CELTDecoder * OPUS_RESTRICT st, int N, int LM)
ALLOC(X, C*N, celt_norm); /**< Interleaved normalised MDCTs */ ALLOC(X, C*N, celt_norm); /**< Interleaved normalised MDCTs */
#endif #endif
if (loss_count >= 5) /* Energy decay */
plcLogE = backgroundLogE; decay = loss_count==0 ? QCONST16(1.5f, DB_SHIFT) : QCONST16(.5f, DB_SHIFT);
else { c=0; do
/* Energy decay */ {
opus_val16 decay = loss_count==0 ? for (i=start;i<end;i++)
QCONST16(1.5f, DB_SHIFT) : QCONST16(.5f, DB_SHIFT); oldBandE[c*nbEBands+i] = MAX16(backgroundLogE[c*nbEBands+i], oldBandE[c*nbEBands+i] - decay);
c=0; do } while (++c<C);
{
for (i=start;i<end;i++)
oldBandE[c*nbEBands+i] -= decay;
} while (++c<C);
plcLogE = oldBandE;
}
seed = st->rng; seed = st->rng;
for (c=0;c<C;c++) for (c=0;c<C;c++)
{ {
@ -510,7 +503,7 @@ static void celt_decode_lost(CELTDecoder * OPUS_RESTRICT st, int N, int LM)
DECODE_BUFFER_SIZE-N+(overlap>>1)); DECODE_BUFFER_SIZE-N+(overlap>>1));
} while (++c<C); } while (++c<C);
celt_synthesis(mode, X, out_syn, plcLogE, start, effEnd, C, C, 0, LM, st->downsample, 0, st->arch); celt_synthesis(mode, X, out_syn, oldBandE, start, effEnd, C, C, 0, LM, st->downsample, 0, st->arch);
} else { } else {
/* Pitch-based PLC */ /* Pitch-based PLC */
const opus_val16 *window; const opus_val16 *window;