diff options
author | Jean-Marc Valin <jmvalin@jmvalin.ca> | 2017-10-07 01:22:17 +0300 |
---|---|---|
committer | Jean-Marc Valin <jmvalin@jmvalin.ca> | 2017-10-07 01:24:57 +0300 |
commit | 072d133f7899c4783e67f90d07ab25b3b8414b8f (patch) | |
tree | 77551df48d9373065759a0d1fb36094e7df98951 | |
parent | b30f45b9a8bfc7b97afb75042bf2ab16a2150972 (diff) |
Fixes CELT PLC
The regression was introduced in 783ad76766e1f6b6aaca5d6eb415ac8a8269e1f2
by changes to celt_fir() that make it no longer in-place.
-rw-r--r-- | celt/celt_decoder.c | 27 | ||||
-rw-r--r-- | celt/celt_lpc.c | 2 |
2 files changed, 14 insertions, 15 deletions
diff --git a/celt/celt_decoder.c b/celt/celt_decoder.c index 567d7456..10958a51 100644 --- a/celt/celt_decoder.c +++ b/celt/celt_decoder.c @@ -554,6 +554,7 @@ static void celt_decode_lost(CELTDecoder * OPUS_RESTRICT st, int N, int LM) celt_synthesis(mode, X, out_syn, oldBandE, start, effEnd, C, C, 0, LM, st->downsample, 0, st->arch); } else { + int exc_length; /* Pitch-based PLC */ const opus_val16 *window; opus_val16 *exc; @@ -561,6 +562,7 @@ static void celt_decode_lost(CELTDecoder * OPUS_RESTRICT st, int N, int LM) int pitch_index; VARDECL(opus_val32, etmp); VARDECL(opus_val16, _exc); + VARDECL(opus_val16, fir_tmp); if (loss_count == 0) { @@ -570,8 +572,13 @@ static void celt_decode_lost(CELTDecoder * OPUS_RESTRICT st, int N, int LM) fade = QCONST16(.8f,15); } + /* We want the excitation for 2 pitch periods in order to look for a + decaying signal, but we can't get more than MAX_PERIOD. */ + exc_length = IMIN(2*pitch_index, MAX_PERIOD); + ALLOC(etmp, overlap, opus_val32); ALLOC(_exc, MAX_PERIOD+LPC_ORDER, opus_val16); + ALLOC(fir_tmp, exc_length, opus_val16); exc = _exc+LPC_ORDER; window = mode->window; c=0; do { @@ -581,13 +588,11 @@ static void celt_decode_lost(CELTDecoder * OPUS_RESTRICT st, int N, int LM) celt_sig *buf; int extrapolation_offset; int extrapolation_len; - int exc_length; int j; buf = decode_mem[c]; - for (i=0;i<MAX_PERIOD;i++) { - exc[i] = ROUND16(buf[DECODE_BUFFER_SIZE-MAX_PERIOD+i], SIG_SHIFT); - } + for (i=0;i<MAX_PERIOD+LPC_ORDER;i++) + exc[i-LPC_ORDER] = ROUND16(buf[DECODE_BUFFER_SIZE-MAX_PERIOD-LPC_ORDER+i], SIG_SHIFT); if (loss_count == 0) { @@ -631,20 +636,14 @@ static void celt_decode_lost(CELTDecoder * OPUS_RESTRICT st, int N, int LM) } #endif } - /* We want the excitation for 2 pitch periods in order to look for a - decaying signal, but we can't get more than MAX_PERIOD. */ - exc_length = IMIN(2*pitch_index, MAX_PERIOD); /* Initialize the LPC history with the samples just before the start of the region for which we're computing the excitation. */ { - for (i=0;i<LPC_ORDER;i++) - { - exc[MAX_PERIOD-exc_length-LPC_ORDER+i] = - ROUND16(buf[DECODE_BUFFER_SIZE-exc_length-LPC_ORDER+i], SIG_SHIFT); - } - /* Compute the excitation for exc_length samples before the loss. */ + /* Compute the excitation for exc_length samples before the loss. We need the copy + because celt_fir() cannot filter in-place. */ celt_fir(exc+MAX_PERIOD-exc_length, lpc+c*LPC_ORDER, - exc+MAX_PERIOD-exc_length, exc_length, LPC_ORDER, st->arch); + fir_tmp, exc_length, LPC_ORDER, st->arch); + OPUS_COPY(exc+MAX_PERIOD-exc_length, fir_tmp, exc_length); } /* Check if the waveform is decaying, and if so how fast. diff --git a/celt/celt_lpc.c b/celt/celt_lpc.c index 57bc5f3d..90839f40 100644 --- a/celt/celt_lpc.c +++ b/celt/celt_lpc.c @@ -99,7 +99,7 @@ void celt_fir_c( int i,j; VARDECL(opus_val16, rnum); SAVE_STACK; - + celt_assert(x != y); ALLOC(rnum, ord, opus_val16); for(i=0;i<ord;i++) rnum[i] = num[ord-i-1]; |