Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.xiph.org/xiph/opus.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Marc Valin <jmvalin@amazon.com>2022-02-16 08:58:40 +0300
committerJean-Marc Valin <jmvalin@amazon.com>2022-02-16 08:58:40 +0300
commitd1a14ac5d4343bce71640d1e05595df9ffafa103 (patch)
tree0b557be6946b346f8e1ac4f6a409d7cfe8105314 /dnn/lpcnet.c
parent2a8bcf4c0f816e76b0093bbedb15389531a35c23 (diff)
Making state update more robust to discontinuities
Diffstat (limited to 'dnn/lpcnet.c')
-rw-r--r--dnn/lpcnet.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/dnn/lpcnet.c b/dnn/lpcnet.c
index 48dca42d..5a39f924 100644
--- a/dnn/lpcnet.c
+++ b/dnn/lpcnet.c
@@ -192,8 +192,12 @@ void lpcnet_synthesize_tail_impl(LPCNetState *lpcnet, short *output, int N, int
last_sig_ulaw = lin2ulaw(lpcnet->last_sig[0]);
pred_ulaw = lin2ulaw(pred);
exc = run_sample_network(&lpcnet->nnet, lpcnet->gru_a_condition, lpcnet->gru_b_condition, lpcnet->last_exc, last_sig_ulaw, pred_ulaw, lpcnet->sampling_logit_table, &lpcnet->rng);
- if (i < preload) exc = lin2ulaw(output[i]-PREEMPH*lpcnet->deemph_mem - pred);
- pcm = pred + ulaw2lin(exc);
+ if (i < preload) {
+ exc = lin2ulaw(output[i]-PREEMPH*lpcnet->deemph_mem - pred);
+ pcm = output[i]-PREEMPH*lpcnet->deemph_mem;
+ } else {
+ pcm = pred + ulaw2lin(exc);
+ }
RNN_MOVE(&lpcnet->last_sig[1], &lpcnet->last_sig[0], LPC_ORDER-1);
lpcnet->last_sig[0] = pcm;
lpcnet->last_exc = exc;
@@ -201,7 +205,7 @@ void lpcnet_synthesize_tail_impl(LPCNetState *lpcnet, short *output, int N, int
lpcnet->deemph_mem = pcm;
if (pcm<-32767) pcm = -32767;
if (pcm>32767) pcm = 32767;
- output[i] = (int)floor(.5 + pcm);
+ if (i >= preload) output[i] = (int)floor(.5 + pcm);
}
}