Skip to content
Snippets Groups Projects
Verified Commit 000af034 authored by Jean-Marc Valin's avatar Jean-Marc Valin
Browse files

Avoiding work on the PLC update side

Shift computation to concealment
parent d1309dd2
No related branches found
No related tags found
No related merge requests found
......@@ -59,6 +59,7 @@ int lpcnet_plc_init(LPCNetPLCState *st, int options) {
int ret;
fargan_init(&st->fargan);
lpcnet_encoder_init(&st->enc);
st->analysis_pos = PLC_BUF_SIZE;
if ((options&0x3) == LPCNET_PLC_CAUSAL) {
st->enable_blending = 1;
} else if ((options&0x3) == LPCNET_PLC_CODEC) {
......@@ -168,20 +169,10 @@ static void replace_features(LPCNetPLCState *st, const float *features) {
int lpcnet_plc_update(LPCNetPLCState *st, opus_int16 *pcm) {
int i;
float x[FRAME_SIZE];
float plc_features[2*NB_BANDS+NB_FEATURES+1];
for (i=0;i<FRAME_SIZE;i++) x[i] = pcm[i];
burg_cepstral_analysis(plc_features, x);
lpcnet_compute_single_frame_features_float(&st->enc, x, st->features);
if (st->blend) {
replace_features(st, st->features);
if (FEATURES_DELAY > 0) st->plc_net = st->plc_copy[FEATURES_DELAY-1];
} else {
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);
st->analysis_pos = PLC_BUF_SIZE-FRAME_SIZE;
}
if (st->analysis_pos - FRAME_SIZE >= 0) st->analysis_pos -= FRAME_SIZE;
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;
......@@ -193,6 +184,23 @@ static const float att_table[10] = {0, 0, -.2, -.2, -.4, -.4, -.8, -.8, -1.6,
int lpcnet_plc_conceal(LPCNetPLCState *st, opus_int16 *pcm) {
int i;
if (st->blend == 0) {
int count = 0;
while (st->analysis_pos + FRAME_SIZE <= PLC_BUF_SIZE) {
float x[FRAME_SIZE];
float plc_features[2*NB_BANDS+NB_FEATURES+1];
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);
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);
}
st->analysis_pos += FRAME_SIZE;
count++;
}
get_fec_or_pred(st, st->features);
queue_features(st, st->features);
get_fec_or_pred(st, st->features);
......@@ -206,9 +214,7 @@ int lpcnet_plc_conceal(LPCNetPLCState *st, opus_int16 *pcm) {
if (st->loss_count >= 10) st->features[0] = MAX16(-10, st->features[0]+att_table[9] - 2*(st->loss_count-9));
else st->features[0] = MAX16(-10, st->features[0]+att_table[st->loss_count]);
fargan_synthesize_int(&st->fargan, pcm, &st->features[0]);
lpcnet_compute_single_frame_features(&st->enc, pcm, st->features);
OPUS_MOVE(&st->cont_features[0], &st->cont_features[NB_FEATURES], (CONT_VECTORS-1)*NB_FEATURES);
OPUS_COPY(&st->cont_features[(CONT_VECTORS-1)*NB_FEATURES], st->features, NB_FEATURES);
queue_features(st, st->features);
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;
......
......@@ -60,6 +60,7 @@ struct LPCNetPLCState {
int fec_read_pos;
int fec_fill_pos;
int fec_skip;
int analysis_pos;
float pcm[PLC_BUF_SIZE];
int blend;
float features[NB_TOTAL_FEATURES];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment