summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Marc Valin <jmvalin@jmvalin.ca>2015-12-03 13:32:10 -0500
committerJean-Marc Valin <jmvalin@jmvalin.ca>2015-12-04 13:46:09 -0500
commit1970d5becd1cbb6f5a9322e18f8df8250a7cbba7 (patch)
treec21fe2b9e8b5e179b557dd8def1b91a0dc963a1c
parenteda57aa3868c6606eacb3580e0cf75fe48e2a26d (diff)
downloadopus-1970d5becd1cbb6f5a9322e18f8df8250a7cbba7.tar.gz
Always use the max of the decaying PLC energy and the background noise
Should no longer cause discontinuities in the noise after 5 packets
-rw-r--r--celt/celt_decoder.c25
1 files changed, 9 insertions, 16 deletions
diff --git a/celt/celt_decoder.c b/celt/celt_decoder.c
index 505a6ef4..bda317e4 100644
--- a/celt/celt_decoder.c
+++ b/celt/celt_decoder.c
@@ -457,10 +457,9 @@ static void celt_decode_lost(CELTDecoder * OPUS_RESTRICT st, int N, int LM)
VARDECL(celt_norm, X);
#endif
opus_uint32 seed;
- opus_val16 *plcLogE;
int end;
int effEnd;
-
+ opus_val16 decay;
end = st->end;
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 */
#endif
- if (loss_count >= 5)
- plcLogE = backgroundLogE;
- else {
- /* Energy decay */
- opus_val16 decay = loss_count==0 ?
- QCONST16(1.5f, DB_SHIFT) : QCONST16(.5f, DB_SHIFT);
- c=0; do
- {
- for (i=start;i<end;i++)
- oldBandE[c*nbEBands+i] -= decay;
- } while (++c<C);
- plcLogE = oldBandE;
- }
+ /* Energy decay */
+ decay = loss_count==0 ? QCONST16(1.5f, DB_SHIFT) : QCONST16(.5f, DB_SHIFT);
+ c=0; do
+ {
+ for (i=start;i<end;i++)
+ oldBandE[c*nbEBands+i] = MAX16(backgroundLogE[c*nbEBands+i], oldBandE[c*nbEBands+i] - decay);
+ } while (++c<C);
seed = st->rng;
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));
} 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 {
/* Pitch-based PLC */
const opus_val16 *window;