mirror of
https://github.com/xiph/opus.git
synced 2025-06-04 17:47:42 +00:00
Avoiding work on the PLC update side
Shift computation to concealment
This commit is contained in:
parent
d1309dd2b6
commit
000af0340a
2 changed files with 22 additions and 15 deletions
|
@ -59,6 +59,7 @@ int lpcnet_plc_init(LPCNetPLCState *st, int options) {
|
||||||
int ret;
|
int ret;
|
||||||
fargan_init(&st->fargan);
|
fargan_init(&st->fargan);
|
||||||
lpcnet_encoder_init(&st->enc);
|
lpcnet_encoder_init(&st->enc);
|
||||||
|
st->analysis_pos = PLC_BUF_SIZE;
|
||||||
if ((options&0x3) == LPCNET_PLC_CAUSAL) {
|
if ((options&0x3) == LPCNET_PLC_CAUSAL) {
|
||||||
st->enable_blending = 1;
|
st->enable_blending = 1;
|
||||||
} else if ((options&0x3) == LPCNET_PLC_CODEC) {
|
} 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 lpcnet_plc_update(LPCNetPLCState *st, opus_int16 *pcm) {
|
||||||
int i;
|
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) {
|
if (st->blend) {
|
||||||
replace_features(st, st->features);
|
st->analysis_pos = PLC_BUF_SIZE-FRAME_SIZE;
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
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);
|
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];
|
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;
|
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 lpcnet_plc_conceal(LPCNetPLCState *st, opus_int16 *pcm) {
|
||||||
int i;
|
int i;
|
||||||
if (st->blend == 0) {
|
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);
|
get_fec_or_pred(st, st->features);
|
||||||
queue_features(st, st->features);
|
queue_features(st, st->features);
|
||||||
get_fec_or_pred(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));
|
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]);
|
else st->features[0] = MAX16(-10, st->features[0]+att_table[st->loss_count]);
|
||||||
fargan_synthesize_int(&st->fargan, pcm, &st->features[0]);
|
fargan_synthesize_int(&st->fargan, pcm, &st->features[0]);
|
||||||
lpcnet_compute_single_frame_features(&st->enc, pcm, st->features);
|
queue_features(st, 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);
|
|
||||||
OPUS_MOVE(st->pcm, &st->pcm[FRAME_SIZE], PLC_BUF_SIZE-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];
|
for (i=0;i<FRAME_SIZE;i++) st->pcm[PLC_BUF_SIZE-FRAME_SIZE+i] = (1.f/32768.f)*pcm[i];
|
||||||
st->blend = 1;
|
st->blend = 1;
|
||||||
|
|
|
@ -60,6 +60,7 @@ struct LPCNetPLCState {
|
||||||
int fec_read_pos;
|
int fec_read_pos;
|
||||||
int fec_fill_pos;
|
int fec_fill_pos;
|
||||||
int fec_skip;
|
int fec_skip;
|
||||||
|
int analysis_pos;
|
||||||
float pcm[PLC_BUF_SIZE];
|
float pcm[PLC_BUF_SIZE];
|
||||||
int blend;
|
int blend;
|
||||||
float features[NB_TOTAL_FEATURES];
|
float features[NB_TOTAL_FEATURES];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue