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>2023-10-24 16:19:51 +0300
committerJean-Marc Valin <jmvalin@amazon.com>2023-10-24 16:19:51 +0300
commitbc102f5fab5848013c51ed22d3b7bbaf9a0a6aca (patch)
tree4bc811c3e62b8858b1fa4697c90ae35857f14476
parent64236e5201752ccec137abcd051d1fd4de729670 (diff)
Slightly more continuous analysis
-rw-r--r--dnn/lpcnet_plc.c13
-rw-r--r--dnn/lpcnet_private.h1
2 files changed, 8 insertions, 6 deletions
diff --git a/dnn/lpcnet_plc.c b/dnn/lpcnet_plc.c
index c02f2909..9dcd6c3f 100644
--- a/dnn/lpcnet_plc.c
+++ b/dnn/lpcnet_plc.c
@@ -49,6 +49,7 @@ void lpcnet_plc_reset(LPCNetPLCState *st) {
OPUS_CLEAR(st->pcm, PLC_BUF_SIZE);
st->blend = 0;
st->loss_count = 0;
+ st->analysis_gap = 1;
}
int lpcnet_plc_init(LPCNetPLCState *st) {
@@ -140,10 +141,8 @@ static void replace_features(LPCNetPLCState *st, const float *features) {
int lpcnet_plc_update(LPCNetPLCState *st, opus_int16 *pcm) {
int i;
- if (st->blend) {
- st->analysis_pos = PLC_BUF_SIZE-FRAME_SIZE;
- }
if (st->analysis_pos - FRAME_SIZE >= 0) st->analysis_pos -= FRAME_SIZE;
+ else st->analysis_gap = 1;
OPUS_MOVE(st->pcm, &st->pcm[FRAME_SIZE], PLC_BUF_SIZE-FRAME_SIZE);
for (i=0;i<FRAME_SIZE;i++) st->pcm[PLC_BUF_SIZE-FRAME_SIZE+i] = (1.f/32768.f)*pcm[i];
st->loss_count = 0;
@@ -162,9 +161,8 @@ int lpcnet_plc_conceal(LPCNetPLCState *st, opus_int16 *pcm) {
for (i=0;i<FRAME_SIZE;i++) x[i] = 32768.f*st->pcm[st->analysis_pos+i];
burg_cepstral_analysis(plc_features, x);
lpcnet_compute_single_frame_features_float(&st->enc, x, st->features);
- if (count > 0) {
- if (count == 1) replace_features(st, st->features);
- else queue_features(st, st->features);
+ if ((st->analysis_gap && count > 0) || count > 1) {
+ queue_features(st, st->features);
OPUS_COPY(&plc_features[2*NB_BANDS], st->features, NB_FEATURES);
plc_features[2*NB_BANDS+NB_FEATURES] = 1;
compute_plc_pred(st, st->features, plc_features);
@@ -177,6 +175,7 @@ int lpcnet_plc_conceal(LPCNetPLCState *st, opus_int16 *pcm) {
get_fec_or_pred(st, st->features);
queue_features(st, st->features);
fargan_cont(&st->fargan, &st->pcm[PLC_BUF_SIZE-FARGAN_CONT_SAMPLES], st->cont_features);
+ st->analysis_gap = 0;
}
if (get_fec_or_pred(st, st->features)) st->loss_count = 0;
else st->loss_count++;
@@ -184,6 +183,8 @@ int lpcnet_plc_conceal(LPCNetPLCState *st, opus_int16 *pcm) {
else st->features[0] = MAX16(-10, st->features[0]+att_table[st->loss_count]);
fargan_synthesize_int(&st->fargan, pcm, &st->features[0]);
queue_features(st, st->features);
+ if (st->analysis_pos - FRAME_SIZE >= 0) st->analysis_pos -= FRAME_SIZE;
+ else st->analysis_gap = 1;
OPUS_MOVE(st->pcm, &st->pcm[FRAME_SIZE], PLC_BUF_SIZE-FRAME_SIZE);
for (i=0;i<FRAME_SIZE;i++) st->pcm[PLC_BUF_SIZE-FRAME_SIZE+i] = (1.f/32768.f)*pcm[i];
st->blend = 1;
diff --git a/dnn/lpcnet_private.h b/dnn/lpcnet_private.h
index ee269e44..381647ae 100644
--- a/dnn/lpcnet_private.h
+++ b/dnn/lpcnet_private.h
@@ -55,6 +55,7 @@ struct LPCNetPLCState {
#define LPCNET_PLC_RESET_START fec
float fec[PLC_MAX_FEC][NB_FEATURES];
+ int analysis_gap;
int fec_read_pos;
int fec_fill_pos;
int fec_skip;