From 072d133f7899c4783e67f90d07ab25b3b8414b8f Mon Sep 17 00:00:00 2001 From: Jean-Marc Valin Date: Fri, 6 Oct 2017 18:22:17 -0400 Subject: [PATCH] Fixes CELT PLC The regression was introduced in 783ad76766e1f6b6aaca5d6eb415ac8a8269e1f2 by changes to celt_fir() that make it no longer in-place. --- celt/celt_decoder.c | 27 +++++++++++++-------------- 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;iarch); + 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